Search in sources :

Example 1 with ServerDTO

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);
    }
}
Also used : WMSHeaderParam(org.geosdi.geoplatform.services.request.WMSHeaderParam) ServerDTO(org.geosdi.geoplatform.response.ServerDTO) HttpSession(javax.servlet.http.HttpSession) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GSAccount(org.geosdi.geoplatform.core.model.GSAccount) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) RequestByID(org.geosdi.geoplatform.request.RequestByID)

Example 2 with ServerDTO

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);
}
Also used : GeoPlatformServer(org.geosdi.geoplatform.core.model.GeoPlatformServer) ServerDTO(org.geosdi.geoplatform.response.ServerDTO) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) MalformedURLException(java.net.MalformedURLException) GPAuthServer(org.geosdi.geoplatform.core.model.GPAuthServer) GPOrganization(org.geosdi.geoplatform.core.model.GPOrganization) URL(java.net.URL)

Example 3 with ServerDTO

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());
}
Also used : ServerDTO(org.geosdi.geoplatform.response.ServerDTO) RequestByID(org.geosdi.geoplatform.request.RequestByID) Test(org.junit.Test)

Example 4 with ServerDTO

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());
}
Also used : GeoPlatformServer(org.geosdi.geoplatform.core.model.GeoPlatformServer) ServerDTO(org.geosdi.geoplatform.response.ServerDTO) Test(org.junit.Test)

Example 5 with ServerDTO

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);
    }
}
Also used : ServerDTO(org.geosdi.geoplatform.response.ServerDTO) HttpSession(javax.servlet.http.HttpSession) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GSAccount(org.geosdi.geoplatform.core.model.GSAccount) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) RequestByID(org.geosdi.geoplatform.request.RequestByID)

Aggregations

ServerDTO (org.geosdi.geoplatform.response.ServerDTO)14 GeoPlatformServer (org.geosdi.geoplatform.core.model.GeoPlatformServer)8 Test (org.junit.Test)6 RequestByID (org.geosdi.geoplatform.request.RequestByID)5 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)4 HttpSession (javax.servlet.http.HttpSession)2 GSAccount (org.geosdi.geoplatform.core.model.GSAccount)2 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)2 GPSessionTimeout (org.geosdi.geoplatform.gui.utility.GPSessionTimeout)2 ServiceWMSTest (org.geosdi.geoplatform.model.soap.ServiceWMSTest)2 WSSaveServerRequest (org.geosdi.geoplatform.request.server.WSSaveServerRequest)2 RasterLayerDTO (org.geosdi.geoplatform.response.RasterLayerDTO)2 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 GPAuthServer (org.geosdi.geoplatform.core.model.GPAuthServer)1 GPOrganization (org.geosdi.geoplatform.core.model.GPOrganization)1 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)1 WMSHeaderParam (org.geosdi.geoplatform.services.request.WMSHeaderParam)1