use of org.geosdi.geoplatform.response.ServerDTO in project geo-platform by geosdi.
the class OGCService method getCapabilitiesAuth.
@Override
public ArrayList<? extends GPLayerGrid> getCapabilitiesAuth(String serverUrl, HttpServletRequest httpServletRequest, Long idServer) throws GeoPlatformException {
try {
HttpSession session = httpServletRequest.getSession();
String token = (String) session.getAttribute("GOOGLE_TOKEN");
/**
*@TODO think a way to have this configured*
*/
String authValue = httpServletRequest.getHeader("iv-user");
// Enumeration<String> headerNames = httpServletRequest.getHeaderNames();
List<WMSHeaderParam> headerParams = Lists.newArrayList();
if ((authValue != null) && !(authValue.trim().isEmpty())) {
headerParams.add(new WMSHeaderParam("iv-user", authValue));
}
// List<WMSHeaderParam> headerKeyValues = Collections.list(headerNames)
// .stream()
// .filter(key -> ((httpServletRequest.getHeader(key) != null)))
// .map(key -> new WMSHeaderParam(key, httpServletRequest.getHeader(key)))
// .collect(toList());
logger.trace("###########################HEADERS_TO_PASS_TO_SERVICE : {}\n", headerParams);
RequestByID req = new RequestByID(idServer);
GSAccount gsAccount = this.sessionUtility.getLoggedAccount(httpServletRequest).getGsAccount();
String authKey = null;
if (gsAccount != null) {
authKey = gsAccount.getAuthkey();
}
ServerDTO server = geoPlatformWMSServiceClient.getCapabilitiesAuth(serverUrl, req, token, authKey, headerParams);
return dtoServerConverter.createRasterLayerList(server.getLayerList());
} catch (ResourceNotFoundFault ex) {
logger.error("Error GetCapabilities: " + ex);
throw new GeoPlatformException(ex.getMessage());
} catch (GPSessionTimeout timeout) {
throw new GeoPlatformException(timeout);
}
}
use of org.geosdi.geoplatform.response.ServerDTO in project geo-platform by geosdi.
the class GPServerDelegate method saveServer.
@Override
public ServerDTO saveServer(WSSaveServerRequest saveServerReq) throws IllegalParameterFault {
if (saveServerReq == null) {
throw new IllegalParameterFault("The WSSaveServerRequest must " + "not be null.");
}
Long id = saveServerReq.getId();
String serverUrl = saveServerReq.getServerUrl();
String organization = saveServerReq.getOrganization();
String aliasServerName = saveServerReq.getAliasServerName();
try {
URL serverURL = new URL(serverUrl);
} catch (MalformedURLException e) {
logger.error("MalformedURLException: " + e);
throw new IllegalParameterFault("Malformed URL");
}
GPOrganization org = organizationDao.findByName(organization);
if (org == null) {
throw new IllegalParameterFault("Server to save have an organization that does not exist");
}
GeoPlatformServer server;
if (id != null) {
// Existent server
server = serverDao.find(id);
} else {
// New server
if (this.isURLServerAlreadyExists(serverUrl)) {
throw new IllegalParameterFault("Duplicated Server URL");
}
server = new GeoPlatformServer();
server.setServerType(WMS);
}
server.setAliasName(aliasServerName);
server.setServerUrl(serverUrl);
server.setAuthServer(new GPAuthServer(saveServerReq.getUsername(), saveServerReq.getPassword()));
server.setProxy(saveServerReq.isProxy());
server.setOrganization(org);
serverDao.persist(server);
return new ServerDTO(server);
}
use of org.geosdi.geoplatform.response.ServerDTO in project geo-platform by geosdi.
the class CXFWMSTest method testGetCapabilities.
@Test(expected = ResourceNotFoundFault.class)
public void testGetCapabilities() throws ParseException, ResourceNotFoundFault {
ServerDTO serverDTO = gpWMSClient.getShortServer(serverUrlGeoSDI);
logger.info("^^^^^^^^^^^^^^^^^^^^^^^^^ SERVER___DTO ^^^^^^^^^^^^^^^^^^\n{}", serverDTO);
Assert.assertNotNull(serverDTO);
serverDTO = gpWMSClient.getCapabilities(serverDTO.getServerUrl(), new RequestByID(serverDTO.getId()), null, null);
logger.debug("\n*** NUMBER OF LAYERS FOR DPC {} ***", serverDTO.getLayerList().size());
}
use of org.geosdi.geoplatform.response.ServerDTO in project geo-platform by geosdi.
the class SOAPServerTest method testGetServer.
@Test
public void testGetServer() throws ResourceNotFoundFault {
// Get Server from Id
GeoPlatformServer gpServer = gpWSClient.getServerDetail(idServerTest);
logger.debug("\n*** gpServer:\n{}\n***", gpServer);
Assert.assertNotNull(gpServer);
Assert.assertEquals("Id Server NOT match", idServerTest, gpServer.getId().longValue());
Assert.assertEquals("URL Server NOT match", serverUrlTest, gpServer.getServerUrl());
// Get Server from serverUrl
ServerDTO serverDTO = gpWSClient.getShortServer(serverUrlTest);
logger.debug("\n*** serverDTO:\n{}\n***", serverDTO);
Assert.assertNotNull(serverDTO);
Assert.assertEquals("Id Server NOT match", idServerTest, serverDTO.getId().longValue());
Assert.assertEquals("URL Server NOT match", serverUrlTest, serverDTO.getServerUrl());
}
use of org.geosdi.geoplatform.response.ServerDTO in project geo-platform by geosdi.
the class OGCService method getCapabilities.
@Override
public ArrayList<? extends GPLayerGrid> getCapabilities(String serverUrl, HttpServletRequest httpServletRequest, Long idServer) throws GeoPlatformException {
try {
HttpSession session = httpServletRequest.getSession();
String token = (String) session.getAttribute("GOOGLE_TOKEN");
RequestByID req = new RequestByID(idServer);
GSAccount gsAccount = this.sessionUtility.getLoggedAccount(httpServletRequest).getGsAccount();
String authKey = null;
if (gsAccount != null) {
authKey = gsAccount.getAuthkey();
}
ServerDTO server = geoPlatformWMSServiceClient.getCapabilities(serverUrl, req, token, authKey);
return dtoServerConverter.createRasterLayerList(server.getLayerList());
} catch (ResourceNotFoundFault ex) {
logger.error("Error GetCapabilities: " + ex);
throw new GeoPlatformException(ex.getMessage());
} catch (GPSessionTimeout timeout) {
throw new GeoPlatformException(timeout);
}
}
Aggregations