Revision 9122
Added by Jing Tao almost 10 years ago
src/edu/ucsb/nceas/metacat/restservice/v2/MNResourceHandler.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
import java.io.File; |
26 | 26 |
import java.io.FileInputStream; |
27 |
import java.io.FileNotFoundException; |
|
27 | 28 |
import java.io.IOException; |
28 | 29 |
import java.io.InputStream; |
29 | 30 |
import java.io.OutputStream; |
... | ... | |
114 | 115 |
* update() - PUT /d1/mn/object/PID |
115 | 116 |
* delete() - DELETE /d1/mn/object/PID |
116 | 117 |
* archive() - PUT /d1/mn/archive/PID |
118 |
* updateSystemMetadata() - PUT /d1/mn/meta |
|
117 | 119 |
|
118 | 120 |
* systemMetadataChanged() - POST /dirtySystemMetadata/PID |
119 | 121 |
* |
... | ... | |
240 | 242 |
logMetacat.debug("Using resource 'meta'"); |
241 | 243 |
// get |
242 | 244 |
if (httpVerb == GET) { |
245 |
logMetacat.debug("Using resource 'meta' for GET"); |
|
243 | 246 |
// after the command |
244 | 247 |
extra = parseTrailing(resource, RESOURCE_META); |
245 | 248 |
getSystemMetadataObject(extra); |
246 | 249 |
status = true; |
250 |
} else if (httpVerb == PUT) { |
|
251 |
logMetacat.debug("Using resource 'meta' for PUT"); |
|
252 |
updateSystemMetadata(); |
|
253 |
status = true; |
|
247 | 254 |
} |
248 | 255 |
|
249 | 256 |
} else if (resource.startsWith(RESOURCE_OBJECTS)) { |
... | ... | |
1492 | 1499 |
SynchronizationFailed syncFailed = (SynchronizationFailed) ExceptionHandler.deserializeXml(sf, "Error deserializing exception"); |
1493 | 1500 |
return syncFailed; |
1494 | 1501 |
} |
1502 |
|
|
1503 |
/** |
|
1504 |
* Update the system metadata for a specified identifier |
|
1505 |
* @throws ServiceFailure |
|
1506 |
* @throws InvalidRequest |
|
1507 |
* @throws InstantiationException |
|
1508 |
* @throws IllegalAccessException |
|
1509 |
* @throws IOException |
|
1510 |
* @throws JiBXException |
|
1511 |
* @throws NotImplemented |
|
1512 |
* @throws NotAuthorized |
|
1513 |
* @throws InvalidSystemMetadata |
|
1514 |
* @throws InvalidToken |
|
1515 |
*/ |
|
1516 |
protected void updateSystemMetadata() throws ServiceFailure, InvalidRequest, |
|
1517 |
InstantiationException, IllegalAccessException, IOException, JiBXException, NotImplemented, |
|
1518 |
NotAuthorized, InvalidSystemMetadata, InvalidToken { |
|
1519 |
// Read the incoming data from its Mime Multipart encoding |
|
1520 |
Map<String, File> files = collectMultipartFiles(); |
|
1521 |
|
|
1522 |
// get the encoded pid string from the body and make the object |
|
1523 |
String pidString = multipartparams.get("pid").get(0); |
|
1524 |
Identifier pid = new Identifier(); |
|
1525 |
pid.setValue(pidString); |
|
1526 |
|
|
1527 |
logMetacat.debug("updateSystemMetadata: " + pid); |
|
1495 | 1528 |
|
1529 |
// get the system metadata from the request |
|
1530 |
File smFile = files.get("sysmeta"); |
|
1531 |
FileInputStream sysmeta = new FileInputStream(smFile); |
|
1532 |
SystemMetadata systemMetadata = TypeMarshaller.unmarshalTypeFromStream(SystemMetadata.class, sysmeta); |
|
1533 |
|
|
1534 |
logMetacat.debug("updating system metadata with pid " + pid.getValue()); |
|
1535 |
|
|
1536 |
MNodeService.getInstance(request).updateSystemMetadata(session, pid, systemMetadata); |
|
1537 |
} |
|
1538 |
|
|
1496 | 1539 |
} |
Also available in: Unified diff
Add the code to handle the PUT method for meta url. See https://projects.ecoinformatics.org/ecoinfo/issues/6666.