Project

General

Profile

« Previous | Next » 

Revision 7429

mark documents as archived=true when they are deleted using the Metacat API.
https://redmine.dataone.org/issues/3406

View differences:

src/edu/ucsb/nceas/metacat/DocumentImpl.java
64 64
import edu.ucsb.nceas.metacat.database.DBConnection;
65 65
import edu.ucsb.nceas.metacat.database.DBConnectionPool;
66 66
import edu.ucsb.nceas.metacat.database.DatabaseService;
67
import edu.ucsb.nceas.metacat.dataone.hazelcast.HazelcastService;
67 68
import edu.ucsb.nceas.metacat.properties.PropertyService;
68 69
import edu.ucsb.nceas.metacat.replication.ForceReplicationHandler;
69 70
import edu.ucsb.nceas.metacat.replication.ReplicationService;
......
82 83
import org.apache.commons.io.IOUtils;
83 84
import org.apache.commons.io.input.XmlStreamReader;
84 85
import org.apache.log4j.Logger;
86
import org.dataone.service.types.v1.Identifier;
87
import org.dataone.service.types.v1.SystemMetadata;
85 88
import org.xml.sax.ContentHandler;
86 89
import org.xml.sax.DTDHandler;
87 90
import org.xml.sax.EntityResolver;
......
3257 3260
            // CLIENT SHOULD ALWAYS PROVIDE ACCESSION NUMBER INCLUDING REV
3258 3261
            //AccessionNumber ac = new AccessionNumber(accnum, "DELETE");
3259 3262
            String docid = DocumentUtil.getDocIdFromAccessionNumber(accnum);
3260
            //String rev = ac.getRev();
3263
            int rev = DocumentUtil.getRevisionFromAccessionNumber(accnum);;
3261 3264

  
3262 3265
            // Check if the document exists.
3263 3266
            pstmt = conn.prepareStatement("SELECT * FROM xml_documents WHERE docid = ?");
......
3406 3409
            	deleteFromFileSystem(accnum, isXML);
3407 3410
            }
3408 3411
            
3412
            // set as archived in the systemMetadata 
3413
            String pid = IdentifierManager.getInstance().getGUID(docid, rev);
3414
            SystemMetadata sysMeta = HazelcastService.getInstance().getSystemMetadataMap().get(pid);
3415
            if (sysMeta != null) {
3416
            	sysMeta.setArchived(true);
3417
            	sysMeta.setDateSysMetadataModified(Calendar.getInstance().getTime());
3418
            	Identifier guid = new Identifier();
3419
            	guid.setValue(pid);
3420
				HazelcastService.getInstance().getSystemMetadataMap().put(guid, sysMeta);
3421
            }
3422
            
3409 3423
           double end = System.currentTimeMillis()/1000;
3410 3424
           logMetacat.info("DocumentImpl.delete - total delete time is:  " + (end - start));
3411 3425

  

Also available in: Unified diff