Project

General

Profile

« Previous | Next » 

Revision 10340

Added by Jing Tao almost 7 years ago

In the delete method, if we got not MdcDocNotFound exception, we will continue to delete the system metadata.

View differences:

src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
245 245
      try {
246 246
          localId = IdentifierManager.getInstance().getLocalId(pid.getValue());
247 247
      } catch (McdbDocNotFoundException e) {
248
          throw new NotFound("1340", "The object with the provided " + "identifier was not found.");
248
          //throw new NotFound("1340", "The object with the provided " + "identifier was not found.");
249
          logMetacat.warn("D1NodeService.delete - the object itself with the provided identifier "+pid.getValue()+" doesn't exist in the system. But we will continute to delete the system metadata of the object.");
250
          Lock lock = null;
251
          try {
252
              lock = HazelcastService.getInstance().getLock(pid.getValue());
253
              lock.lock();
254
              logMetacat.debug("Locked identifier " + pid.getValue());
255
              SystemMetadata sysMeta = HazelcastService.getInstance().getSystemMetadataMap().get(pid);
256
              if ( sysMeta != null ) {
257
                HazelcastService.getInstance().getSystemMetadataMap().remove(pid);
258
                HazelcastService.getInstance().getIdentifiers().remove(pid);
259
                sysMeta.setArchived(true);
260
                try {
261
                    MetacatSolrIndex.getInstance().submit(pid, sysMeta, null, false);
262
                } catch (Exception ee ) {
263
                    logMetacat.warn("D1NodeService.delete - the object with the provided identifier "+pid.getValue()+" was deleted. But the MN solr index can't be deleted.");
264
                }
265
                //since data objects were not registered in the identifier table, we use pid as the docid
266
                EventLog.getInstance().log(request.getRemoteAddr(), request.getHeader("User-Agent"), username, pid.getValue(), Event.DELETE.xmlValue());
267
                
268
              } else {
269
                  throw new ServiceFailure("1350", "Couldn't delete the object " + pid.getValue() +
270
                      ". Couldn't obtain the system metadata record.");
271
                  
272
              }
273
              
274
          } catch (RuntimeException re) {
275
              throw new ServiceFailure("1350", "Couldn't delete " + pid.getValue() + 
276
                  ". The error message was: " + re.getMessage());
277
              
278
          } finally {
279
              if(lock != null) {
280
                  lock.unlock();
281
                  logMetacat.debug("Unlocked identifier " + pid.getValue());
282
              }
283
          }
284
          return pid;
249 285
      } catch (SQLException e) {
250 286
          throw new ServiceFailure("1350", "The object with the provided " + "identifier "+pid.getValue()+" couldn't be identified since "+e.getMessage());
251 287
      }

Also available in: Unified diff