Project

General

Profile

« Previous | Next » 

Revision 6091

In order to sync up with DataONE 0.6.1 changes, I'm backing out ObjectFormatService changes temporarily in Metacat. Most functionality will be rolled back in using the DataONE 0.6.2 tag, but some methods in ObjectFormatService (such as getListFromDisk()) will be moved into d1_libclient_java.

View differences:

src/edu/ucsb/nceas/metacat/restservice/ResourceHandler.java
77 77
import edu.ucsb.nceas.metacat.dataone.CrudService;
78 78
import edu.ucsb.nceas.metacat.dataone.HealthService;
79 79
import edu.ucsb.nceas.metacat.properties.PropertyService;
80
import edu.ucsb.nceas.metacat.service.ObjectFormatService;
81 80
import edu.ucsb.nceas.metacat.service.SessionService;
82 81
import edu.ucsb.nceas.metacat.util.RequestUtil;
83 82
import edu.ucsb.nceas.metacat.util.SystemUtil;
......
533 532
                            if(params.containsKey("format"))
534 533
                            {
535 534
                                String format = params.get("format")[0];
536
                                of = ObjectFormatService.getFormat(format);
535
                                of = ObjectFormat.convert(format);
537 536
                            }
538 537
                            if(params.containsKey("time"))
539 538
                            {
......
570 569
                            if(params.containsKey("format"))
571 570
                            {
572 571
                                String format = params.get("format")[0];
573
                                of = ObjectFormatService.getFormat(format);
572
                                of = ObjectFormat.convert(format);
574 573
                            }
575 574
                            if(params.containsKey("eventtime"))
576 575
                            {
......
1167 1166
        cs.setParamsFromRequest(request);
1168 1167
        AuthToken token = new AuthToken(sessionId);
1169 1168
        OutputStream out = null;
1170
        String textCSV     = ObjectFormatService.getFormat("text/csv").toString();
1171
        String textPlain   = ObjectFormatService.getFormat("text/plain").toString();
1172
        String octetStream = ObjectFormatService.getFormat("application/octet-stream").toString();
1173
        
1174 1169
        try {
1175 1170
            out = response.getOutputStream();
1176 1171
            response.setStatus(200);
......
1188 1183
                    SystemMetadata sm = cs.getSystemMetadata(token, id);
1189 1184
                    
1190 1185
                    //set the content type
1191
                    if(sm.getObjectFormat().toString().trim().equals(textCSV))
1186
                    if(sm.getObjectFormat().toString().trim().equals(ObjectFormat.TEXT_CSV.toString()))
1192 1187
                    {
1193 1188
                        response.setContentType("text/csv");
1194 1189
                        response.setHeader("Content-Disposition", "inline; filename=" + id.getValue() + ".csv");
1195 1190
                    }
1196
                    else if(sm.getObjectFormat().toString().trim().equals(textPlain))
1191
                    else if(sm.getObjectFormat().toString().trim().equals(ObjectFormat.TEXT_PLAIN.toString()))
1197 1192
                    {
1198 1193
                        response.setContentType("text/plain");
1199 1194
                        response.setHeader("Content-Disposition", "inline; filename=" + id.getValue() + ".txt");
1200 1195
                    } 
1201
                    else if(sm.getObjectFormat().toString().trim().equals(octetStream))
1196
                    else if(sm.getObjectFormat().toString().trim().equals(ObjectFormat.OCTET_STREAM.toString()))
1202 1197
                    {
1203 1198
                        response.setContentType("application/octet-stream");
1204 1199
                    }
......
1295 1290
                    }
1296 1291
                    else if(name.equals("objectFormat") && value != null) 
1297 1292
                    {
1298
                        objectFormat = ObjectFormatService.getFormat(value[0]);
1293
                        objectFormat = ObjectFormat.convert(value[0]);
1299 1294
                    }
1300 1295
                    else if(name.equals("replicaStatus") && value != null)
1301 1296
                    {
src/edu/ucsb/nceas/metacat/MetaCatServlet.java
345 345
			ServiceService.registerService("XMLSchemaService", XMLSchemaService.getInstance());
346 346
			
347 347
			// register the object format service
348
      ServiceService.registerService("ObjectFormatService", ObjectFormatService.getInstance());
348
      //ServiceService.registerService("ObjectFormatService", ObjectFormatService.getInstance());
349 349

  
350 350
			// check if eml201 document were corrected or not. if not, correct eml201 documents.
351 351
			// Before Metacat 1.8.1, metacat uses tag RELEASE_EML_2_0_1_UPDATE_6 as eml
src/edu/ucsb/nceas/metacat/MetacatHandler.java
1
/**ml
1
/**
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;
46 45
import edu.ucsb.nceas.metacat.service.SessionService;
47 46
import edu.ucsb.nceas.metacat.service.XMLSchemaService;
48 47
import edu.ucsb.nceas.metacat.shared.HandlerException;
......
3631 3630
      
3632 3631
      //set the default object format
3633 3632
      String doctype = (String) docInfo.get("doctype");
3634
      ObjectFormat format = ObjectFormatService.getFormat(doctype);
3633
      ObjectFormat format = ObjectFormat.convert(doctype);
3635 3634
      if (format == null) {
3636 3635
          if (doctype.trim().equals("BIN")) {
3637
              format = ObjectFormatService.getFormat("application/octet-stream");
3636
              format = ObjectFormat.OCTET_STREAM;
3638 3637
          } else {
3639
              format = ObjectFormatService.getFormat("text/plain");
3638
              format = ObjectFormat.convert("text/plain");
3640 3639
          }
3641 3640
      }
3642 3641
      sysMeta.setObjectFormat(format);
......
3645 3644
      
3646 3645
      // further parse EML documents to get data object format,
3647 3646
      // describes and describedBy information
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")) {
3647
      if ( format == ObjectFormat.EML_2_0_0 ||
3648
           format == ObjectFormat.EML_2_0_1 ||
3649
           format == ObjectFormat.EML_2_1_0 ) {
3651 3650
        
3652 3651
        try {
3653 3652
          DataoneEMLParser emlParser = DataoneEMLParser.getInstance();
......
3664 3663
              emlDocument.distributionMetadata.elementAt(j);
3665 3664
            String dataDocUrl = distMetadata.url;
3666 3665
            String dataDocMimeType = "";
3667
            
3668 3666
            if (distMetadata.mimeType == null) {
3669
                
3670
              dataDocMimeType = 
3671
                  ObjectFormatService.getFormat("application/octet-stream").toString();
3672
            
3667
                dataDocMimeType = ObjectFormat.OCTET_STREAM.name();
3673 3668
            } else {
3674
                
3675
              dataDocMimeType = distMetadata.mimeType;
3676
              
3669
                dataDocMimeType = distMetadata.mimeType;
3677 3670
            }
3678 3671
            String dataDocLocalId = "";
3679 3672
            String dataSysMetaId = "";
......
3704 3697
                logMetacat.debug("Setting describedBy for " + dataDocId.getValue() +
3705 3698
                                 " to " + identifier.getValue());
3706 3699
                dataSysMeta.addDescribedBy(identifier);
3707
                ObjectFormat f = ObjectFormatService.getFormat(dataDocMimeType);
3700
                ObjectFormat f = ObjectFormat.convert(dataDocMimeType);
3708 3701
                if (f == null) {
3709
                    f = ObjectFormatService.getFormat("application/octet-stream");
3702
                    f = ObjectFormat.OCTET_STREAM;
3710 3703
                }
3711 3704
                dataSysMeta.setObjectFormat(f);
3712 3705
                dataSysMetaId = insertOrUpdateSystemMetadata(
......
3728 3721
                  
3729 3722
                  logMetacat.debug("Setting mimeType for " + 
3730 3723
                    dataDocId.getValue() + " to " + dataDocMimeType);
3731
                  
3732
                  ObjectFormat f = ObjectFormatService.getFormat(dataDocMimeType);
3733
                  
3724
                  ObjectFormat f = ObjectFormat.convert(dataDocMimeType);
3734 3725
                  if (f == null) {
3735
                      f = ObjectFormatService.getFormat("application/octet-stream");
3726
                      f = ObjectFormat.OCTET_STREAM;
3736 3727
                  }
3737 3728
                  dataSysMeta.setObjectFormat(f);
3738 3729
                  
src/edu/ucsb/nceas/metacat/service/ObjectFormatService.java
55 55
import org.dataone.service.exceptions.ServiceFailure;
56 56
import org.dataone.service.types.Identifier;
57 57
import org.dataone.service.types.ObjectFormat;
58
import org.dataone.service.types.ObjectFormatList;
58
//import org.dataone.service.types.ObjectFormatList;
59 59
import org.dataone.service.types.util.ServiceTypeUtil;
60 60
import org.jibx.runtime.JiBXException;
61 61

  
......
87 87
  private String accNumber = null;
88 88

  
89 89
  /* The list of object formats */
90
  private static ObjectFormatList objectFormatList = null;
90
  //private static ObjectFormatList objectFormatList = null;
91 91
  
92 92
  /* the searchable map of object formats */
93 93
  private static HashMap<String, ObjectFormat> objectFormatMap = 
......
229 229
       */
230 230
      
231 231
      // this will be replaced with external lookup code above
232
      this.getCachedList();
232
      //this.getCachedList();
233 233
      
234 234
    } else if ( this.nodeType.equals("cn") ) {
235 235
      
236 236
      // get the list from the local metacat database
237
      this.getCachedList();  
237
      //this.getCachedList();  
238 238

  
239 239
    } else {
240 240
      
......
245 245
    }
246 246
    
247 247
    // index the object format list based on the format identifier
248
    int listSize = ObjectFormatService.objectFormatList.sizeObjectFormats();
249
    
250
    for (int i = 0; i < listSize; i++ ) {
251
      
252
      ObjectFormat objectFormat = 
253
        ObjectFormatService.objectFormatList.getObjectFormat(i);
254
      String identifier = objectFormat.getFmtid();
255
      ObjectFormatService.objectFormatMap.put(identifier, objectFormat);
256
      
257
    }
248
    //int listSize = ObjectFormatService.objectFormatList.sizeObjectFormats();
249
    //
250
    //for (int i = 0; i < listSize; i++ ) {
251
    //  
252
    //  ObjectFormat objectFormat = 
253
    //    ObjectFormatService.objectFormatList.getObjectFormat(i);
254
    //  String identifier = objectFormat.getFmtid();
255
    //  ObjectFormatService.objectFormatMap.put(identifier, objectFormat);
256
    //  
257
    //}
258 258
        
259 259

  
260 260
    
......
287 287
   * 
288 288
   * @return objectFormatList - the list of object formats
289 289
   */
290
  public ObjectFormatList listFormats() {
291
    
292
    return ObjectFormatService.objectFormatList;
293
    
294
  }
290
  //public ObjectFormatList listFormats() {
291
  //  
292
  //  return ObjectFormatService.objectFormatList;
293
  //  
294
  //}
295 295
  
296 296
  /**
297 297
   * Get the object format based on the given identifier as a string.
......
299 299
   * @param format - the object format as a string
300 300
   * @return objectFormat - the ObjectFormat represented by the format string
301 301
   */
302
  public static ObjectFormat getFormat(String format) {
303
    
304
    ObjectFormat objectFormat = null;
305
    objectFormat = ObjectFormatService.objectFormatMap.get(format);
306
    
307
    return objectFormat;
308
    
309
  }
302
  //public static ObjectFormat getFormat(String format) {
303
  //  
304
  //  ObjectFormat objectFormat = null;
305
  //  objectFormat = ObjectFormatService.objectFormatMap.get(format);
306
  //  
307
  //  return objectFormat;
308
  //  
309
  //}
310 310
  /**
311 311
   * Get the object format list cached in Metacat, or on failure, via a
312 312
   * cached file on disk
313 313
   * 
314 314
   * @return objectFormatList - the cached object format list
315 315
   */
316
  private void getCachedList()
317
    throws ServiceException {
318
          
319
    try {
320
      
321
      // reset the accession number separator in case it is 
322
      // different than the default
323
      try {
324
        
325
        this.separator = PropertyService.getProperty("document.accNumSeparator");
326
        
327
      } catch ( PropertyNotFoundException pnfe ) {
328
        
329
        // use the default separator, but log the issue
330
        logMetacat.debug("There was a problem finding the document " +
331
          "separator property. The error message was: " + pnfe.getMessage());
332
      }
333
      
334
      // get the latest accession number if it is in Metacat
335
      this.rev = 
336
        DBUtil.getLatestRevisionInDocumentTable(this.OBJECT_FORMAT_DOCID);
337
      
338
      if ( this.rev != -1 ) {
339
        this.accNumber = this.OBJECT_FORMAT_DOCID + 
340
                         this.separator + 
341
                         this.rev;
342
        DocumentImpl objectFormatsDocument = new DocumentImpl(accNumber, false);
343
        ByteArrayInputStream bais = 
344
          new ByteArrayInputStream(objectFormatsDocument.toString().getBytes());
345
        ObjectFormatService.objectFormatList = 
346
          this.deserializeObjectFormatList(bais);
316
  //private void getCachedList()
317
  //  throws ServiceException {
318
  //        
319
  //  try {
320
  //    
321
  //    // reset the accession number separator in case it is 
322
  //    // different than the default
323
  //    try {
324
  //      
325
  //      this.separator = PropertyService.getProperty("document.accNumSeparator");
326
  //      
327
  //    } catch ( PropertyNotFoundException pnfe ) {
328
  //      
329
  //      // use the default separator, but log the issue
330
  //      logMetacat.debug("There was a problem finding the document " +
331
  //        "separator property. The error message was: " + pnfe.getMessage());
332
  //    }
333
  //    
334
  //    // get the latest accession number if it is in Metacat
335
  //    this.rev = 
336
  //      DBUtil.getLatestRevisionInDocumentTable(this.OBJECT_FORMAT_DOCID);
337
  //    
338
  //    if ( this.rev != -1 ) {
339
  //      this.accNumber = this.OBJECT_FORMAT_DOCID + 
340
  //                       this.separator + 
341
  //                       this.rev;
342
  //      DocumentImpl objectFormatsDocument = new DocumentImpl(accNumber, false);
343
  //      ByteArrayInputStream bais = 
344
  //        new ByteArrayInputStream(objectFormatsDocument.toString().getBytes());
345
  //      ObjectFormatService.objectFormatList = 
346
  //        this.deserializeObjectFormatList(bais);
347
  //
348
  //    } else {
349
  //      
350
  //      logMetacat.info("The latest revision number of "   + 
351
  //        this.OBJECT_FORMAT_DOCID                         +
352
  //        " could not be found. Reverting to the on-disk " +
353
  //        "object format list");
354
  //      try {
355
  //        
356
  //        ObjectFormatService.objectFormatList = this.getListFromDisk();
357
  //      
358
  //      } catch (ServiceException se) {
359
  //        
360
  //        throw new ServiceException(se.getMessage());
361
  //      
362
  //      }
363
  //
364
  //    }
365
  //    
366
  //  } catch ( SQLException sqle ) {
367
  //    
368
  //    // we either have a metacat error or the docid was not inserted yet
369
  //    logMetacat.info("The latest revision number of "   + 
370
  //      this.OBJECT_FORMAT_DOCID                         +
371
  //      " could not be found. Reverting to the on-disk " +
372
  //      "object format list");
373
  //    
374
  //    try {
375
  //      
376
  //      ObjectFormatService.objectFormatList = this.getListFromDisk();
377
  //    
378
  //    } catch (ServiceException se) {
379
  //      
380
  //      throw se; 
381
  //      
382
  //    }
383
  //    
384
  //  } catch (McdbException mcdbe) {
385
  //    
386
  //    // we have a metacat doc not found error
387
  //    logMetacat.info( this.OBJECT_FORMAT_DOCID          +
388
  //      " could not be found. Reverting to the on-disk " +
389
  //      "object format list");
390
  //    
391
  //    try {
392
  //      
393
  //      ObjectFormatService.objectFormatList = this.getListFromDisk();
394
  //    
395
  //    } catch (ServiceException se) {
396
  //      
397
  //      throw se; 
398
  //      
399
  //    }
400
  //    
401
  //
402
  //  }
403
  //
404
  //  return;
405
  //  
406
  //}
347 407

  
348
      } else {
349
        
350
        logMetacat.info("The latest revision number of "   + 
351
          this.OBJECT_FORMAT_DOCID                         +
352
          " could not be found. Reverting to the on-disk " +
353
          "object format list");
354
        try {
355
          
356
          ObjectFormatService.objectFormatList = this.getListFromDisk();
357
        
358
        } catch (ServiceException se) {
359
          
360
          throw new ServiceException(se.getMessage());
361
        
362
        }
363
  
364
      }
365
      
366
    } catch ( SQLException sqle ) {
367
      
368
      // we either have a metacat error or the docid was not inserted yet
369
      logMetacat.info("The latest revision number of "   + 
370
        this.OBJECT_FORMAT_DOCID                         +
371
        " could not be found. Reverting to the on-disk " +
372
        "object format list");
373
      
374
      try {
375
        
376
        ObjectFormatService.objectFormatList = this.getListFromDisk();
377
      
378
      } catch (ServiceException se) {
379
        
380
        throw se; 
381
        
382
      }
383
      
384
    } catch (McdbException mcdbe) {
385
      
386
      // we have a metacat doc not found error
387
      logMetacat.info( this.OBJECT_FORMAT_DOCID          +
388
        " could not be found. Reverting to the on-disk " +
389
        "object format list");
390
      
391
      try {
392
        
393
        ObjectFormatService.objectFormatList = this.getListFromDisk();
394
      
395
      } catch (ServiceException se) {
396
        
397
        throw se; 
398
        
399
      }
400
      
401

  
402
    }
403

  
404
    return;
405
    
406
  }
407

  
408 408
  /**
409 409
   * Get the object format list cached on disk as stated in the metacat
410 410
   * properties file.
......
412 412
   * @return objectFormatList - the on-disk object format list
413 413
   * @throws ServiceException
414 414
   */
415
  private ObjectFormatList getListFromDisk() 
416
    throws ServiceException {
417
    
418
    // the filesystem location of the object format list xml file
419
    String objectFormatFilePath = null;
420
    
421
    // get the object format list from disk and parse it
422
    try {
423
      objectFormatFilePath = SystemUtil.getContextDir() + "/WEB-INF/" +
424
        PropertyService.getProperty("dataone.objectFormatListName");
425
            
426
      FileInputStream fileInputStream = new FileInputStream(objectFormatFilePath);         
415
  //private ObjectFormatList getListFromDisk() 
416
  //  throws ServiceException {
417
  //  
418
  //  // the filesystem location of the object format list xml file
419
  //  String objectFormatFilePath = null;
420
  //  
421
  //  // get the object format list from disk and parse it
422
  //  try {
423
  //    objectFormatFilePath = SystemUtil.getContextDir() + "/WEB-INF/" +
424
  //      PropertyService.getProperty("dataone.objectFormatListName");
425
  //          
426
  //    FileInputStream fileInputStream = new FileInputStream(objectFormatFilePath);         
427
  //
428
  //    ObjectFormatService.objectFormatList = 
429
  //      this.deserializeObjectFormatList(fileInputStream);
430
  //
431
  //  } catch (PropertyNotFoundException pnfe) {
432
  //    
433
  //    logMetacat.error("The object format list file could not be parsed. " +
434
  //      "The error message was: " + pnfe.getMessage());
435
  //    throw new ServiceException(pnfe.getMessage());
436
  //    
437
  //  } catch ( FileNotFoundException fnfe ) {
438
  //    
439
  //    logMetacat.debug("There was an error reading the file " +
440
  //      objectFormatFilePath + ". The error was: "            +
441
  //      fnfe.getMessage());
442
  //    throw new ServiceException(fnfe.getMessage());
443
  //        
444
  //  }
445
  //  
446
  //  return ObjectFormatService.objectFormatList;
447
  //}
427 448

  
428
      ObjectFormatService.objectFormatList = 
429
        this.deserializeObjectFormatList(fileInputStream);
430

  
431
    } catch (PropertyNotFoundException pnfe) {
432
      
433
      logMetacat.error("The object format list file could not be parsed. " +
434
        "The error message was: " + pnfe.getMessage());
435
      throw new ServiceException(pnfe.getMessage());
436
      
437
    } catch ( FileNotFoundException fnfe ) {
438
      
439
      logMetacat.debug("There was an error reading the file " +
440
        objectFormatFilePath + ". The error was: "            +
441
        fnfe.getMessage());
442
      throw new ServiceException(fnfe.getMessage());
443
          
444
    }
445
    
446
    return ObjectFormatService.objectFormatList;
447
  }
448

  
449 449
  /**
450 450
   * Deserialize the object format list file to an object format list object
451 451
   * 
......
453 453
   * @return objectFormatList - the ObjectFormatList object from the XML stream
454 454
   * @throws ServiceException
455 455
   */
456
  private ObjectFormatList deserializeObjectFormatList(InputStream inputStream) 
457
    throws ServiceException {
458
    
459
    ObjectFormatList objectFormatList;
460
    try {
461
      objectFormatList = (ObjectFormatList)
462
      ServiceTypeUtil.deserializeServiceType(ObjectFormatList.class, inputStream);
463
    
464
    } catch ( JiBXException jbxe ) {
465
      
466
      logMetacat.debug("There was an error deserializing the input stream. " +
467
        "The error was: " + jbxe.getMessage());
468
      jbxe.printStackTrace();
469
      throw new ServiceException(jbxe.getMessage());
470
    }
471
    
472
    return objectFormatList;
473
  }
456
  //private ObjectFormatList deserializeObjectFormatList(InputStream inputStream) 
457
  //  throws ServiceException {
458
  //  
459
  //  ObjectFormatList objectFormatList;
460
  //  try {
461
  //    objectFormatList = (ObjectFormatList)
462
  //    ServiceTypeUtil.deserializeServiceType(ObjectFormatList.class, inputStream);
463
  //  
464
  //  } catch ( JiBXException jbxe ) {
465
  //    
466
  //    logMetacat.debug("There was an error deserializing the input stream. " +
467
  //      "The error was: " + jbxe.getMessage());
468
  //    jbxe.printStackTrace();
469
  //    throw new ServiceException(jbxe.getMessage());
470
  //  }
471
  //  
472
  //  return objectFormatList;
473
  //}
474 474
  
475 475
}
src/edu/ucsb/nceas/metacat/util/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;
52 51

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

  
......
2070 2069

  
2071 2070
    	//set the default object format
2072 2071
    	String doctype = (String) docInfo.get("doctype");
2073
    	ObjectFormat format = ObjectFormatService.getFormat(doctype);
2072
    	ObjectFormat format = ObjectFormat.convert(doctype);
2074 2073
    	if (format == null) {
2075 2074
    		if (doctype.trim().equals("BIN")) {
2076
    			format = ObjectFormatService.getFormat("application/octet-stream");
2075
    			format = ObjectFormat.OCTET_STREAM;
2077 2076
    		} else {
2078
    			format = ObjectFormatService.getFormat("text/plain");
2077
    			format = ObjectFormat.convert("text/plain");
2079 2078
    		}
2080 2079
    	}
2081 2080
    	sm.setObjectFormat(format);
......
2083 2082

  
2084 2083
    	// further parse EML documents to get data object format,
2085 2084
    	// describes and describedBy information
2086
    	if ( format == ObjectFormatService.getFormat("eml://ecoinformatics.org/eml/2.0.0") ||
2087
    			format == ObjectFormatService.getFormat("eml://ecoinformatics.org/eml/2.0.1") ||
2088
    			format == ObjectFormatService.getFormat("eml://ecoinformatics.org/eml/2.1.0") ) {
2085
    	if ( format == ObjectFormat.EML_2_0_0 ||
2086
    			format == ObjectFormat.EML_2_0_1 ||
2087
    			format == ObjectFormat.EML_2_1_0 ) {
2089 2088

  
2090 2089
    		try {
2091 2090
    			DataoneEMLParser emlParser = DataoneEMLParser.getInstance();
......
2128 2127
    						logCrud.debug("Setting describedBy for " + dataDocId.getValue() +
2129 2128
    								" to " + identifier.getValue());
2130 2129
    						dataSysMeta.addDescribedBy(identifier);
2131
    						dataSysMeta.setObjectFormat(ObjectFormatService.getFormat(dataDocMimeType));
2130
    						dataSysMeta.setObjectFormat(ObjectFormat.convert(dataDocMimeType));
2132 2131
    						this.updateSystemMetadata(dataSysMeta, getSessionData(token));
2133 2132

  
2134 2133
    					} catch ( NotFound nf ) {
......
2141 2140
    						dataSysMeta.addDescribedBy(identifier);
2142 2141

  
2143 2142
    						logCrud.debug("Setting mimeType for " + dataDocId.getValue() + " to " + dataDocMimeType);
2144
    						dataSysMeta.setObjectFormat(ObjectFormatService.getFormat(dataDocMimeType));
2143
    						dataSysMeta.setObjectFormat(ObjectFormat.convert(dataDocMimeType));
2145 2144

  
2146 2145
    						logCrud.debug("Updating system metadata for " + dataDocId.getValue() + " to " + dataDocMimeType);
2147 2146
    						this.updateSystemMetadata(dataSysMeta, getSessionData(token));
src/edu/ucsb/nceas/metacat/IdentifierManager.java
43 43
import edu.ucsb.nceas.metacat.database.DBConnection;
44 44
import edu.ucsb.nceas.metacat.database.DBConnectionPool;
45 45
import edu.ucsb.nceas.metacat.properties.PropertyService;
46
import edu.ucsb.nceas.metacat.service.ObjectFormatService;
47 46
import edu.ucsb.nceas.metacat.shared.ServiceException;
48 47
import edu.ucsb.nceas.metacat.util.DocumentUtil;
49 48
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
......
1002 1001
                //cs.setAlgorithm(ChecksumAlgorithm.convert(checksumAlgorithm));
1003 1002
                oi.setChecksum(cs);
1004 1003
                
1005
                ObjectFormat oFormat = ObjectFormatService.getFormat(format);
1004
                ObjectFormat oFormat = ObjectFormat.convert(format);
1006 1005
                if(oFormat != null)
1007 1006
                {
1008 1007
                    oi.setObjectFormat(oFormat);
1009 1008
                }
1010 1009
                else
1011 1010
                { //if there is no object format, just default to text/plain
1012
                    oi.setObjectFormat(ObjectFormatService.getFormat("application/octet-stream"));
1011
                    oi.setObjectFormat(ObjectFormat.OCTET_STREAM);
1013 1012
                }
1014 1013
                                
1015 1014
                oi.setSize(size);

Also available in: Unified diff