Project

General

Profile

« Previous | Next » 

Revision 9375

Added by Jing Tao about 9 years ago

In the systemMetadataChanged method, the object will be archived if the new archive value is true and old value is false.
The log event is recorded in the systemMetadataChanged method as well.

View differences:

src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
1510 1510
                        //this is for the v2 api.
1511 1511
                        if(isAuthoritativeNode(pid)) {
1512 1512
                            //this is the authoritative node, so we only accept replica and serial version
1513
                            logMetacat.debug("MNodeService.systemMetadataChanged - this is the authoritative node for the pid "+pid.getValue());
1513 1514
                            List<Replica> replicas = newSysMeta.getReplicaList();
1514 1515
                            newSysMeta = currentLocalSysMeta;
1515 1516
                            newSysMeta.setSerialVersion(new BigInteger((new Long(serialVersion)).toString()));
1516 1517
                            newSysMeta.setReplicaList(replicas);
1518
                        } else {
1519
                            //we need to archive the object in the replica node
1520
                            logMetacat.debug("MNodeService.systemMetadataChanged - this is NOT the authoritative node for the pid "+pid.getValue());
1521
                            logMetacat.debug("MNodeService.systemMetadataChanged - the new value of archive is "+newSysMeta.getArchived()+" for the pid "+pid.getValue());
1522
                            logMetacat.debug("MNodeService.systemMetadataChanged - the local value of archive is "+currentLocalSysMeta.getArchived()+" for the pid "+pid.getValue());
1523
                            if (newSysMeta.getArchived() != null && newSysMeta.getArchived() == true  && 
1524
                                    ((currentLocalSysMeta.getArchived() != null && currentLocalSysMeta.getArchived() == false ) || currentLocalSysMeta.getArchived() == null)){
1525
                                logMetacat.debug("MNodeService.systemMetadataChanged - start to archive object "+pid.getValue());
1526
                                boolean logArchive = false;
1527
                                boolean needUpdateModificationDate = false;
1528
                                try {
1529
                                    archiveObject(logArchive, session, pid, newSysMeta, needUpdateModificationDate);
1530
                                } catch (NotFound e) {
1531
                                    throw new InvalidRequest("1334", "Can't find the pid "+pid.getValue()+" for archive.");
1532
                                }
1533
                                
1534
                            }
1517 1535
                        }
1518 1536
                    }
1519 1537
                    HazelcastService.getInstance().getSystemMetadataMap().put(newSysMeta.getIdentifier(), newSysMeta);
......
1541 1559
                    throw sf;
1542 1560
                }
1543 1561
                
1562
                try {
1563
                    String localId = IdentifierManager.getInstance().getLocalId(pid.getValue());
1564
                    EventLog.getInstance().log(request.getRemoteAddr(), 
1565
                            request.getHeader("User-Agent"), session.getSubject().getValue(), 
1566
                            localId, "updateSystemMetadata");
1567
                } catch (Exception e) {
1568
                    // do nothing, no localId to log with
1569
                    logMetacat.warn("MNodeService.systemMetadataChanged - Could not log 'updateSystemMetadata' event because no localId was found for pid: " + pid.getValue());
1570
                } 
1571
                
1544 1572
               
1545 1573
            }
1546 1574
        } finally {

Also available in: Unified diff