Search in sources :

Example 11 with IllegalParameterFault

use of org.geosdi.geoplatform.exception.IllegalParameterFault in project geo-platform by geosdi.

the class GPWFSServiceImpl method searchFeaturesByBboxAndQuery.

/**
 * @param request
 * @return {@link Response}
 * @throws Exception
 */
@Override
public Response searchFeaturesByBboxAndQuery(GPWFSSearchFeaturesByBboxAndQueryRequest request) throws Exception {
    if (request == null) {
        throw new IllegalParameterFault(this.wfsMessageSource.getMessage("gp_wfs_request.valid", new Object[] { "GPWFSSearchFeaturesByBboxAndQueryRequest" }, ENGLISH));
    }
    logger.trace("##########################Validating Request -------------------> {}\n", request);
    String message = this.wfsRequestValidator.validate(request, forLanguageTag(request.getLang()));
    if (message != null)
        throw new IllegalParameterFault(message);
    try {
        LayerSchemaDTO layerSchemaDTO = this.describeFeatureType(decode(request.getServerURL(), UTF_8.name()), request.getTypeName(), null);
        return Response.ok(this.gpGetFeatureService.searchFeaturesByBboxAndQuery(layerSchemaDTO, request.getQueryDTO(), request.getBBox(), request.getMaxFeatures())).build();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new IllegalParameterFault(ex.getMessage());
    }
}
Also used : IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault)

Example 12 with IllegalParameterFault

use of org.geosdi.geoplatform.exception.IllegalParameterFault in project geo-platform by geosdi.

the class CSWServiceDelegate method createGetRecordsRequest.

private CatalogGetRecordsRequest<GetRecordsResponseType> createGetRecordsRequest(String serverUrl) throws Exception {
    GPCatalogConnectorStore serverConnector = null;
    try {
        URL url = new URL(serverUrl);
        GPCSWConnectorBuilder builder = GPCSWConnectorBuilder.newConnector().withServerUrl(url).withProxyConfiguration(cswProxyConfiguration);
        if (serverUrl.contains("snipc.protezionecivile.it")) {
            GPSecurityConnector securityConnector = new BasicPreemptiveSecurityConnector(snipcProvider.getSnipcUsername(), snipcProvider.getSnipcPassword());
            builder.withClientSecurity(securityConnector);
        }
        serverConnector = builder.build();
    } catch (MalformedURLException ex) {
        logger.error("### MalformedURLException: {}", ex.getMessage());
        throw new IllegalParameterFault("Malformed URL");
    }
    CatalogGetRecordsRequest<GetRecordsResponseType> request = serverConnector.createGetRecordsRequest();
    return request;
}
Also used : GPCatalogConnectorStore(org.geosdi.geoplatform.connector.GPCatalogConnectorStore) MalformedURLException(java.net.MalformedURLException) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPSecurityConnector(org.geosdi.geoplatform.connector.server.security.GPSecurityConnector) GPCSWConnectorBuilder(org.geosdi.geoplatform.connector.GPCSWConnectorBuilder) BasicPreemptiveSecurityConnector(org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector) URL(java.net.URL)

Example 13 with IllegalParameterFault

use of org.geosdi.geoplatform.exception.IllegalParameterFault 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 14 with IllegalParameterFault

use of org.geosdi.geoplatform.exception.IllegalParameterFault 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 15 with IllegalParameterFault

use of org.geosdi.geoplatform.exception.IllegalParameterFault in project geo-platform by geosdi.

the class GPViewportDelegate method replaceViewportList.

@Override
public void replaceViewportList(ManageViewportRequest request) throws ResourceNotFoundFault, IllegalParameterFault {
    if (request == null) {
        throw new IllegalParameterFault("The ManageViewportRequest must " + "not be null.");
    }
    Long accountProjectID = request.getAccountProjectID();
    ArrayList<GPViewport> viewportList = request.getViewportList();
    GPAccountProject accountProject = this.accountProjectDao.find(accountProjectID);
    if (accountProject == null) {
        throw new ResourceNotFoundFault("AccountProject not found", accountProjectID);
    }
    List<GPViewport> oldViewportList = this.viewportDao.findByAccountProjectID(accountProjectID);
    for (GPViewport viewport : oldViewportList) {
        this.viewportDao.removeById(viewport.getId());
    }
    if (viewportList != null) {
        for (GPViewport viewport : viewportList) {
            this.insertViewport(accountProjectID, viewport);
        }
    }
}
Also used : GPViewport(org.geosdi.geoplatform.core.model.GPViewport) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPAccountProject(org.geosdi.geoplatform.core.model.GPAccountProject) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault)

Aggregations

IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)56 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)32 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)22 GPSessionTimeout (org.geosdi.geoplatform.gui.utility.GPSessionTimeout)15 GPWebServiceMapData (org.geosdi.geoplatform.response.collection.GPWebServiceMapData)11 IOException (java.io.IOException)8 MalformedURLException (java.net.MalformedURLException)8 GPFolder (org.geosdi.geoplatform.core.model.GPFolder)7 GPUser (org.geosdi.geoplatform.core.model.GPUser)7 GPOrganization (org.geosdi.geoplatform.core.model.GPOrganization)6 GPAccount (org.geosdi.geoplatform.core.model.GPAccount)5 GPAccountProject (org.geosdi.geoplatform.core.model.GPAccountProject)4 Test (org.junit.Test)4 URL (java.net.URL)3 InsertAccountRequest (org.geosdi.geoplatform.request.InsertAccountRequest)3 BasePagingLoadResult (com.extjs.gxt.ui.client.data.BasePagingLoadResult)2 GPCSWConnectorBuilder (org.geosdi.geoplatform.connector.GPCSWConnectorBuilder)2 GPCatalogConnectorStore (org.geosdi.geoplatform.connector.GPCatalogConnectorStore)2 BasicPreemptiveSecurityConnector (org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector)2 GPSecurityConnector (org.geosdi.geoplatform.connector.server.security.GPSecurityConnector)2