Project

General

Profile

« Previous | Next » 

Revision 1326

Added by Jing Tao about 22 years ago

Add a method writing info into log file. So the change information can be kept physically.

View differences:

src/edu/ucsb/nceas/metacat/CleanupAccessTable.java
30 30
import edu.ucsb.nceas.morpho.datapackage.Triple;
31 31
import edu.ucsb.nceas.morpho.datapackage.TripleCollection;
32 32

  
33
import java.io.FileOutputStream;
34
import java.io.PrintWriter;
33 35
import java .io.StringReader;
34 36
import java.sql.ResultSet;
35 37
import java.sql.PreparedStatement;
......
68 70
  private static final String TRIPLESTAG = "//triple";
69 71
  private static final String IDENTIFIER = "//identifier";
70 72
  private static final String RELATIONSHIP = "provides access control rules for";
71
  public static final String DELIMITER = "!";
73
  public  static final String DELIMITER = "!";
72 74
  private static final String DOT = ".";
75
  private static final String LOGFILENAME = "log";
73 76
  
74 77
  public static void addNewTripleIntoDataset(String accessionNumber, 
75 78
                                             Vector newTripleVector)
......
137 140
      DocumentImpl.write(dbConn, xml, pub, dtd, doAction,
138 141
                       accessionNumber, null, null, validate);
139 142
      System.out.println("update data set file: "+ accessionNumber);
143
      writeToLogFile("Update data set file: " + accessionNumber);
144
      writeToLogFile("New triples added are: "+ newTripleVector.toString());
140 145
    }
141 146
    catch (Exception e)
142 147
    {
......
521 526
      pStmt.close();
522 527
      System.out.println("delete rules: "+accessRule+" for "
523 528
                          +aclDocid+" in table");
529
      writeToLogFile("Delete rules: "+accessRule+" for "
530
                     +aclDocid+" in xml_access table");
524 531
    }
525 532
    catch (SQLException e)
526 533
    {
......
773 780
    }//for
774 781
  }
775 782
  
783
  /*
784
   * Method to write information into log file
785
   */
786
  private static void writeToLogFile(String message)
787
  {
788
    try
789
    {
790
      FileOutputStream fos = new FileOutputStream(LOGFILENAME, true);
791
      PrintWriter pw = new PrintWriter(fos);
792
      pw.println(message);
793
      pw.flush();
794
    }
795
    catch(Exception e)
796
    {
797
      System.out.println("error writing to log: " + e.getMessage());
798
     
799
    }
800
  }
801
  
776 802
  public static void main(String[] agus)
777 803
  {
778 804
    

Also available in: Unified diff