Project

General

Profile

« Previous | Next » 

Revision 1432

Added by Jing Tao almost 22 years ago

Add the code to handle subtree control for reading(but finished yet).

View differences:

src/edu/ucsb/nceas/metacat/DocumentImpl.java
40 40
import java.text.SimpleDateFormat;
41 41

  
42 42
import java.util.Date;
43
import java.util.Hashtable;
43 44
import java.util.Iterator;
44 45
import java.util.Stack;
45 46
import java.util.TreeSet;
47
import java.util.Vector;
46 48
import java.util.Enumeration;
47 49

  
48 50
import org.xml.sax.AttributeList;
......
752 754
   /**
753 755
   * Print a string representation of the XML document
754 756
   */
755
  public String toString()
757
  public String toString(String user, String[] groups)
756 758
  {
757 759
    StringWriter docwriter = new StringWriter();
758 760
    try {
759
      this.toXml(docwriter);
761
      this.toXml(docwriter, user, groups);
760 762
    } catch (McdbException mcdbe) {
761 763
      return null;
762 764
    }
......
807 809
   *
808 810
   * @param pw the Writer to which we print the document
809 811
   */
810
  public void toXml(Writer pw) throws McdbException
812
  public void toXml(Writer pw, String user, String[] groups) 
813
                                                          throws McdbException
811 814
  {
812 815
    PrintWriter out = null;
813 816
    if (pw instanceof PrintWriter) {
......
818 821

  
819 822
    MetaCatUtil util = new MetaCatUtil();
820 823
    
824
    // Here add code to handle subtree access control
825
    PermissionController control = new PermissionController(docid);
826
    Hashtable unaccessableSubTree =control.hasUnaccessableSubTree(user, groups, 
827
                                             AccessControlInterface.READSTRING);
828
    
829
    if (!unaccessableSubTree.isEmpty())
830
    {
831
       Enumeration en = unaccessableSubTree.elements();
832
       while (en.hasMoreElements())
833
       {
834
         SubTree tree = (SubTree)en.nextElement();
835
         //System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
836
         //System.out.println("subtree id pull out: "+tree.getSubTreeId());
837
         //System.out.println("start node id: "+tree.getStartNodeId());
838
         //System.out.println("end node id: "+tree.getEndNodeId());
839
       }
840
    }
841
    
821 842
    // First, check that we have the needed node data, and get it if not
822
    if (nodeRecordList == null) {
843
    if (nodeRecordList == null) 
844
    {
823 845
      nodeRecordList = getNodeRecordList(rootnodeid);
824 846
    }
825 847

  
......
2542 2564
          if (useOldReadAlgorithm) {
2543 2565
            System.out.println(xmldoc.readUsingSlowAlgorithm());
2544 2566
          } else {
2545
            xmldoc.toXml(new PrintWriter(System.out));
2567
            xmldoc.toXml(new PrintWriter(System.out), null, null);
2546 2568
          }
2547 2569
      } else if (action.equals("DELETE")) {
2548 2570
        DocumentImpl.delete(docid, null, null);

Also available in: Unified diff