📄 cswcatalog.java
字号:
package com.esri.solutions.jitk.datasources.ogc.csw;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
/**
* Maintains information of CSW Catalog
*
* @remark The catalogs contain all the information like url, profile information
* credentials and capabilities.
* @version 1.0
* @created 25-Jul-2007 1:28:44 PM
*/
public class CswCatalog implements Comparable<CswCatalog> {
//private static int IDCounter = 1;
private String baseUrl;
private CswCatalogCapabilities capabilities = null;
private UsernamePasswordCredentials credentials;
private String id;
private boolean isConnected = false;
//private boolean locking = false;
private String name;
private CswProfile profile;
private String url;
public CswCatalog() {
}
/**
*
* @param surl
* @param sname
* @param oprofile
*/
public CswCatalog(String url, String name, CswProfile profile) {
this.url = url;
this.id = this.url;
this.name = name;
this.profile = profile;
}
public String getBaseUrl() {
return baseUrl;
}
public void setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl;
}
/**
* Execute GetCapabilities using SAX objects.
* Send GetCapabilities request, receive the response from a service, and
* parse the response to get URLs for "GetRecords" and "GetRecordsById".
* @return
* @throws SAXException
* @throws IOException
* @throws ParserConfigurationException
*/
private CswCatalogCapabilities executeCapabilitiesWithSAX()
throws SAXException, IOException, ParserConfigurationException {
CswCatalogCapabilities capabilities = new CswCatalogCapabilities();
CswClient client = new CswClient();
// Execute submission and parsing into response element
InputStream responseStream = client.submitHttpRequest("GET", url, "");
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
CapabilitiesParse cParse = new CapabilitiesParse(capabilities);
factory.newSAXParser().parse(new InputSource(responseStream), cParse);
this.capabilities = capabilities;
return capabilities;
}
public CswCatalogCapabilities getCapabilities() {
return this.capabilities;
}
public void setCapabilities(CswCatalogCapabilities capabilities) {
this.capabilities = capabilities;
}
public UsernamePasswordCredentials getCredentials() {
return credentials;
}
public void setCredentials(UsernamePasswordCredentials credentials) {
this.credentials = credentials;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
// if there is no input for name, use url as a name
if ((name == null) || (name.length() == 0)) {
name = url;
}
this.name = name;
}
public CswProfile getProfile() {
return profile;
}
public void setProfile(CswProfile profile) {
this.profile = profile;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
/**
* To connect to a catalog service. The capabilties details are populated based on
* the service.
* @throws ParserConfigurationException
* @throws IOException
* @throws SAXException
*
* @remark
* @returns true if connection can be made to the csw service
*/
public boolean connect()
throws SAXException, IOException, ParserConfigurationException {
//Execute getCapabilites and setup URLs for "GetRecords" and "GetRecordById"
CswCatalogCapabilities capabilities = executeCapabilitiesWithSAX();
this.isConnected = capabilities.isReady();
return this.isConnected;
}
/**
* To test if already connected to a catalog service.
*
* @remark
* @returns true if connection has already been made to the csw service else false
*/
public boolean IsConnected() {
return this.isConnected;
}
public boolean Locking() {
return false;
}
public int compareTo(CswCatalog arg0) {
// TODO Auto-generated method stub
return 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -