private void deactivateApp(App app) { try { //noinspection StringConcatenationMissingWhitespace fileStore.deleteDirectory(FILE_STORE_PLUGIN_APPS_PATH + separatorChar + app.getId()); } catch (IOException e) { LOG.error("", e); throw new RuntimeException(format("An error occurred deactivating app '%s'", app.getName())); } }
@Override public AppConfig checkAndObtainConfig(String tempDir, String configContent) throws IOException { if (configContent.isEmpty() || !isConfigContentValidJson(configContent)) { fileStore.deleteDirectory(APPS_TMP_DIR); throw new InvalidAppConfigException(); } AppConfig appConfig = gson.fromJson(configContent, AppConfig.class); List<String> missingAppConfigParams = buildMissingConfigParams(appConfig); if (!missingAppConfigParams.isEmpty()) { fileStore.deleteDirectory(APPS_TMP_DIR); throw new AppConfigMissingParametersException(missingAppConfigParams); } if (appConfig.getName().contains("/")) { fileStore.deleteDirectory(APPS_TMP_DIR); throw new IllegalAppNameException(appConfig.getName()); } if (fileStore.getFile(APPS_DIR + separator + appConfig.getName()).exists()) { fileStore.deleteDirectory(APPS_TMP_DIR); throw new AppAlreadyExistsException(appConfig.getName()); } fileStore.move(tempDir, APPS_DIR + separator + appConfig.getName()); fileStore.deleteDirectory(APPS_TMP_DIR); return appConfig; }
@Override public String uploadApp(InputStream zipData, String zipFileName, String formFieldName) throws IOException { String tempFilesDir = "extracted_" + zipFileName; String tempAppDirectoryName = APPS_TMP_DIR + separator + tempFilesDir; fileStore.createDirectory(tempAppDirectoryName); try { ZipFileUtil.unzip(zipData, fileStore.getFile(tempAppDirectoryName)); } catch (UnzipException unzipException) { fileStore.delete(tempAppDirectoryName); throw new InvalidAppArchiveException(formFieldName, unzipException); } List<String> missingRequiredFilesList = buildMissingRequiredFiles(tempAppDirectoryName); if (!missingRequiredFilesList.isEmpty()) { fileStore.deleteDirectory(APPS_TMP_DIR); throw new AppArchiveMissingFilesException(missingRequiredFilesList); } return tempAppDirectoryName; }