Project

General

Profile

« Previous | Next » 

Revision 652

Added by bojilova over 23 years ago

unified getting "docid" value from metacat URLs specified in <resourceIdentifier> tags
by using MetaCatUtil.parseQuery() method in the same way as in MetaCatServlet.

View differences:

AccessControlList.java
18 18
import java.sql.*;
19 19
import java.util.Stack;
20 20
import java.util.Vector;
21
import java.util.Hashtable;
22
import java.net.URL;
23
import java.net.MalformedURLException;
21 24

  
22 25
import org.xml.sax.Attributes;
23 26
import org.xml.sax.InputSource;
......
210 213
    if (currentTag.equals("resourceIdentifier")) {
211 214

  
212 215
      resourceURL = inputString;
213
      resourceId = getDocID(inputString);
216
      resourceId = getDocid(inputString);
214 217
      // check permissions for @user on resourceId first
215 218
      // @user must have permission "all" on resourceId
216 219
      boolean hasPermission = false;
......
369 372
  {
370 373
    // delete all acl records for resources related to @aclid if any
371 374
    Statement stmt = conn.createStatement();
372
//    String docURL = "metacat://" + server + "/?docid=";
373
//    stmt.execute("DELETE FROM xml_access WHERE '" + docURL + "'||docid IN " +
374
//                 "(SELECT object FROM xml_relation" +
375
//                 " WHERE docid = '" + aclid + "'" +
376
//                 " AND relationship = 'isaclfor')" );
377 375
    stmt.execute("DELETE FROM xml_access WHERE accessfileid = '" + aclid + "'");
378 376
    stmt.close();
379 377
  }
......
622 620
    return -1;
623 621
  }
624 622
  
625
  // TEMPORARY - ProtocolHandler should be used instead
626
  // get the docid from @url
627
  private String getDocID ( String url ) throws SAXException
623
  // get docid from @url
624
  private String getDocid ( String url ) throws SAXException
628 625
  {
626
    MetaCatUtil util = new MetaCatUtil();
629 627
    try {
630
      return url.substring(url.lastIndexOf("docid=")+6);
631
    } catch (StringIndexOutOfBoundsException e) {
628
      URL urlobj = new URL(url);
629
      Hashtable urlParams = util.parseQuery(urlobj.getQuery());
630
      if ( urlParams.containsKey("docid") ) {
631
        return (String)urlParams.get("docid"); // return the docid value
632
      } else {
633
        throw new 
634
        SAXException("\"docid\" not specified within " + url);
635
      }
636
    } catch (MalformedURLException e) {
632 637
      throw new SAXException(e.getMessage());
633 638
    }
634 639
  }  
640

  
635 641
}

Also available in: Unified diff