Ignore:
Timestamp:
2012-09-27T18:37:00+12:00 (12 years ago)
Author:
ak19
Message:
  1. Now checks request for nodeStructureInfo documentType, as is needed to get it working with GS3 again. 2. Added in reusable constants of gsdl3/util/AbstractBasicDocument.java since these have now been made public constants.
Location:
other-projects/gs3-webservices-java-client/trunk/src/GS3Fedora/org/greenstone/fedora/services
Files:
2 edited

Legend:

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

    r26259 r26270  
    2020
    2121package org.greenstone.fedora.services;
     22import org.greenstone.gsdl3.util.AbstractBasicDocument; // for constants
    2223import org.greenstone.gsdl3.util.GSXML;
    2324
     
    12921293     * the structure to retrieve.
    12931294     * @param info can contain any combination of: siblingPosition, numSiblings,
    1294      * numChildren, requesting additional information about the structure. */
     1295     * numChildren, documentType, requesting additional information about the structure. */
    12951296    public Element getSectionStructureXML(String docPID, String sectionID, String structure, String info)
    12961297        throws RemoteException, UnsupportedEncodingException, SAXException, IOException
     
    17481749
    17491750    if(!info.equals("")) {   
    1750         if(info.indexOf("numChildren") != -1) {
     1751        if(info.indexOf(AbstractBasicDocument.INFO_NUM_CHILDREN) != -1
     1752           || info.indexOf(AbstractBasicDocument.INFO_DOC_TYPE) != -1) {
    17511753        //int numChildren = e.getElementsByTagName(SECTION_ELEMENT).getLength();
    17521754        int numChildren = 0;
     
    17601762        }
    17611763       
    1762         root.setAttribute("numChildren", Integer.toString(numChildren));
     1764        if(info.indexOf(AbstractBasicDocument.INFO_NUM_CHILDREN) != -1) {
     1765            root.setAttribute(AbstractBasicDocument.INFO_NUM_CHILDREN, Integer.toString(numChildren));
     1766        }
     1767        if(info.indexOf(AbstractBasicDocument.INFO_DOC_TYPE) != -1) {
     1768            //String docType = (numChildren > 0) ? "hierarchy" : "simple";
     1769            String docType = "hierarchy";
     1770            root.setAttribute(AbstractBasicDocument.INFO_DOC_TYPE, docType);
     1771        }
    17631772        }
    17641773       
     
    17871796        }       
    17881797       
    1789         if(info.indexOf("numSiblings") != -1) {
    1790             root.setAttribute("numSiblings", Integer.toString(numSiblings));
    1791         }
    1792        
    1793         if(info.indexOf("siblingPosition") != -1) {
    1794             root.setAttribute("siblingPosition", Integer.toString(siblingPosition));
     1798        if(info.indexOf(AbstractBasicDocument.INFO_NUM_SIBS) != -1) {
     1799            root.setAttribute(AbstractBasicDocument.INFO_NUM_SIBS, Integer.toString(numSiblings));
     1800        }
     1801       
     1802        if(info.indexOf(AbstractBasicDocument.INFO_SIB_POS) != -1) {
     1803            root.setAttribute(AbstractBasicDocument.INFO_SIB_POS, Integer.toString(siblingPosition));
    17951804        }
    17961805        }
  • other-projects/gs3-webservices-java-client/trunk/src/GS3Fedora/org/greenstone/fedora/services/FedoraGS3Connection.java

    r26262 r26270  
    2929import org.greenstone.fedora.services.FedoraGS3Exception.FedoraGS3RunException;
    3030import org.greenstone.fedora.services.FedoraGS3Exception.NotAFedoraServerException;
     31import org.greenstone.gsdl3.util.AbstractBasicDocument; // for constants
    3132import org.greenstone.gsdl3.util.GSXML;
    3233import org.w3c.dom.Document;
     
    888889            //    ...
    889890            // </nodeStructureInfo>
    890             Element nodeStructureInfo = doc.createElement(GSXML.NODE_STRUCTURE_ELEM+GSXML.INFO_ATT);
     891            Element nodeStructureInfo = doc.createElement(GSXML.NODE_STRUCTURE_ELEM+"Info");
    891892            Element root = srcDocElement.getOwnerDocument().getDocumentElement();
    892893           
    893             if(root.hasAttribute("numSiblings")) {
    894             String numSiblings = root.getAttribute("numSiblings");
     894            if(root.hasAttribute(AbstractBasicDocument.INFO_NUM_SIBS)) {
     895            String numSiblings = root.getAttribute(AbstractBasicDocument.INFO_NUM_SIBS);
    895896            Element infoEl = doc.createElement(GSXML.INFO_ATT);
    896             infoEl.setAttribute(GSXML.NAME_ATT, "numSiblings");
     897            infoEl.setAttribute(GSXML.NAME_ATT, AbstractBasicDocument.INFO_NUM_SIBS);
    897898            infoEl.setAttribute(GSXML.VALUE_ATT, numSiblings);
    898899            nodeStructureInfo.appendChild(infoEl);
    899900            }
    900901           
    901             if(root.hasAttribute("siblingPosition")) {
    902             String siblingPosition = root.getAttribute("siblingPosition");
     902            if(root.hasAttribute(AbstractBasicDocument.INFO_SIB_POS)) {
     903            String siblingPosition = root.getAttribute(AbstractBasicDocument.INFO_SIB_POS);
    903904            Element infoEl = doc.createElement(GSXML.INFO_ATT);
    904             infoEl.setAttribute(GSXML.NAME_ATT, "siblingPosition");
     905            infoEl.setAttribute(GSXML.NAME_ATT, AbstractBasicDocument.INFO_SIB_POS);
    905906            infoEl.setAttribute(GSXML.VALUE_ATT, siblingPosition);
    906907            nodeStructureInfo.appendChild(infoEl);
    907908            }
    908909           
    909             if(root.hasAttribute("numChildren")) {
    910             String numChildren = root.getAttribute("numChildren");
     910            if(root.hasAttribute(AbstractBasicDocument.INFO_NUM_CHILDREN)) {
     911            String numChildren = root.getAttribute(AbstractBasicDocument.INFO_NUM_CHILDREN);
    911912            Element infoEl = doc.createElement(GSXML.INFO_ATT);     
    912             infoEl.setAttribute(GSXML.NAME_ATT, "numChildren");
     913            infoEl.setAttribute(GSXML.NAME_ATT, AbstractBasicDocument.INFO_NUM_CHILDREN);
    913914            infoEl.setAttribute(GSXML.VALUE_ATT, numChildren);
    914915            nodeStructureInfo.appendChild(infoEl);
    915916            }
     917
     918            if(root.hasAttribute(AbstractBasicDocument.INFO_DOC_TYPE)) {
     919            String documentType = root.getAttribute(AbstractBasicDocument.INFO_DOC_TYPE);
     920            Element infoEl = doc.createElement(GSXML.INFO_ATT);     
     921            infoEl.setAttribute(GSXML.NAME_ATT, AbstractBasicDocument.INFO_DOC_TYPE);
     922            infoEl.setAttribute(GSXML.VALUE_ATT, documentType);
     923            nodeStructureInfo.appendChild(infoEl);
     924            }       
     925
    916926            docNode.appendChild(nodeStructureInfo);
    917927        }
     
    24782488            for(int i = 0; i < docIDs.length; i++) {
    24792489                System.out.println("Descendents and numChildren:\n"
    2480                            + con.getDocumentStructure(docIDs[i], new String[] {"descendants"}, new String[] {"numChildren"}));
     2490                           + con.getDocumentStructure(docIDs[i], new String[] {"descendants"}, new String[] {AbstractBasicDocument.INFO_NUM_CHILDREN}));
    24812491                System.out.println("Parent and numSiblings:\n"
    2482                            + con.getDocumentStructure(docIDs[i], new String[] {"parent"}, new String[] {"numSiblings"}));
     2492                           + con.getDocumentStructure(docIDs[i], new String[] {"parent"}, new String[] {AbstractBasicDocument.INFO_NUM_SIBS}));
    24832493            }
    24842494           
     
    24902500            System.out.println(con.getContent(errorCases));
    24912501            System.out.println(con.getDocumentMetadata(errorCases, new String[]{"all"}));
    2492                            System.out.println(con.getDocumentStructure(errorCases, new String[] {"descendants"}, new String[] {"numChildren"}));
     2502                           System.out.println(con.getDocumentStructure(errorCases, new String[] {"descendants"}, new String[] {AbstractBasicDocument.INFO_NUM_CHILDREN}));
    24932503           
    24942504            System.out.println("\nCLASSIFIER BROWSE");
Note: See TracChangeset for help on using the changeset viewer.