Revision 7855
Added by ben leinfelder almost 11 years ago
MNResourceHandler.java | ||
---|---|---|
139 | 139 |
protected static final String RESOURCE_ERROR = "error"; |
140 | 140 |
protected static final String RESOURCE_META_CHANGED = "dirtySystemMetadata"; |
141 | 141 |
protected static final String RESOURCE_GENERATE_ID = "generate"; |
142 |
protected static final String RESOURCE_PACKAGE = "package"; |
|
142 | 143 |
|
143 | 144 |
|
144 | 145 |
// shared executor |
... | ... | |
369 | 370 |
generateIdentifier(); |
370 | 371 |
status = true; |
371 | 372 |
} |
372 |
} |
|
373 |
} else if (resource.startsWith(RESOURCE_PACKAGE)) { |
|
374 |
logMetacat.debug("Using resource: " + RESOURCE_PACKAGE); |
|
375 |
// get |
|
376 |
if (httpVerb == GET) { |
|
377 |
// after the command |
|
378 |
extra = parseTrailing(resource, RESOURCE_META); |
|
379 |
getPackage(extra); |
|
380 |
status = true; |
|
381 |
} |
|
382 |
|
|
383 |
} |
|
373 | 384 |
|
374 | 385 |
if (!status) { |
375 | 386 |
throw new ServiceFailure("0000", "Unknown error, status = " + status); |
... | ... | |
1173 | 1184 |
|
1174 | 1185 |
|
1175 | 1186 |
/** |
1187 |
* Retrieve data package as Bagit zip |
|
1188 |
* @param pid |
|
1189 |
* @throws NotImplemented |
|
1190 |
* @throws NotFound |
|
1191 |
* @throws NotAuthorized |
|
1192 |
* @throws ServiceFailure |
|
1193 |
* @throws InvalidToken |
|
1194 |
* @throws IOException |
|
1195 |
*/ |
|
1196 |
protected void getPackage(String pid) throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, NotImplemented, IOException { |
|
1197 |
|
|
1198 |
Identifier id = new Identifier(); |
|
1199 |
id.setValue(pid); |
|
1200 |
InputStream is = MNodeService.getInstance(request).getPackage(session, id); |
|
1201 |
|
|
1202 |
response.setContentType("application/zip"); |
|
1203 |
response.setStatus(200); |
|
1204 |
OutputStream out = response.getOutputStream(); |
|
1205 |
|
|
1206 |
// write it to the output stream |
|
1207 |
IOUtils.copyLarge(is, out); |
|
1208 |
} |
|
1209 |
|
|
1210 |
/** |
|
1176 | 1211 |
* Retrieve System Metadata |
1177 | 1212 |
* @param pid |
1178 | 1213 |
* @throws InvalidToken |
Also available in: Unified diff
include GET /package/{pid} endpoint in MN service. https://projects.ecoinformatics.org/ecoinfo/issues/6027