Search in sources :

Example 6 with GeoPlatformServer

use of org.geosdi.geoplatform.core.model.GeoPlatformServer in project geo-platform by geosdi.

the class CSWServiceDelegate method getCSWServerByID.

private GeoPlatformServer getCSWServerByID(Long serverID) throws ResourceNotFoundFault {
    GeoPlatformServer server = serverDao.find(serverID);
    if (server == null) {
        throw new ResourceNotFoundFault("Server not found", serverID);
    }
    // TODO assert
    CSWEntityCorrectness.checkCSWServerLog(server);
    return server;
}
Also used : GeoPlatformServer(org.geosdi.geoplatform.core.model.GeoPlatformServer) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault)

Example 7 with GeoPlatformServer

use of org.geosdi.geoplatform.core.model.GeoPlatformServer in project geo-platform by geosdi.

the class CSWServiceDelegate method insertServerCSW.

/**
 * @see GeoPlatformCSWService#insertServerCSW(org.geosdi.geoplatform.core.model.GeoPlatformServer)
 */
@Override
public Long insertServerCSW(GeoPlatformServer server) throws IllegalParameterFault {
    // TODO assert
    CSWEntityCorrectness.checkCSWServer(server);
    /**
     * IMPORTANT TO AVOID EXCEPTION IN DB FOR UNIQUE URL SERVER *
     */
    String serverUrl = this.deleteQueryStringFromURL(server.getServerUrl());
    GeoPlatformServer serverSearch = serverDao.findByServerUrl(serverUrl);
    if (serverSearch != null) {
        // If there is already a server with the specified URLs
        return serverSearch.getId();
    }
    server.setServerType(GPCapabilityType.CSW);
    serverDao.persist(server);
    return server.getId();
}
Also used : GeoPlatformServer(org.geosdi.geoplatform.core.model.GeoPlatformServer)

Example 8 with GeoPlatformServer

use of org.geosdi.geoplatform.core.model.GeoPlatformServer in project geo-platform by geosdi.

the class CSWServiceDelegate method saveServerCSW.

/**
 * @see {@link GeoPlatformCSWService#saveServerCSW(String, String, String)},
 * java.lang.String)
 */
@Override
public ServerCSWDTO saveServerCSW(String alias, String serverUrl, String organization) throws IllegalParameterFault {
    serverUrl = this.deleteQueryStringFromURL(serverUrl);
    GeoPlatformServer server = serverDao.findByServerUrl(serverUrl);
    if (server != null) {
        // If there is already a server with the specified URLs
        return new ServerCSWDTO(server);
    }
    GPOrganization org = organizationDao.findByName(organization);
    if (org == null) {
        throw new IllegalParameterFault("CSW Server to save have an organization that does not exist");
    }
    try {
        CatalogCapabilities capabilities = catalogCapabilitiesBean.bindUrl(serverUrl);
        server = new GeoPlatformServer();
        server.setServerType(GPCapabilityType.CSW);
        server.setServerUrl(serverUrl);
        server.setAliasName(alias);
        server.setOrganization(org);
        server.setTitle(capabilities.getServiceIdentification().getTitle());
        server.setAbstractServer(capabilities.getServiceIdentification().getAbstractText());
        server.setName(capabilities.getServiceProvider().getProviderName());
        // TODO assert
        CSWEntityCorrectness.checkCSWServer(server);
        serverDao.persist(server);
    } catch (Exception ex) {
        logger.error("### MalformedURLException: {}", ex.getMessage());
        throw new IllegalParameterFault("Exception : " + ex.getMessage());
    }
    return new ServerCSWDTO(server);
}
Also used : CatalogCapabilities(org.geosdi.geoplatform.connector.api.capabilities.model.csw.CatalogCapabilities) GeoPlatformServer(org.geosdi.geoplatform.core.model.GeoPlatformServer) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) ServerCSWDTO(org.geosdi.geoplatform.responce.ServerCSWDTO) GPOrganization(org.geosdi.geoplatform.core.model.GPOrganization) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 9 with GeoPlatformServer

use of org.geosdi.geoplatform.core.model.GeoPlatformServer in project geo-platform by geosdi.

the class GPServerDelegate method insertServer.

@Override
public Long insertServer(GeoPlatformServer server) {
    /**
     * IMPORTANT TO AVOID EXCEPTION IN DB FOR UNIQUE URL SERVER *
     */
    GeoPlatformServer serverSearch = serverDao.findByServerUrl(server.getServerUrl());
    if (serverSearch != null) {
        return serverSearch.getId();
    }
    serverDao.persist(server);
    return server.getId();
}
Also used : GeoPlatformServer(org.geosdi.geoplatform.core.model.GeoPlatformServer)

Example 10 with GeoPlatformServer

use of org.geosdi.geoplatform.core.model.GeoPlatformServer 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)

Aggregations

GeoPlatformServer (org.geosdi.geoplatform.core.model.GeoPlatformServer)40 Test (org.junit.Test)15 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)9 ServerDTO (org.geosdi.geoplatform.response.ServerDTO)8 GPOrganization (org.geosdi.geoplatform.core.model.GPOrganization)6 GPDAOException (org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)6 ServerCSWDTO (org.geosdi.geoplatform.responce.ServerCSWDTO)3 Ignore (org.junit.Ignore)3 MalformedURLException (java.net.MalformedURLException)2 ArrayList (java.util.ArrayList)2 JAXBElement (javax.xml.bind.JAXBElement)2 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)2 ServerInternalFault (org.geosdi.geoplatform.exception.ServerInternalFault)2 PaginatedSearchRequest (org.geosdi.geoplatform.request.PaginatedSearchRequest)2 WSSaveServerRequest (org.geosdi.geoplatform.request.server.WSSaveServerRequest)2 RasterLayerDTO (org.geosdi.geoplatform.response.RasterLayerDTO)2 IOException (java.io.IOException)1 URL (java.net.URL)1 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1