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