Revision 7010
Added by Chris Jones almost 13 years ago
src/edu/ucsb/nceas/metacat/IdentifierManager.java | ||
---|---|---|
37 | 37 |
|
38 | 38 |
import org.apache.log4j.Logger; |
39 | 39 |
import org.dataone.client.ObjectFormatCache; |
40 |
import org.dataone.service.exceptions.BaseException; |
|
40 | 41 |
import org.dataone.service.exceptions.InvalidSystemMetadata; |
41 | 42 |
import org.dataone.service.exceptions.NotFound; |
43 |
import org.dataone.service.exceptions.NotImplemented; |
|
44 |
import org.dataone.service.exceptions.ServiceFailure; |
|
42 | 45 |
import org.dataone.service.types.v1.AccessPolicy; |
43 | 46 |
import org.dataone.service.types.v1.AccessRule; |
44 | 47 |
import org.dataone.service.types.v1.Checksum; |
... | ... | |
132 | 135 |
Subject submitterSubject = new Subject(); |
133 | 136 |
submitterSubject.setValue(submitter); |
134 | 137 |
sysMeta.setSubmitter(submitterSubject); |
138 |
ObjectFormatIdentifier fmtid = null; |
|
135 | 139 |
try { |
136 |
ObjectFormatIdentifier fmtid = |
|
137 |
ObjectFormatCache.getInstance().getFormat(fmtidStr).getFormatId(); |
|
140 |
ObjectFormatIdentifier formatId = new ObjectFormatIdentifier(); |
|
141 |
formatId.setValue(fmtidStr); |
|
142 |
fmtid = ObjectFormatCache.getInstance().getFormat(formatId).getFormatId(); |
|
138 | 143 |
sysMeta.setFormatId(fmtid); |
139 |
} catch (NotFound nfe) { |
|
140 |
logMetacat.error("The objectFormat " + fmtidStr + |
|
144 |
|
|
145 |
} catch (BaseException nfe) { |
|
146 |
logMetacat.error("The objectFormat " + fmtidStr + |
|
141 | 147 |
" is not registered. Setting the default format id."); |
142 |
ObjectFormatIdentifier fmtid = new ObjectFormatIdentifier(); |
|
143 |
fmtid.setValue("application/octet-stream"); |
|
144 |
sysMeta.setFormatId(fmtid); |
|
148 |
fmtid = new ObjectFormatIdentifier(); |
|
149 |
fmtid.setValue("application/octet-stream"); |
|
150 |
sysMeta.setFormatId(fmtid); |
|
151 |
|
|
145 | 152 |
} |
146 | 153 |
sysMeta.setSize(size); |
147 | 154 |
sysMeta.setSerialVersion(serialVersion); |
... | ... | |
308 | 315 |
Subject submitterSubject = new Subject(); |
309 | 316 |
submitterSubject.setValue(submitter); |
310 | 317 |
sysMeta.setSubmitter(submitterSubject); |
318 |
ObjectFormatIdentifier fmtid = null; |
|
311 | 319 |
try { |
312 |
ObjectFormatIdentifier fmtid = |
|
313 |
ObjectFormatCache.getInstance().getFormat(fmtidStr).getFormatId(); |
|
320 |
ObjectFormatIdentifier formatId = new ObjectFormatIdentifier(); |
|
321 |
formatId.setValue(fmtidStr); |
|
322 |
fmtid = ObjectFormatCache.getInstance().getFormat(formatId).getFormatId(); |
|
314 | 323 |
sysMeta.setFormatId(fmtid); |
315 |
} catch (NotFound nfe) { |
|
324 |
|
|
325 |
} catch (BaseException nfe) { |
|
316 | 326 |
logMetacat.error("The objectFormat " + fmtidStr + |
317 | 327 |
" is not registered. Setting the default format id."); |
318 |
ObjectFormatIdentifier fmtid = new ObjectFormatIdentifier();
|
|
328 |
fmtid = new ObjectFormatIdentifier(); |
|
319 | 329 |
fmtid.setValue("application/octet-stream"); |
320 | 330 |
sysMeta.setFormatId(fmtid); |
331 |
|
|
321 | 332 |
} |
322 | 333 |
sysMeta.setSize(size); |
323 | 334 |
if (obsoletes != null) { |
Also available in: Unified diff
ObjectFormatCache.getFormat(String formatStr) has been deprecated, and now only takes a formatId instance to get a format from the cache. It also throws Service Failure and NotImplemented, so here just set the format to application/octet-stream in any case.