@Test public void testUpdateResourceTemplate() { final String updateContent = "<server>updatedContent</server>"; when(Config.service.updateResourceTemplate(anyString(), anyString(), anyString(), anyString(), anyString())).thenReturn(updateContent); Response response = applicationServiceRestInterface.updateResourceTemplate(Config.application.getName(), "ServerXMLTemplate.tpl", updateContent, "jvmName", "groupName"); assertNotNull(response.getEntity()); when(Config.service.updateResourceTemplate(anyString(), anyString(), anyString(), anyString(), anyString())).thenThrow(new ResourceTemplateUpdateException("jvmName", "server")); response = applicationServiceRestInterface.updateResourceTemplate(Config.application.getName(), "ServerXMLTemplate.tpl", updateContent, "jvmName", "groupName"); assertNotNull(response.getEntity()); }
@Override public Response updateResourceTemplate(final String appName, final String resourceTemplateName, final String jvmName, final String groupName, final String content) { LOGGER.info("Update resource template {} for app {} associated to JVM {} in group {}", resourceTemplateName, appName, jvmName, groupName); LOGGER.debug(content); try { if (jvmName == null) { return ResponseBuilder.ok(groupService.updateGroupAppResourceTemplate(groupName, appName, resourceTemplateName, content)); } return ResponseBuilder.ok(service.updateResourceTemplate(appName, resourceTemplateName, content, jvmName, groupName)); } catch (ResourceTemplateUpdateException | NonRetrievableResourceTemplateContentException e) { LOGGER.debug("Failed to update resource template {}", resourceTemplateName, e); return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.PERSISTENCE_ERROR, e.getMessage())); } }
ApplicationServiceRestImpl implements ApplicationServiceRest { @Override public Response updateResourceTemplate(final String appName, final String resourceTemplateName, final String jvmName, final String groupName, final String content) { LOGGER.info("Update resource template {} for app {} associated to JVM {} in group {}", resourceTemplateName, appName, jvmName, groupName); LOGGER.debug(content); try { if (jvmName == null) { return ResponseBuilder.ok(groupService.updateGroupAppResourceTemplate(groupName, appName, resourceTemplateName, content)); } return ResponseBuilder.ok(service.updateResourceTemplate(appName, resourceTemplateName, content, jvmName, groupName)); } catch (ResourceTemplateUpdateException | NonRetrievableResourceTemplateContentException e) { LOGGER.debug("Failed to update resource template {}", resourceTemplateName, e); return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.PERSISTENCE_ERROR, e.getMessage())); } } }
ApplicationServiceRestImpl implements ApplicationServiceRest { @Override public Response updateResourceTemplate(final String appName, final String resourceTemplateName, final String jvmName, final String groupName, final String content) { LOGGER.info("Update resource template {} for app {} associated to JVM {} in group {}", resourceTemplateName, appName, jvmName, groupName); LOGGER.debug(content); try { if (jvmName == null) { return ResponseBuilder.ok(groupService.updateGroupAppResourceTemplate(groupName, appName, resourceTemplateName, content)); } return ResponseBuilder.ok(service.updateResourceTemplate(appName, resourceTemplateName, content, jvmName, groupName)); } catch (ResourceTemplateUpdateException | NonRetrievableResourceTemplateContentException e) { LOGGER.debug("Failed to update resource template {}", resourceTemplateName, e); return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.PERSISTENCE_ERROR, e.getMessage())); } } ApplicationServiceRestImpl(ApplicationService applicationService,
                                      ResourceService resourceService,
                                      final GroupService groupService); }
