use of org.geosdi.geoplatform.responce.ServerCSWDTO in project geo-platform by geosdi.
the class GPCatalogFinderService method searchCSWServers.
@Override
public PagingLoadResult<GPCSWServerBeanModel> searchCSWServers(PagingLoadConfig config, String searchText, String organization, HttpServletRequest httpServletRequest) throws GeoPlatformException {
SearchRequest srq = new SearchRequest(searchText);
int serversCount = geoPlatformCSWClient.getCSWServersCount(srq, organization);
ArrayList<GPCSWServerBeanModel> searchServers;
if (serversCount == 0) {
logger.info("\n*** No catalog found ***");
searchServers = new ArrayList<GPCSWServerBeanModel>(0);
} else {
int start = config.getOffset();
int page = start == 0 ? start : start / config.getLimit();
PaginatedSearchRequest psr = new PaginatedSearchRequest(searchText, config.getLimit(), page);
List<ServerCSWDTO> serverList = geoPlatformCSWClient.searchCSWServers(psr, organization);
searchServers = new ArrayList<GPCSWServerBeanModel>(serverList.size());
for (ServerCSWDTO serverDTO : serverList) {
searchServers.add(this.convertServerDTO(serverDTO));
}
}
return new BasePagingLoadResult<GPCSWServerBeanModel>(searchServers, config.getOffset(), serversCount);
}
use of org.geosdi.geoplatform.responce.ServerCSWDTO 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.responce.ServerCSWDTO in project geo-platform by geosdi.
the class CSWCatalogServerTest method testSearchCSWServers.
@Test
public void testSearchCSWServers() {
// wrt title
PaginatedSearchRequest request = new PaginatedSearchRequest("test", 10, 0);
List<ServerCSWDTO> search = cswService.searchCSWServers(request, super.organizationNameTest);
Assert.assertNotNull(search);
Assert.assertEquals(1, search.size());
}
use of org.geosdi.geoplatform.responce.ServerCSWDTO in project geo-platform by geosdi.
the class CSWCatalogServerTest method testSearchCSWServersMore.
@Test
public void testSearchCSWServersMore() throws Exception {
// Insert 27 servers (only 25 for matching wrt alias)
Long[] serverIDs = new Long[27];
for (int i = 1; i <= 27; i++) {
GeoPlatformServer server = super.createCSWServer("Mock title " + i, "http://url.mock-" + i, organizationTest);
if (i >= 3) {
server.setAliasName("Alias test " + i);
}
serverIDs[i - 1] = cswService.insertServerCSW(server);
Assert.assertNotNull(serverIDs[i - 1]);
}
// First page
// wrt title and alias
PaginatedSearchRequest request = new PaginatedSearchRequest("test", 10, 0);
List<ServerCSWDTO> search = cswService.searchCSWServers(request, super.organizationNameTest);
Assert.assertNotNull(search);
Assert.assertEquals(10, search.size());
// Second page
// wrt title and alias
request = new PaginatedSearchRequest("test", 10, 1);
search = cswService.searchCSWServers(request, super.organizationNameTest);
Assert.assertNotNull(search);
Assert.assertEquals(10, search.size());
// Third page
// wrt title and alias
request = new PaginatedSearchRequest("test", 10, 2);
search = cswService.searchCSWServers(request, super.organizationNameTest);
Assert.assertNotNull(search);
Assert.assertEquals(6, search.size());
// Delete the servers
for (Long serverID : serverIDs) {
boolean deleted = cswService.deleteServerCSW(serverID);
Assert.assertTrue(deleted);
}
}
use of org.geosdi.geoplatform.responce.ServerCSWDTO in project geo-platform by geosdi.
the class CSWCatalogServerTest method testSecureSaveServerSNIPC.
@Ignore("Require to add the SNIPC certificate into default keystore")
@Test
public void testSecureSaveServerSNIPC() throws Exception {
// Save the server
String serverURL = super.snipcProvider.getSnipcUrl();
ServerCSWDTO serverDTO = cswService.saveServerCSW("SNIPC", serverURL, organizationNameTest);
Assert.assertNotNull(serverDTO);
// Retrieve the server
ServerCSWDTO retrievedServerDTO = cswService.getShortServerCSW(serverURL);
this.compareServer(serverDTO, retrievedServerDTO);
// Delete the server
boolean deleted = cswService.deleteServerCSW(serverDTO.getId());
Assert.assertTrue(deleted);
}
Aggregations