@Test public void testCreateWebServer() { final JsonCreateWebServer jsonCreateWebServer = mock(JsonCreateWebServer.class); when(Config.mockWebServerService.createWebServer(any(CreateWebServerRequest.class), any(User.class))).thenReturn(webServer2); final Response response = webServerServiceRest.createWebServer(jsonCreateWebServer, Config.mockAuthenticatedUser); assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus()); final ApplicationResponse applicationResponse = (ApplicationResponse) response.getEntity(); final Object content = applicationResponse.getApplicationResponseContent(); assertTrue(content instanceof WebServer); final WebServer received = (WebServer) content; assertEquals(webServer2, received); }
@Override public Response createWebServer(final JsonCreateWebServer aWebServerToCreate, final AuthenticatedUser aUser) { LOGGER.info("Create WS requested: {} by user {}", aWebServerToCreate, aUser.getUser().getId()); try { final WebServer webServer = webServerService.createWebServer(aWebServerToCreate.toCreateWebServerRequest(), aUser.getUser()); Collection<Group> groups = webServer.getGroups(); if (null != groups && !groups.isEmpty()) { Group group = groups.iterator().next(); final String groupName = group.getName(); for (final String templateName : groupService.getGroupWebServersResourceTemplateNames(groupName)) { String templateContent = groupService.getGroupWebServerResourceTemplate(groupName, templateName, false, new ResourceGroup()); final String metaDataStr = groupService.getGroupWebServerResourceTemplateMetaData(groupName, templateName); webServerService.uploadWebServerConfig(webServer, templateName, templateContent, metaDataStr, groupName, aUser.getUser()); } if (groups.size() > 1) { LOGGER.warn("Multiple groups were associated with the Web Server, but the Web Server was created using the templates from group " + groupName); } } return ResponseBuilder.created(webServer); } catch (EntityExistsException eee) { LOGGER.error("Web server \"{}\" already exists", aWebServerToCreate, eee); return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.DUPLICATE_WEBSERVER_NAME, eee.getMessage(), eee)); } }
WebServerServiceRestImpl implements WebServerServiceRest { @Override public Response createWebServer(final JsonCreateWebServer aWebServerToCreate, final AuthenticatedUser aUser) { LOGGER.info("Create WS requested: {} by user {}", aWebServerToCreate, aUser.getUser().getId()); try { final WebServer webServer = webServerService.createWebServer(aWebServerToCreate.toCreateWebServerRequest(), aUser.getUser()); Collection<Group> groups = webServer.getGroups(); if (null != groups && !groups.isEmpty()) { Group group = groups.iterator().next(); final String groupName = group.getName(); for (final String templateName : groupService.getGroupWebServersResourceTemplateNames(groupName)) { String templateContent = groupService.getGroupWebServerResourceTemplate(groupName, templateName, false, new ResourceGroup()); final String metaDataStr = groupService.getGroupWebServerResourceTemplateMetaData(groupName, templateName); webServerService.uploadWebServerConfig(webServer, templateName, templateContent, metaDataStr, groupName, aUser.getUser()); } if (groups.size() > 1) { LOGGER.warn("Multiple groups were associated with the Web Server, but the Web Server was created using the templates from group " + groupName); } } return ResponseBuilder.created(webServer); } catch (EntityExistsException eee) { LOGGER.error("Web server \"{}\" already exists", aWebServerToCreate, eee); return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.DUPLICATE_WEBSERVER_NAME, eee.getMessage(), eee)); } } }
WebServerServiceRestImpl implements WebServerServiceRest { @Override public Response createWebServer(final JsonCreateWebServer aWebServerToCreate, final AuthenticatedUser aUser) { LOGGER.info("Create WS requested: {} by user {}", aWebServerToCreate, aUser.getUser().getId()); try { final WebServer webServer = webServerService.createWebServer(aWebServerToCreate.toCreateWebServerRequest(), aUser.getUser()); Collection<Group> groups = webServer.getGroups(); if (null != groups && !groups.isEmpty()) { Group group = groups.iterator().next(); final String groupName = group.getName(); for (final String templateName : groupService.getGroupWebServersResourceTemplateNames(groupName)) { String templateContent = groupService.getGroupWebServerResourceTemplate(groupName, templateName, false, new ResourceGroup()); final String metaDataStr = groupService.getGroupWebServerResourceTemplateMetaData(groupName, templateName); webServerService.uploadWebServerConfig(webServer, templateName, templateContent, metaDataStr, groupName, aUser.getUser()); } if (groups.size() > 1) { LOGGER.warn("Multiple groups were associated with the Web Server, but the Web Server was created using the templates from group " + groupName); } } return ResponseBuilder.created(webServer); } catch (EntityExistsException eee) { LOGGER.error("Web server \"{}\" already exists", aWebServerToCreate, eee); return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.DUPLICATE_WEBSERVER_NAME, eee.getMessage(), eee)); } } WebServerServiceRestImpl(final WebServerService theWebServerService,
                                    final WebServerControlService theWebServerControlService,
                                    final WebServerCommandService theWebServerCommandService,
                                    final ResourceService theResourceService, GroupService groupService,
                                    final BinaryDistributionService binaryDistributionService,
                                    final HistoryFacadeService historyFacadeService
                                    ); }
