Project

General

Profile

« Previous | Next » 

Revision 6036

Added by Matt Jones over 13 years ago

MOdified MetacatHandler to catch cases where ObjectFormat is not being set properly on data files when
generating SystemMetadata. When the EML document contains a format for an entity that maps to a null
type in ObjectFormat.convert(), then the type ends up being null and an error is generated on insertion
of the system metadata. This was causing two tests under AuthControlTest to fail, which should now pass.
The long-term fix is much better handling of ObjectFormat assignments, which is a work in progress under
https://redmine.dataone.org/issues/1378 .

View differences:

src/edu/ucsb/nceas/metacat/MetacatHandler.java
3586 3586
            DistributionMetadata distMetadata = 
3587 3587
              emlDocument.distributionMetadata.elementAt(j);
3588 3588
            String dataDocUrl = distMetadata.url;
3589
            String dataDocMimeType = distMetadata.mimeType;
3589
            String dataDocMimeType = "";
3590
            if (distMetadata.mimeType == null) {
3591
                dataDocMimeType = ObjectFormat.OCTET_STREAM.name();
3592
            } else {
3593
                dataDocMimeType = distMetadata.mimeType;
3594
            }
3590 3595
            String dataDocLocalId = "";
3591 3596
            String dataSysMetaId = "";
3592 3597
            logMetacat.debug("Data local ID: " + dataDocLocalId);
......
3616 3621
                logMetacat.debug("Setting describedBy for " + dataDocId.getValue() +
3617 3622
                                 " to " + identifier.getValue());
3618 3623
                dataSysMeta.addDescribedBy(identifier);
3619
                dataSysMeta.setObjectFormat(ObjectFormat.convert(dataDocMimeType));
3624
                ObjectFormat f = ObjectFormat.convert(dataDocMimeType);
3625
                if (f == null) {
3626
                    f = ObjectFormat.OCTET_STREAM;
3627
                }
3628
                dataSysMeta.setObjectFormat(f);
3620 3629
                dataSysMetaId = insertOrUpdateSystemMetadata(
3621 3630
                  dataSysMeta, "update", username, groups);
3622 3631
                
......
3636 3645
                  
3637 3646
                  logMetacat.debug("Setting mimeType for " + 
3638 3647
                    dataDocId.getValue() + " to " + dataDocMimeType);
3639
                  dataSysMeta.setObjectFormat(ObjectFormat.convert(dataDocMimeType));
3648
                  ObjectFormat f = ObjectFormat.convert(dataDocMimeType);
3649
                  if (f == null) {
3650
                      f = ObjectFormat.OCTET_STREAM;
3651
                  }
3652
                  dataSysMeta.setObjectFormat(f);
3640 3653
                  
3641 3654
                  logMetacat.debug("Updating system metadata for " + 
3642 3655
                    dataDocId.getValue() + " to " + dataDocMimeType);
......
3827 3840
      
3828 3841
      // get the xml from the sytem metadata object
3829 3842
      try {
3830
        xml = new String(serializeSystemMetadata(sysMeta).toByteArray());
3843
          xml = new String(serializeSystemMetadata(sysMeta).toByteArray());
3831 3844
        
3832 3845
      } catch ( JiBXException jxe ) {
3833 3846
        throw jxe;

Also available in: Unified diff