@Test public void testDeleteExternalProperties() { String[] externalPropertiesArray = new String[]{"external.properties"}; ResourceHierarchyParam param = new ResourceHierarchyParam(); when(impl.deleteExternalProperties()).thenReturn(1); Response result = cut.deleteResources(externalPropertiesArray, param, authenticatedUser); Assert.assertEquals(200, result.getStatus()); verify(impl).deleteExternalProperties(); ApplicationResponse entity = (ApplicationResponse) result.getEntity(); int recCount = (int) entity.getApplicationResponseContent(); Assert.assertEquals(1, recCount); }
@Override public Response deleteResources(final String[] templateNameArray, ResourceHierarchyParam resourceHierarchyParam, AuthenticatedUser user) { LOGGER.info("Delete resources {} by user {} with details {}", templateNameArray, user.getUser().getId(), resourceHierarchyParam); int deletedRecCount = 0; final List<String> templateNameList = Arrays.asList(templateNameArray); if (ParamValidator.getNewInstance().isNotEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isNotEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteGroupLevelAppResources(resourceHierarchyParam.getWebApp(), resourceHierarchyParam.getGroup(), templateNameList); } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isNotEmpty(resourceHierarchyParam.getJvm()) .isNotEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteAppResources(templateNameList, resourceHierarchyParam.getWebApp(), resourceHierarchyParam.getJvm()); } else if (ParamValidator.getNewInstance().isNotEmpty(resourceHierarchyParam.getGroup()) .isNotEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { if (resourceHierarchyParam.getWebServer().equalsIgnoreCase("*")) { deletedRecCount = resourceService.deleteGroupLevelWebServerResources(templateNameList, resourceHierarchyParam.getGroup()); } } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isNotEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteWebServerResources(templateNameList, resourceHierarchyParam.getWebServer()); } else if (ParamValidator.getNewInstance().isNotEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isNotEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { if (resourceHierarchyParam.getJvm().equalsIgnoreCase("*")) { deletedRecCount = resourceService.deleteGroupLevelJvmResources(templateNameList, resourceHierarchyParam.getGroup()); } } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isNotEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteJvmResources(templateNameList, resourceHierarchyParam.getJvm()); } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteExternalProperties(); } else { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException(FaultType.INVALID_REST_SERVICE_PARAMETER, "Parameters passed to the rest service is/are invalid!")); } return ResponseBuilder.ok(deletedRecCount); }
ResourceServiceRestImpl implements ResourceServiceRest { @Override public Response deleteResources(final String[] templateNameArray, ResourceHierarchyParam resourceHierarchyParam, AuthenticatedUser user) { LOGGER.info("Delete resources {} by user {} with details {}", templateNameArray, user.getUser().getId(), resourceHierarchyParam); int deletedRecCount = 0; final List<String> templateNameList = Arrays.asList(templateNameArray); if (ParamValidator.getNewInstance().isNotEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isNotEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteGroupLevelAppResources(resourceHierarchyParam.getWebApp(), resourceHierarchyParam.getGroup(), templateNameList); } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isNotEmpty(resourceHierarchyParam.getJvm()) .isNotEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteAppResources(templateNameList, resourceHierarchyParam.getWebApp(), resourceHierarchyParam.getJvm()); } else if (ParamValidator.getNewInstance().isNotEmpty(resourceHierarchyParam.getGroup()) .isNotEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { if (resourceHierarchyParam.getWebServer().equalsIgnoreCase("*")) { deletedRecCount = resourceService.deleteGroupLevelWebServerResources(templateNameList, resourceHierarchyParam.getGroup()); } } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isNotEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteWebServerResources(templateNameList, resourceHierarchyParam.getWebServer()); } else if (ParamValidator.getNewInstance().isNotEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isNotEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { if (resourceHierarchyParam.getJvm().equalsIgnoreCase("*")) { deletedRecCount = resourceService.deleteGroupLevelJvmResources(templateNameList, resourceHierarchyParam.getGroup()); } } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isNotEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteJvmResources(templateNameList, resourceHierarchyParam.getJvm()); } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteExternalProperties(); } else { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException(FaultType.INVALID_REST_SERVICE_PARAMETER, "Parameters passed to the rest service is/are invalid!")); } return ResponseBuilder.ok(deletedRecCount); } }
ResourceServiceRestImpl implements ResourceServiceRest { @Override public Response deleteResources(final String[] templateNameArray, ResourceHierarchyParam resourceHierarchyParam, AuthenticatedUser user) { LOGGER.info("Delete resources {} by user {} with details {}", templateNameArray, user.getUser().getId(), resourceHierarchyParam); int deletedRecCount = 0; final List<String> templateNameList = Arrays.asList(templateNameArray); if (ParamValidator.getNewInstance().isNotEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isNotEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteGroupLevelAppResources(resourceHierarchyParam.getWebApp(), resourceHierarchyParam.getGroup(), templateNameList); } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isNotEmpty(resourceHierarchyParam.getJvm()) .isNotEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteAppResources(templateNameList, resourceHierarchyParam.getWebApp(), resourceHierarchyParam.getJvm()); } else if (ParamValidator.getNewInstance().isNotEmpty(resourceHierarchyParam.getGroup()) .isNotEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { if (resourceHierarchyParam.getWebServer().equalsIgnoreCase("*")) { deletedRecCount = resourceService.deleteGroupLevelWebServerResources(templateNameList, resourceHierarchyParam.getGroup()); } } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isNotEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteWebServerResources(templateNameList, resourceHierarchyParam.getWebServer()); } else if (ParamValidator.getNewInstance().isNotEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isNotEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { if (resourceHierarchyParam.getJvm().equalsIgnoreCase("*")) { deletedRecCount = resourceService.deleteGroupLevelJvmResources(templateNameList, resourceHierarchyParam.getGroup()); } } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isNotEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteJvmResources(templateNameList, resourceHierarchyParam.getJvm()); } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteExternalProperties(); } else { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException(FaultType.INVALID_REST_SERVICE_PARAMETER, "Parameters passed to the rest service is/are invalid!")); } return ResponseBuilder.ok(deletedRecCount); } ResourceServiceRestImpl(final ResourceService resourceService); }
ResourceServiceRestImpl implements ResourceServiceRest { @Override public Response deleteResources(final String[] templateNameArray, ResourceHierarchyParam resourceHierarchyParam, AuthenticatedUser user) { LOGGER.info("Delete resources {} by user {} with details {}", templateNameArray, user.getUser().getId(), resourceHierarchyParam); int deletedRecCount = 0; final List<String> templateNameList = Arrays.asList(templateNameArray); if (ParamValidator.getNewInstance().isNotEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isNotEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteGroupLevelAppResources(resourceHierarchyParam.getWebApp(), resourceHierarchyParam.getGroup(), templateNameList); } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isNotEmpty(resourceHierarchyParam.getJvm()) .isNotEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteAppResources(templateNameList, resourceHierarchyParam.getWebApp(), resourceHierarchyParam.getJvm()); } else if (ParamValidator.getNewInstance().isNotEmpty(resourceHierarchyParam.getGroup()) .isNotEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { if (resourceHierarchyParam.getWebServer().equalsIgnoreCase("*")) { deletedRecCount = resourceService.deleteGroupLevelWebServerResources(templateNameList, resourceHierarchyParam.getGroup()); } } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isNotEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteWebServerResources(templateNameList, resourceHierarchyParam.getWebServer()); } else if (ParamValidator.getNewInstance().isNotEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isNotEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { if (resourceHierarchyParam.getJvm().equalsIgnoreCase("*")) { deletedRecCount = resourceService.deleteGroupLevelJvmResources(templateNameList, resourceHierarchyParam.getGroup()); } } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isNotEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteJvmResources(templateNameList, resourceHierarchyParam.getJvm()); } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteExternalProperties(); } else { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException(FaultType.INVALID_REST_SERVICE_PARAMETER, "Parameters passed to the rest service is/are invalid!")); } return ResponseBuilder.ok(deletedRecCount); } ResourceServiceRestImpl(final ResourceService resourceService); Response createTemplate(final List<Attachment> attachments, final String targetName, final AuthenticatedUser user); @Override Response getResourceAttrData(); @Override Response getResourceTopology(); @Override Response getApplicationResourceNames(final String groupName, final String appName); @Override Response getAppTemplate(final String groupName, final String appName, final String templateName); @Override Response checkFileExists(final String groupName, final String jvmName, final String webappName, final String webserverName, final String fileName); @Override Response createResource(final String deployFilename, final CreateResourceParam createResourceParam,
                                   final List<Attachment> attachments); void setMessageContext(MessageContext messageContext); @Override Response uploadExternalProperties(AuthenticatedUser user); @Override // TODO: Re validation, maybe we can use CXF bean validation ? Response deleteResource(final String templateName, final ResourceHierarchyParam resourceHierarchyParam,
                                   final AuthenticatedUser aUser); @Override Response deleteResources(final String[] templateNameArray, ResourceHierarchyParam
            resourceHierarchyParam, AuthenticatedUser user); @Override Response getResourceContent(final String resourceName, final ResourceHierarchyParam param); @Override Response updateResourceContent(String resourceName, ResourceHierarchyParam
            resourceHierarchyParam, String templateContent); @Override Response updateResourceMetaData(String resourceName, ResourceHierarchyParam resourceHierarchyParam, String metaData); @Override Response previewResourceContent(final String resourceName, final ResourceHierarchyParam resourceHierarchyParam, String content); @Override Response getResourcesFileNames(ResourceHierarchyParam resourceHierarchyParam); @Override Response getExternalProperties(); @Override Response getExternalPropertiesView(); @Override Response getExternalPropertiesDownload(); @Override void afterPropertiesSet(); }
