ORCentral
|
00001 package eu.coform.command.datasetingestion; 00002 00003 import eu.coform.Mimetype; 00004 import eu.coform.ORException; 00005 import eu.coform.Error; 00006 import eu.coform.command.proto.Abstract; 00007 import eu.coform.database.DBException; 00008 import eu.coform.database.command.InsertMimetypeCommand; 00009 00013 public class CreateMimetypeCommand implements AbstractSectionDatasetIngestion { 00014 00015 private Mimetype mime; 00016 00026 @Override 00027 public Integer execute() throws ORException { 00028 // TODO check permissions 00029 00030 if (mime.getName() == null || mime.getExtension() == null || 00031 mime.getUri() == null || mime.getDescription() == null) 00032 throw new ORException(Error.MimetypeInvalid); 00033 00034 InsertMimetypeCommand c = new InsertMimetypeCommand(mime); 00035 try { 00036 c.exec(); 00037 return c.getResult(); 00038 } catch (DBException e) { 00039 throw new ORException(Error.MimetypeCreationFailed); 00040 } 00041 } 00042 00043 public void setMime(Mimetype mime) { 00044 this.mime = mime; 00045 } 00046 00047 public Mimetype getMime() { 00048 return mime; 00049 } 00050 00051 }