Search in sources :

Example 1 with GPAuthServer

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

MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 GPAuthServer (org.geosdi.geoplatform.core.model.GPAuthServer)1 GPOrganization (org.geosdi.geoplatform.core.model.GPOrganization)1 GeoPlatformServer (org.geosdi.geoplatform.core.model.GeoPlatformServer)1 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)1 ServerDTO (org.geosdi.geoplatform.response.ServerDTO)1