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());
}
}
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;
}
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);
}
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);
}
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);
}
}
}
Aggregations