diff --git a/adapter/ohos/CompressVerify.java b/adapter/ohos/CompressVerify.java index 162a283b0d8a9a90669dba32ebcb1418b2a1d86c..f8eeb476b1c7cb93a4a806fa4a00bb994b5d870e 100644 --- a/adapter/ohos/CompressVerify.java +++ b/adapter/ohos/CompressVerify.java @@ -235,11 +235,13 @@ public class CompressVerify { if (!utility.getRpcidPath().isEmpty()) { File file = new File(utility.getRpcidPath()); if (!file.isFile()) { - LOG.error("CompressVerify::isArgsValidInHapMode rpcid-path is not a file."); + String errMsg = "isArgsValidInHapMode rpcid-path is not a file."; + LOG.error(PackingToolErrMsg.RPCID_PATH_INVALID.toString(errMsg)); return false; } if (!RPCID_PROFILE.equals(file.getName())) { - LOG.error("CompressVerify::isArgsValidInHapMode rpcid-path must be rpcid.sc file."); + String errMsg = "isArgsValidInHapMode rpcid-path must be rpcid.sc file."; + LOG.error(PackingToolErrMsg.RPCID_PATH_INVALID.toString(errMsg)); return false; } } @@ -250,11 +252,13 @@ public class CompressVerify { if (!utility.getPackInfoPath().isEmpty()) { File file = new File(utility.getPackInfoPath()); if (!file.isFile()) { - LOG.error("CompressVerify::isArgsValidInHapMode --pack-info-path is not a file."); + String errMsg = "isArgsValidInHapMode --pack-info-path is not a file."; + LOG.error(PackingToolErrMsg.PACKINFO_PATH_FAILED.toString(errMsg)); return false; } if (!PACK_INFO.equals(file.getName())) { - LOG.error("CompressVerify::isArgsValidInHapMode --pack-info-path must be pack.info file."); + String errMsg = "isArgsValidInHapMode --pack-info-path must be pack.info file."; + LOG.error(PackingToolErrMsg.PACKINFO_PATH_FAILED.toString(errMsg)); return false; } } @@ -263,12 +267,14 @@ public class CompressVerify { private static boolean isVerifyValidInHapCommonMode(Utility utility) { if (utility.getJsonPath().isEmpty()) { - LOG.error("CompressVerify::commandPathVerify json-path is empty."); + String errMsg = "commandPathVerify json-path is empty"; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!isPathValid(utility.getJsonPath(), TYPE_FILE, JSON_PROFILE) && !isPathValid(utility.getJsonPath(), TYPE_FILE, MODULE_PROFILE)) { - LOG.error("CompressVerify::isArgsValidInHarMode json-path must be config.json file."); + String errMsg = "isArgsValidInHarMode json-path must be config.json file."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } @@ -278,39 +284,45 @@ public class CompressVerify { if (!utility.getApkPath().isEmpty() && !compatibleProcess(utility, utility.getApkPath(), utility.getFormattedApkPathList(), APK_SUFFIX)) { - LOG.error("CompressVerify::isArgsValidInHapMode shell-apk-path is invalid."); + String errMsg = "isArgsValidInHapMode shell-apk-path is invalid."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getProfilePath().isEmpty()) { File file = new File(utility.getProfilePath()); if (!file.isFile() || !PROFILE_NAME.equals(file.getName())) { - LOG.error("CompressVerify::isArgsValidInHapMode profile-path must be CAPABILITY.profile file."); + String errMsg = "isArgsValidInHapMode profile-path must be CAPABILITY.profile file."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } } if (!utility.getDexPath().isEmpty() && !compatibleProcess(utility, utility.getDexPath(), utility.getFormattedDexPathList(), DEX_SUFFIX)) { - LOG.error("CompressVerify::isArgsValidInHapMode dex-path is invalid."); + String errMsg = "isArgsValidInHapMode dex-path is invalid."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getAbcPath().isEmpty() && !compatibleProcess(utility, utility.getAbcPath(), utility.getFormattedAbcPathList(), ABC_SUFFIX)) { - LOG.error("CompressVerify::isArgsValidInHapMode abc-path is invalid."); + String errMsg = "isArgsValidInHapMode abc-path is invalid."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getDirList().isEmpty() && !splitDirList(utility, utility.getDirList(), utility.getFormatedDirList())) { - LOG.error("CompressVerify::isArgsValidInHapMode --dir-list is invalid."); + String errMsg = "isArgsValidInHapMode --dir-list is invalid."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getPkgContextPath().isEmpty()) { File file = new File(utility.getPkgContextPath()); if (!file.isFile() || !PKG_CONTEXT_INFO.equals(file.getName())) { - LOG.error("CompressVerify::isArgsValidInHapMode --pkg-context-path file must be " + PKG_CONTEXT_INFO); + String errMsg = "isArgsValidInHapMode --pkg-context-path file must be "; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg + PKG_CONTEXT_INFO )); return false; } } @@ -326,76 +338,90 @@ public class CompressVerify { private static boolean isVerifyValidInHapMode(Utility utility) { File file = new File(utility.getIndexPath()); if (!utility.getIndexPath().isEmpty() && !file.isFile() && INDEX_PROFILE.equals(file.getName())) { - LOG.error("CompressVerify::isArgsValidInHapMode index-path must be resources.index file."); + String errMsg = "isArgsValidInHapMode index-path must be resources.index file."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getSoPath().isEmpty() && !compatibleProcess(utility, utility.getSoPath(), utility.getFormattedSoPathList(), SO_SUFFIX)) { - LOG.error("CompressVerify::isArgsValidInHapMode maple-so-path is invalid."); + String errMsg = "isArgsValidInHapMode maple-so-path is invalid."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getAbilitySoPath().isEmpty() && !compatibleProcess(utility, utility.getAbilitySoPath(), utility.getFormattedAbilitySoPathList(), SO_SUFFIX)) { - LOG.error("CompressVerify::isArgsValidInHapMode ability-so-path is invalid."); + String errMsg = "isArgsValidInHapMode ability-so-path is invalid."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (isHapPathValid(utility.getSoDir())) { - LOG.error("CompressVerify::isArgsValidInHapMode maple-so-dir is invalid."); + String errMsg = "isArgsValidInHapMode maple-so-dir is invalid."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (isHapPathValid(utility.getLibPath())) { - LOG.error("CompressVerify::isArgsValidInHapMode lib-path is invalid."); + String errMsg = "isArgsValidInHapMode lib-path is invalid."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (isHapPathValid(utility.getHnpPath())) { - LOG.error("CompressVerify::isArgsValidInHapMode hnp-path is invalid."); + String errMsg = "isArgsValidInHapMode hnp-path is invalid."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (isHapPathValid(utility.getResPath())) { - LOG.error("CompressVerify::isArgsValidInHapMode res-path is invalid."); + String errMsg = "isArgsValidInHapMode res-path is invalid."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (isHapPathValid(utility.getResourcesPath())) { - LOG.error("CompressVerify::isArgsValidInHapMode resources-path is invalid."); + String errMsg = "isArgsValidInHapMode resources-path is invalid."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (isHapPathValid(utility.getAssetsPath())) { - LOG.error("CompressVerify::isArgsValidInHapMode assets-path is invalid."); + String errMsg = "isArgsValidInHapMode assets-path is invalid."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (isHapPathValid(utility.getSharedLibsPath())) { - LOG.error("CompressVerify::isArgsValidInHapMode shared-libs-path is invalid."); + String errMsg = "isArgsValidInHapMode shared-libs-path is invalid."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getJarPath().isEmpty() && !compatibleProcess(utility, utility.getJarPath(), utility.getFormattedJarPathList(), JAR_SUFFIX)) { - LOG.error("CompressVerify::isArgsValidInHapMode jar-path is invalid."); + String errMsg = "isArgsValidInHapMode jar-path is invalid."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getTxtPath().isEmpty() && !compatibleProcess(utility, utility.getTxtPath(), utility.getFormattedTxtPathList(), TXT_SUFFIX)) { - LOG.error("CompressVerify::isArgsValidInHapMode txt-path is invalid."); + String errMsg = "isArgsValidInHapMode txt-path is invalid."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (isHapPathValid(utility.getANPath())) { - LOG.error("CompressVerify::isArgsValidInHapMode an-path is invalid."); + String errMsg = "isArgsValidInHapMode an-path is invalid."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getEtsPath().isEmpty() && !isPathExists(utility.getEtsPath())) { - LOG.error("CompressVerify::isArgsValidInHapMode ets-path is invalid."); + String errMsg = "isArgsValidInHapMode ets-path is invalid."; + LOG.error(PackingToolErrMsg.HAP_MODE_ARGS_INVALID.toString(errMsg)); return false; } @@ -420,45 +446,53 @@ public class CompressVerify { */ private static boolean isVerifyValidInHarMode(Utility utility) { if (utility.getJsonPath().isEmpty()) { - LOG.error("CompressVerify::isArgsValidInHarMode json-path is empty."); + String errMsg = "isArgsValidInHarMode json-path is empty."; + LOG.error(PackingToolErrMsg.HAR_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!isPathValid(utility.getJsonPath(), TYPE_FILE, JSON_PROFILE) && !isPathValid(utility.getJsonPath(), TYPE_FILE, MODULE_PROFILE)) { - LOG.error("CompressVerify::isArgsValidInHarMode json-path must be config.json file."); + String errMsg = "isArgsValidInHarMode json-path must be config.json file."; + LOG.error(PackingToolErrMsg.HAR_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getJarPath().isEmpty() && !compatibleProcess(utility, utility.getJarPath(), utility.getFormattedJarPathList(), JAR_SUFFIX)) { - LOG.error("CompressVerify::isArgsValidInHarMode jar-path is invalid."); + String errMsg = "isArgsValidInHarMode jar-path is invalid."; + LOG.error(PackingToolErrMsg.HAR_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getTxtPath().isEmpty() && !compatibleProcess(utility, utility.getTxtPath(), utility.getFormattedTxtPathList(), TXT_SUFFIX)) { - LOG.error("CompressVerify::isArgsValidInHarMode txt-path is invalid."); + String errMsg = "isArgsValidInHarMode txt-path is invalid."; + LOG.error(PackingToolErrMsg.HAR_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getLibPath().isEmpty() && !isPathValid(utility.getLibPath(), TYPE_DIR, null)) { - LOG.error("CompressVerify::isArgsValidInHarMode lib-path is invalid."); + String errMsg = "isArgsValidInHarMode lib-path is invalid."; + LOG.error(PackingToolErrMsg.HAR_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getResPath().isEmpty() && !isPathValid(utility.getResPath(), TYPE_DIR, null)) { - LOG.error("CompressVerify::isArgsValidInHarMode res-path is invalid."); + String errMsg = "isArgsValidInHarMode res-path is invalid."; + LOG.error(PackingToolErrMsg.HAR_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (utility.getResourcesPath().isEmpty() || !isPathValid(utility.getResourcesPath(), TYPE_DIR, null)) { - LOG.error("CompressVerify::isArgsValidInHarMode resources-path is invalid."); + String errMsg = "isArgsValidInHarMode resources-path is invalid."; + LOG.error(PackingToolErrMsg.HAR_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getAssetsPath().isEmpty() && !isPathValid(utility.getAssetsPath(), TYPE_DIR, null)) { - LOG.error("CompressVerify::isArgsValidInHarMode assets-path is invalid."); + String errMsg = "isArgsValidInHarMode assets-path is invalid."; + LOG.error(PackingToolErrMsg.HAR_MODE_ARGS_INVALID.toString(errMsg)); return false; } @@ -884,8 +918,8 @@ public class CompressVerify { private static boolean isDirectoryValidStrictCase(String path, String directoryName) { File file = new File(path); if (!file.exists()) { - LOG.error("CompressVerify::isDirectoryValidStrictCase directory is not exist, directoryPath: " - + path + "."); + String errMsg = "isDirectoryValidStrictCase directory is not exist, directoryPath: "; + LOG.error(PackingToolErrMsg.DIRECTORY_INVALID.toString(errMsg + path)); return false; } if (file.isDirectory()) { @@ -914,12 +948,14 @@ public class CompressVerify { private static boolean isVerifyValidInHspMode(Utility utility) { if (utility.getJsonPath().isEmpty()) { - LOG.error("CompressVerify::isArgsValidInHspMode json-path is empty."); + String errMsg = "isArgsValidInHspMode json-path is empty."; + LOG.error(PackingToolErrMsg.HSP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!isPathValid(utility.getJsonPath(), TYPE_FILE, MODULE_PROFILE)) { - LOG.error("CompressVerify::isArgsValidInHspMode json-path must be module.json file."); + String errMsg = "isArgsValidInHspMode json-path must be module.json file."; + LOG.error(PackingToolErrMsg.HSP_MODE_ARGS_INVALID.toString(errMsg)); return false; } @@ -927,87 +963,99 @@ public class CompressVerify { boolean hspHasAbilities = hspHasAbilities(utility); boolean hspHasExtensionAbilities = hspHasExtensionAbilities(utility); if (hspHasAbilities && hspHasExtensionAbilities) { - LOG.error("shared/appService hsp has abilities and extensionAbilities"); + String errMsg = "shared/appService hsp has abilities and extensionAbilities"; + LOG.error(PackingToolErrMsg.HSP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (hspHasAbilities) { - LOG.error("shared/appService hsp has abilities"); + LOG.error(PackingToolErrMsg.HSP_MODE_ARGS_INVALID.toString("shared/appService hsp has abilities")); return false; } if (hspHasExtensionAbilities) { - LOG.error("shared/appService hsp has extensionAbilities"); + LOG.error(PackingToolErrMsg.HSP_MODE_ARGS_INVALID.toString("shared/appService hsp has extensionAbilities")); return false; } } if(hasHomeAbility(utility)) { - LOG.error("hsp has entry ability"); + LOG.error(PackingToolErrMsg.HSP_MODE_ARGS_INVALID.toString("hsp has home ability")); return false; } if (hasHomeExtensionAbility(utility)) { - LOG.error("hsp has entry extensionAbility"); + LOG.error(PackingToolErrMsg.HSP_MODE_ARGS_INVALID.toString("hsp has home extensionAbility")); return false; } if (!utility.getJarPath().isEmpty() && !compatibleProcess(utility, utility.getJarPath(), utility.getFormattedJarPathList(), JAR_SUFFIX)) { - LOG.error("CompressVerify::isArgsValidInHspMode jar-path is invalid."); + String errMsg = "isArgsValidInHspMode jar-path is invalid."; + LOG.error(PackingToolErrMsg.HSP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getTxtPath().isEmpty() && !compatibleProcess(utility, utility.getTxtPath(), utility.getFormattedTxtPathList(), TXT_SUFFIX)) { - LOG.error("CompressVerify::isArgsValidInHspMode txt-path is invalid."); + String errMsg = "isArgsValidInHspMode txt-path is invalid."; + LOG.error(PackingToolErrMsg.HSP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getLibPath().isEmpty() && !isPathValid(utility.getLibPath(), TYPE_DIR, null)) { - LOG.error("CompressVerify::isArgsValidInHspMode lib-path is invalid."); + String errMsg = "isArgsValidInHspMode lib-path is invalid."; + LOG.error(PackingToolErrMsg.HSP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getResPath().isEmpty() && !isPathValid(utility.getResPath(), TYPE_DIR, null)) { - LOG.error("CompressVerify::isArgsValidInHspMode res-path is invalid."); + String errMsg = "isArgsValidInHspMode res-path is invalid."; + LOG.error(PackingToolErrMsg.HSP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getResourcesPath().isEmpty() && !isPathValid(utility.getResourcesPath(), TYPE_DIR, null)) { - LOG.error("CompressVerify::isArgsValidInHspMode resources-path is invalid."); + String errMsg = "isArgsValidInHspMode resources-path is invalid."; + LOG.error(PackingToolErrMsg.HSP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getAssetsPath().isEmpty() && !isPathValid(utility.getAssetsPath(), TYPE_DIR, null)) { - LOG.error("CompressVerify::isArgsValidInHspMode assets-path is invalid."); + String errMsg = "isArgsValidInHspMode assets-path is invalid."; + LOG.error(PackingToolErrMsg.HSP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getDirList().isEmpty() && !splitDirList(utility, utility.getDirList(), utility.getFormatedDirList())) { - LOG.error("CompressVerify::isArgsValidInHapMode --dir-list is invalid."); + String errMsg = "isArgsValidInHapMode --dir-list is invalid."; + LOG.error(PackingToolErrMsg.HSP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (isHapPathValid(utility.getAPPath())) { - LOG.error("CompressVerify::isArgsValidInHapMode ap-path is invalid."); + String errMsg = "isArgsValidInHapMode ap-path is invalid."; + LOG.error(PackingToolErrMsg.HSP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (isHapPathValid(utility.getANPath())) { - LOG.error("CompressVerify::isArgsValidInHapMode an-path is invalid."); + String errMsg = "isArgsValidInHapMode an-path is invalid."; + LOG.error(PackingToolErrMsg.HSP_MODE_ARGS_INVALID.toString(errMsg)); return false; } if (!utility.getPkgContextPath().isEmpty()) { File file = new File(utility.getPkgContextPath()); if (!file.isFile() || !PKG_CONTEXT_INFO.equals(file.getName())) { - LOG.error("CompressVerify::isArgsValidInHspMode --pkg-context-path file must be " + PKG_CONTEXT_INFO); + String errMsg = "isArgsValidInHspMode --pkg-context-path file must be "+ PKG_CONTEXT_INFO; + LOG.error(PackingToolErrMsg.HSP_MODE_ARGS_INVALID.toString(errMsg)); return false; } } if (!utility.getEtsPath().isEmpty() && !isPathExists(utility.getEtsPath())) { - LOG.error("CompressVerify::isArgsValidInHspMode ets-path is invalid."); + String errMsg = "isArgsValidInHspMode ets-path is invalid."; + LOG.error(PackingToolErrMsg.HSP_MODE_ARGS_INVALID.toString(errMsg)); return false; } @@ -1016,48 +1064,58 @@ public class CompressVerify { private static boolean isVerifyValidInHapAdditionMode(Utility utility) { if (utility.getHapPath().isEmpty()) { - LOG.error("CompressVerify::isVerifyValidInHapAdditionMode hapPath is empty."); + String errMsg = "isVerifyValidInHapAdditionMode hapPath is empty."; + LOG.error(PackingToolErrMsg.HAP_ADD_VERIF_INVALID.toString(errMsg)); return false; } String hapPath = utility.getAbsoluteHapPath(); File hapFile = new File(hapPath); if (hapFile.isDirectory()) { - LOG.error("CompressVerify::isVerifyValidInHapAdditionMode hapPath cannot be a folder."); + String errMsg = "isVerifyValidInHapAdditionMode hapPath cannot be a folder."; + LOG.error(PackingToolErrMsg.HAP_ADD_VERIF_INVALID.toString(errMsg)); return false; } if (!(hapPath.endsWith(HAP_SUFFIX) || hapPath.endsWith(HSP_SUFFIX))) { - LOG.error("CompressVerify::isVerifyValidInHapAdditionMode hapPath is invalid."); + String errMsg = "isVerifyValidInHapAdditionMode hapPath is invalid."; + LOG.error(PackingToolErrMsg.HAP_ADD_VERIF_INVALID.toString(errMsg)); return false; } if (!hapFile.exists()) { - LOG.error("CompressVerify::isVerifyValidInHapAdditionMode hap file does not exist."); + String errMsg = "isVerifyValidInHapAdditionMode hap file does not exist."; + LOG.error(PackingToolErrMsg.HAP_ADD_VERIF_INVALID.toString(errMsg)); return false; } if (utility.getJsonPath().isEmpty()) { - LOG.error("CompressVerify::isVerifyValidInHapAdditionMode jsonPath is empty."); + String errMsg = "isVerifyValidInHapAdditionMode jsonPath is empty."; + LOG.error(PackingToolErrMsg.HAP_ADD_VERIF_INVALID.toString(errMsg)); return false; } if (!utility.getJsonPath().endsWith(JSON_SUFFIX)) { - LOG.error("CompressVerify::isVerifyValidInHapAdditionMode jsonPath is invalid."); + String errMsg = "isVerifyValidInHapAdditionMode jsonPath is invalid."; + LOG.error(PackingToolErrMsg.HAP_ADD_VERIF_INVALID.toString(errMsg)); return false; } File jsonFile = new File(utility.getJsonPath()); if (!jsonFile.exists()) { - LOG.error("CompressVerify::isVerifyValidInHapAdditionMode json file does not exist."); + String errMsg = "isVerifyValidInHapAdditionMode json file does not exist."; + LOG.error(PackingToolErrMsg.HAP_ADD_VERIF_INVALID.toString(errMsg)); return false; } if (!checkJsonIsValid(jsonFile)) { - LOG.error("CompressVerify::isVerifyValidInHapAdditionMode json format is incorrect."); + String errMsg = "isVerifyValidInHapAdditionMode json format is incorrect."; + LOG.error(PackingToolErrMsg.HAP_ADD_VERIF_INVALID.toString(errMsg)); return false; } if (utility.getOutPath().isEmpty()) { - LOG.error("CompressVerify::isVerifyValidInHapAdditionMode outPath is empty."); + String errMsg = "isVerifyValidInHapAdditionMode outPath is empty."; + LOG.error(PackingToolErrMsg.HAP_ADD_VERIF_INVALID.toString(errMsg)); return false; } File dir = new File(utility.getOutPath()); if (dir.exists() && dir.isFile()) { - LOG.error("CompressVerify::isVerifyValidInHapAdditionMode outPath is file."); + String errMsg = "isVerifyValidInHapAdditionMode outPath is file."; + LOG.error(PackingToolErrMsg.HAP_ADD_VERIF_INVALID.toString(errMsg)); return false; } File absoluteHapFile = new File(utility.getAbsoluteHapPath()); @@ -1065,7 +1123,8 @@ public class CompressVerify { String destPath = utility.getOutPath() + LINUX_FILE_SEPARATOR + hapFileName; File destFile = new File(destPath); if ("false".equals(utility.getForceRewrite()) && destFile.exists()) { - LOG.error("CompressVerify::isVerifyValidInHapAdditionMode target file already exists."); + String errMsg = "isVerifyValidInHapAdditionMode target file already exists."; + LOG.error(PackingToolErrMsg.HAP_ADD_VERIF_INVALID.toString(errMsg)); return false; } return true; @@ -1080,7 +1139,8 @@ public class CompressVerify { jsonData.append((char) ch); } } catch (IOException e) { - LOG.error("CompressVerify::CheckJsonIsValid failed: " + e.getMessage()); + String errMsg = "CheckJsonIsValid failed: "; + LOG.error(PackingToolErrMsg.CHECK_JSON_INVALID.toString(errMsg + e.getMessage())); return false; } JSONValidator validator = JSONValidator.from(jsonData.toString()); @@ -1154,11 +1214,13 @@ public class CompressVerify { if(optional.isPresent()) { return ModuleJsonUtil.parseStageBundleType(optional.get()).equals(BUNDLE_TYPE_SHARE); } else { - LOG.error("CompressVerify::isBundleTypeShared jsonPath content invalid"); + String errMsg = "isBundleTypeShared jsonPath content invalid."; + LOG.error(PackingToolErrMsg.BUNDLE_TYPE_SHARED_INVALID.toString(errMsg)); return false; } } catch (BundleException e) { - LOG.error("CompressVerify::isBundleTypeShared exception: " + e.getMessage()); + String errMsg = "isBundleTypeShared exception:"; + LOG.error(PackingToolErrMsg.BUNDLE_TYPE_SHARED_INVALID.toString(errMsg +e.getMessage())); return false; } } @@ -1169,11 +1231,13 @@ public class CompressVerify { if(optional.isPresent()) { return ModuleJsonUtil.parseStageBundleType(optional.get()).equals(BUNDLE_TYPE_APP_SERVICE); } else { - LOG.error("CompressVerify::isBundleTypeAppService jsonPath content invalid"); + String errMsg = "isBundleTypeAppService jsonPath content invalid"; + LOG.error(PackingToolErrMsg.BUNDLE_TYPE_APPSERVICE_INVALID.toString(errMsg)); return false; } } catch (BundleException e) { - LOG.error("CompressVerify::isBundleTypeAppService exception: " + e.getMessage()); + String errMsg = "isBundleTypeAppService exception: "; + LOG.error(PackingToolErrMsg.BUNDLE_TYPE_APPSERVICE_INVALID.toString(errMsg +e.getMessage())); return false; } } @@ -1184,11 +1248,13 @@ public class CompressVerify { if(optional.isPresent()) { return ModuleJsonUtil.parseModuleType(optional.get()).equals(BUNDLE_TYPE_SHARE) && !ModuleJsonUtil.parseAbilityNames(optional.get()).isEmpty(); } else { - LOG.error("CompressVerify::hspHasAbilities jsonPath content invalid"); + String errMsg = "hspHasAbilities jsonPath content invalid"; + LOG.error(PackingToolErrMsg.HSP_HAS_ABILITIES_INVALID.toString(errMsg)); return false; } } catch (BundleException e) { - LOG.error("CompressVerify::hspHasAbilities exception: " + e.getMessage()); + String errMsg = "hspHasAbilities exception: "; + LOG.error(PackingToolErrMsg.HSP_HAS_ABILITIES_INVALID.toString(errMsg +e.getMessage())); return false; } } @@ -1200,10 +1266,12 @@ public class CompressVerify { return ModuleJsonUtil.parseModuleType(optional.get()).equals(BUNDLE_TYPE_SHARE) && !ModuleJsonUtil.parseExtensionAbilityName(optional.get()).isEmpty(); } else { - LOG.error("CompressVerify::hspHasExtensionAbilities jsonPath content invalid"); + String errMsg = "hspHasExtensionAbilities jsonPath content invalid"; + LOG.error(PackingToolErrMsg.HSP_HAS_EXTENSION_ABILITIES_INVALID.toString(errMsg)); } } catch (BundleException e) { - LOG.error("CompressVerify::hspHasExtensionAbilities exception: " + e.getMessage()); + String errMsg = "hspHasExtensionAbilities exception: "; + LOG.error(PackingToolErrMsg.HSP_HAS_EXTENSION_ABILITIES_INVALID.toString(errMsg + e.getMessage())); } return false; } @@ -1213,17 +1281,20 @@ public class CompressVerify { boolean result = false; Optional optional = FileUtils.getFileContent(utility.getJsonPath()); if(!optional.isPresent()) { - LOG.error("CompressVerify::hasHomeAbility jsonPath content invalid"); + String errMsg = "hasHomeAbility jsonPath content invalid"; + LOG.error(PackingToolErrMsg.HAS_HOME_ABILITY_INVALID.toString(errMsg)); return false; } Map abilitiesMap = ModuleJsonUtil.parseAbilitySkillsMap(optional.get()); if (abilitiesMap.containsValue(true)) { result = true; } - LOG.info("CompressVerify::hasHomeAbilities result = " + result); + String errMsg = "hasHomeAbilities result "; + LOG.error(PackingToolErrMsg.HAS_HOME_ABILITY_INVALID.toString(errMsg + result)); return result; } catch (BundleException e) { - LOG.error("CompressVerify::hasHomeAbilities exception: " + e.getMessage()); + String errMsg = "hasHomeAbilities exception: "; + LOG.error(PackingToolErrMsg.HAS_HOME_ABILITY_INVALID.toString(errMsg + e.getMessage())); return false; } } @@ -1249,17 +1320,20 @@ public class CompressVerify { boolean result = false; Optional optional = FileUtils.getFileContent(utility.getJsonPath()); if (!optional.isPresent()) { - LOG.error("CompressVerify::hasHomeExtensionAbility jsonPath content invalid"); + String errMsg = "hasHomeExtensionAbility jsonPath content invalid"; + LOG.error(PackingToolErrMsg.HAS_HOME_EXTENSION_ABILITY_INVALID.toString(errMsg)); return false; } Map extensionAbilitiesMap = ModuleJsonUtil.parseExtensionAbilitySkillsMap(optional.get()); if (extensionAbilitiesMap.containsValue(true)) { result = true; } - LOG.info("CompressVerify::hasHomeExtensionAbility result = " + result); + String errMsg = "hasHomeExtensionAbility result "; + LOG.error(PackingToolErrMsg.HAS_HOME_EXTENSION_ABILITY_INVALID.toString(errMsg + result)); return result; } catch (BundleException e) { - LOG.error("CompressVerify::hasHomeExtensionAbility exception: " + e.getMessage()); + String errMsg = "hasHomeExtensionAbility exception: "; + LOG.error(PackingToolErrMsg.HAS_HOME_EXTENSION_ABILITY_INVALID.toString(errMsg + e.getMessage())); return false; } } diff --git a/adapter/ohos/Compressor.java b/adapter/ohos/Compressor.java index 3346181239db2cea508c5d383ca75fc0eb4f9a5b..84b892aa2e79487384d10bfe4d0f618fb6611a6a 100644 --- a/adapter/ohos/Compressor.java +++ b/adapter/ohos/Compressor.java @@ -426,35 +426,35 @@ public class Compressor { Optional optional = FileUtils.getFileContent(utility.getJsonPath()); String jsonString = optional.get(); if (!checkStageAsanTsanEnabledValid(jsonString)) { - LOG.error("checkStageAsanTsanEnabledValid failed."); - throw new BundleException("compressHsp failed."); + LOG.error(PackingToolErrMsg.COMPRESS_HSP_FAILED.toString("checkStageAsanTsanEnabledValid failed.")); + throw new BundleException("compressHsp failed"); } if (!checkStageHwasanEnabledValid(jsonString)) { - LOG.error("checkStageHwasanEnabledValid failed."); - throw new BundleException("compressHsp failed."); + LOG.error(PackingToolErrMsg.COMPRESS_HSP_FAILED.toString("checkStageHwasanEnabledValid failed.")); + throw new BundleException("compressHsp failed"); } if (!checkStageUbsanEnabledValid(jsonString)) { - LOG.error("checkStageUbsanEnabledValid failed."); - throw new BundleException("compressHsp failed."); + LOG.error(PackingToolErrMsg.COMPRESS_HSP_FAILED.toString("checkStageUbsanEnabledValid failed.")); + throw new BundleException("compressHsp failed"); } if (!checkStageAtomicService(jsonString)) { - LOG.error("checkStageAtomicService failed."); - throw new BundleException("checkStageAtomicService failed."); + LOG.error(PackingToolErrMsg.COMPRESS_HSP_FAILED.toString("checkStageAtomicService failed.")); + throw new BundleException("checkStageAtomicService failed"); } // check continueBundleName in module.json if (!checkContinueBundleNameIsValid(jsonString)) { - LOG.error("checkContinueBundleNameIsValid failed."); - throw new BundleException("compressHsp failed."); + LOG.error(PackingToolErrMsg.COMPRESS_HSP_FAILED.toString("checkContinueBundleNameIsValid failed.")); + throw new BundleException("compressHsp failed"); } // check whether is an overlay hsp or not if (!checkStageOverlayCfg(jsonString)) { - LOG.error("checkStageOverlayCfg failed."); - throw new BundleException("checkStageOverlayCfg failed."); + LOG.error(PackingToolErrMsg.COMPRESS_HSP_FAILED.toString("checkStageOverlayCfg failed.")); + throw new BundleException("checkStageOverlayCfg failed"); } String moduleType = ModuleJsonUtil.parseModuleType(jsonString); if (!TYPE_SHARED.equals(moduleType)) { - LOG.error("module type must be shared."); - throw new BundleException("compressHsp failed."); + LOG.error(PackingToolErrMsg.COMPRESS_HSP_FAILED.toString("module type must be shared")); + throw new BundleException("compressHsp failed"); } } compressHSPMode(utility); @@ -471,7 +471,8 @@ public class Compressor { if (isModuleJSON(utility.getJsonPath())) { if (!checkStageHap(utility)) { LOG.error("checkStageHap failed."); - throw new BundleException("checkStageHap failed."); + LOG.error(PackingToolErrMsg.COMPRESS_HAP_FAILED.toString("checkStageHap failed.")); + throw new BundleException("checkStageHap failed"); } Optional optional = FileUtils.getFileContent(utility.getJsonPath()); String jsonString = optional.get(); @@ -749,25 +750,25 @@ public class Compressor { Optional optional = FileUtils.getFileContent(utility.getJsonPath()); String jsonString = optional.get(); if (!checkStageAsanTsanEnabledValid(jsonString)) { - LOG.error("checkStageAsanTsanEnabledValid failed."); + LOG.error(PackingToolErrMsg.CHECK_STAGE_HAP_FAILED.toString("checkStageAsanTsanEnabledValid failed.")); return false; } if (!checkStageHwasanEnabledValid(jsonString)) { - LOG.error("checkStageHwasanEnabledValid failed."); + LOG.error(PackingToolErrMsg.CHECK_STAGE_HAP_FAILED.toString("checkStageHwasanEnabledValid failed.")); return false; } if (!checkStageUbsanEnabledValid(jsonString)) { - LOG.error("checkStageUbsanEnabledValid failed."); + LOG.error(PackingToolErrMsg.CHECK_STAGE_HAP_FAILED.toString("checkStageUbsanEnabledValid failed.")); return false; } // check atomicService in module.json if (!checkStageAtomicService(jsonString)) { - LOG.error("checkStageAtomicService failed."); + LOG.error(PackingToolErrMsg.CHECK_STAGE_HAP_FAILED.toString("checkStageAtomicService failed.")); return false; } // check continueBundleName in module.json if (!checkContinueBundleNameIsValid(jsonString)) { - LOG.error("checkContinueBundleNameIsValid failed."); + LOG.error(PackingToolErrMsg.CHECK_STAGE_HAP_FAILED.toString("checkContinueBundleNameIsValid failed.")); return false; } return true; @@ -777,7 +778,7 @@ public class Compressor { boolean asanEnabled = ModuleJsonUtil.getStageAsanEnabled(jsonString); boolean tsanEnabled = ModuleJsonUtil.getStageTsanEnabled(jsonString); if (asanEnabled && tsanEnabled) { - LOG.error("asanEnabled and tsanEnabled cannot be true at the same time."); + LOG.error(PackingToolErrMsg.CHECK_AS_TSAN_ENABLED.toString("asanEnabled and tsanEnabled cannot be true at the same time.")); return false; } return true; @@ -789,15 +790,15 @@ public class Compressor { boolean gwpAsanEnabled = ModuleJsonUtil.getStageGwpAsanEnabled(jsonString); boolean hwasanEnabled = ModuleJsonUtil.getStageHwasanEnabled(jsonString); if (hwasanEnabled && asanEnabled) { - LOG.error("hwasanEnabled and asanEnabled cannot be true at the same time."); + LOG.error(PackingToolErrMsg.CHECK_HWASAN_ENABLED_INVALID.toString("hwasanEnabled and asanEnabled cannot be true at the same time")); return false; } if (hwasanEnabled && tsanEnabled) { - LOG.error("hwasanEnabled and tsanEnabled cannot be true at the same time."); + LOG.error(PackingToolErrMsg.CHECK_HWASAN_ENABLED_INVALID.toString("hwasanEnabled and tsanEnabled cannot be true at the same time")); return false; } if (hwasanEnabled && gwpAsanEnabled) { - LOG.error("hwasanEnabled and GWPAsanEnabled cannot be true at the same time."); + LOG.error(PackingToolErrMsg.CHECK_HWASAN_ENABLED_INVALID.toString("hwasanEnabled and GWPAsanEnabled cannot be true at the same time")); return false; } return true; @@ -813,7 +814,7 @@ public class Compressor { } for (int i = 0; i < continueBundleNameList.size(); i++) { if (bundleName.equals(continueBundleNameList.get(i))) { - LOG.error("continueBundleName cannot include self."); + LOG.error(PackingToolErrMsg.CHECK_CONTINUE_BUNDLENAME_INVALID.toString("continueBundleName cannot include self.")); return false; } } @@ -827,15 +828,15 @@ public class Compressor { boolean hwasanEnabled = ModuleJsonUtil.getStageHwasanEnabled(jsonString); boolean ubsanEnabled = ModuleJsonUtil.getStageUbsanEnabled(jsonString); if(ubsanEnabled && asanEnabled) { - LOG.error("ubsanEnabled and asanEnabled cannot be true at the same time."); + LOG.error(PackingToolErrMsg.CHECK_UBASAN_ENABLED_INVALID.toString("ubsanEnabled and asanEnabled cannot be true at the same time")); return false; } if(ubsanEnabled && tsanEnabled) { - LOG.error("ubsanEnabled and tsanEnabled cannot be true at the same time."); + LOG.error(PackingToolErrMsg.CHECK_UBASAN_ENABLED_INVALID.toString("ubsanEnabled and tsanEnabled cannot be true at the same time.")); return false; } if(ubsanEnabled && hwasanEnabled) { - LOG.error("ubsanEnabled and hwasanEnabled cannot be true at the same time."); + LOG.error(PackingToolErrMsg.CHECK_UBASAN_ENABLED_INVALID.toString("ubsanEnabled and hwasanEnabled cannot be true at the same time")); return false; } return true; @@ -844,17 +845,17 @@ public class Compressor { private static boolean checkStageAtomicService(String jsonString) throws BundleException { // check consistency of atomicService if (!ModuleJsonUtil.isModuleAtomicServiceValid(jsonString)) { - LOG.error("check module atomicService failed."); + LOG.error(PackingToolErrMsg.CHECK_ATOMIC_SERVICE_FAILED.toString("check module atomicService failed.")); return false; } // check entry module must have ability if (!ModuleJsonUtil.checkEntryInAtomicService(jsonString)) { - LOG.error("checkEntryInAtomicService failed."); + LOG.error(PackingToolErrMsg.CHECK_ATOMIC_SERVICE_FAILED.toString("checkEntryInAtomicService failed.")); return false; } // check installationFree if (!ModuleJsonUtil.checkAtomicServiceInstallationFree(jsonString)) { - LOG.error("check atomic service installationFree failed."); + LOG.error(PackingToolErrMsg.CHECK_ATOMIC_SERVICE_FAILED.toString("check atomic service installationFree failed.")); return false; } @@ -867,17 +868,17 @@ public class Compressor { if (!targetModuleName.isEmpty()) { // check targetModuleName and requestPermission if (ModuleJsonUtil.isExistedStageRequestPermissions(jsonString)) { - LOG.error("targetModuleName cannot be existed with requestPermissions."); + LOG.error(PackingToolErrMsg.CHECK_OVERLAYCF_CFG_FAILED.toString("targetModuleName cannot be existed with requestPermissions.")); return false; } // check targetModuleName and name if (targetModuleName.equals(ModuleJsonUtil.parseStageModuleName(jsonString))) { - LOG.error("targetModuleName cannot be same with name in the overlay module."); + LOG.error(PackingToolErrMsg.CHECK_OVERLAYCF_CFG_FAILED.toString("targetModuleName cannot be same with name in the overlay module.")); return false; } } else { if (ModuleJsonUtil.isExistedStageModuleTargetPriority(jsonString)) { - LOG.error("targetPriority cannot be existed without the targetModuleName in module.json."); + LOG.error(PackingToolErrMsg.CHECK_OVERLAYCF_CFG_FAILED.toString("targetPriority cannot be existed without the targetModuleName in module.json.")); return false; } } @@ -885,16 +886,16 @@ public class Compressor { String targetBundleName = ModuleJsonUtil.getStageTargetBundleName(jsonString); if (!targetBundleName.isEmpty()) { if (targetModuleName.isEmpty()) { - LOG.error("targetModuleName is necessary in the overlay bundle."); + LOG.error(PackingToolErrMsg.CHECK_OVERLAYCF_CFG_FAILED.toString("targetModuleName is necessary in the overlay bundle.")); return false; } if (targetBundleName.equals(ModuleJsonUtil.parseBundleName(jsonString))) { - LOG.error("targetBundleName cannot be same with the bundleName."); + LOG.error(PackingToolErrMsg.CHECK_OVERLAYCF_CFG_FAILED.toString("targetBundleName cannot be same with the bundleName.")); return false; } } else { if (ModuleJsonUtil.isExistedStageAppTargetPriority(jsonString)) { - LOG.error("targetPriority cannot be existed without the targetBundleName in app.json."); + LOG.error(PackingToolErrMsg.CHECK_OVERLAYCF_CFG_FAILED.toString("targetPriority cannot be existed without the targetBundleName in app.json.")); return false; } } @@ -2796,7 +2797,7 @@ public class Compressor { } } } catch (IOException exception) { - LOG.error("Compressor::parseCompressNativeLibs io exception: " + exception.getMessage()); + LOG.error(PackingToolErrMsg.PARSE_COMPRESS_NATIVE_LIBS_FAILED.toString(exception.getMessage())); throw new BundleException("Parse compress native libs failed."); } } @@ -2853,7 +2854,7 @@ public class Compressor { break; } } catch (IOException exception) { - LOG.error("Compressor::parseDeviceType io exception: " + exception.getMessage()); + LOG.error(PackingToolErrMsg.PARSE_DEVICE_TYPE_FAILED.toString(exception.getMessage())); throw new BundleException("Parse device type failed."); } } @@ -2870,18 +2871,18 @@ public class Compressor { List hapVerifyInfos = new ArrayList<>(); for (String hapPath : fileLists) { if (hapPath.isEmpty()) { - LOG.error("Compressor::checkHapIsValid input wrong hap file."); + LOG.error(PackingToolErrMsg.INVALID_HAP_FILE.toString("Input wrong hap or hsp file.")); throw new BundleException("Compressor::checkHapIsValid input wrong hap file."); } File srcFile = new File(hapPath); String fileStr = srcFile.getName(); if (fileStr.isEmpty()) { - LOG.error("Compressor::checkHapIsValid get file name failed."); + LOG.error(PackingToolErrMsg.INVALID_HAP_FILE.toString("get file name failed.")); throw new BundleException("Compressor::checkHapIsValid get file name failed."); } if (!fileStr.toLowerCase(Locale.ENGLISH).endsWith(HAP_SUFFIX) && !fileStr.toLowerCase(Locale.ENGLISH).endsWith(HSP_SUFFIX)) { - LOG.error("Compressor::checkHapIsValid input wrong hap file."); + LOG.error(PackingToolErrMsg.INVALID_HAP_FILE.toString("input wrong hap file.")); throw new BundleException("Compressor::checkHapIsValid input wrong hap file."); } if (isModuleHap(hapPath)) { @@ -2907,8 +2908,9 @@ public class Compressor { for (HapVerifyInfo hapVerifyInfo : hapVerifyInfos) { String bundleType = hapVerifyInfo.getBundleType(); if (TYPE_SHARED.equals(bundleType)) { - LOG.error("Compressor::checkHapIsValid only one item can be entered in the -hsp-path" + - " when bundleType is shared."); + String cause = "Only one item can be entered in the -hsp-path when bundleType is 'shared'."; + String solution = "Ensure that only one item entered in the -hsp-path when bundleType is 'shared'"; + LOG.error(PackingToolErrMsg.CHECK_BUNDLETYPE_INVALID.toString(cause, solution)); return false; } } diff --git a/adapter/ohos/ModuleJsonUtil.java b/adapter/ohos/ModuleJsonUtil.java index 6bbf26904310f5d8c3875987e875d564116f5d92..d07ccd13f5446003fe9fe3cdd48c3ba76d69c477 100644 --- a/adapter/ohos/ModuleJsonUtil.java +++ b/adapter/ohos/ModuleJsonUtil.java @@ -387,13 +387,15 @@ class ModuleJsonUtil { finalPackObj = JSON.parseObject(finalPackInfo); JSONObject srcPackObj = JSON.parseObject(srcPackInfo); if (!verifyPackInfo(finalPackObj, srcPackObj)) { - LOG.error("ModuleJsonUtil:mergeTwoPackInfo verify pack.info failed."); - throw new BundleException("ModuleJsonUtil:mergeTwoPackInfo verify pack.info failed."); + String errMsg = "mergeTwoPackInfo verify pack.info failed."; + LOG.error(PackingToolErrMsg.MERGE_TWO_PACKINFO_FAILED.toString(errMsg)); + throw new BundleException(errMsg); } desPackInfo = mergePackInfoObj(finalPackObj, srcPackObj); } catch (BundleException | JSONException e) { - LOG.error("ModuleJsonUtil:mergeTwoPackInfo merge pack.info failed: " + e.getMessage()); - throw new BundleException("ModuleJsonUtil:mergeTwoPackInfo merge pack.info failed."); + String errMsg = "mergeTwoPackInfo merge pack.info failed: "; + LOG.error(PackingToolErrMsg.MERGE_TWO_PACKINFO_FAILED.toString(errMsg + e.getMessage())); + throw new BundleException(errMsg); } return desPackInfo; } @@ -407,24 +409,28 @@ class ModuleJsonUtil { */ public static boolean verifyPackInfo(JSONObject finalPackObj, JSONObject srcPackObj) throws BundleException { if (finalPackObj == null || srcPackObj == null) { - LOG.error("ModuleJsonUtil:verifyPackInfo fail to read pack.info."); + String errMsg = "verifyPackInfo fail to read pack.info."; + LOG.error(PackingToolErrMsg.VERIFY_PACKINFO_FAILED.toString(errMsg)); return false; } JSONObject finalSummaryObj = finalPackObj.getJSONObject(SUMMARY); JSONObject srcSummaryObj = srcPackObj.getJSONObject(SUMMARY); if (finalSummaryObj == null || srcSummaryObj == null) { - LOG.error("ModuleJsonUtil:verifyPackInfo pack.info do not contain summary."); + String errMsg = "verifyPackInfo pack.info do not contain summary."; + LOG.error(PackingToolErrMsg.VERIFY_PACKINFO_FAILED.toString(errMsg)); return false; } // check app info JSONObject finalAppObj = finalSummaryObj.getJSONObject(APP); JSONObject srcAppObj = srcSummaryObj.getJSONObject(APP); if (finalAppObj == null || srcAppObj == null) { - LOG.error("ModuleJsonUtil:verifyPackInfo pack.info do not contain app."); + String errMsg = "verifyPackInfo pack.info do not contain app."; + LOG.error(PackingToolErrMsg.VERIFY_PACKINFO_FAILED.toString(errMsg)); return false; } if (!verifyAppInPackInfo(finalAppObj, srcAppObj)) { - LOG.error("ModuleJsonUtil:verifyPackInfo verify app failed."); + String errMsg = "verifyPackInfo verify app failed."; + LOG.error(PackingToolErrMsg.VERIFY_PACKINFO_FAILED.toString(errMsg)); return false; } @@ -440,32 +446,37 @@ class ModuleJsonUtil { */ public static boolean verifyAppInPackInfo(JSONObject finalAppObj, JSONObject srcAppObj) { if (finalAppObj == null || srcAppObj == null) { - LOG.error("ModuleJsonUtil:verifyAppInPackInfo input null json object."); + String errMsg = "verifyAppInPackInfo input null json object."; + LOG.error(PackingToolErrMsg.VERIFY_APP_PACKINFO_FAILED.toString(errMsg)); return false; } // check bundleName String finalBundleName = finalAppObj.getString(BUNDLE_NAME); String srcBundleName = srcAppObj.getString(BUNDLE_NAME); if (!finalBundleName.equals(srcBundleName)) { - LOG.error("ModuleJsonUtil:verifyAppInPackInfo bundleName is different."); + String errMsg = "verifyAppInPackInfo bundleName is different."; + LOG.error(PackingToolErrMsg.VERIFY_APP_PACKINFO_FAILED.toString(errMsg)); return false; } // check bundleType if (!checkBundleTypeInPackInfo(finalAppObj, srcAppObj)) { - LOG.error("ModuleJsonUtil:verifyAppInPackInfo bundleType is different."); + String errMsg = "verifyAppInPackInfo bundleType is different."; + LOG.error(PackingToolErrMsg.VERIFY_APP_PACKINFO_FAILED.toString(errMsg)); return false; } // check version JSONObject finalVersionObj = finalAppObj.getJSONObject(VERSION); JSONObject srcVersionObj = srcAppObj.getJSONObject(VERSION); if (finalVersionObj == null || srcVersionObj == null) { - LOG.error("ModuleJsonUtil:verifyAppInPackInfo version object is empty."); + String errMsg = "verifyAppInPackInfo version object is empty."; + LOG.error(PackingToolErrMsg.VERIFY_APP_PACKINFO_FAILED.toString(errMsg)); return false; } int finalVersionCode = finalVersionObj.getIntValue(CODE); int srcVersionCode = srcVersionObj.getIntValue(CODE); if (finalVersionCode != srcVersionCode) { - LOG.error("ModuleJsonUtil:verifyAppInPackInfo versionCode is different."); + String errMsg = "verifyAppInPackInfo versionCode is different."; + LOG.error(PackingToolErrMsg.VERIFY_APP_PACKINFO_FAILED.toString(errMsg)); return false; } return true; @@ -480,7 +491,8 @@ class ModuleJsonUtil { */ public static boolean checkBundleTypeInPackInfo(JSONObject finalAppObj, JSONObject srcAppObj) { if (finalAppObj.isEmpty() || srcAppObj.isEmpty()) { - LOG.error("ModuleJsonUtil:checkBundleTypeInPackInfo pack.info has empty module."); + String errMsg = "checkBundleTypeInPackInfo pack.info has empty module."; + LOG.error(PackingToolErrMsg.BUNDLE_TYPE_PACKINFO_INVALID.toString(errMsg)); return false; } String finalBundleType = "app"; @@ -492,7 +504,8 @@ class ModuleJsonUtil { srcBundleType = getJsonString(srcAppObj, BUNDLE_TYPE); } if (!finalBundleType.equals(srcBundleType)) { - LOG.error("bundleType in pack.info is not same."); + String errMsg = "bundleType in pack.info is not same."; + LOG.error(PackingToolErrMsg.BUNDLE_TYPE_PACKINFO_INVALID.toString(errMsg)); return false; } return true; @@ -508,7 +521,7 @@ class ModuleJsonUtil { public static boolean verifyModuleInPackInfo(JSONArray finalModuleObs, JSONArray srcModuleObs) throws BundleException { if (finalModuleObs.isEmpty() || srcModuleObs.isEmpty()) { - LOG.error("ModuleJsonUtil:verifyModuleInPackInfo pack.info has empty module."); + LOG.error("verifyModuleInPackInfo pack.info has empty module."); throw new BundleException("ModuleJsonUtil:verifyModuleInPackInfo pack.info has empty module."); } List moduleNames = new ArrayList<>(); @@ -516,7 +529,7 @@ class ModuleJsonUtil { JSONObject finalModuleObj = finalModuleObs.getJSONObject(i); String moduleName = parseDistroModuleName(finalModuleObj); if (moduleNames.contains(moduleName)) { - LOG.error("ModuleJsonUtil:verifyModuleInPackInfo duplicated moduleName."); + LOG.error("verifyModuleInPackInfo duplicated moduleName."); return false; } else { moduleNames.add(moduleName); @@ -526,7 +539,7 @@ class ModuleJsonUtil { JSONObject srcModuleObj = srcModuleObs.getJSONObject(i); String moduleName = parseDistroModuleName(srcModuleObj); if (moduleNames.contains(moduleName)) { - LOG.error("ModuleJsonUtil:verifyModuleInPackInfo duplicated moduleName."); + LOG.error("verifyModuleInPackInfo duplicated moduleName."); return false; } else { moduleNames.add(moduleName); @@ -548,13 +561,15 @@ class ModuleJsonUtil { throws BundleException { JSONObject jsonObject = JSONObject.parseObject(jsonString); if (jsonObject == null || !jsonObject.containsKey(SUMMARY)) { - LOG.error("ModuleJsonUtil::parsePackInfoFormsName error: summary is null."); + String errMsg = "parsePackInfoFormsName error: summary is null."; + LOG.error(PackingToolErrMsg.PARSE_PACKINFO_FORMS_NAME_FAILED.toString(errMsg)); throw new BundleException("Parse pack info forms name failed, summary is null."); } JSONObject summaryJson = jsonObject.getJSONObject(SUMMARY); if (summaryJson == null || !summaryJson.containsKey("modules")) { - LOG.error("ModuleJsonUtil::parsePackInfoFormsName error: summary.modules is null."); + String errMsg = "parsePackInfoFormsName error: summary.modules is null."; + LOG.error(PackingToolErrMsg.PARSE_PACKINFO_FORMS_NAME_FAILED.toString(errMsg)); return; } @@ -562,13 +577,15 @@ class ModuleJsonUtil { for (int i = 0; i < moduleJsonList.size(); i++) { JSONObject moduleJson = moduleJsonList.getJSONObject(i); if (moduleJson == null || !moduleJson.containsKey(DISTRO)) { - LOG.error("ModuleJsonUtil::parsePackInfoFormsName error: summary.modules.distro is null."); + String errMsg = "parsePackInfoFormsName error: summary.modules.distro is null."; + LOG.error(PackingToolErrMsg.PARSE_PACKINFO_FORMS_NAME_FAILED.toString(errMsg)); continue; } JSONObject distroObj = moduleJson.getJSONObject(DISTRO); if (distroObj == null || !distroObj.containsKey(MODULE_NAME)) { - LOG.error("ModuleJsonUtil::parsePackInfoFormsName error: summary.modules.distro.moduleName is null."); + String errMsg = "parsePackInfoFormsName error: summary.modules.distro.moduleName is null."; + LOG.error(PackingToolErrMsg.PARSE_PACKINFO_FORMS_NAME_FAILED.toString(errMsg)); continue; } @@ -623,22 +640,26 @@ class ModuleJsonUtil { String moduleName = ""; try { if (moduleObj == null) { - LOG.error("ModuleJsonUtil:parseFaModuleName failed: json file do not contain module."); + String errMsg = "parseFaModuleName failed: json file do not contain module."; + LOG.error(PackingToolErrMsg.PARSE_DISTOR_MODULENAME_FAILED.toString(errMsg)); throw new BundleException("ModuleJsonUtil:parseFaModuleName failed: json file do not contain module."); } JSONObject distroObj = moduleObj.getJSONObject(DISTRO); if (distroObj == null) { - LOG.error("ModuleJsonUtil:parseFaModuleName failed: json file do not contain distro."); + String errMsg = "parseFaModuleName failed: json file do not contain distro."; + LOG.error(PackingToolErrMsg.PARSE_DISTOR_MODULENAME_FAILED.toString(errMsg)); throw new BundleException("ModuleJsonUtil:parseFaModuleName failed: json file do not contain distro."); } if (!distroObj.containsKey(MODULE_NAME)) { - LOG.error("ModuleJsonUtil:parseFaModuleName failed: json file do not contain moduleName."); + String errMsg = "parseFaModuleName failed: json file do not contain moduleName."; + LOG.error(PackingToolErrMsg.PARSE_DISTOR_MODULENAME_FAILED.toString(errMsg)); throw new BundleException("ModuleJsonUtil:parseFaModuleName failed:" + "json file do not contain moduleName."); } moduleName = distroObj.getString(MODULE_NAME); } catch (BundleException e) { - LOG.error("ModuleJsonUtil:parseFaModuleName failed."); + String errMsg = "parseFaModuleName failed."; + LOG.error(PackingToolErrMsg.PARSE_DISTOR_MODULENAME_FAILED.toString(errMsg)); throw new BundleException("ModuleJsonUtil:parseFaModuleName failed."); } return moduleName; @@ -653,23 +674,23 @@ class ModuleJsonUtil { */ public static String mergePackInfoObj(JSONObject finalPackinfoObj, JSONObject srcPackinfoObj) throws BundleException { if (finalPackinfoObj == null || srcPackinfoObj == null) { - String errMsg = "ModuleJsonUtil:mergePackInfoObj input an invalid json object."; - LOG.error(errMsg); + String errMsg = "mergePackInfoObj input an invalid json object."; + LOG.error(PackingToolErrMsg.MERGE_PACKINFO_OBJ_FAILED.toString(errMsg)); throw new BundleException(errMsg); } JSONObject finalSummaryObj = finalPackinfoObj.getJSONObject(SUMMARY); JSONObject srcSummaryObj = srcPackinfoObj.getJSONObject(SUMMARY); if (finalSummaryObj == null || srcSummaryObj == null) { - String errMsg = "ModuleJsonUtil:mergePackInfoObj input json file has empty summary."; - LOG.error(errMsg); + String errMsg = "mergePackInfoObj input json file has empty summary."; + LOG.error(PackingToolErrMsg.MERGE_PACKINFO_OBJ_FAILED.toString(errMsg)); throw new BundleException(errMsg); } // merge modules JSONArray finalModuleObs = finalSummaryObj.getJSONArray(MODULES); JSONArray srcModuleObs = srcSummaryObj.getJSONArray(MODULES); if (finalModuleObs == null || srcModuleObs == null) { - String errMsg = "ModuleJsonUtil:mergePackInfoObj input json file has empty module."; - LOG.error(errMsg); + String errMsg = "mergePackInfoObj input json file has empty module."; + LOG.error(PackingToolErrMsg.MERGE_PACKINFO_OBJ_FAILED.toString(errMsg)); throw new BundleException(errMsg); } finalModuleObs.addAll(srcModuleObs); @@ -677,8 +698,8 @@ class ModuleJsonUtil { JSONArray finalPackageObs = finalPackinfoObj.getJSONArray(PACKAGES); JSONArray srcPackageObs = srcPackinfoObj.getJSONArray(PACKAGES); if (finalPackageObs == null || srcPackageObs == null) { - String errMsg = "ModuleJsonUtil:mergePackInfoObj input json file has empty packages."; - LOG.error(errMsg); + String errMsg = "mergePackInfoObj input json file has empty packages."; + LOG.error(PackingToolErrMsg.MERGE_PACKINFO_OBJ_FAILED.toString(errMsg)); throw new BundleException(errMsg); } finalPackageObs.addAll(srcPackageObs); @@ -703,7 +724,7 @@ class ModuleJsonUtil { srcPackObj = JSON.parseObject(srcPackInfo); } catch (JSONException exception) { String errMsg = "parse JSONObject failed: " + exception.getMessage(); - LOG.error(errMsg); + LOG.error(PackingToolErrMsg.MERGE_BYPACKAGE_PAIR_FAILED.toString(errMsg)); throw new BundleException(errMsg); } // verify app in pack.info @@ -713,7 +734,7 @@ class ModuleJsonUtil { JSONObject srcAppObj = srcSummaryObj.getJSONObject(APP); if (!verifyAppInPackInfo(finalAppObj, srcAppObj)) { String errMsg = "verify pack.info failed, different version, bundleType or bundleName."; - LOG.error(errMsg); + LOG.error(PackingToolErrMsg.MERGE_BYPACKAGE_PAIR_FAILED.toString(errMsg)); throw new BundleException(errMsg); } for (HashMap.Entry entry : packagePair.entrySet()) { @@ -735,22 +756,23 @@ class ModuleJsonUtil { public static void mergeTwoPackInfoObjByPackagePair(JSONObject finalPackObj, JSONObject srcPackObj, String packageName, String moduleName) throws BundleException { if (finalPackObj == null || srcPackObj == null) { - String errMsg = "ModuleJsonUtil:mergeTwoPackInfoObjByPackagePair failed: pack.info is not json object."; - LOG.error(errMsg); + String errMsg = "mergeTwoPackInfoObjByPackagePair failed: pack.info is not json object."; + LOG.error(PackingToolErrMsg.MERGE_OBJBY_PACKAGE_PAIR_FAILED.toString(errMsg)); throw new BundleException(errMsg); } // merge module JSONObject finalSummaryObj = finalPackObj.getJSONObject(SUMMARY); JSONObject srcSummaryObj = srcPackObj.getJSONObject(SUMMARY); if (finalSummaryObj == null || srcSummaryObj == null) { - String errMsg = "ModuleJsonUtil:mergeTwoPackInfoObjByPackagePair failed: pack.info do not contain summary."; - LOG.error(errMsg); + String errMsg = "mergeTwoPackInfoObjByPackagePair failed: pack.info do not contain summary."; + LOG.error(PackingToolErrMsg.MERGE_OBJBY_PACKAGE_PAIR_FAILED.toString(errMsg)); throw new BundleException(errMsg); } JSONArray finalModules = finalSummaryObj.getJSONArray(MODULES); JSONArray srcModules = srcSummaryObj.getJSONArray(MODULES); if (finalModules == null || srcModules == null) { - LOG.error("ModuleJsonUtil:mergeTwoPackInfoObjByPackagePair input json file has empty module."); + String errMsg = "mergeTwoPackInfoObjByPackagePair input json file has empty module."; + LOG.error(PackingToolErrMsg.MERGE_OBJBY_PACKAGE_PAIR_FAILED.toString(errMsg)); throw new BundleException("ModuleJsonUtil:mergeTwoPackInfoObjByPackagePair input json file has empty module."); } @@ -765,9 +787,9 @@ class ModuleJsonUtil { } } if (!findModule) { - String errMsg = "ModuleJsonUtil:mergeTwoPackInfoObjByPackagePair" + + String errMsg = "mergeTwoPackInfoObjByPackagePair" + " input json do not contain " + moduleName + "."; - LOG.error(errMsg); + LOG.error(PackingToolErrMsg.MERGE_OBJBY_PACKAGE_PAIR_FAILED.toString(errMsg)); throw new BundleException(errMsg); } // merge package @@ -775,8 +797,8 @@ class ModuleJsonUtil { JSONArray srcPackages = srcPackObj.getJSONArray(PACKAGES); if (finalPackages == null || srcPackages == null) { String errMsg = - "ModuleJsonUtil:mergeTwoPackInfoObjByPackagePair failed: pack.info do not contain packages."; - LOG.error(errMsg); + "mergeTwoPackInfoObjByPackagePair failed: pack.info do not contain packages."; + LOG.error(PackingToolErrMsg.MERGE_OBJBY_PACKAGE_PAIR_FAILED.toString(errMsg)); throw new BundleException(errMsg); } boolean findPackage = false; @@ -789,9 +811,9 @@ class ModuleJsonUtil { } } if (!findPackage) { - String errMsg = "ModuleJsonUtil:mergeTwoPackInfoObjByPackagePair input json do not contain " + String errMsg = "mergeTwoPackInfoObjByPackagePair input json do not contain " + packageName + "."; - LOG.error(errMsg); + LOG.error(PackingToolErrMsg.MERGE_OBJBY_PACKAGE_PAIR_FAILED.toString(errMsg)); throw new BundleException(errMsg); } } @@ -1842,12 +1864,13 @@ class ModuleJsonUtil { try { jsonObject = JSON.parseObject(jsonString); } catch (JSONException exception) { - LOG.error("parse JOSNObject failed in isExistedProperty."); + LOG.error(PackingToolErrMsg.PARSE_JSONOBJECT_FAILED.toString("parse JOSNObject failed in isExistedProperty.")); throw new BundleException("parse JOSNObject failed in isExistedProperty."); } JSONObject appObj = jsonObject.getJSONObject(fatherProperty); if (appObj == null) { - LOG.error("parse failed, input module.json is invalid, module.json has no " + fatherProperty + "."); + String errMsg = "parse failed, input module.json is invalid, module.json has no "+ fatherProperty; + LOG.error(PackingToolErrMsg.PARSE_JSONOBJECT_FAILED.toString(errMsg)); throw new BundleException("parse failed, input module.json is invalid, module.json has no " + fatherProperty + "."); } @@ -1899,7 +1922,8 @@ class ModuleJsonUtil { if (moduleObj.containsKey(ATOMIC_SERVICE) && (!appObj.containsKey(BUNDLE_TYPE) || !getJsonString(appObj, BUNDLE_TYPE).equals(ATOMIC_SERVICE))) { - LOG.error("module can not config atomicService when bundleType is not atomicService."); + String errMsg = "module can not config atomicService when bundleType is not atomicService."; + LOG.error(PackingToolErrMsg.CHECK_MODULE_ATOMIC_SERVICE_FAILED.toString(errMsg)); return false; } return true; @@ -1916,7 +1940,8 @@ class ModuleJsonUtil { return true; } if (parseModuleType(jsonString).equals(ENTRY) && parseAbilityNames(jsonString).isEmpty()) { - LOG.error("entry module must contain at least one ability."); + String errMsg = "entry module must contain at least one ability."; + LOG.error(PackingToolErrMsg.CHECK_LEASTONE_ABILITY.toString(errMsg)); return false; } return true; @@ -1938,7 +1963,7 @@ class ModuleJsonUtil { if (installationFree) { String errMessage = "The app.json5 file configuration does not match the installationFree:" + " true settings. Add the bundleType field to the app.json5 file and set it atomicService."; - LOG.error(errMessage); + LOG.error(PackingToolErrMsg.CHECK_ATOMIC_SERVICE_INSTALLATION_FREE_FAILED.toString(errMessage)); return false; } return true; @@ -1946,26 +1971,26 @@ class ModuleJsonUtil { String bundleType = getJsonString(appObj, BUNDLE_TYPE); if (bundleType.equals(APP)) { if (installationFree) { - LOG.error("installationFree must be false when bundleType is app."); + LOG.error(PackingToolErrMsg.CHECK_ATOMIC_SERVICE_INSTALLATION_FREE_FAILED.toString("installationFree must be false when bundleType is app.")); return false; } } else if (bundleType.equals(ATOMIC_SERVICE)) { if (!installationFree) { - LOG.error("installationFree must be true when bundleType is atomicService."); + LOG.error(PackingToolErrMsg.CHECK_ATOMIC_SERVICE_INSTALLATION_FREE_FAILED.toString("installationFree must be true when bundleType is atomicService.")); return false; } } else if (SHARED.equals(bundleType)) { if (installationFree) { - LOG.error("installationFree must be false when bundleType is shared."); + LOG.error(PackingToolErrMsg.CHECK_ATOMIC_SERVICE_INSTALLATION_FREE_FAILED.toString("installationFree must be false when bundleType is shared.")); return false; } } else if (APP_SERVICE.equals(bundleType)) { if (installationFree) { - LOG.error("installationFree must be false when bundleType is appService."); + LOG.error(PackingToolErrMsg.CHECK_ATOMIC_SERVICE_INSTALLATION_FREE_FAILED.toString("installationFree must be false when bundleType is appService.")); return false; } } else { - LOG.error("bundleType is invalid in app.json."); + LOG.error(PackingToolErrMsg.CHECK_ATOMIC_SERVICE_INSTALLATION_FREE_FAILED.toString("bundleType is invalid in app.json.")); return false; } return true; @@ -2030,7 +2055,7 @@ class ModuleJsonUtil { for (int i = 0; i < formJsonList.size(); i++) { JSONObject formObj = formJsonList.getJSONObject(i); if (formObj == null || !formObj.containsKey(NAME)) { - LOG.warning("ModuleJsonUtil::parsePackInfoForms error: " + + LOG.warning("parsePackInfoForms error: " + "summary.modules.extensionAbilities.forms.name is null."); continue; } @@ -2038,20 +2063,23 @@ class ModuleJsonUtil { String name = formObj.getString(NAME); formNameList.add(name); if (!formObj.containsKey(DEFAULTDIMENSION)) { - LOG.error("ModuleJsonUtil::parsePackInfoForms exception: " + - "summary.modules.extensionAbilities.forms.defaultDimension is null."); + String errMsg = "parsePackInfoForms exception: " + + "summary.modules.extensionAbilities.forms.defaultDimension is null."; + LOG.error(PackingToolErrMsg.PARSE_PACKINFO_FORMS_FAILED.toString(errMsg)); throw new BundleException("Parse pack info defaultDimension failed, defaultDimension is null."); } String defaultDimension = formObj.getString(DEFAULTDIMENSION); if (getCount(defaultDimension, '*') != 1) { - LOG.error("ModuleJsonUtil::parsePackInfoForms exception: " + - "summary.modules.extensionAbilities.forms.defaultDimension is not only 1."); + String errMsg = "parsePackInfoForms exception: " + + "summary.modules.extensionAbilities.forms.defaultDimension is not only 1."; + LOG.error(PackingToolErrMsg.PARSE_PACKINFO_FORMS_FAILED.toString(errMsg)); throw new BundleException("Parse pack info defaultDimension failed, defaultDimension is not only 1."); } if (!formObj.containsKey(SUPPORTDIMENSIONS)) { - LOG.error("ModuleJsonUtil::parsePackInfoForms exception: " + - "summary.modules.extensionAbilities.forms.supportDimensions is null."); + String errMsg = "parsePackInfoForms exception: " + + "summary.modules.extensionAbilities.forms.supportDimensions is null."; + LOG.error(PackingToolErrMsg.PARSE_PACKINFO_FORMS_FAILED.toString(errMsg)); throw new BundleException("Parse pack info supportDimensions failed, supportDimensions is null."); } diff --git a/adapter/ohos/PackingToolErrMsg.java b/adapter/ohos/PackingToolErrMsg.java new file mode 100644 index 0000000000000000000000000000000000000000..d4b159af889cfe5ed4ed71b8ea9fe3f0a90accb6 --- /dev/null +++ b/adapter/ohos/PackingToolErrMsg.java @@ -0,0 +1,528 @@ +/* + * Copyright (c) 2025-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ohos; + +/** + * SignToolErrMsg + * + * @since 2025/01/06 + */ +public class PackingToolErrMsg { + + /** + * CHECK_MODULE_ATOMIC_SERVICE_FAILED + */ + public static final ErrorMsg CHECK_MODULE_ATOMIC_SERVICE_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("10") + .addErrCode("003") + .addDescription("when bundleType is not atomicService") + .addCause("%s") + .build(); + + /** + * CHECK_LEASTONE_ABILITY + */ + public static final ErrorMsg CHECK_LEASTONE_ABILITY = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("10") + .addErrCode("004") + .addDescription("check at least one ability") + .addCause("%s") + .build(); + + /** + * CHECK_ATOMIC_SERVICE_FAILED + */ + public static final ErrorMsg CHECK_ATOMIC_SERVICE_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("10") + .addErrCode("005") + .addDescription("check EntryInAtomicService failed.") + .addCause("%s") + .build(); + + /** + * CHECK_STAGE_HAP_FAILED + */ + public static final ErrorMsg CHECK_STAGE_HAP_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("11") + .addErrCode("001") + .addDescription("check AsanTsanEnabledValid failed") + .addCause("%s") + .build(); + + /** + * CHECK_AS_TSAN_ENABLED + */ + public static final ErrorMsg CHECK_AS_TSAN_ENABLED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("11") + .addErrCode("004") + .addDescription("Check asanEnabled and tsanEnabled failed") + .addCause("%s") + .addSolution("Please set the correct values for the parameters.") + .build(); + + /** + * CHECK_HWASAN_ENABLED_INVALID + */ + + public static final ErrorMsg CHECK_HWASAN_ENABLED_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("11") + .addErrCode("005") + .addDescription("Check hwasanEnabled and asanEnabled failed") + .addCause("%s") + .addSolution("Please set the correct values for the parameters.") + .build(); + + /** + * CHECK_UBASAN_ENABLED_INVALID + */ + public static final ErrorMsg CHECK_UBASAN_ENABLED_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("11") + .addErrCode("008") + .addDescription("Check ubsanEnabled and asanEnabled failed") + .addCause("%s") + .addSolution("Please set the correct values for the parameters.") + .build(); + + /** + * CHECK_ATOMIC_SERVICE_INSTALLATION_FREE_FAILED + */ + public static final ErrorMsg CHECK_ATOMIC_SERVICE_INSTALLATION_FREE_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("12") + .addErrCode("002") + .addDescription("file configuration does not match") + .addCause("%s") + .build(); + + //file operator failed + /** + * FILE_NOT_FOUND + */ + public static final ErrorMsg FILE_NOT_FOUND = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("14") + .addErrCode("001") + .addDescription("File not found exception.") + .addCause("%s") + .build(); + + /** + * FILE_DELETE_FAILED + */ + public static final ErrorMsg FILE_DELETE_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("14") + .addErrCode("002") + .addDescription("File delete failed.") + .addCause("%s") + .build(); + + + // compress process error + /** + * COMPRESS_PROCESS_EXCEPTION + */ + public static final ErrorMsg COMPRESS_PROCESS_EXCEPTION = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("15") + .addErrCode("001") + .addDescription("Process compress exception.") + .addCause("%s") + .addSolution("Please check the related error message and modify. If the issue persists, review the logs for more details.") + .build(); + + /** + * INVALID_HAP_FILE + */ + public static final ErrorMsg INVALID_HAP_FILE = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("16") + .addErrCode("001") + .addDescription("Invaild hap or hsp file.") + .addCause("%s") + .build(); + + /** + * READ_STAGE_HAP_VERIFY_INFO_FAILED + */ + public static final ErrorMsg READ_STAGE_HAP_VERIFY_INFO_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("20") + .addErrCode("001") + .addDescription("Read stage hap verify info io exception.") + .addCause("%s") + .build(); + + /** + * READ_FA_HAP_VERIFY_INFO_FAILED + */ + public static final ErrorMsg READ_FA_HAP_VERIFY_INFO_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("20") + .addErrCode("002") + .addDescription("Read FA hap verify info io exception.") + .addCause("%s") + .build(); + + /** + * PARSE_COMPRESS_NATIVE_LIBS_FAILED + */ + public static final ErrorMsg PARSE_COMPRESS_NATIVE_LIBS_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("21") + .addErrCode("007") + .addDescription("Failed to parse compress native libs.") + .addCause("%s") + .build(); + + /** + * PARSE_DEVICE_TYPE_FAILED + */ + public static final ErrorMsg PARSE_DEVICE_TYPE_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("21") + .addErrCode("009") + .addDescription("parse DeviceType io exception.") + .addCause("%s") + .build(); + + /** + * CHECK_BUNDLETYPE_INVALID + */ + public static final ErrorMsg CHECK_BUNDLETYPE_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("22") + .addErrCode("003") + .addDescription("Check bundleType is invalid") + .addCause("%s") + .addSolution("%s") + .build(); + + /** + * CHECK_OVERLAYCF_CFG_FAILED + */ + public static final ErrorMsg CHECK_OVERLAYCF_CFG_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("27") + .addErrCode("002") + .addDescription("The names cannot be the same") + .addCause("%s") + .build(); + + /** + * CHECK_CONTINUE_BUNDLENAME_INVALID + */ + public static final ErrorMsg CHECK_CONTINUE_BUNDLENAME_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("28") + .addErrCode("004") + .addDescription("continueBundleName and BundleName cannot be the same") + .addCause("%s") + .addSolution("") + .build(); + + /** + * COMPRESS_HAP_FAILED + */ + public static final ErrorMsg COMPRESS_HAP_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("29") + .addErrCode("001") + .addDescription("check StageHap failed") + .addCause("%s") + .build(); + + /** + * COMPRESS_HSP_FAILED + */ + public static final ErrorMsg COMPRESS_HSP_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("29") + .addErrCode("002") + .addDescription("Compress Hsp failed") + .addCause("%s") + .build(); + + //packing process error + /** + * COMPRESS_PROCESS + */ + public static final ErrorMsg COMPRESS_PROCESS_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("31") + .addErrCode("001") + .addDescription("Execute compress process failed.") + .addCause("%s") + .addSolution("%s") + .build(); + + + /** + * HSP_MODE_ARGS_INVALID + */ + public static final ErrorMsg HSP_MODE_ARGS_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("32") + .addErrCode("001") + .addDescription("ArgsValidInHspMode invalid") + .addCause("%s") + .build(); + + /** + * HAP_ADD_VERIF_INVALID + */ + public static final ErrorMsg HAP_ADD_VERIF_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("32") + .addErrCode("004") + .addDescription("VerifyValidInHapAdditionMode invalid.") + .addCause("%s") + .build(); + + /** + * BUNDLE_TYPE_SHARED_INVALID + */ + public static final ErrorMsg BUNDLE_TYPE_SHARED_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("32") + .addErrCode("005") + .addDescription("isBundleTypeShared invalid.") + .addCause("%s") + .build(); + + /** + * BUNDLE_TYPE_APPSERVICE_INVALID + */ + public static final ErrorMsg BUNDLE_TYPE_APPSERVICE_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("32") + .addErrCode("006") + .addDescription("isBundleTypeAppService invalid.") + .addCause("%s") + .build(); + + /** + * HSP_HAS_ABILITIES_INVALID + */ + public static final ErrorMsg HSP_HAS_ABILITIES_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("32") + .addErrCode("007") + .addDescription("hspHasAbilities invalid.") + .addCause("%s") + .build(); + + /** + * HSP_HAS_EXTENSION_ABILITIES_INVALID + */ + public static final ErrorMsg HSP_HAS_EXTENSION_ABILITIES_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("32") + .addErrCode("008") + .addDescription("hspHasExtensionAbilities invalid.") + .addCause("%s") + .build(); + + /** + * HAS_HOME_ABILITY_INVALID + */ + public static final ErrorMsg HAS_HOME_ABILITY_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("32") + .addErrCode("009") + .addDescription("hasHomeAbility invalid.") + .addCause("%s") + .build(); + + /** + * HAS_HOME_EXTENSION_ABILITY_INVALID + */ + public static final ErrorMsg HAS_HOME_EXTENSION_ABILITY_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("32") + .addErrCode("010") + .addDescription("hasHomeExtensionAbility invalid.") + .addCause("%s") + .build(); + + /** + * CHECK_JSON_INVALID + */ + public static final ErrorMsg CHECK_JSON_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("32") + .addErrCode("011") + .addDescription("CheckJsonIsValid invalid.") + .addCause("%s") + .build(); + + /** + * DIRECTORY_INVALID + */ + public static final ErrorMsg DIRECTORY_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("32") + .addErrCode("012") + .addDescription("directory is not exist.") + .addCause("%s") + .build(); + + /** + * HAR_MODE_ARGS_INVALID + */ + public static final ErrorMsg HAR_MODE_ARGS_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("32") + .addErrCode("013") + .addDescription("isArgsValidInHarMode invalid.") + .addCause("%s") + .build(); + + /** + * HAP_MODE_ARGS_INVALID + */ + public static final ErrorMsg HAP_MODE_ARGS_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("32") + .addErrCode("014") + .addDescription("isArgsValidInHapMode invalid.") + .addCause("%s") + .build(); + + /** + * PACKINFO_PATH_FAILED + */ + public static final ErrorMsg PACKINFO_PATH_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("32") + .addErrCode("016") + .addDescription("isArgsValidInHapMode failed.") + .addCause("%s") + .build(); + + /** + * RPCID_PATH_INVALID + */ + public static final ErrorMsg RPCID_PATH_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("32") + .addErrCode("017") + .addDescription("isArgsValidInHapMode failed.") + .addCause("%s") + .build(); + + /** + * MERGE_TWO_PACKINFO_FAILED + */ + public static final ErrorMsg MERGE_TWO_PACKINFO_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("33") + .addErrCode("001") + .addDescription("mergeTwoPackInfo failed.") + .addCause("%s") + .build(); + + /** + * VERIFY_PACKINFO_FAILED + */ + public static final ErrorMsg VERIFY_PACKINFO_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("33") + .addErrCode("002") + .addDescription("verifyPackInfo failed.") + .addCause("%s") + .build(); + + /** + * VERIFY_APP_PACKINFO_FAILED + */ + public static final ErrorMsg VERIFY_APP_PACKINFO_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("33") + .addErrCode("003") + .addDescription("verifyAppInPackInfo failed.") + .addCause("%s") + .build(); + + /** + * BUNDLE_TYPE_PACKINFO_INVALID + */ + public static final ErrorMsg BUNDLE_TYPE_PACKINFO_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("33") + .addErrCode("004") + .addDescription("bundleType invalid.") + .addCause("%s") + .build(); + + /** + * PARSE_PACKINFO_FORMS_NAME_FAILED + */ + public static final ErrorMsg PARSE_PACKINFO_FORMS_NAME_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("33") + .addErrCode("005") + .addDescription("parsePackInfoFormsName error") + .addCause("%s") + .build(); + + /** + * PARSE_DISTOR_MODULENAME_FAILED + */ + public static final ErrorMsg PARSE_DISTOR_MODULENAME_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("33") + .addErrCode("006") + .addDescription("parseFaModuleName failed") + .addCause("%s") + .build(); + + /** + * MERGE_PACKINFO_OBJ_FAILED + */ + public static final ErrorMsg MERGE_PACKINFO_OBJ_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("33") + .addErrCode("007") + .addDescription("mergePackInfoObj invalid") + .addCause("%s") + .build(); + + /** + * MERGE_BYPACKAGE_PAIR_FAILED + */ + public static final ErrorMsg MERGE_BYPACKAGE_PAIR_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("33") + .addErrCode("008") + .addDescription("packinfo failed") + .addCause("%s") + .build(); + + /** + * MERGE_OBJBY_PACKAGE_PAIR_FAILED + */ + public static final ErrorMsg MERGE_OBJBY_PACKAGE_PAIR_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("33") + .addErrCode("009") + .addDescription("mergeTwoPackInfoObjByPackagePair failed") + .addCause("%s") + .build(); + + /** + * PARSE_JSONOBJECT_FAILED + */ + public static final ErrorMsg PARSE_JSONOBJECT_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("33") + .addErrCode("010") + .addDescription("parse JOSNObject failed") + .addCause("%s") + .build(); + + /** + * PARSE_PACKINFO_FORMS_FAILED + */ + public static final ErrorMsg PARSE_PACKINFO_FORMS_FAILED = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("33") + .addErrCode("011") + .addDescription("parsePackInfoForms exception") + .addCause("%s") + .build(); + + /** + * COMMAND_FUNCS_FAILED + */ + public static final ErrorMsg COMMAND_FUNCS_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("34") + .addErrCode("001") + .addDescription("version-code invalid") + .addCause("%s") + .build(); + + /** + * PACK_PATH_INVALID + */ + public static final ErrorMsg PACK_PATH_INVALID = ErrorMsg.getPackingToolErrBuilder() + .addTypeCode("34") + .addErrCode("001") + .addDescription("Path invalid") + .addCause("%s") + .build(); + +}