Project

General

Profile

Revision 1423

Added by Jing Tao over 18 years ago

Add code to delete the previous permission when update.

View differences:

src/edu/ucsb/nceas/metacat/EmlSAXHandler.java
541 541
  /* The method to write all access rule intodb */
542 542
  private void writeAccessRuleToDB() throws SAXException
543 543
  {
544
    //Delete old permssion
545
    deletePermissionsInAccessTable(docid);
544 546
    //write top leve access rule
545 547
    writeTopLevelAccessRuleToDB();
546 548
    //write additional access rule
......
773 775
        }
774 776
      }//finally
775 777
     
778
  }//writeGivenAccessRuleIntoDB
779
  
780
  /* Delete from db all permission for resources related to @aclid if any.*/
781
  private void deletePermissionsInAccessTable(String aclid) 
782
          throws SAXException 
783
  {
784
    Statement stmt = null;
785
    try
786
    {
787
      // delete all acl records for resources related to @aclid if any
788
      stmt = connection.createStatement();
789
      // Increase DBConnection usage count
790
      connection.increaseUsageCount(1);
791
      stmt.execute("DELETE FROM xml_access WHERE accessfileid = '" + aclid +
792
                   "'"); 
793
    
794
    }
795
    catch (SQLException e)
796
    {
797
      throw new SAXException(e.getMessage());
798
    }
799
    finally
800
    {
801
      try
802
      {
803
        stmt.close();
804
      }
805
      catch (SQLException ee)
806
      {
807
        throw new SAXException(ee.getMessage());
808
      }
809
    }
776 810
  }
777 811
 
778 812
}

Also available in: Unified diff