Revision 3510 trunk/applications/appCatalogYNomenclatorClient/src/es/gva/cit/catalogClient/CatalogClient.java
CatalogClient.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
import es.gva.cit.catalogClient.csw.drivers.CSWCatalogServiceDriver; |
44 | 44 |
import es.gva.cit.catalogClient.drivers.ICatalogServiceDriver; |
45 |
import es.gva.cit.catalogClient.metadataXML.XMLNode; |
|
45 | 46 |
import es.gva.cit.catalogClient.srw.drivers.SRWCatalogServiceDriver; |
46 | 47 |
import es.gva.cit.catalogClient.utils.comboServer.ServerData; |
47 | 48 |
import es.gva.cit.catalogClient.z3950.drivers.Z3950CatalogServiceDriver; |
... | ... | |
63 | 64 |
private String sURL = null; |
64 | 65 |
private String protocol = null; |
65 | 66 |
private ICatalogServiceDriver lnkICatalogServerDriver; |
67 |
private String serverStatus = null; |
|
66 | 68 |
|
67 | 69 |
/** |
68 | 70 |
* Constructor |
... | ... | |
116 | 118 |
lnkICatalogServerDriver = new Z3950CatalogServiceDriver(); |
117 | 119 |
} |
118 | 120 |
} |
121 |
|
|
122 |
/** |
|
123 |
* This function is a link between the user interface and |
|
124 |
* the driver. It tryes if the server exists, if the server |
|
125 |
* supports the protocolo and finally it sents a getCapabilities |
|
126 |
* request. |
|
127 |
* @return |
|
128 |
* True if all is OK. |
|
129 |
*/ |
|
130 |
public boolean getCapabilities(){ |
|
131 |
//try to connect |
|
132 |
if (!serverReady()) { |
|
133 |
serverStatus = ("errorServerNotFound"); |
|
134 |
} else if (!getLnkICatalogServerDriver().isProtocolSupported(getUrl())) { |
|
135 |
serverStatus = "errorNotSupportedProtocol"; |
|
136 |
} else { |
|
137 |
//getCapabilities |
|
138 |
XMLNode[] nodesCapabilities = getLnkICatalogServerDriver() |
|
139 |
.getCapabilities(getUrl()); |
|
119 | 140 |
|
141 |
if (nodesCapabilities == null) { |
|
142 |
serverStatus = "errorNotSupportedCapabilities"; |
|
143 |
} else { |
|
144 |
//Configure the client |
|
145 |
if (!getLnkICatalogServerDriver().setParameters(nodesCapabilities,getUrl())) { |
|
146 |
if (!(getLnkICatalogServerDriver() |
|
147 |
.getServerAnswerReady().equals(""))) { |
|
148 |
serverStatus = getLnkICatalogServerDriver().getServerAnswerReady(); |
|
149 |
} else { |
|
150 |
serverStatus = "errorNotParsedReply"; |
|
151 |
} |
|
152 |
} else { |
|
153 |
//Show the answer |
|
154 |
serverStatus = getLnkICatalogServerDriver().getServerAnswerReady(); |
|
155 |
return true; |
|
156 |
} |
|
157 |
} |
|
158 |
} |
|
159 |
|
|
160 |
return false; |
|
161 |
} |
|
162 |
|
|
120 | 163 |
/** |
121 | 164 |
* @return Returns the lnkICatalogServerDriver. |
122 | 165 |
*/ |
... | ... | |
175 | 218 |
* true --> server is ready |
176 | 219 |
* false --> server is not ready |
177 | 220 |
*/ |
178 |
public boolean serverReady() {
|
|
221 |
private boolean serverReady() {
|
|
179 | 222 |
try { |
180 | 223 |
new Socket(this.getUrl().getHost(),this.getUrl().getPort()); |
181 | 224 |
} catch (UnknownHostException e) { |
... | ... | |
200 | 243 |
public void setSURL(String surl) { |
201 | 244 |
sURL = surl; |
202 | 245 |
} |
246 |
|
|
247 |
/** |
|
248 |
* @return Returns the serverStatus. |
|
249 |
*/ |
|
250 |
public String getServerStatus() { |
|
251 |
return serverStatus; |
|
252 |
} |
|
203 | 253 |
} |
Also available in: Unified diff