Ignore:
Timestamp:
2010-06-24T13:45:34+12:00 (14 years ago)
Author:
ak19
Message:
  1. Changes to get Fedora to work with Greenstone3: to let the Greenstone3 Reader Interface work with a Fedora Repository behind the scenes. 2. No longer returns XML Strings formatted for display, but unformatted, since when it's converted to XML DOM on the Greenstone end, new lines introduced due to whitespace interfere with Greenstone 3's default parsing of the XML.
File:
1 edited

Legend:

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

    r21855 r22300  
    2020
    2121package org.greenstone.fedora.services;
    22 
     22import org.greenstone.gsdl3.util.GSXML;
    2323
    2424import fedora.client.utility.AutoFinder;
     
    9595   
    9696    /* Some fixed strings of known literals */
    97     protected static final String TYPE = "type";
    98     protected static final String INTERNAL_NODE = "internalNode";
    9997    protected static final String GET= "/get/";
    10098   
     
    632630     * @see <a href="http://www.fedora.info/definitions/1/0/api/Fedora-API-A.html">Fedora access API, API-A for method findObjects</a>
    633631     * @see <a href="http://www.fedora.info/definitions/1/0/types/&#035;complexType_FieldSearchQuery_Link031D7D80">XML type definition of FieldSearchQuery</a>
    634      * @see <a href="http://www.fedora.info/download/2.2.1/javadocs/fedora/server/types/gen/FieldSearchQuery.html>Type definition of 2.2.1 FieldSearchQuery</a>
     632     * @see <a href="http://www.fedora.info/download/2.2.1/javadocs/fedora/server/types/gen/FieldSearchQuery.html">Type definition of 2.2.1 FieldSearchQuery</a>
    635633     * @see <a href="http://www.fedora.info/download/2.1.1/userdocs/server/serverdocs/fedora/server/search/FieldSearchQuery.html">does not apply: type definition of 2.1.1 FieldSearchQuery</a>
    636634     * @see <a href="http://john.drc-dev.ohiolink.edu/browser/drc-core/trunk/src/java/edu/ohiolink/drc/drcdl/BrowseController.java?rev=462">BrowseController.java for an example</a>
     
    12371235    }
    12381236
    1239     /** @return the XML content of the TOC of just that portion of the TOC which   
    1240      * contains the section denoted by sectionID and its direct child subsections.
    1241      * The children are returned in the order they are encountered, which
    1242      * happens to be in the required order of ascending sectionID.
    1243      * @param docPID - a fedora pid identifying a greenstone document object.
    1244      * @param sectionID - identifyies the particular section in the
    1245      * document denoted by docPID, may be a section name or number. */
    1246     public Element getChildrenOfSectionXML(String docPID, String sectionID)
    1247         throws RemoteException, UnsupportedEncodingException,
    1248             SAXException, IOException
    1249     {
    1250         // Store just the number
    1251         String sectionNumber = removePrefix(sectionID, SECTION);
    1252         // get the TOC XML datastream as a String
    1253         String xmlTOC = getTOC(docPID);
    1254        
    1255         // convert it into a DOM document
    1256         InputSource source = new InputSource(new StringReader(xmlTOC));
    1257         Document doc = builder.parse(source);
    1258         // toplevel element docEl = <Section id="1"></Section>
    1259         Element docEl = doc.getDocumentElement();
    1260        
    1261         // check whether we're requested to return the toplevel element itself
    1262         if(sectionID.equals("") || // subSection of entire docPID is requested
    1263            (docEl.hasAttribute(ID) && docEl.getAttribute(ID).equals(sectionNumber)))
    1264             return getSubstructure(docEl, false);
    1265        
    1266         // Otherwise, get all <Section> elements and find the
    1267         // <Section id="sectionNumber"></Section> and return that and its
    1268         // children
    1269         NodeList sections = docEl.getElementsByTagName(SECTION_ELEMENT);
    1270         for(int i = 0; i < sections.getLength(); i++) {
    1271             Element e = (Element)sections.item(i);
    1272             if(e.hasAttribute(ID)
    1273                     && e.getAttribute(ID).equals(sectionNumber))
    1274             {
    1275                 //System.err.println("Found: " + e.getAttribute(ID));
    1276                 return getSubstructure(e, false); // false: get just e and children
    1277             }
    1278         }
    1279         return null; // not found
    1280     }
    1281    
    1282     /** @return a string representing the XML content of the TOC of just
    1283      * that portion of the TOC which contains the section denoted by sectionID 
    1284      * and its direct child subsections.
    1285      * The children are returned in the order they are encountered, which
    1286      * happens to be in the required order of ascending sectionID.
    1287      * @param docPID - a fedora pid identifying a greenstone document object.
    1288      * @param sectionID - identifyies the particular section in the
    1289      * document denoted by docPID, may be a section name or number. */
    1290     public String getChildrenOfSection(String docPID, String sectionID)
    1291         throws RemoteException, UnsupportedEncodingException,
    1292             SAXException, IOException, TransformerException
    1293     {
    1294         Element children = getChildrenOfSectionXML(docPID, sectionID);
    1295         return (children == null) ? "" : FedoraCommons.elementToString(children);
    1296     }
    1297    
    1298     /** @return the part of the TOC XML file (which outlines doc structure) 
    1299      * relating to the given section. This includes the section denoted by
    1300      * sectionID as well as all descendent subsections thereof.
    1301      * @param docPID - a fedora pid identifying a greenstone document object.
    1302      * @param sectionID - identifyies the particular section in the
    1303      * document denoted by docPID, may be a section name or number. */
    1304     public Element getSubsectionXML(String docPID, String sectionID)
    1305         throws RemoteException, UnsupportedEncodingException,
    1306             SAXException, IOException
    1307     {
    1308         // get the TableOfContents (TOC) XML datastream as a String
    1309         String xmlTOC = getTOC(docPID);
    1310        
    1311         // convert it into a DOM document
    1312         InputSource source = new InputSource(new StringReader(xmlTOC));
    1313         Document doc = builder.parse(source);
    1314         // toplevel element docEl = <Section id="1"></Section>
    1315         Element docEl = doc.getDocumentElement();
    1316        
    1317         if(sectionID.equals("")) // subSection of entire docPID is requested
    1318             return docEl;
    1319        
    1320         // Store just the number
    1321         String sectionNumber = removePrefix(sectionID, SECTION);
    1322         // Check whether we're requested to return the toplevel element itself
    1323         // If sectionNumber=1, then the top-level element/document element
    1324         // of the TOC XML is requested, so return the TOC as is.
    1325         if(sectionNumber.equals("1")) {
    1326             return docEl;
    1327         }
    1328        
    1329         // Get all <Section> elements and find the
    1330         // <Section id="sectionNumber"></Section> and return that
    1331         NodeList sections = docEl.getElementsByTagName(SECTION_ELEMENT);
    1332         for(int i = 0; i < sections.getLength(); i++) {
    1333             Element e = (Element)sections.item(i);
    1334             if(e.hasAttribute(ID)
    1335                     && e.getAttribute(ID).equals(sectionNumber)) {
    1336                 //System.err.println("Found: " + e.getAttribute(ID));
    1337                 return getSubstructure(e, true); // true:get all descendents
    1338             }
    1339         }
    1340         return null; // not found
    1341     }
    1342    
    1343     /** @return a String representation of the part of the TOC XML file   
    1344      * (which outlines doc structure) relating to the given section. This   
    1345      * includes the section denoted by sectionID as well as all descendent 
    1346      * subsections thereof.
    1347      * @param docPID a fedora pid identifying a greenstone document object.
    1348      * @param sectionID identifyies the particular section in the
    1349      * document denoted by docPID, may be a section name or number. */
    1350     public String getSubsection(String docPID, String sectionID)
    1351         throws RemoteException, UnsupportedEncodingException, SAXException, 
    1352             IOException, TransformerException
    1353     {
    1354         // Store just the number
    1355         String sectionNumber = removePrefix(sectionID, SECTION);
    1356         // get the TableOfContents (TOC) XML datastream as a String
    1357         String xmlTOC = getTOC(docPID);
    1358        
    1359         // Check whether we're requested to return the toplevel element itself
    1360         // If sectionNumber=1, then the top-level element/document element
    1361         // of the TOC XML is requested, so return the TOC as is.
    1362         if(sectionNumber.equals("1"))
    1363             return xmlTOC;
    1364        
    1365         // else
    1366         Element subsection = getSubsectionXML(docPID, sectionID);
    1367         return (subsection == null) ? "" : FedoraCommons.elementToString(subsection);
    1368     }
     1237    /** Given a documentNode element, adds the nodetype attribute to all of its
     1238     * docNode descendants. The nodetype is either Root, Internal or Leaf to indicate
     1239     * whether the docnode is a toplevel document Node, or has children or has none.
     1240     * @param e - the documentNode element whose descendants' nodetypes will be set
     1241     * at method's end. */
     1242    protected void addNodeTypeToDescendants(Element e) {
     1243    NodeList sections = e.getElementsByTagName(SECTION_ELEMENT);
     1244    for(int i = 0; i < sections.getLength(); i++) {
     1245        Element section = (Element)sections.item(i);
     1246        NodeList descendants = section.getElementsByTagName(SECTION_ELEMENT);
     1247        if(descendants.getLength() > 0) {
     1248        // if there are any descendants (which includes children) that are SECTIONS
     1249        section.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERNAL);
     1250        } else {
     1251        section.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF);
     1252        }
     1253    }
     1254    }
     1255
     1256
     1257    /** @return the part of the TOC XML file (which outlines doc structure) 
     1258     * relating to the given section. This includes the section denoted by
     1259     * sectionID as well as all descendent subsections thereof.
     1260     * @param docPID - a fedora pid identifying a greenstone document object.
     1261     * @param sectionID - identifyies the particular section in the
     1262     * document denoted by docPID, may be a section name or number.
     1263     * @param structure can contain any combination of: ancestors, parent,
     1264     * siblings, children, descendants, entire, specifying the portion of
     1265     * the structure to retrieve.
     1266     * @param info can contain any combination of: siblingPosition, numSiblings,
     1267     * numChildren, requesting additional information about the structure. */
     1268    public Element getSectionStructureXML(String docPID, String sectionID, String structure, String info)
     1269        throws RemoteException, UnsupportedEncodingException, SAXException, IOException
     1270    {
     1271    // get the TableOfContents (TOC) XML datastream as a String
     1272    String xmlTOC = getTOC(docPID);
     1273   
     1274    // convert it into a DOM document
     1275    InputSource source = new InputSource(new StringReader(xmlTOC));
     1276    Document doc = builder.parse(source);
     1277    // toplevel element docEl = <Section id="1"></Section>
     1278    Element docEl = doc.getDocumentElement();
     1279    addNodeTypeToDescendants(docEl);
     1280    docEl.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT);
     1281
     1282    if(structure.indexOf("entire") != -1) { // don't need to find the specific section, doc root is what's required
     1283        docEl = getStructureInfo(docEl.getOwnerDocument(), docEl, info);
     1284        return docEl;
     1285    }
     1286
     1287    if(sectionID.equals("")) {
     1288        sectionID = "1";
     1289    }
     1290   
     1291    // Store just the number
     1292    String sectionNumber = removePrefix(sectionID, SECTION);
     1293    // Check whether we're requested to return the toplevel element itself
     1294    // If sectionNumber=1, then the top-level element/document element
     1295    // of the TOC XML is requested, so return the TOC as is.   
     1296    if(sectionNumber.equals("1") && structure.indexOf("descendants") != -1) {
     1297        docEl = getStructureInfo(docEl.getOwnerDocument(), docEl, info);
     1298        return docEl;       
     1299    }
     1300   
     1301    // if the root is the section required, return that
     1302    if(docEl.getTagName().equals(SECTION_ELEMENT)
     1303       && docEl.getAttribute(ID).equals(sectionNumber)) {
     1304        Element substructure = getSubstructure(docEl, structure);
     1305        return getStructureInfo(substructure.getOwnerDocument(), docEl, info);
     1306        //return docEl;
     1307    }
     1308   
     1309
     1310    // Else, get all <Section> elements and find the
     1311    // <Section id="sectionNumber"></Section> and return that
     1312    NodeList sections = docEl.getElementsByTagName(SECTION_ELEMENT);
     1313    for(int i = 0; i < sections.getLength(); i++) {
     1314       
     1315        Element e = (Element)sections.item(i);
     1316        if(e.hasAttribute(ID) && e.getAttribute(ID).equals(sectionNumber)) {
     1317        Element substructure = getSubstructure(e, structure);
     1318        return getStructureInfo(substructure.getOwnerDocument(), e, info);
     1319        }
     1320    }
     1321
     1322    return null; // not found
     1323    }
     1324
    13691325   
    13701326    /** Implements browsing document titles of a greenstone collection stored in
    13711327     * the fedora repository by letter.
    13721328     * @return the document pids whose titles start with the given letter.
     1329     * @param collName - the name of the collection.
    13731330     * @param letter - the starting letter to browse by.
    13741331     */
     
    14351392        // We want to do the following kind of search (when written in Fedora's
    14361393        // REST format - see http://localhost:8080/fedora/search):
    1437         // pid~greenstone:<colname>* title~<1st word of titleContents>
     1394        // pid~greenstone:<colname>-* title~<1st word of titleContents>
    14381395       
    14391396        // We don't need to normalise the word first (to search titles starting
     
    14521409        // only pids of those titles that contain the entire phrase titleContents
    14531410       
    1454         final String pid = GREENSTONE_+collName+WILDCARD;
     1411        final String pid = GREENSTONE_+collName+HYPHEN+WILDCARD;
    14551412       
    14561413        int indexOfFirstSpace = titleContents.indexOf(' '); // check for space
     
    15621519        throws RemoteException, FedoraVersionNotSupportedException
    15631520    {
    1564         // Searching for pids of the form "greenstone:gs2mgdemo*";
    1565         final String pid = GREENSTONE_+collName+WILDCARD;
     1521        // Searching for pids of the form "greenstone:gs2mgdemo-*";
     1522        final String pid = GREENSTONE_+collName+HYPHEN+WILDCARD;
    15661523       
    15671524        Condition[] conditions = new Condition[2];
     
    16141571        return collPID.substring(collPID.indexOf(':')+1, collPID.indexOf('-'));
    16151572    }
    1616        
    1617     /** Convert the given Element to a String representing the same XML.
    1618      * @return an element containing a copy element e with either only its child
    1619      * elements or with all its descendents (depending on whether parameter
    1620      * descendents is true or false).
    1621      * @param e - the element to start copying from.
    1622      * @param descendents - if true, e is copied with all its descendetns into the
    1623      * element that's returned. If false, only e and its direct children are copied 
    1624      * @see <a href="http://forum.java.sun.com/thread.jspa?threadID=678472&tstart=30">Sun java thread on transforming a DOM XML to a String</a>
    1625     */
    1626     protected Element getSubstructure(Element e, boolean descendents)
    1627     {
    1628         Document doc = builder.newDocument();
    1629         Node n = doc.importNode(e, descendents);
    1630                 // descendents=true: import/copy descendents.
    1631                 // Else, copy just current node e (later copy its direct children)
    1632         doc.appendChild(n); // need to put the copied node into a document
    1633             // else it won't have a parent doc (DOMSource can't work with it
    1634             // without it having a document parent).
    1635    
    1636         // if we are not recursively copying all descendents, then copy just
    1637         // the childnodes:
    1638         if(!descendents) { // then copy just the children
    1639             // get e's children and copy them into the new document
    1640             NodeList children = e.getChildNodes();
    1641             for(int i = 0; i < children.getLength(); i++) {
    1642                 // create copy
    1643                 n = doc.importNode(children.item(i), false);
    1644                 // attach it to parent
    1645                 doc.getDocumentElement().appendChild(n);
    1646                
    1647                 // Now we need to indicate whether this new node (child) is a leaf
    1648                 // or not. (This is necessary for getChildrenOfSection(), else
    1649                 // it's hard to know if the children are leaves or have further
    1650                 // subsections.
    1651                 if(n.getNodeName().equals(SECTION_ELEMENT)) {
    1652                     // we're dealing only with section children
    1653                    
    1654                     // Check if the matching original had children:
    1655                     Element originalsChild = (Element)children.item(i);
    1656                     NodeList grandchildren =
    1657                         originalsChild.getElementsByTagName(SECTION_ELEMENT);
    1658                     if(grandchildren.getLength() > 0) {
    1659                         // original's child has children, so indicate this
    1660                         // in the copied child:
    1661                         Element child = (Element)n;
    1662                         child.setAttribute(TYPE, INTERNAL_NODE);
    1663                     }
    1664                 }
     1573   
     1574   
     1575    /** Return the TOC substructure requested
     1576     * @return an element containing a copy if element e with either only its child
     1577     * elements or with all its descendants and/or its ancestors or only its parent
     1578     * and/or its siblings (depending on what the parameter structure specifies).
     1579     * @param e - the element to start copying from and whose structure is requested.
     1580     * @param structure - a string containing any combination of the values:
     1581     * ancestors, parent, siblings, children, descendants,
     1582     * specifying the portion of the structure to retrieve.
     1583     * @see <a href="http://forum.java.sun.com/thread.jspa?threadID=678472&tstart=30">Sun java thread on transforming a DOM XML to a String</a>
     1584     */
     1585    protected Element getSubstructure(Element original, String structure)
     1586    {
     1587    Document doc = builder.newDocument();
     1588   
     1589    boolean descendants = (structure.indexOf("descendants") != -1) ? true : false;
     1590    Node current = doc.importNode(original, descendants);
     1591
     1592    // descendants=true: import/copy descendants.
     1593    // Else, copy just current node original (later copy its direct children)   
     1594   
     1595    Node parentOfCurrent = null;
     1596    Node parentOfOriginal = original.getParentNode();
     1597    if(parentOfOriginal == original.getOwnerDocument()) { // don't want document node (original is docRoot)
     1598        parentOfOriginal = null;
     1599    }
     1600   
     1601    if(parentOfOriginal == null) { // no parentNode, so current is the root node.
     1602        // can't get ancestors/parent/siblings, since all these need parentNode
     1603        doc.appendChild(current);
     1604    } else { // siblings, ancestors and parent requests all require parent node to exist
     1605        // First check if we need to get ancestors, else for whether parent is required
     1606        if(structure.indexOf("ancestors") != -1) {
     1607        parentOfCurrent = doc.importNode(parentOfOriginal, false);
     1608       
     1609        Node child = null;
     1610        Node parent = parentOfCurrent;      // the copy
     1611        Node n = parentOfOriginal.getParentNode(); // the doc to copy from
     1612       
     1613        while(n != null && n != original.getOwnerDocument()) {
     1614            child = parent;
     1615            parent = doc.importNode(n, false); // no descendants
     1616            parent.appendChild(child);
     1617            n = n.getParentNode();
     1618        }
     1619       
     1620        doc.appendChild(parent); // need to put the copied node into a document
     1621        // else it won't have a parent doc (DOMSource can't work with it
     1622        // without it having a document parent).
     1623       
     1624        } else if(structure.indexOf("parent") != -1) {
     1625        parentOfCurrent = doc.importNode(parentOfOriginal, false);
     1626        //parentOfCurrent.appendChild(current);
     1627        doc.appendChild(parentOfCurrent);
     1628        }
     1629       
     1630        // a request for siblings is independently tested for
     1631        if(structure.indexOf("siblings") != -1) {
     1632        // only import parent if we didn't already import
     1633        // it for a request for ancestors or parent
     1634        if(parentOfCurrent == null) {
     1635            parentOfCurrent = doc.importNode(parentOfOriginal, false);
     1636            doc.appendChild(parentOfCurrent);     // this becomes the root
     1637        }
     1638        // now the siblings of current (children of parentOfCurrent)
     1639        NodeList children = parentOfOriginal.getChildNodes();           
     1640        for(int i = 0; i < children.getLength(); i++) {
     1641            Node n = children.item(i);
     1642
     1643            if(n.getNodeName().equals(SECTION_ELEMENT)) {
     1644            if((Element)n != original) { // skip original which was already imported
     1645                Node child = doc.importNode(n, false); // no descendants
     1646                parentOfCurrent.appendChild(child);
     1647            } else { // already imported Current element, insert at this position               
     1648                parentOfCurrent.appendChild(current);
     1649            }           
     1650           
     1651            }           
     1652        }
     1653        } else if(parentOfCurrent != null) { // include current node for ancestors and parent requests
     1654        // (sibling request adds the current node into a particular position)
     1655        parentOfCurrent.appendChild(current);
     1656             // need to put the copied node into a document
     1657             // else it won't have a parent doc (DOMSource can't work with it
     1658             // without it having a document parent).
     1659        } else { // when only children or descendants were requested, current becomes root document
     1660        doc.appendChild(current);
     1661        }
     1662    }
     1663
     1664    // if we are not recursively copying all descendants, then copy just
     1665    // the childnodes of current:
     1666    if(structure.indexOf("children") != -1 && !descendants) { // then copy just the children
     1667
     1668        // get e's children and copy them into the new document
     1669        NodeList children = original.getChildNodes();
     1670        for(int i = 0; i < children.getLength(); i++) {
     1671        // create copy
     1672        Node n = doc.importNode(children.item(i), false);
     1673        // attach it to parent
     1674        current.appendChild(n);
     1675       
     1676        // Now we need to indicate whether this new node (child) is a leaf
     1677        // or not. (This is necessary for getChildrenOfSection(), else
     1678        // it's hard to know if the children are leaves or have further
     1679        // subsections.
     1680        if(n.getNodeName().equals(SECTION_ELEMENT)) {
     1681            // we're dealing only with section children
     1682           
     1683            // Check if the matching original had children:
     1684            Element originalsChild = (Element)children.item(i);
     1685            NodeList grandchildren = originalsChild.getElementsByTagName(SECTION_ELEMENT);
     1686            if(grandchildren.getLength() > 0) {
     1687            // original's child has children, so indicate this
     1688            // in the copied child:
     1689            Element child = (Element)current;           
     1690            //  child.setAttribute(TYPE, INTERNAL_NODE);
     1691           
     1692            }
     1693        }
     1694        }
     1695    }
     1696
     1697    return doc.getDocumentElement();
     1698    }   
     1699
     1700
     1701    /** Return the TOC substructure with the requested structural info.
     1702     * @return an element containing a copy if element e with either only its child
     1703     * elements or with all its descendants and/or its ancestors or only its parent
     1704     * and/or its siblings (depending on what the parameter structure specifies).
     1705     * Returns null if the element, e, passed in is null.
     1706     * @param doc - the new document into whose root element the structural information
     1707     * will be inserted as attributes.
     1708     * @param e - the element to start copying from and whose structure is requested.
     1709     * @param info - a string containing any combination of the values: numChildren,
     1710     * numSiblings, siblingPosition. The requested info gets added as attributes to
     1711     * the returned root element.
     1712     * @see <a href="http://forum.java.sun.com/thread.jspa?threadID=678472&tstart=30">Sun java thread on transforming a DOM XML to a String</a>
     1713     */
     1714    protected Element getStructureInfo(Document doc, Element e, String info)
     1715    {
     1716    if(e == null) {
     1717        return null;
     1718    }
     1719   
     1720    Element root = doc.getDocumentElement();
     1721
     1722    if(!info.equals("")) {   
     1723        if(info.indexOf("numChildren") != -1) {
     1724        //int numChildren = e.getElementsByTagName(SECTION_ELEMENT).getLength();
     1725        int numChildren = 0;
     1726       
     1727        NodeList children = e.getChildNodes();
     1728        for(int i = 0; i < children.getLength(); i++) {
     1729            Node n = children.item(i);
     1730            if(n.getNodeName().equals(SECTION_ELEMENT)) {
     1731            numChildren++;
     1732            }
     1733        }
     1734       
     1735        root.setAttribute("numChildren", Integer.toString(numChildren));
     1736        }
     1737       
     1738        if(info.indexOf("ibling") != -1) { // siblingPosition or numSiblings
     1739        int numSiblings = 0;
     1740        int siblingPosition = 0;
     1741           
     1742        Node parent = e.getParentNode();
     1743        if(parent == null) {
     1744            numSiblings = 0;
     1745            siblingPosition = 1;
     1746        } else {
     1747            //numSiblings = parent.getChildNodes().getLength();
     1748            NodeList siblings = parent.getChildNodes();
     1749           
     1750            for(int i = 0; i < siblings.getLength(); i++) {
     1751            Node n = siblings.item(i);
     1752            if(n.getNodeName().equals(SECTION_ELEMENT)) {
     1753                if(e == (Element)n) {
     1754                siblingPosition = numSiblings+1;
     1755                } else { // count every sibling section element, except e itself
     1756                numSiblings++;
     1757                }               
    16651758            }
    1666         }
    1667         return doc.getDocumentElement();
    1668     }
    1669    
    1670    
     1759            }
     1760        }       
     1761       
     1762        if(info.indexOf("numSiblings") != -1) {
     1763            root.setAttribute("numSiblings", Integer.toString(numSiblings));
     1764        }
     1765       
     1766        if(info.indexOf("siblingPosition") != -1) {
     1767            root.setAttribute("siblingPosition", Integer.toString(siblingPosition));
     1768        }
     1769        }
     1770    }
     1771   
     1772    return root;
     1773    }
     1774
     1775
    16711776    /**
    16721777     * Return a datastream of a document, given the document's id
     
    17901895            String sectionID = "SECTION1"; //SECTION1.5
    17911896            System.out.println("\n");
    1792             System.out.println(sectionID+ " - entire subsection:\n"
    1793                     + fedoraCon.getSubsection(docPID, sectionID));
    1794            
    1795             System.out.println(sectionID + " and children:\n"
    1796                     + fedoraCon.getChildrenOfSection(docPID, sectionID));
    17971897                   
    17981898            System.out.println(
     
    18161916            System.out.println("Unable to instantiate FedoraConnection\n" + e);
    18171917            e.printStackTrace();
    1818             //LOG.error("Unable to instantiate FedoraConnection\n" + e);
     1918            //LOG.error("Unable to instantiate FedoraConnection\n" + e, e);
    18191919        }
    18201920    }
Note: See TracChangeset for help on using the changeset viewer.