pnever      2003/12/27 06:57:19

  Modified:    src/stores/slidestore/file UriProperties.java
  Log:
  Save *binding* vectors instead of *children* vectors to
  bind-enable the TX store
  
  Revision  Changes    Path
  1.8       +46 -9     jakarta-slide/src/stores/slidestore/file/UriProperties.java
  
  Index: UriProperties.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/stores/slidestore/file/UriProperties.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- UriProperties.java        12 Dec 2003 02:58:43 -0000      1.7
  +++ UriProperties.java        27 Dec 2003 14:57:19 -0000      1.8
  @@ -71,9 +71,9 @@
   import java.util.Date;
   import java.util.Enumeration;
   import java.util.Hashtable;
  +import java.util.Iterator;
   import java.util.List;
   import java.util.Vector;
  -
   import org.apache.slide.common.ServiceAccessException;
   import org.apache.slide.common.UnknownObjectClassException;
   import org.apache.slide.common.Uri;
  @@ -85,6 +85,7 @@
   import org.apache.slide.security.NodePermission;
   import org.apache.slide.structure.LinkNode;
   import org.apache.slide.structure.ObjectNode;
  +import org.jdom.Attribute;
   import org.jdom.Document;
   import org.jdom.Element;
   import org.jdom.input.SAXBuilder;
  @@ -189,7 +190,8 @@
           Element aElementObjectNode=new Element("objectnode");
           aElementObjectNode.setAttribute("classname",object.getClass().getName());
           aElementObjectNode.setAttribute("uri",object.getUri());
  -        
aElementObjectNode.addContent(createElements("childs","child",object.enumerateChildren()));
  +        aElementObjectNode.addContent(createBindings("children", "child", 
object.enumerateBindings()));
  +        aElementObjectNode.addContent(createBindings("parents", "parent", 
object.enumerateParentBindings()));
           
aElementObjectNode.addContent(createElements("links","link",object.enumerateLinks()));
           if (object instanceof LinkNode) {
               
aElementObjectNode.setAttribute("linkTo",((LinkNode)object).getLinkedUri());
  @@ -197,6 +199,20 @@
           return aElementObjectNode;
       }
       // --------------------------------------
  +    private Element createBindings(String aParent, String aChild, Enumeration 
aEnum) {
  +        Element aElement=new Element(aParent);
  +        Element childNode;
  +        ObjectNode.Binding binding;
  +        while (aEnum.hasMoreElements()) {
  +            binding = (ObjectNode.Binding) aEnum.nextElement();
  +            childNode = new Element(aChild);
  +            childNode.setAttribute(new Attribute("name", binding.getName()));
  +            childNode.setAttribute(new Attribute("uuri", binding.getUuri()));
  +            aElement.addContent(childNode);
  +        }
  +        return aElement;
  +    }
  +    // --------------------------------------
       public Element encodePermissions() {
           Element aPermissions=new Element("permissions");
           if (permissions==null) return aPermissions;
  @@ -378,7 +394,8 @@
               Element aElementObjectNode=aElement.getChild("objectnode");
               String aClasseName=aElementObjectNode.getAttributeValue("classname");
               String aUri=aElementObjectNode.getAttributeValue("uri");
  -            Vector aChilds=createVector(aElementObjectNode,"childs","child");
  +            Vector 
aChilds=createBindingVector(aElementObjectNode,"children","child",false);
  +            Vector 
aParents=createBindingVector(aElementObjectNode,"parents","parent",true);
               Vector aLinks=createVector(aElementObjectNode,"links","link");
               // System.out.println("--------- decodeObject  aChilds="+aChilds);
               // System.out.println("--------- decodeObject  aLinks="+aLinks);
  @@ -391,10 +408,11 @@
                   aArgs= new Object[]{aUri, aChilds, aLinks,aLinkTo};
               }
               else {
  -                aTypes=new Class[] {String.class,Vector.class,Vector.class};
  -                aArgs=new Object[] {aUri, aChilds, aLinks};
  +                aTypes=new Class[] 
{String.class,Vector.class,Vector.class,Vector.class};
  +                aArgs=new Object[] {aUri, aChilds, aParents, aLinks};
               }
               object=(ObjectNode) createObject(aClasseName,aTypes,aArgs);
  +            object.setUri(object.getUuri());
           }
           catch (Exception e) {
               e.printStackTrace();
  @@ -564,6 +582,25 @@
           for (int i=0;i<aList.size();i++) {
               Element aChild=(Element)aList.get(i);
               aRet.addElement(aChild.getAttributeValue("val"));
  +        }
  +        return aRet;
  +    }
  +    // --------------------------------------
  +    public Vector createBindingVector(Element aElement,String aParentName,String 
aChildName,boolean parentBindings) {
  +        Element aParent=aElement.getChild(aParentName);
  +        Vector aRet=new Vector();
  +        // System.out.println("--------- createVector  aParentName="+aParentName+" 
aChildName="+aChildName);
  +        Iterator it = aParent.getChildren().iterator();
  +        while (it.hasNext()) {
  +            Element aChild = (Element)it.next();
  +            String name = aChild.getAttributeValue("name");
  +            String uuri = aChild.getAttributeValue ("uuri");
  +            if (parentBindings) {
  +                aRet.add(new ObjectNode.ParentBinding(name, uuri));
  +            }
  +            else {
  +                aRet.add(new ObjectNode.Binding(name, uuri));
  +            }
           }
           return aRet;
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to