WebServerServiceRestImpl implements WebServerServiceRest { @Override public Response createWebServer(final JsonCreateWebServer aWebServerToCreate, final AuthenticatedUser aUser) { LOGGER.info("Create WS requested: {} by user {}", aWebServerToCreate, aUser.getUser().getId()); try { final WebServer webServer = webServerService.createWebServer(aWebServerToCreate.toCreateWebServerRequest(), aUser.getUser()); Collection<Group> groups = webServer.getGroups(); if (null != groups && !groups.isEmpty()) { Group group = groups.iterator().next(); final String groupName = group.getName(); for (final String templateName : groupService.getGroupWebServersResourceTemplateNames(groupName)) { String templateContent = groupService.getGroupWebServerResourceTemplate(groupName, templateName, false, new ResourceGroup()); final String metaDataStr = groupService.getGroupWebServerResourceTemplateMetaData(groupName, templateName); webServerService.uploadWebServerConfig(webServer, templateName, templateContent, metaDataStr, groupName, aUser.getUser()); } if (groups.size() > 1) { LOGGER.warn("Multiple groups were associated with the Web Server, but the Web Server was created using the templates from group " + groupName); } } return ResponseBuilder.created(webServer); } catch (EntityExistsException eee) { LOGGER.error("Web server \"{}\" already exists", aWebServerToCreate, eee); return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.DUPLICATE_WEBSERVER_NAME, eee.getMessage(), eee)); } } WebServerServiceRestImpl(final WebServerService theWebServerService,
                                    final WebServerControlService theWebServerControlService,
                                    final WebServerCommandService theWebServerCommandService,
                                    final ResourceService theResourceService, GroupService groupService,
                                    final BinaryDistributionService binaryDistributionService,
                                    final HistoryFacadeService historyFacadeService
                                    ); @Override Response getWebServers(final Identifier<Group> aGroupId); @Override Response getWebServer(final Identifier<WebServer> aWsId); @Override Response createWebServer(final JsonCreateWebServer aWebServerToCreate, final AuthenticatedUser aUser); @Override Response updateWebServer(final JsonUpdateWebServer aWebServerToCreate, final AuthenticatedUser aUser); @Override Response deleteWebServer(final Identifier<WebServer> id, boolean hardDelete, final AuthenticatedUser authUser); @Override Response controlWebServer(final Identifier<WebServer> aWebServerId,
                                     final JsonControlWebServer aWebServerToControl, final AuthenticatedUser aUser,
                                     final Boolean wait, Long waitTimeout); @Override Response generateConfig(final String webServerName); @Override Response generateAndDeployConfig(final String aWebServerName, final String resourceFileName, final AuthenticatedUser user); @Override Response generateAndDeployWebServer(final String aWebServerName, final AuthenticatedUser aUser); @Override Response getHttpdConfig(Identifier<WebServer> aWebServerId); @Override Response getResourceNames(final String wsName); @Override Response getResourceTemplate(final String wsName, final String resourceTemplateName,
                                        final boolean tokensReplaced); @Override Response updateResourceTemplate(final String wsName, final String resourceTemplateName, final String content); @Override Response previewResourceTemplate(final String webServerName, final String fileName, final String groupName, String template); }
