247 |
247 |
handler = new MetacatHandler(new Timer());
|
248 |
248 |
boolean allowed = false;
|
249 |
249 |
String localId; // the metacat docid for the pid
|
250 |
|
Subject subject = session.getSubject(); // the requesting user
|
251 |
|
List<Group> groupList; // the user's groups
|
252 |
250 |
|
253 |
|
// set the public user as a fallback
|
254 |
|
if ( subject == null ) {
|
255 |
|
subject.setValue("Public");
|
256 |
|
session.setSubject(subject);
|
257 |
|
|
258 |
|
}
|
259 |
|
|
260 |
|
// convert groups to a string array (for handler)
|
261 |
|
groupList = session.getSubjectList().getGroupList();
|
262 |
|
String[] groups = new String[groupList.size()];
|
263 |
|
|
264 |
251 |
// get the local docid from Metacat
|
265 |
252 |
try {
|
266 |
253 |
localId = IdentifierManager.getInstance().getLocalId(pid.getValue());
|
... | ... | |
277 |
264 |
// if the person is authorized, perform the read
|
278 |
265 |
if ( allowed ) {
|
279 |
266 |
|
280 |
|
for ( int i = 0; i > groupList.size(); i++ ) {
|
281 |
|
groups[i] = groupList.get(i).getGroupName();
|
282 |
|
|
283 |
|
}
|
284 |
|
|
285 |
267 |
// get the object bytes
|
286 |
268 |
// TODO: stream to file to stream conversion throughout Metacat needs to
|
287 |
269 |
// be resolved
|
... | ... | |
302 |
284 |
FileOutputStream dataSink;
|
303 |
285 |
try {
|
304 |
286 |
dataSink = new FileOutputStream(outputFile);
|
305 |
|
handler.readFromMetacat(localId, null,
|
306 |
|
dataSink, localId, "xml",
|
307 |
|
subject.getValue(),
|
308 |
|
groups, true, params);
|
|
287 |
handler.read(localId);
|
309 |
288 |
|
310 |
289 |
} catch (FileNotFoundException e) {
|
311 |
290 |
throw new ServiceFailure("1020", "The object specified by " +
|
... | ... | |
349 |
328 |
"could not be returned due to a parse error: " +
|
350 |
329 |
e.getMessage());
|
351 |
330 |
|
352 |
|
} catch (InsufficientKarmaException e) {
|
353 |
|
// TODO Auto-generated catch block
|
354 |
|
e.printStackTrace();
|
355 |
331 |
}
|
356 |
332 |
|
357 |
333 |
//set a timer to clean up the temp files
|
Change Metacathandler.read() to be public since it's internal to Metacat, and use read() in D1NodeService after isAuthorized() for the calling Subject from the Session object.