ApplicationServiceRestImpl implements ApplicationServiceRest { @Override public Response updateResourceTemplate(final String appName, final String resourceTemplateName, final String jvmName, final String groupName, final String content) { LOGGER.info("Update resource template {} for app {} associated to JVM {} in group {}", resourceTemplateName, appName, jvmName, groupName); LOGGER.debug(content); try { if (jvmName == null) { return ResponseBuilder.ok(groupService.updateGroupAppResourceTemplate(groupName, appName, resourceTemplateName, content)); } return ResponseBuilder.ok(service.updateResourceTemplate(appName, resourceTemplateName, content, jvmName, groupName)); } catch (ResourceTemplateUpdateException | NonRetrievableResourceTemplateContentException e) { LOGGER.debug("Failed to update resource template {}", resourceTemplateName, e); return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.PERSISTENCE_ERROR, e.getMessage())); } } ApplicationServiceRestImpl(ApplicationService applicationService,
                                      ResourceService resourceService,
                                      final GroupService groupService); @Override Response getApplication(Identifier<Application> anAppId); @Override Response getApplicationByName(final String name); @Override Response getApplications(Identifier<Group> aGroupId); @Override Response findApplicationsByJvmId(Identifier<Jvm> aJvmId); @Override Response createApplication(final JsonCreateApplication anAppToCreate, final AuthenticatedUser aUser); @Override Response updateApplication(final JsonUpdateApplication anAppToUpdate, final AuthenticatedUser aUser); @Override Response removeApplication(final Identifier<Application> anAppToRemove, final AuthenticatedUser aUser); @Override Response deployWebArchive(final Identifier<Application> anAppToGet, final AuthenticatedUser aUser); @Override Response deployWebArchive(final Identifier<Application> anAppToGet, String hostName); @Override Response getResourceNames(final String appName, final String jvmName); @Override Response updateResourceTemplate(final String appName,
                                           final String resourceTemplateName,
                                           final String jvmName,
                                           final String groupName,
                                           final String content); @Override Response deployConf(final String appName, final String groupName, final String jvmName,
                               final String resourceTemplateName, final AuthenticatedUser authUser); @Override Response previewResourceTemplate(final String appName, final String groupName, final String jvmName,
                                            final String fileName,
                                            final String template); @Override Response deployConf(final String appName, final AuthenticatedUser aUser, final String hostName); @Override Response checkIfFileExists(final String filePath, final AuthenticatedUser aUser, final String hostName); }
ApplicationServiceRestImpl implements ApplicationServiceRest { @Override public Response updateResourceTemplate(final String appName, final String resourceTemplateName, final String jvmName, final String groupName, final String content) { LOGGER.info("Update resource template {} for app {} associated to JVM {} in group {}", resourceTemplateName, appName, jvmName, groupName); LOGGER.debug(content); try { if (jvmName == null) { return ResponseBuilder.ok(groupService.updateGroupAppResourceTemplate(groupName, appName, resourceTemplateName, content)); } return ResponseBuilder.ok(service.updateResourceTemplate(appName, resourceTemplateName, content, jvmName, groupName)); } catch (ResourceTemplateUpdateException | NonRetrievableResourceTemplateContentException e) { LOGGER.debug("Failed to update resource template {}", resourceTemplateName, e); return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.PERSISTENCE_ERROR, e.getMessage())); } } ApplicationServiceRestImpl(ApplicationService applicationService,
                                      ResourceService resourceService,
                                      final GroupService groupService); @Override Response getApplication(Identifier<Application> anAppId); @Override Response getApplicationByName(final String name); @Override Response getApplications(Identifier<Group> aGroupId); @Override Response findApplicationsByJvmId(Identifier<Jvm> aJvmId); @Override Response createApplication(final JsonCreateApplication anAppToCreate, final AuthenticatedUser aUser); @Override Response updateApplication(final JsonUpdateApplication anAppToUpdate, final AuthenticatedUser aUser); @Override Response removeApplication(final Identifier<Application> anAppToRemove, final AuthenticatedUser aUser); @Override Response deployWebArchive(final Identifier<Application> anAppToGet, final AuthenticatedUser aUser); @Override Response deployWebArchive(final Identifier<Application> anAppToGet, String hostName); @Override Response getResourceNames(final String appName, final String jvmName); @Override Response updateResourceTemplate(final String appName,
                                           final String resourceTemplateName,
                                           final String jvmName,
                                           final String groupName,
                                           final String content); @Override Response deployConf(final String appName, final String groupName, final String jvmName,
                               final String resourceTemplateName, final AuthenticatedUser authUser); @Override Response previewResourceTemplate(final String appName, final String groupName, final String jvmName,
                                            final String fileName,
                                            final String template); @Override Response deployConf(final String appName, final AuthenticatedUser aUser, final String hostName); @Override Response checkIfFileExists(final String filePath, final AuthenticatedUser aUser, final String hostName);  }