WebServerServiceRestImpl implements WebServerServiceRest { @Override public Response createWebServer(final JsonCreateWebServer aWebServerToCreate, final AuthenticatedUser aUser) { LOGGER.info("Create WS requested: {} by user {}", aWebServerToCreate, aUser.getUser().getId()); try { final WebServer webServer = webServerService.createWebServer(aWebServerToCreate.toCreateWebServerRequest(), aUser.getUser()); Collection<Group> groups = webServer.getGroups(); if (null != groups && !groups.isEmpty()) { Group group = groups.iterator().next(); final String groupName = group.getName(); for (final String templateName : groupService.getGroupWebServersResourceTemplateNames(groupName)) { String templateContent = groupService.getGroupWebServerResourceTemplate(groupName, templateName, false, new ResourceGroup()); final String metaDataStr = groupService.getGroupWebServerResourceTemplateMetaData(groupName, templateName); webServerService.uploadWebServerConfig(webServer, templateName, templateContent, metaDataStr, groupName, aUser.getUser()); } if (groups.size() > 1) { LOGGER.warn("Multiple groups were associated with the Web Server, but the Web Server was created using the templates from group " + groupName); } } return ResponseBuilder.created(webServer); } catch (EntityExistsException eee) { LOGGER.error("Web server \"{}\" already exists", aWebServerToCreate, eee); return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.DUPLICATE_WEBSERVER_NAME, eee.getMessage(), eee)); } } WebServerServiceRestImpl(final WebServerService theWebServerService,
                                    final WebServerControlService theWebServerControlService,
                                    final WebServerCommandService theWebServerCommandService,
                                    final ResourceService theResourceService, GroupService groupService,
                                    final BinaryDistributionService binaryDistributionService,
                                    final HistoryFacadeService historyFacadeService
                                    ); @Override Response getWebServers(final Identifier<Group> aGroupId); @Override Response getWebServer(final Identifier<WebServer> aWsId); @Override Response createWebServer(final JsonCreateWebServer aWebServerToCreate, final AuthenticatedUser aUser); @Override Response updateWebServer(final JsonUpdateWebServer aWebServerToCreate, final AuthenticatedUser aUser); @Override Response deleteWebServer(final Identifier<WebServer> id, boolean hardDelete, final AuthenticatedUser authUser); @Override Response controlWebServer(final Identifier<WebServer> aWebServerId,
                                     final JsonControlWebServer aWebServerToControl, final AuthenticatedUser aUser,
                                     final Boolean wait, Long waitTimeout); @Override Response generateConfig(final String webServerName); @Override Response generateAndDeployConfig(final String aWebServerName, final String resourceFileName, final AuthenticatedUser user); @Override Response generateAndDeployWebServer(final String aWebServerName, final AuthenticatedUser aUser); @Override Response getHttpdConfig(Identifier<WebServer> aWebServerId); @Override Response getResourceNames(final String wsName); @Override Response getResourceTemplate(final String wsName, final String resourceTemplateName,
                                        final boolean tokensReplaced); @Override Response updateResourceTemplate(final String wsName, final String resourceTemplateName, final String content); @Override Response previewResourceTemplate(final String webServerName, final String fileName, final String groupName, String template);  }