use of org.geosdi.geoplatform.exception.ServerInternalFault in project geo-platform by geosdi.
the class CSWServiceDelegate method searchFullRecords.
/**
* TODO Factorize source code for search*Records methods.
* <p>
* Changed wrt searchSummaryRecords: 1 - ElementSetType.FULL 2 - Downcast to
* RecordType
* <p>
* TODO GMD list.
*/
@Override
public List<FullRecordDTO> searchFullRecords(int num, int start, CatalogFinderBean catalogFinder) throws Exception {
logger.trace("\n*** searchFullRecords ***\n{}", catalogFinder);
GeoPlatformServer server = this.getCSWServerByID(catalogFinder.getServerID());
CatalogGetRecordsRequest<GetRecordsResponseType> request = this.createGetRecordsRequest(server.getServerUrl());
request.setTypeName(TypeName.RECORD_V202);
request.setOutputSchema(OutputSchema.CSW_V202);
request.setElementSetName(ElementSetType.FULL.value());
request.setResultType(ResultType.RESULTS.value());
request.setConstraintLanguage(ConstraintLanguage.FILTER);
request.setConstraintLanguageVersion(ConstraintLanguageVersion.V110);
request.setCatalogFinder(catalogFinder);
// Pagination search
request.setMaxRecords(BigInteger.valueOf(num));
request.setStartPosition(BigInteger.valueOf(start));
logger.debug("\n*** Num: {} *** Start: {} ***", request.getMaxRecords(), request.getStartPosition());
GetRecordsResponseType response = this.createGetRecordsResponse(request);
logger.debug("\n*** Records matched: {} *** Records returned: {} *** Record next: {} ***", response.getSearchResults().getNumberOfRecordsMatched(), response.getSearchResults().getNumberOfRecordsReturned(), response.getSearchResults().getNextRecord());
if (response.getSearchResults().getNumberOfRecordsReturned().intValue() != response.getSearchResults().getAbstractRecord().size()) {
throw new ServerInternalFault("CSW Catalog Server Error: incorrect number of records, expected " + response.getSearchResults().getNumberOfRecordsReturned() + " but was " + response.getSearchResults().getAbstractRecord().size());
}
List<JAXBElement<? extends AbstractRecordType>> records = response.getSearchResults().getAbstractRecord();
logger.trace("\n*** Record list size: {} ***", records.size());
List<FullRecordDTO> recordListDTO = Lists.<FullRecordDTO>newArrayListWithCapacity(records.size());
for (JAXBElement<? extends AbstractRecordType> r : records) {
RecordType record = (RecordType) r.getValue();
recordListDTO.add(this.convertFullRecords(record, server));
}
return recordListDTO;
}
use of org.geosdi.geoplatform.exception.ServerInternalFault in project geo-platform by geosdi.
the class GPCatalogFinderService method searchSummaryRecords.
@Override
public PagingLoadResult<SummaryRecord> searchSummaryRecords(PagingLoadConfig config, CatalogFinderBean catalogFinder, HttpServletRequest httpServletRequest) throws Exception {
int recordsCount;
ArrayList<SummaryRecord> searchRecords;
try {
recordsCount = geoPlatformCSWClient.getRecordsCount(catalogFinder);
if (recordsCount == 0) {
logger.info("\n*** No Summary Record found ***");
searchRecords = new ArrayList<SummaryRecord>(0);
} else {
List<SummaryRecordDTO> recordList = geoPlatformCSWClient.searchSummaryRecords(config.getLimit(), config.getOffset() + 1, catalogFinder);
searchRecords = new ArrayList<SummaryRecord>(recordList.size());
for (SummaryRecordDTO recordDTO : recordList) {
searchRecords.add(this.convertSummaryRecordDTO(recordDTO));
}
}
} catch (IllegalParameterFault ex) {
logger.error("\n*** IllegalParameterFault ***\n{}", ex.getMessage());
throw new GeoPlatformException(ex.getMessage());
} catch (ResourceNotFoundFault ex) {
logger.error("\n*** ResourceNotFoundFault ***\n{}", ex.getMessage());
throw new GeoPlatformException(ex.getMessage());
} catch (ServerInternalFault ex) {
logger.error("\n*** ServerInternalFault ***\n{}", ex.getMessage());
throw new GeoPlatformException(ex.getMessage());
}
return new BasePagingLoadResult<SummaryRecord>(searchRecords, config.getOffset(), recordsCount);
}
use of org.geosdi.geoplatform.exception.ServerInternalFault in project geo-platform by geosdi.
the class GPCatalogFinderService method searchFullRecords.
@Override
public PagingLoadResult<FullRecord> searchFullRecords(PagingLoadConfig config, CatalogFinderBean catalogFinder, HttpServletRequest httpServletRequest) throws Exception {
logger.debug("\n--------------------------\n{}\n--------------------------\n", catalogFinder);
int recordsCount;
ArrayList<FullRecord> searchRecords;
try {
recordsCount = geoPlatformCSWClient.getRecordsCount(catalogFinder);
if (recordsCount == 0) {
logger.info("\n*** No Full Record found ***");
searchRecords = new ArrayList<FullRecord>(0);
} else {
List<FullRecordDTO> recordList = geoPlatformCSWClient.searchFullRecords(config.getLimit(), config.getOffset() + 1, catalogFinder);
searchRecords = new ArrayList<FullRecord>(recordList.size());
for (FullRecordDTO recordDTO : recordList) {
searchRecords.add(this.convertFullRecordDTO(recordDTO));
}
}
} catch (IllegalParameterFault ex) {
logger.error("\n*** IllegalParameterFault ***\n{}", ex.getMessage());
throw new GeoPlatformException(ex.getMessage());
} catch (ResourceNotFoundFault ex) {
logger.error("\n*** ResourceNotFoundFault ***\n{}", ex.getMessage());
throw new GeoPlatformException(ex.getMessage());
} catch (ServerInternalFault ex) {
logger.error("\n*** ServerInternalFault ***\n{}", ex.getMessage());
throw new GeoPlatformException(ex.getMessage());
}
return new BasePagingLoadResult<FullRecord>(searchRecords, config.getOffset(), recordsCount);
}
use of org.geosdi.geoplatform.exception.ServerInternalFault in project geo-platform by geosdi.
the class GPCatalogFinderService method getRecordById.
@Override
public String getRecordById(Long serverID, String identifier, String moduleName, HttpServletRequest httpServletRequest) throws Exception {
try {
String url = httpServletRequest.getSession().getServletContext().getRealPath("/" + moduleName + "/csw-template");
logger.trace("PATH @@@@@@@@@@@@@@@@@@ {}", url);
String response = geoPlatformCSWClient.getRecordById(serverID, identifier);
response = this.deAccent(response);
String fileName = url + "/" + System.currentTimeMillis() + "-" + identifier + ".xml";
File file = new File(fileName);
FileUtils.writeStringToFile(file, response);
logger.debug("Name FILE Created @@@@@@@@@@@@@@@@@@@@@@@@@@@ {}", file.getName());
return file.getName();
} catch (IOException ex) {
logger.error("\n*** IOException ***\n{}", ex.getMessage());
throw new GeoPlatformException(ex.getMessage());
} catch (IllegalParameterFault ex) {
logger.error("\n*** IllegalParameterFault ***\n{}", ex.getMessage());
throw new GeoPlatformException(ex.getMessage());
} catch (ResourceNotFoundFault ex) {
logger.error("\n*** ResourceNotFoundFault ***\n{}", ex.getMessage());
throw new GeoPlatformException(ex.getMessage());
} catch (ServerInternalFault ex) {
logger.error("\n*** ServerInternalFault ***\n{}", ex.getMessage());
throw new GeoPlatformException(ex.getMessage());
}
}
use of org.geosdi.geoplatform.exception.ServerInternalFault in project geo-platform by geosdi.
the class CSWServiceDelegate method searchSummaryRecords.
/**
* TODO Factorize source code for search*Records methods.
* <p>
* TODO GMD list.
*/
@Override
public List<SummaryRecordDTO> searchSummaryRecords(int num, int start, CatalogFinderBean catalogFinder) throws Exception {
logger.trace("\n*** searchSummaryRecords ***\n{}", catalogFinder);
GeoPlatformServer server = this.getCSWServerByID(catalogFinder.getServerID());
CatalogGetRecordsRequest<GetRecordsResponseType> request = this.createGetRecordsRequest(server.getServerUrl());
request.setTypeName(TypeName.RECORD_V202);
request.setOutputSchema(OutputSchema.CSW_V202);
request.setElementSetName(ElementSetType.SUMMARY.value());
request.setResultType(ResultType.RESULTS.value());
request.setConstraintLanguage(ConstraintLanguage.FILTER);
request.setConstraintLanguageVersion(ConstraintLanguageVersion.V110);
request.setCatalogFinder(catalogFinder);
// Pagination search
request.setMaxRecords(BigInteger.valueOf(num));
request.setStartPosition(BigInteger.valueOf(start));
logger.debug("\n*** Num: {} *** Start: {} ***", request.getMaxRecords(), request.getStartPosition());
GetRecordsResponseType response = this.createGetRecordsResponse(request);
logger.debug("\n*** Records matched: {} *** Records returned: {} *** Record next: {} ***", response.getSearchResults().getNumberOfRecordsMatched(), response.getSearchResults().getNumberOfRecordsReturned(), response.getSearchResults().getNextRecord());
if (response.getSearchResults().getNumberOfRecordsReturned().intValue() != response.getSearchResults().getAbstractRecord().size()) {
throw new ServerInternalFault("CSW Catalog Server Error: incorrect number of records, expected " + response.getSearchResults().getNumberOfRecordsReturned() + " but was " + response.getSearchResults().getAbstractRecord().size());
}
List<JAXBElement<? extends AbstractRecordType>> records = response.getSearchResults().getAbstractRecord();
logger.trace("\n*** Record list size: {} ***", records.size());
List<SummaryRecordDTO> recordListDTO = new ArrayList<SummaryRecordDTO>(records.size());
for (JAXBElement<? extends AbstractRecordType> record : records) {
SummaryRecordType summary = (SummaryRecordType) record.getValue();
recordListDTO.add(this.convertSummaryRecords(summary, server));
}
return recordListDTO;
}
Aggregations