Project

General

Profile

« Previous | Next » 

Revision 6088

Changes in the DataONE ObjectFormat class deprecate the convert() method, and we're now using Metacat's ObjectFormatService to look up object format attributes. The following changes replace ObjectFormat.convert() with ObjectFormatService.getFormat() in several classes.

Also added a few methods to ObjectFormatService where doRefresh() calls populateObjectFormatList(), which in turn calls either getCachedList() or falls back to getListFromDisk() in the case of a CN, or will call cn.listFormats() from the D1 libclient if the Metacat installation is an MN.

Added the ObjectFormatService.objectFormatMap as a static hash used for lookups of object formats based on their canonical identifier. This is populated from the ObjectFormatService.objectFormatList.

Added deserializeObjectFormatList(InputStream) to return the ObjectFormatList from the XML serialization (from Metacat or disk).

View differences:

MetacatHandler.java
1
/**
1
/**ml
2 2
 *  '$RCSfile$'
3 3
 *  Copyright: 2010 Regents of the University of California and the
4 4
 *             National Center for Ecological Analysis and Synthesis
......
42 42
import edu.ucsb.nceas.metacat.event.MetacatEventService;
43 43
import edu.ucsb.nceas.metacat.properties.PropertyService;
44 44
import edu.ucsb.nceas.metacat.replication.ForceReplicationHandler;
45
import edu.ucsb.nceas.metacat.service.ObjectFormatService;
45 46
import edu.ucsb.nceas.metacat.service.SessionService;
46 47
import edu.ucsb.nceas.metacat.service.XMLSchemaService;
47 48
import edu.ucsb.nceas.metacat.shared.HandlerException;
......
3630 3631
      
3631 3632
      //set the default object format
3632 3633
      String doctype = (String) docInfo.get("doctype");
3633
      ObjectFormat format = ObjectFormat.convert(doctype);
3634
      ObjectFormat format = ObjectFormatService.getFormat(doctype);
3634 3635
      if (format == null) {
3635 3636
          if (doctype.trim().equals("BIN")) {
3636
              format = ObjectFormat.OCTET_STREAM;
3637
              format = ObjectFormatService.getFormat("application/octet-stream");
3637 3638
          } else {
3638
              format = ObjectFormat.convert("text/plain");
3639
              format = ObjectFormatService.getFormat("text/plain");
3639 3640
          }
3640 3641
      }
3641 3642
      sysMeta.setObjectFormat(format);
......
3644 3645
      
3645 3646
      // further parse EML documents to get data object format,
3646 3647
      // describes and describedBy information
3647
      if ( format == ObjectFormat.EML_2_0_0 ||
3648
           format == ObjectFormat.EML_2_0_1 ||
3649
           format == ObjectFormat.EML_2_1_0 ) {
3648
      if ( format == ObjectFormatService.getFormat("eml://ecoinformatics.org/eml/2.0.0") ||
3649
           format == ObjectFormatService.getFormat("eml://ecoinformatics.org/eml/2.0.1") ||
3650
           format == ObjectFormatService.getFormat("eml://ecoinformatics.org/eml/2.1.0")) {
3650 3651
        
3651 3652
        try {
3652 3653
          DataoneEMLParser emlParser = DataoneEMLParser.getInstance();
......
3663 3664
              emlDocument.distributionMetadata.elementAt(j);
3664 3665
            String dataDocUrl = distMetadata.url;
3665 3666
            String dataDocMimeType = "";
3667
            
3666 3668
            if (distMetadata.mimeType == null) {
3667
                dataDocMimeType = ObjectFormat.OCTET_STREAM.name();
3669
                
3670
              dataDocMimeType = 
3671
                  ObjectFormatService.getFormat("application/octet-stream").toString();
3672
            
3668 3673
            } else {
3669
                dataDocMimeType = distMetadata.mimeType;
3674
                
3675
              dataDocMimeType = distMetadata.mimeType;
3676
              
3670 3677
            }
3671 3678
            String dataDocLocalId = "";
3672 3679
            String dataSysMetaId = "";
......
3697 3704
                logMetacat.debug("Setting describedBy for " + dataDocId.getValue() +
3698 3705
                                 " to " + identifier.getValue());
3699 3706
                dataSysMeta.addDescribedBy(identifier);
3700
                ObjectFormat f = ObjectFormat.convert(dataDocMimeType);
3707
                ObjectFormat f = ObjectFormatService.getFormat(dataDocMimeType);
3701 3708
                if (f == null) {
3702
                    f = ObjectFormat.OCTET_STREAM;
3709
                    f = ObjectFormatService.getFormat("application/octet-stream");
3703 3710
                }
3704 3711
                dataSysMeta.setObjectFormat(f);
3705 3712
                dataSysMetaId = insertOrUpdateSystemMetadata(
......
3721 3728
                  
3722 3729
                  logMetacat.debug("Setting mimeType for " + 
3723 3730
                    dataDocId.getValue() + " to " + dataDocMimeType);
3724
                  ObjectFormat f = ObjectFormat.convert(dataDocMimeType);
3731
                  
3732
                  ObjectFormat f = ObjectFormatService.getFormat(dataDocMimeType);
3733
                  
3725 3734
                  if (f == null) {
3726
                      f = ObjectFormat.OCTET_STREAM;
3735
                      f = ObjectFormatService.getFormat("application/octet-stream");
3727 3736
                  }
3728 3737
                  dataSysMeta.setObjectFormat(f);
3729 3738
                  

Also available in: Unified diff