Changeset 26171 for other-projects
- Timestamp:
- 2012-09-11T16:22:31+12:00 (12 years ago)
- Location:
- other-projects/gs3-webservices-java-client/trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/gs3-webservices-java-client/trunk/src/GS3DemoClient/org/greenstone/gs3client/dlservices/FedoraServicesAPIA.java
r22298 r26171 242 242 return this.browseMetadataRetrieve(nodeIDs, metafields); 243 243 } 244 245 246 // FOR NOW, add the new method that converts URLs to document identifiers(PIDs) here, 247 // since it is not used by GS3 classes 248 public String getDocIDforURL(String url, String collection) { 249 return this.getPIDforURL(url, collection); 250 } 244 251 245 252 } -
other-projects/gs3-webservices-java-client/trunk/src/GS3Fedora/org/greenstone/fedora/services/FedoraConnection.java
r22368 r26171 984 984 } 985 985 986 987 /** Used to obtain the dc:title value (hashID) of the DC stream of a digital 988 * object whose fedoraID is of a special sort: greenstone-http:<colname>-id. */ 989 protected String getDCTitle(String fedoraPID) 990 throws RemoteException, UnsupportedEncodingException, 991 SAXException, IOException 992 { 993 String title = ""; 994 MIMETypedStream dcdata = APIA.getDatastreamDissemination(fedoraPID, DC, null); 995 if(dcdata == null || dcdata.equals("")) { 996 return title; 997 } 998 String dcStream = new String(dcdata.getStream(), UTF8); 999 1000 InputSource source = new InputSource(new StringReader(dcStream)); 1001 Document doc = builder.parse(source); 1002 Element docEl = doc.getDocumentElement(); // docEl=<oai_dc:dc></oai_dc:dc> 1003 NodeList children = docEl.getElementsByTagName("dc:title"); 1004 if(children != null && children.getLength() > 0) { 1005 Node n = children.item(0); // <dc:title> 1006 Element e = (Element)n; 1007 title = FedoraCommons.getValue(e); 1008 } 1009 return title; 1010 } 1011 986 1012 /** @return the title metadata for the given document sections. 987 1013 * These titles are returned in the same order as the given docPIDs -
other-projects/gs3-webservices-java-client/trunk/src/GS3Fedora/org/greenstone/fedora/services/FedoraGS3Connection.java
r22308 r26171 455 455 // <documentNodeList> 456 456 457 // <documentNode nodeID="docID"> - the docNode on which a structure457 // <documentNode nodeID="docID"> - the docNode on which a metadata 458 458 // retrieve is being performed 459 459 Element docNode = doc.createElement(GSXML.DOC_NODE_ELEM); … … 2352 2352 } 2353 2353 } 2354 2355 2356 // FOR NOW, add the new method that converts URLs to document identifiers(PIDs) 2357 /** Given a URL that represents a fedoraPID, will look up the object. 2358 * If it exists, it will return the contents of the DC:Title of its datastream. 2359 * If it doesn't exist, it will return the URL as-is. 2360 * @param URL: the URL that (after modification) represents a fedoraPID to look up. 2361 * @param collection: the name of collection in which to search for the URL 2362 * representing a fedoraPID. 2363 * @return the string (representing a fedoraPID) stored in the DC:Title of the 2364 * URL-fedoraPID. If the URL-fedoraPID is not an object in the given collection, 2365 * then the parameter URL is returned. 2366 */ 2367 public String getPIDforURL(String url, String collection) { 2368 FedoraGS3RunException ex = null; // any RemoteException 2369 2370 // (1) convert url to the fedorapid 2371 // / -> _ and : -> - 2372 String fedoraPID = url.replaceAll("/", "_"); 2373 fedoraPID = fedoraPID.replaceAll(":", "-"); 2374 // prefix "greenstone-http:<colname>-" to the fedoraPID 2375 fedoraPID = GREENSTONE+_HTTP+COLON+collection+HYPHEN+fedoraPID; 2376 //LOG.error("### fedoraPID: " + fedoraPID); 2377 2378 // (2) Look up the datastream for the fedorapid 2379 String dcTitle = ""; 2380 try { 2381 dcTitle = getDCTitle(fedoraPID); 2382 } catch(Exception e) { 2383 LOG.error("Error retrieving dcTitle for PID " + fedoraPID + ": " + e); 2384 ex = new FedoraGS3RunException("When trying to retrieve dc:title for URL: " + url, e); 2385 } 2386 //String dc = this.getDC(fedoraPID); 2387 //LOG.error("### document ID (in dcTitle) found is: " + dcTitle); 2388 2389 // (3) if fedorapid exists, extract the dc:title content. 2390 // if it doesn't exist, return url 2391 if(dcTitle.equals("")) { 2392 return url; 2393 } else { 2394 // It represents a fedoraPID of its own, so prefix fedora namespace and return it. 2395 //return GREENSTONE+COLON+collection+HYPHEN+dcTitle; // NO. Handled in g2f-buildcol.pl 2396 return dcTitle+"-1"; 2397 } 2398 } 2354 2399 2355 2400 public static void main(String args[]) { -
other-projects/gs3-webservices-java-client/trunk/src/GS3Fedora/org/greenstone/fedora/services/FedoraGS3DL.java
r22300 r26171 54 54 public static final String COLLECTION = "collection"; 55 55 public static final String _COLLECTION = "-"+COLLECTION; 56 public static final String _HTTP = "-http"; 56 57 57 58 public static final String WILDCARD = "*"; -
other-projects/gs3-webservices-java-client/trunk/src/GS3Fedora/org/greenstone/fedora/services/FedoraGS3Exception.java
r15439 r26171 201 201 msg = " " + msg + ". "; 202 202 } 203 204 LOG.error("### ERROR"); 205 LOG.error(msg, cause); 203 206 return this.getClass().getCanonicalName() 204 207 + msg + super.getMessage(); -
other-projects/gs3-webservices-java-client/trunk/src/GS3Fedora/org/greenstone/fedora/services/FedoraToGS3Interface.java
r22300 r26171 296 296 public String query(String collection, String service, 297 297 Map nameValParamsMap); 298 299 300 /** Given a URL that represents a fedoraPID, will look up the object. 301 * If it exists, it will return the contents of the DC:Title of its datastream. 302 * If it doesn't exist, it will return the URL as-is. 303 * @param URL: the URL that (after modification) represents a fedoraPID to look up. 304 * @param collection: the name of collection in which to search for the URL 305 * representing a fedoraPID. 306 * @return the string (representing a fedoraPID) stored in the DC:Title of the 307 * URL-fedoraPID. If the URL-fedoraPID is not an object in the given collection, 308 * then the parameter URL is returned. 309 */ 310 public String getPIDforURL(String url, String collection); 298 311 }
Note:
See TracChangeset
for help on using the changeset viewer.