Project

General

Profile

« Previous | Next » 

Revision 1449

Added by Jing Tao over 21 years ago

Add nodes access control for print extended query.

View differences:

src/edu/ucsb/nceas/metacat/QuerySpecification.java
758 758
   * pathquery document.  This allows for customization of the 
759 759
   * returned fields
760 760
   * @param doclist the list of document ids to search by
761
   * @param unaccessableNodePair  the node pair(start id and end id) which this
762
   *                               user could not access it
761 763
   */
762
  public String printExtendedSQL(String doclist)
764
  public String printExtendedSQL(String doclist, Hashtable unaccessableNodePair)
763 765
  {  
764 766
    StringBuffer self = new StringBuffer();
765 767
    self.append("select xml_nodes.docid, xml_index.path, xml_nodes.nodedata, ");
......
789 791
    self.append(doclist);
790 792
    self.append(")");
791 793
    self.append(" AND xml_nodes.nodetype = 'TEXT'");
794
    
795
    // add control part for extended query
796
    Enumeration en = unaccessableNodePair.keys();
797
    
798
    while (en.hasMoreElements())
799
    {
800
      // Get control pairs in object
801
      Long startNodeIdObject = (Long)en.nextElement();
802
      Long endNodeIdObject = (Long)unaccessableNodePair.get(startNodeIdObject);
803
      // change it to long
804
      long startNodeId = startNodeIdObject.longValue();
805
      long endNodeId   = endNodeIdObject.longValue();
806
      // add into query
807
      self.append(" AND( nodeid < ");
808
      self.append(startNodeId);
809
      self.append(" OR nodeid > ");
810
      self.append(endNodeId);
811
      self.append(")");
812
    }
792 813

  
793 814
   
794 815
    return self.toString();

Also available in: Unified diff