Project

General

Profile

« Previous | Next » 

Revision 819

Added by bojilova over 22 years ago

- when the Access file goes first before the Package file (eml-dataset-2.0)
relations are not available in xml_relation, thus updated the code
to check and run ACL also after the Package file is saved.
- cut out the rev# from subject and object in xml_relation as needed by ACL
- put missing pstmt.close in RelationHandler.

View differences:

DBSAXHandler.java
214 214

  
215 215
  }
216 216
  
217
  // The run method of xmlIndex thread. It writes XML Index for the document.
217
  /* The run method of xmlIndex thread. It writes XML Index for the document. */
218 218
  public void run () {
219 219
    DBSAXNode currNode = null;
220 220
    DBSAXNode prevNode = null;
......
238 238
    
239 239
      dbconn.commit();
240 240
         
241
      //if this is a package file then write the package info to 
242
      //the xml_relation table. RelationHandler checks to see
243
      //if it is a package file so you don't have to do it here.
241
      //if this is a package file
244 242
      if ( doctype.equals(util.getOption("packagedoctype")) )
245 243
      {
246
        //DocumentImpl xmldoc = new DocumentImpl(dbconn, docid);
244
        // write the package info to xml_relation table
247 245
        RelationHandler rth = new RelationHandler(docid, dbconn);
248
      } 
249
      else if ( doctype.equals(util.getOption("accessdoctype")) ) 
250
      {
251
        DocumentImpl xmldoc = new DocumentImpl(dbconn, docid);
252
        String xml = xmldoc.toString();
253
        try {
254
          AccessControlList aclobj = 
255
          new AccessControlList(dbconn, docid, new StringReader(xml),
256
                                user, groups, serverCode);
257
          dbconn.commit();
258
        } catch (SAXException e) {
259
          try {
260
            dbconn.rollback();
261
            dbconn.close();
262
          } catch (SQLException sqle) {}
263
          System.out.println("Error writing ACL in DBSaxHandler.run " + 
264
                             e.getMessage()); 
246
        // from the relations get the access file id for that package
247
        String aclid = rth.getAccessFileID(docid);
248
        // if there are access file, write ACL for that package
249
        if ( aclid != null ) {
250
          runAccessControlList(dbconn, aclid);
265 251
        }
266 252
      }
253
      // if it is an access file
254
      else if ( doctype.equals(util.getOption("accessdoctype")) )
255
      {
256
        // write ACL for the package
257
        runAccessControlList(dbconn, docid);
258
      }
267 259
      
268
      
269 260
      dbconn.close();
270 261

  
271 262
    } catch (Exception e) {
......
273 264
        dbconn.rollback();
274 265
        dbconn.close();
275 266
      } catch (SQLException sqle) {}
276
      System.out.println("Error writing XML Index in DBSaxHandler.run " + 
277
                         e.getMessage()); 
267
      System.out.println("Error in DBSAXHandler.run " + e.getMessage());
268
      e.printStackTrace();
278 269
    }      
279 270
  }
271
  
272
  // It runs in xmlIndex thread. It writes ACL for a package.
273
  private void runAccessControlList (Connection conn, String aclid)
274
                                                throws Exception
275
  {
276
    // read the access file from xml_nodes
277
    // parse the access file and store the access info into xml_access
278
    AccessControlList aclobj = 
279
    new AccessControlList(conn, aclid, //new StringReader(xml),
280
                          user, groups, serverCode);
281
    conn.commit();
282
  }
280 283

  
284

  
281 285
  /** SAX Handler that is called for each XML text node */
282 286
  public void characters(char[] cbuf, int start, int len) throws SAXException {
283 287
     MetaCatUtil.debugMessage("CHARACTERS");

Also available in: Unified diff