Project

General

Profile

« Previous | Next » 

Revision 5975

Modified MetacatHandler.createSystemMetadata() to take a localId, not a guid as an argument since there are times when the guid has yet to have been created, and it is created in this method if so.
Also, put the read() call to get the InputStream of the data/metadata document into it's own try/catch statement.

View differences:

src/edu/ucsb/nceas/metacat/MetacatHandler.java
3305 3305
     *
3306 3306
     * @return sysMeta  The system metadata object created
3307 3307
     */
3308
    public SystemMetadata createSystemMetadata(Identifier identifier,
3308
    public SystemMetadata createSystemMetadata(String localId,
3309 3309
      String username, String[] groups) 
3310 3310
      throws McdbException, McdbDocNotFoundException, SQLException, 
3311 3311
      IOException, AccessionNumberException, ClassNotFoundException,
......
3317 3317
      // create system metadata for the document
3318 3318
      IdentifierManager im = IdentifierManager.getInstance();
3319 3319
      Hashtable<String, Object> docInfo;
3320
      docInfo = im.getDocumentInfo(localId);
3320 3321
      SystemMetadata sysMeta = new SystemMetadata();
3321
      String localId = "";
3322 3322
      InputStream inputStream;
3323
      //set the id
3324
      sysMeta.setIdentifier(identifier);
3323
      int rev = im.getLatestRevForLocalId(localId);
3324
      Identifier identifier = new Identifier();
3325 3325
      
3326
      // get the data or metadata object
3327 3326
      try {
3328
        localId = im.getLocalId(identifier.getValue());
3329
        docInfo = im.getDocumentInfo(localId);
3330
        inputStream = this.read(localId, username, groups);
3327
        // get the identifier if it exists
3328
        identifier.setValue(im.getGUID(localId, rev));
3331 3329
        
3332 3330
      } catch ( McdbDocNotFoundException dnfe ) {
3331
        // otherwise create the mapping
3333 3332
        logMetacat.debug("There was a problem getting the localId from " +
3334 3333
          "the given guid. The error message was: " + dnfe.getMessage());
3335
        throw dnfe;
3334
        logMetacat.debug("No guid in the identifier table.  adding it for " + localId);
3335
        im.createMapping(localId, localId);
3336
        logMetacat.debug("Mapping created for " + localId);
3337
        AccessionNumber accNum = new AccessionNumber(localId, "NONE");
3338
        identifier.setValue(im.getGUID(accNum.getDocid(), rev));
3339
        
3340
      }
3341
      
3342
      // get the data or metadata object
3343
      try {
3344
          inputStream = this.read(localId, username, groups);
3336 3345
          
3337 3346
      } catch ( InsufficientKarmaException ike ) {
3338 3347
        logMetacat.debug("There was an access problem reading " +
......
3371 3380
        
3372 3381
      } // end try()
3373 3382
    
3383
      //set the id
3384
      sysMeta.setIdentifier(identifier);
3385
      
3374 3386
      //set the default object format
3375 3387
      String doctype = (String) docInfo.get("doctype");
3376 3388
      ObjectFormat format = ObjectFormat.convert(doctype);
......
3445 3457
                  logMetacat.debug("Creating a system metadata " + 
3446 3458
                    "document for " + dataDocId.getValue());
3447 3459
                  dataSysMeta = 
3448
                    this.createSystemMetadata(dataDocId, username, groups);
3460
                    this.createSystemMetadata(dataDocLocalId, username, groups);
3449 3461
                  
3450 3462
                  logMetacat.debug("Setting describedBy for " + 
3451 3463
                    dataDocId.getValue() + " to " + identifier.getValue());

Also available in: Unified diff