ResourceServiceRestImpl implements ResourceServiceRest { @Override public Response deleteResources(final String[] templateNameArray, ResourceHierarchyParam resourceHierarchyParam, AuthenticatedUser user) { LOGGER.info("Delete resources {} by user {} with details {}", templateNameArray, user.getUser().getId(), resourceHierarchyParam); int deletedRecCount = 0; final List<String> templateNameList = Arrays.asList(templateNameArray); if (ParamValidator.getNewInstance().isNotEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isNotEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteGroupLevelAppResources(resourceHierarchyParam.getWebApp(), resourceHierarchyParam.getGroup(), templateNameList); } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isNotEmpty(resourceHierarchyParam.getJvm()) .isNotEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteAppResources(templateNameList, resourceHierarchyParam.getWebApp(), resourceHierarchyParam.getJvm()); } else if (ParamValidator.getNewInstance().isNotEmpty(resourceHierarchyParam.getGroup()) .isNotEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { if (resourceHierarchyParam.getWebServer().equalsIgnoreCase("*")) { deletedRecCount = resourceService.deleteGroupLevelWebServerResources(templateNameList, resourceHierarchyParam.getGroup()); } } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isNotEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteWebServerResources(templateNameList, resourceHierarchyParam.getWebServer()); } else if (ParamValidator.getNewInstance().isNotEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isNotEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { if (resourceHierarchyParam.getJvm().equalsIgnoreCase("*")) { deletedRecCount = resourceService.deleteGroupLevelJvmResources(templateNameList, resourceHierarchyParam.getGroup()); } } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isNotEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteJvmResources(templateNameList, resourceHierarchyParam.getJvm()); } else if (ParamValidator.getNewInstance().isEmpty(resourceHierarchyParam.getGroup()) .isEmpty(resourceHierarchyParam.getWebServer()) .isEmpty(resourceHierarchyParam.getJvm()) .isEmpty(resourceHierarchyParam.getWebApp()).isValid()) { deletedRecCount = resourceService.deleteExternalProperties(); } else { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException(FaultType.INVALID_REST_SERVICE_PARAMETER, "Parameters passed to the rest service is/are invalid!")); } return ResponseBuilder.ok(deletedRecCount); } ResourceServiceRestImpl(final ResourceService resourceService); Response createTemplate(final List<Attachment> attachments, final String targetName, final AuthenticatedUser user); @Override Response getResourceAttrData(); @Override Response getResourceTopology(); @Override Response getApplicationResourceNames(final String groupName, final String appName); @Override Response getAppTemplate(final String groupName, final String appName, final String templateName); @Override Response checkFileExists(final String groupName, final String jvmName, final String webappName, final String webserverName, final String fileName); @Override Response createResource(final String deployFilename, final CreateResourceParam createResourceParam,
                                   final List<Attachment> attachments); void setMessageContext(MessageContext messageContext); @Override Response uploadExternalProperties(AuthenticatedUser user); @Override // TODO: Re validation, maybe we can use CXF bean validation ? Response deleteResource(final String templateName, final ResourceHierarchyParam resourceHierarchyParam,
                                   final AuthenticatedUser aUser); @Override Response deleteResources(final String[] templateNameArray, ResourceHierarchyParam
            resourceHierarchyParam, AuthenticatedUser user); @Override Response getResourceContent(final String resourceName, final ResourceHierarchyParam param); @Override Response updateResourceContent(String resourceName, ResourceHierarchyParam
            resourceHierarchyParam, String templateContent); @Override Response updateResourceMetaData(String resourceName, ResourceHierarchyParam resourceHierarchyParam, String metaData); @Override Response previewResourceContent(final String resourceName, final ResourceHierarchyParam resourceHierarchyParam, String content); @Override Response getResourcesFileNames(ResourceHierarchyParam resourceHierarchyParam); @Override Response getExternalProperties(); @Override Response getExternalPropertiesView(); @Override Response getExternalPropertiesDownload(); @Override void afterPropertiesSet(); static final String UNEXPECTED_CONTENT_TYPE_ERROR_MSG; static final String TPL_FILE_EXTENSION; static final String EXT_PROPERTIES_RESOURCE_NAME; static final String EXT_PROPERTIES_RESOURCE_META_DATA; static final int CREATE_RESOURCE_ATTACHMENT_SIZE; }