Ignore:
Timestamp:
2012-09-11T16:22:31+12:00 (12 years ago)
Author:
ak19
Message:

Uncommitted changes from ages back to fedoraGS3 classes to get greenstone to work as an interface to fedora repository backend.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • other-projects/gs3-webservices-java-client/trunk/src/GS3Fedora/org/greenstone/fedora/services/FedoraGS3Connection.java

    r22308 r26171  
    455455            // <documentNodeList>
    456456       
    457         // <documentNode nodeID="docID"> - the docNode on which a structure 
     457        // <documentNode nodeID="docID"> - the docNode on which a metadata
    458458        // retrieve is being performed
    459459        Element docNode = doc.createElement(GSXML.DOC_NODE_ELEM);
     
    23522352        }
    23532353    }
     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    }
    23542399   
    23552400    public static void main(String args[]) {
Note: See TracChangeset for help on using the changeset viewer.