GetConfigurationCommand implements CommandHasRequest<GetConfigurationRequest, GetConfigurationResponse> { @Override public void execute(GetConfigurationRequest request, GetConfigurationResponse response) throws Exception { if (null == request.getApplicationId()) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "applicationId"); } ClientApplicationInfo original = context.getBean(request.getApplicationId(), ClientApplicationInfo.class); if (original == null) { throw new GeomajasException(ExceptionCode.APPLICATION_NOT_FOUND, request.getApplicationId()); } ClientApplicationInfo client = new ClientApplicationInfo(); client.setId(original.getId()); if (!(original.getUserData() instanceof ServerSideOnlyInfo)) { client.setUserData(original.getUserData()); } client.setWidgetInfo(mapConfigurationCommand.securityClone(original.getWidgetInfo())); client.setScreenDpi(original.getScreenDpi()); List<ClientMapInfo> maps = new ArrayList<ClientMapInfo>(); client.setMaps(maps); for (ClientMapInfo map : original.getMaps()) { maps.add(mapConfigurationCommand.securityClone(map)); } response.setApplication(client); }  @Override GetConfigurationRequest getEmptyCommandRequest(); @Override GetConfigurationResponse getEmptyCommandResponse(); @Override void execute(GetConfigurationRequest request, GetConfigurationResponse response);  }
@Test public void testConvertApplication() throws Exception { GetConfigurationRequest request = new GetConfigurationRequest(); request.setApplicationId(APP_ID); GetConfigurationResponse response = (GetConfigurationResponse) dispatcher.execute( GetConfigurationRequest.COMMAND, request, null, "en"); if (response.isError()) { response.getErrors().get(0).printStackTrace(); } Assert.assertFalse(response.isError()); ClientApplicationInfo appInfo = response.getApplication(); Assert.assertNotNull(appInfo); Assert.assertEquals(APP_ID, appInfo.getId()); Assert.assertEquals(96, appInfo.getScreenDpi()); Assert.assertNotNull(appInfo.getWidgetInfo()); Assert.assertNotNull(appInfo.getWidgetInfo("mapSelect")); Assert.assertNull(appInfo.getWidgetInfo("layerTree")); Assert.assertEquals("map1, map2", ((ClientApplicationInfo.DummyClientWidgetInfo) appInfo.getWidgetInfo("mapSelect")).getDummy()); verifyMap(appInfo.getMaps().get(2)); }
@Test public void testServerSideOnlyInfo() throws Exception { GetConfigurationRequest request = new GetConfigurationRequest(); request.setApplicationId("appServerSideOnly"); GetConfigurationResponse response = (GetConfigurationResponse) dispatcher.execute( GetConfigurationRequest.COMMAND, request, null, "en"); if (response.isError()) { response.getErrors().get(0).printStackTrace(); } Assert.assertFalse(response.isError()); ClientApplicationInfo appInfo = response.getApplication(); Assert.assertNotNull(appInfo); Assert.assertNull(appInfo.getUserData()); Assert.assertNotNull(appInfo.getWidgetInfo()); Assert.assertNull(appInfo.getWidgetInfo("appDummy")); Assert.assertNotNull(appInfo.getWidgetInfo("mapSelect")); Assert.assertNull(appInfo.getWidgetInfo("mapDummy")); ClientMapInfo mapInfo = appInfo.getMaps().get(0); Assert.assertNull(mapInfo.getUserData()); Assert.assertNotNull(mapInfo); Assert.assertNotNull(mapInfo.getWidgetInfo()); Assert.assertNull(mapInfo.getWidgetInfo("appDummy")); Assert.assertNotNull(mapInfo.getWidgetInfo("layerTree")); Assert.assertNull(mapInfo.getWidgetInfo("mapDummy")); }