📄 cswmetadatadao.java
字号:
* @see com.esri.solutions.jitk.common.metadata.IMetadataDAO#getAllDocuments()
*/
public List<IMetadataDocument> getAllDocuments() {
Map<String, Object> criteria = null;
criteria = new HashMap<String, Object>();
criteria.put(SEARCH_TERM_KEY, WILDCARD_CHARACTER);
criteria.put(NUMBER_OF_RECORDS_KEY, VIEW_ALL_RECORDS);
criteria.put(LIVE_DATA_ONLY_KEY, Boolean.FALSE);
return findDocuments(criteria);
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.IMetadataDAO#getRepositoryItemByID(com.esri.solutions.jitk.common.metadata.IMetadataID)
*/
public IMetadataDocument getRepositoryItemByID(IMetadataID id)
throws InvalidMetadataOperationException {
CswCatalog cswCatalog = null;
CswSearchRequest searchRequest = null;
CswSearchResponse searchResponse = null;
CswRecord record = null;
Iterator<CswRecord> iter = null;
CSWMetadataDocument document = null;
if (id == null) {
throw new NullPointerException("id cannot be null");
}
cswCatalog = createCswCatalog();
searchRequest = new CswSearchRequest();
searchRequest.setCatalog(cswCatalog);
try {
searchRequest.getRepositoryItem(id.getId());
searchResponse = searchRequest.getCswSearchResponse();
iter = searchResponse.getRecords().iterator();
if (iter.hasNext()) {
record = iter.next();
document = new CSWMetadataDocument();
document.setMetadataID(id);
document.setMetadataProfile(_catalog.getMetadataProfile());
document.setRecord(record);
} else {
_logger.warn(
"No repository item found for metadata record: ID[" +
id.getId() + "] on catalog service [" + _catalog.getName() +
"]");
}
} catch (TransformerException ex) {
_logger.warn(
"TransformerException occurred while getting repository item by ID: ID [" +
id.getId() + "] on catalog service [" + _catalog.getName() +
"]", ex);
} catch (SAXException ex) {
_logger.warn(
"SAXException occurred while getting repository item by ID: ID [" +
id.getId() + "] on catalog service [" + _catalog.getName() +
"]", ex);
} catch (NullReferenceException ex) {
_logger.warn(
"NullReferenceException occurred while getting repository item by ID: ID [" +
id.getId() + "] on catalog service [" + _catalog.getName() +
"]", ex);
} catch (ParserConfigurationException ex) {
_logger.warn(
"ParserConfigurationException occurred while getting repository item by ID: ID [" +
id.getId() + "] on catalog service [" + _catalog.getName() +
"]", ex);
} catch (IOException ex) {
_logger.warn(
"IOException occurred while getting repository item by ID: ID [" +
id.getId() + "] on catalog service [" + _catalog.getName() +
"]", ex);
} catch (InvalidOperationException ex) {
_logger.warn(
"InvalidOperationException occurred while getting repository item by ID: ID [" +
id.getId() + "] on catalog service [" + _catalog.getName() +
"]", ex);
throw new InvalidMetadataOperationException(
"GetRepositoryItem operation is not supported by the CS/W service");
}
return document;
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.IMetadataDAO#getDocumentByID(com.esri.solutions.jitk.common.metadata.IMetadataID)
*/
public IMetadataDocument getDocumentByID(IMetadataID id) {
CswCatalog cswCatalog = null;
CswSearchRequest searchRequest = null;
CswSearchResponse searchResponse = null;
CswRecord record = null;
Iterator<CswRecord> iter = null;
CSWMetadataDocument document = null;
if (id == null) {
throw new NullPointerException("id cannot be null");
}
cswCatalog = createCswCatalog();
searchRequest = new CswSearchRequest();
searchRequest.setCatalog(cswCatalog);
try {
searchRequest.getMetadataByID(id.getId());
searchResponse = searchRequest.getCswSearchResponse();
iter = searchResponse.getRecords().iterator();
if (iter.hasNext()) {
record = iter.next();
document = new CSWMetadataDocument();
document.setMetadataID(id);
document.setMetadataProfile(_catalog.getMetadataProfile());
document.setRecord(record);
} else {
_logger.warn("No records found for metadata record: ID[" +
id.getId() + "] on catalog service [" + _catalog.getName() +
"]");
}
} catch (TransformerException ex) {
_logger.warn(
"TransformerException occurred while getting metadata record by ID: ID [" +
id.getId() + "] on catalog service [" + _catalog.getName() +
"]", ex);
} catch (SAXException ex) {
_logger.warn(
"SAXException occurred while getting metadata record by ID: ID [" +
id.getId() + "] on catalog service [" + _catalog.getName() +
"]", ex);
} catch (NullReferenceException ex) {
_logger.warn(
"NullReferenceException occurred while getting metadata record by ID: ID [" +
id.getId() + "] on catalog service [" + _catalog.getName() +
"]", ex);
} catch (ParserConfigurationException ex) {
_logger.warn(
"ParserConfigurationException occurred while getting metadata record by ID: ID [" +
id.getId() + "] on catalog service [" + _catalog.getName() +
"]", ex);
} catch (IOException ex) {
_logger.warn(
"IOException occurred while getting metadata record by ID: ID [" +
id.getId() + "] on catalog service [" + _catalog.getName() +
"]", ex);
} catch (InvalidOperationException ex) {
_logger.warn(
"InvalidOperationException occurred while getting metadata record by ID: ID [" +
id.getId() + "] on catalog service [" + _catalog.getName() +
"]", ex);
}
return document;
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.IMetadataDAO#getID()
*/
public String getId() {
return _id;
}
/**
* Sets the Id of this DAO.
*
* @param id {@link String} Id of this DAO.
*/
public void setId(String id) {
if (id == null) {
throw new NullPointerException("id cannot be null");
}
_id = id;
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.IMetadataDAO#getProperties()
*/
public Map<String, Object> getProperties() {
return _properties;
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.IMetadataDAO#setProperties(java.util.Map)
*/
public void setProperties(Map<String, Object> properties) {
if (properties == null) {
throw new NullPointerException("properties cannot be null");
}
_properties = properties;
if (_properties.containsKey("catalog")) {
if (_properties.get("catalog") instanceof CSWMetadataCatalog) {
_catalog = (CSWMetadataCatalog) _properties.get("catalog");
}
}
}
/**
* Utility method to create a {@link CswCatalog} object by first creating
* a {@link CswProfile} object using {@link #createCswProfile()}.
*
* @return newly create {@link CswCatalog} object.
* @throws IllegalStateException Thrown if the {@link #_catalog} reference has not been
* set via the {@link #setProperties(Map)} method.
*/
private CswCatalog createCswCatalog() {
CswCatalog catalog = null;
CswProfile profile = null;
if (_catalog == null) {
throw new IllegalStateException(
"Invalid catalog, uable to retrieve service connection details");
}
profile = createCswProfile();
catalog = new CswCatalog(_catalog.getServiceURL(), _catalog.getName(),
profile);
return catalog;
}
/**
* Utility method to create a {@link CswProfile} object with the configured
* parameters on the {@link #_catalog} reference.
*
* @return newly create {@link CswProfile} object.
* @throws IllegalStateException Thrown if the {@link #_catalog} reference has not been
* set via the {@link #setProperties(Map)} method.
*/
private CswProfile createCswProfile() {
CswProfile profile = null;
if (_catalog == null) {
throw new IllegalStateException("invalid catalog");
}
profile = new CswProfile(_catalog.getMetadataProfile().getId(),
_catalog.getMetadataProfile().getId(), "",
_catalog.getMetadataProfile().getGetRecordByIdRequestKVPs(),
_catalog.getMetadataProfile().getGetRepositoryItemRequestKVPs(),
_catalog.getMetadataProfile().getGetRecordsRequestXslt(),
_catalog.getMetadataProfile().getGetRecordsResponseXslt(),
_catalog.getMetadataProfile().getGetRecordByIdResponseXslt(),
_catalog.getMetadataProfile().getSupportSpatialQuery(),
_catalog.getMetadataProfile().getSupportContentTypeQuery(),
_catalog.getMetadataProfile().getUsesMetadataResourceUrl());
return profile;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -