src/main/java/org/edgegallery/appstore/application/inner/AppService.java
public void updateRepoInfoInSwImageDesc(File swImageDesc) {

        try {
            String descStr = FileUtils.readFileToString(swImageDesc, StandardCharsets.UTF_8);
            JsonArray swImgDescArray = new JsonParser().parse(descStr).getAsJsonArray();

            for (JsonElement desc : swImgDescArray) {
                JsonObject jsonObject = desc.getAsJsonObject();
                String swImage = jsonObject.get(SWIMAGE).getAsString();
                if (StringUtils.isEmpty(swImage)) {
                    throw new AppException("wrong image descriptor", ResponseConst.RET_GET_IMAGE_DESC_FAILED);
                }
                String[] image = swImage.split("/");
                jsonObject.addProperty(SWIMAGE, appstoreRepoEndpoint + APPSTORE_URL + image[image.length - 1]);
            }
            Gson gson = new GsonBuilder().setPrettyPrinting().create();
            appUtil.writeFile(swImageDesc, gson.toJson(swImgDescArray));
            LOGGER.info("Updated swImages : {}", swImgDescArray);
        } catch (IOException e) {
            LOGGER.info("failed to update sw image descriptor");
            throw new AppException("Failed to update repo info to image descriptor file",
                ResponseConst.RET_UPDATE_IMAGE_FAILED);
        }
    }
/**
     * Updates software image descriptor with docker repo info.
     *
     * @param swImageDesc software image descriptor file content
     */
Updates software image descriptor with docker repo info.
@param swImageDesc software image descriptor file content
Updates software image descriptor with docker repo info . @param swImageDesc software image descriptor file content
public void updateRepoInfoInSwImageDesc(File swImageDesc) {
        try {
            String descStr = FileUtils.readFileToString(swImageDesc, StandardCharsets.UTF_8);
            JsonArray swImgDescArray = new JsonParser().parse(descStr).getAsJsonArray();
            for (JsonElement desc : swImgDescArray) {
                JsonObject jsonObject = desc.getAsJsonObject();
                String swImage = jsonObject.get(SWIMAGE).getAsString();
                if (StringUtils.isEmpty(swImage)) {
                    throw new AppException("wrong image descriptor", ResponseConst.RET_GET_IMAGE_DESC_FAILED);
                }
                String[] image = swImage.split("/");
                jsonObject.addProperty(SWIMAGE, appstoreRepoEndpoint + APPSTORE_URL + image[image.length - 1]);
            }
            Gson gson = new GsonBuilder().setPrettyPrinting().create();
            appUtil.writeFile(swImageDesc, gson.toJson(swImgDescArray));
            LOGGER.info("Updated swImages : {}", swImgDescArray);
        } catch (IOException e) {
            LOGGER.info("failed to update sw image descriptor");
            throw new AppException("Failed to update repo info to image descriptor file",
                ResponseConst.RET_UPDATE_IMAGE_FAILED);
        }
    }
public void updateRepoInfoInSwImageDesc ( File swImageDesc ) { try { String descStr = FileUtils . readFileToString ( swImageDesc , StandardCharsets . UTF_8 ) ; JsonArray swImgDescArray = new JsonParser ( ) . parse ( descStr ) . getAsJsonArray ( ) ; for ( JsonElement desc : swImgDescArray ) { JsonObject jsonObject = desc . getAsJsonObject ( ) ; String swImage = jsonObject . get ( SWIMAGE ) . getAsString ( ) ; if ( StringUtils . isEmpty ( swImage ) ) { throw new AppException ( "wrong image descriptor" , ResponseConst . RET_GET_IMAGE_DESC_FAILED ) ; } String [ ] image = swImage . split ( "/" ) ; jsonObject . addProperty ( SWIMAGE , appstoreRepoEndpoint + APPSTORE_URL + image [ image . length - 1 ] ) ; } Gson gson = new GsonBuilder ( ) . setPrettyPrinting ( ) . create ( ) ; appUtil . writeFile ( swImageDesc , gson . toJson ( swImgDescArray ) ) ; LOGGER . info ( "Updated swImages : {}" , swImgDescArray ) ; } catch ( IOException e ) { LOGGER . info ( "failed to update sw image descriptor" ) ; throw new AppException ( "Failed to update repo info to image descriptor file" , ResponseConst . RET_UPDATE_IMAGE_FAILED ) ; } }
Updates software image descriptor with docker repo info.
Updates software image descriptor with docker repo info .