Project

General

Profile

« Previous | Next » 

Revision 9373

Added by Jing Tao about 9 years ago

In the updateSystemMetadata method, we avoid to log the event twice for archive=true.

View differences:

src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
636 636
   */
637 637
  private Identifier archiveCNObjectWithNotificationReplica(Session session, Identifier pid, SystemMetadata sysMeta, boolean needModifyDate) 
638 638
                  throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, NotImplemented {
639
          archiveCNObject(session, pid, sysMeta, needModifyDate);
639
          boolean logArchive = true;
640
          archiveCNObject(logArchive, session, pid, sysMeta, needModifyDate);
640 641
          // notify the replicas
641 642
          notifyReplicaNodes(sysMeta);
642 643
          return pid;
src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
1803 1803
      // do the actual update
1804 1804
      if(sysmeta.getArchived() != null && sysmeta.getArchived() == true && 
1805 1805
                 ((currentSysmeta.getArchived() != null && currentSysmeta.getArchived() == false ) || currentSysmeta.getArchived() == null)) {
1806
          boolean logArchive = false;//we log it as the update system metadata event. So don't log it again.
1806 1807
          if(fromCN) {
1807 1808
              logMetacat.debug("D1Node.update - this is to archive a cn object "+pid.getValue());
1808 1809
              try {
1809
                  archiveCNObject(session, pid, sysmeta, needUpdateModificationDate);
1810
                  archiveCNObject(logArchive, session, pid, sysmeta, needUpdateModificationDate);
1810 1811
              } catch (NotFound e) {
1811 1812
                  throw new InvalidRequest("4869", "Can't find the pid "+pid.getValue()+" for archive.");
1812 1813
              }
1813 1814
          } else {
1814 1815
              logMetacat.debug("D1Node.update - this is to archive a MN object "+pid.getValue());
1815 1816
              try {
1816
                  archiveObject(session, pid, sysmeta, needUpdateModificationDate);
1817
                  archiveObject(logArchive, session, pid, sysmeta, needUpdateModificationDate);
1817 1818
              } catch (NotFound e) {
1818 1819
                  throw new InvalidRequest("4869", "Can't find the pid "+pid.getValue()+" for archive.");
1819 1820
              }
......
2032 2033
   * @throws NotImplemented
2033 2034
   * @throws InvalidRequest
2034 2035
   */
2035
  protected Identifier archiveObject(Session session, Identifier pid, SystemMetadata sysMeta, boolean needModifyDate) 
2036
  protected Identifier archiveObject(boolean log, Session session, Identifier pid, SystemMetadata sysMeta, boolean needModifyDate) 
2036 2037
      throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, NotImplemented {
2037 2038

  
2038 2039
      String localId = null;
......
2065 2066
          try {
2066 2067
              // archive the document
2067 2068
              DocumentImpl.delete(localId, null, null, null, false);
2068
              try {
2069
                  EventLog.getInstance().log(request.getRemoteAddr(), request.getHeader("User-Agent"), username, localId, Event.DELETE.xmlValue());
2070
              } catch (Exception e) {
2071
                  logMetacat.warn("D1NodeService.archiveObject - can't log the delete event since "+e.getMessage());
2069
              if(log) {
2070
                   try {
2071
                      EventLog.getInstance().log(request.getRemoteAddr(), request.getHeader("User-Agent"), username, localId, Event.DELETE.xmlValue());
2072
                   } catch (Exception e) {
2073
                      logMetacat.warn("D1NodeService.archiveObject - can't log the delete event since "+e.getMessage());
2074
                   }
2072 2075
              }
2076
             
2073 2077
              
2074 2078
              // archive it
2075 2079
              sysMeta.setArchived(true);
......
2116 2120
   * @throws NotFound
2117 2121
   * @throws NotImplemented
2118 2122
   */
2119
  protected void archiveCNObject(Session session, Identifier pid, SystemMetadata sysMeta, boolean needModifyDate) 
2123
  protected void archiveCNObject(boolean log, Session session, Identifier pid, SystemMetadata sysMeta, boolean needModifyDate) 
2120 2124
          throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, NotImplemented {
2121 2125

  
2122 2126
          String localId = null; // The corresponding docid for this pid
......
2124 2128
          // Check for the existing identifier
2125 2129
          try {
2126 2130
              localId = IdentifierManager.getInstance().getLocalId(pid.getValue());
2127
              archiveObject(session, pid, sysMeta, needModifyDate);
2131
              archiveObject(log, session, pid, sysMeta, needModifyDate);
2128 2132
          
2129 2133
          } catch (McdbDocNotFoundException e) {
2130 2134
              // This object is not registered in the identifier table. Assume it is of formatType DATA,
src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
2356 2356
	             logMetacat.debug("MNodeService.archive - lock the identifier "+pid.getValue()+" in the system metadata map.");
2357 2357
	             SystemMetadata sysmeta = HazelcastService.getInstance().getSystemMetadataMap().get(pid);
2358 2358
	             boolean needModifyDate = true;
2359
	             super.archiveObject(session, pid, sysmeta, needModifyDate); 
2359
	             boolean logArchive = true;
2360
	             super.archiveObject(logArchive, session, pid, sysmeta, needModifyDate); 
2360 2361
	         } finally {
2361 2362
	             HazelcastService.getInstance().getSystemMetadataMap().unlock(pid);
2362 2363
	             logMetacat.debug("MNodeService.archive - unlock the identifier "+pid.getValue()+" in the system metadata map.");

Also available in: Unified diff