@Test public void givenThereIsStillRunningInstanceForPluginPackageWhenDecommissionThenShouldThrowException() { Timestamp now = new Timestamp(System.currentTimeMillis()); PluginPackage pluginPackage = new PluginPackage(null, "qcloud", "v1.0", PluginPackage.Status.REGISTERED, now, false); PluginPackage savedPluginPackage = packageRepository.save(pluginPackage); PluginInstance instance = new PluginInstance(null, savedPluginPackage, "qcloud", "127.0.0.1", 20000, PluginInstance.CONTAINER_STATUS_RUNNING); instanceRepository.save(instance); try { pluginPackageService.decommissionPluginPackage(savedPluginPackage.getId()); } catch (Exception e) { assertThat(e instanceof WecubeCoreException).isTrue(); } }
public void decommissionPluginPackage(String pluginPackageId) { ensurePluginPackageExists(pluginPackageId); ensureNoPluginInstanceIsRunningForPluginPackage(pluginPackageId); PluginPackage pluginPackage = pluginPackageRepository.findById(pluginPackageId).get(); pluginConfigService.disableAllPluginsForPluginPackage(pluginPackageId); deactivateSystemVariables(pluginPackage); decommissionPluginPackageAndDisableAllItsPlugins(pluginPackage); removeLocalDockerImageFiles(pluginPackage); removePluginUiResourcesIfRequired(pluginPackage); }
PluginPackageService { public void decommissionPluginPackage(String pluginPackageId) { ensurePluginPackageExists(pluginPackageId); ensureNoPluginInstanceIsRunningForPluginPackage(pluginPackageId); PluginPackage pluginPackage = pluginPackageRepository.findById(pluginPackageId).get(); pluginConfigService.disableAllPluginsForPluginPackage(pluginPackageId); deactivateSystemVariables(pluginPackage); decommissionPluginPackageAndDisableAllItsPlugins(pluginPackage); removeLocalDockerImageFiles(pluginPackage); removePluginUiResourcesIfRequired(pluginPackage); } }
PluginPackageService { public void decommissionPluginPackage(String pluginPackageId) { ensurePluginPackageExists(pluginPackageId); ensureNoPluginInstanceIsRunningForPluginPackage(pluginPackageId); PluginPackage pluginPackage = pluginPackageRepository.findById(pluginPackageId).get(); pluginConfigService.disableAllPluginsForPluginPackage(pluginPackageId); deactivateSystemVariables(pluginPackage); decommissionPluginPackageAndDisableAllItsPlugins(pluginPackage); removeLocalDockerImageFiles(pluginPackage); removePluginUiResourcesIfRequired(pluginPackage); }  }
PluginPackageService { public void decommissionPluginPackage(String pluginPackageId) { ensurePluginPackageExists(pluginPackageId); ensureNoPluginInstanceIsRunningForPluginPackage(pluginPackageId); PluginPackage pluginPackage = pluginPackageRepository.findById(pluginPackageId).get(); pluginConfigService.disableAllPluginsForPluginPackage(pluginPackageId); deactivateSystemVariables(pluginPackage); decommissionPluginPackageAndDisableAllItsPlugins(pluginPackage); removeLocalDockerImageFiles(pluginPackage); removePluginUiResourcesIfRequired(pluginPackage); }  void enablePluginConfigInBatchByPackageId(String packageId, List<PluginDeclarationDto> pluginConfigDtos); List<PluginDeclarationDto> getPluginConfigOutlinesByPackageId(String packageId); PluginConfigOutlineDto fromDomainEnablePluginConfigDto(PluginConfig pluginConfig); PluginDeclarationDto fromDomain(PluginConfig pluginConfig); List<S3PluginActifactDto> listS3PluginActifacts(); S3PluginActifactPullRequestDto createS3PluginActifactPullRequest(S3PluginActifactDto pullRequestDto); void handlePullPluginArtifactFailure(PluginArtifactPullContext ctx, Exception e); void pullPluginArtifact(PluginArtifactPullContext ctx); S3PluginActifactPullRequestDto queryS3PluginActifactPullRequest(String requestId); @Transactional PluginPackage uploadPackage(MultipartFile pluginPackageFile); List<PluginPackageInfoDto> getPluginPackages(); List<String> getAllDistinctPluginPackageNameList(); @Transactional PluginPackage registerPluginPackage(String pluginPackageId); void decommissionPluginPackage(String pluginPackageId); void setS3Client(S3Client s3Client); PluginPackage getPackageById(String packageId); PluginPackageDependencyDto getDependenciesById(String packageId); List<MenuItemDto> getMenusById(String packageId); @SuppressWarnings("unchecked") List<SystemVariable> getSystemVarsById(String packageId); Set<PluginPackageAuthority> getAuthoritiesById(String packageId); PluginPackageRuntimeResouceDto getResourcesById(String packageId); List<PluginConfigGroupByNameDto> getPluginConfigsByPackageId(String packageId, boolean needInterfaceInfo); List<MenuItemDto> getAllSysMenus(); }
PluginPackageService { public void decommissionPluginPackage(String pluginPackageId) { ensurePluginPackageExists(pluginPackageId); ensureNoPluginInstanceIsRunningForPluginPackage(pluginPackageId); PluginPackage pluginPackage = pluginPackageRepository.findById(pluginPackageId).get(); pluginConfigService.disableAllPluginsForPluginPackage(pluginPackageId); deactivateSystemVariables(pluginPackage); decommissionPluginPackageAndDisableAllItsPlugins(pluginPackage); removeLocalDockerImageFiles(pluginPackage); removePluginUiResourcesIfRequired(pluginPackage); }  void enablePluginConfigInBatchByPackageId(String packageId, List<PluginDeclarationDto> pluginConfigDtos); List<PluginDeclarationDto> getPluginConfigOutlinesByPackageId(String packageId); PluginConfigOutlineDto fromDomainEnablePluginConfigDto(PluginConfig pluginConfig); PluginDeclarationDto fromDomain(PluginConfig pluginConfig); List<S3PluginActifactDto> listS3PluginActifacts(); S3PluginActifactPullRequestDto createS3PluginActifactPullRequest(S3PluginActifactDto pullRequestDto); void handlePullPluginArtifactFailure(PluginArtifactPullContext ctx, Exception e); void pullPluginArtifact(PluginArtifactPullContext ctx); S3PluginActifactPullRequestDto queryS3PluginActifactPullRequest(String requestId); @Transactional PluginPackage uploadPackage(MultipartFile pluginPackageFile); List<PluginPackageInfoDto> getPluginPackages(); List<String> getAllDistinctPluginPackageNameList(); @Transactional PluginPackage registerPluginPackage(String pluginPackageId); void decommissionPluginPackage(String pluginPackageId); void setS3Client(S3Client s3Client); PluginPackage getPackageById(String packageId); PluginPackageDependencyDto getDependenciesById(String packageId); List<MenuItemDto> getMenusById(String packageId); @SuppressWarnings("unchecked") List<SystemVariable> getSystemVarsById(String packageId); Set<PluginPackageAuthority> getAuthoritiesById(String packageId); PluginPackageRuntimeResouceDto getResourcesById(String packageId); List<PluginConfigGroupByNameDto> getPluginConfigsByPackageId(String packageId, boolean needInterfaceInfo); List<MenuItemDto> getAllSysMenus(); static final Set<String> ACCEPTED_FILES; static final String SYS_VAR_PUBLIC_PLUGIN_ARTIFACTS_RELEASE_URL; static final String PLATFORM_NAME; static final Logger log; }