Revision 5362
Added by berkley almost 14 years ago
CrudService.java | ||
---|---|---|
282 | 282 |
} |
283 | 283 |
|
284 | 284 |
/** |
285 |
* set the permission on the document |
|
286 |
* @param token |
|
287 |
* @param principal |
|
288 |
* @param permission |
|
289 |
* @param permissionType |
|
290 |
* @param permissionOrder |
|
291 |
* @return |
|
292 |
*/ |
|
293 |
public void setAccess(AuthToken token, Identifier id, String principal, String permission, |
|
294 |
String permissionType, String permissionOrder) |
|
295 |
throws ServiceFailure |
|
296 |
{ |
|
297 |
try |
|
298 |
{ |
|
299 |
IdentifierManager im = IdentifierManager.getInstance(); |
|
300 |
String docid = im.getLocalId(id.getValue()); |
|
301 |
final SessionData sessionData = getSessionData(token); |
|
302 |
String permNum = "0"; |
|
303 |
if(permission == "read") |
|
304 |
{ |
|
305 |
permNum = "4"; |
|
306 |
} |
|
307 |
else if(permission == "write") |
|
308 |
{ |
|
309 |
permNum = "6"; |
|
310 |
} |
|
311 |
handler.setAccess(metacatUrl, sessionData.getUserName(), docid, |
|
312 |
principal, permNum, permissionType, permissionOrder); |
|
313 |
} |
|
314 |
catch(Exception e) |
|
315 |
{ |
|
316 |
throw new ServiceFailure("1000", "Could not set access on the document with id " + id.getValue()); |
|
317 |
} |
|
318 |
} |
|
319 |
|
|
320 |
/** |
|
285 | 321 |
* Retrieve the list of objects present on the MN that match the calling |
286 | 322 |
* parameters. This method is required to support the process of Member |
287 | 323 |
* Node synchronization. At a minimum, this method should be able to |
... | ... | |
312 | 348 |
throws NotAuthorized, InvalidRequest, NotImplemented, ServiceFailure, InvalidToken |
313 | 349 |
{ |
314 | 350 |
ObjectList ol = new ObjectList(); |
315 |
//do an squery on metacat to return systemMetadata docs where |
|
316 |
//sm.dateSysMetadataModified >= startTime |
|
317 |
//sm.dateSysMetadataModified <= endTime |
|
318 |
//further slice the returned dataset if replicaStatus is false. |
|
319 |
//if start != 0, return only the documents with index >= start |
|
320 |
//if the number of results is > count, return the first count docs |
|
351 |
final SessionData sessionData = getSessionData(token); |
|
352 |
try |
|
353 |
{ |
|
354 |
params.clear(); |
|
355 |
params.put("returndoctype", new String[] {"http://dataone.org/service/types/SystemMetadata/0.1"}); |
|
356 |
params.put("qformat", new String[] {"xml"}); |
|
357 |
//params.put("returnvalue", new String[] {"dateSysMetadataModified", "identifier", "objectFormat"}); |
|
358 |
//params.put("casesensitive", new String[] {"false"}); |
|
359 |
params.put("anyfield", new String[] {"%"}); |
|
360 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
|
361 |
PrintWriter out = new PrintWriter(baos); |
|
362 |
System.out.println("listing objects"); |
|
363 |
handler.query(metacatUrl, out, params, sessionData.getUserName(), |
|
364 |
sessionData.getGroupNames(), sessionData.getId()); |
|
365 |
baos.close(); |
|
366 |
System.out.println("result from query: " + baos.toString()); |
|
367 |
|
|
368 |
//do an squery on metacat to return systemMetadata docs where |
|
369 |
//sm.dateSysMetadataModified >= startTime |
|
370 |
//sm.dateSysMetadataModified <= endTime |
|
371 |
//further slice the returned dataset if replicaStatus is false. |
|
372 |
//if start != 0, return only the documents with index >= start |
|
373 |
//if the number of results is > count, return the first count docs |
|
374 |
} |
|
375 |
catch(Exception e) |
|
376 |
{ |
|
377 |
e.printStackTrace(); |
|
378 |
throw new ServiceFailure("1580", "Error retrieving ObjectList: " + e.getMessage()); |
|
379 |
} |
|
321 | 380 |
return ol; |
322 | 381 |
} |
323 | 382 |
|
Also available in: Unified diff
listObjects is almost working. need to get the result set parsed when returned to CrudService.