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:

MetacatPopulator.java
48 48
import edu.ucsb.nceas.metacat.dataone.CrudService;
49 49
import edu.ucsb.nceas.metacat.properties.PropertyService;
50 50
import edu.ucsb.nceas.metacat.restservice.InputStreamDataSource;
51
import edu.ucsb.nceas.metacat.service.ObjectFormatService;
51 52

  
52 53
import org.dataone.service.exceptions.InvalidSystemMetadata;
53 54
import org.dataone.service.exceptions.ServiceFailure;
......
190 191
                    SystemMetadata dataDocSysMeta = generateSystemMetadata(doc);
191 192
                    //overwrite the bogus values from the last call 
192 193
                    dataDocSysMeta.setIdentifier(did);
193
                    dataDocSysMeta.setObjectFormat(ObjectFormat.convert(dataDocMimeType));
194
                    dataDocSysMeta.setObjectFormat(ObjectFormatService.getFormat(dataDocMimeType));
194 195
                    Checksum checksum = new Checksum();
195 196
                    dataDocIs = stringToStream(dataDocText);
196 197
                    ChecksumAlgorithm ca = ChecksumAlgorithm.convert("MD5");
......
282 283
        sm.setIdentifier(id);
283 284
        
284 285
        //set the object format
285
        ObjectFormat format = ObjectFormat.convert(doc.doctype);
286
        ObjectFormat format = ObjectFormatService.getFormat(doc.doctype);
286 287
        if(format == null)
287 288
        {
288 289
            if(doc.doctype.trim().equals("BIN"))
289 290
            {
290
                format = ObjectFormat.OCTET_STREAM;
291
                format = ObjectFormatService.getFormat("application/octet-stream");
291 292
            }
292 293
            else
293 294
            {
294
                format = ObjectFormat.TEXT_PLAIN;
295
                format = ObjectFormatService.getFormat("text/plain");
295 296
            }
296 297
        }
297 298
        sm.setObjectFormat(format);

Also available in: Unified diff