Revision 5364
Added by berkley over 14 years ago
src/edu/ucsb/nceas/metacat/dataone/CrudService.java | ||
---|---|---|
36 | 36 |
import java.util.Hashtable; |
37 | 37 |
import java.util.Timer; |
38 | 38 |
import java.util.List; |
39 |
import java.text.DateFormat; |
|
39 | 40 |
|
40 | 41 |
import javax.servlet.ServletContext; |
41 | 42 |
import javax.servlet.http.HttpServletRequest; |
... | ... | |
54 | 55 |
import org.dataone.service.exceptions.ServiceFailure; |
55 | 56 |
import org.dataone.service.exceptions.UnsupportedType; |
56 | 57 |
import org.dataone.service.mn.MemberNodeCrud; |
57 |
import org.dataone.service.types.AuthToken; |
|
58 |
import org.dataone.service.types.Checksum; |
|
59 |
import org.dataone.service.types.DescribeResponse; |
|
60 |
import org.dataone.service.types.Identifier; |
|
61 |
import org.dataone.service.types.LogRecordSet; |
|
62 |
import org.dataone.service.types.SystemMetadata; |
|
63 |
import org.dataone.service.types.ObjectList; |
|
64 |
import org.dataone.service.types.ObjectFormat; |
|
58 |
import org.dataone.service.types.*; |
|
65 | 59 |
import org.jibx.runtime.BindingDirectory; |
66 | 60 |
import org.jibx.runtime.IBindingFactory; |
67 | 61 |
import org.jibx.runtime.IMarshallingContext; |
... | ... | |
330 | 324 |
* indicating the starting index of the response (where 0 is the index |
331 | 325 |
* of the first item) and the count of elements to be returned. |
332 | 326 |
* |
327 |
* If startTime or endTime is null, the query is not restricted by that parameter. |
|
328 |
* |
|
333 | 329 |
* @see http://mule1.dataone.org/ArchitectureDocs/mn_api_replication.html#MN_replication.listObjects |
334 | 330 |
* @param token |
335 | 331 |
* @param startTime |
... | ... | |
356 | 352 |
params.clear(); |
357 | 353 |
params.put("returndoctype", new String[] {"http://dataone.org/service/types/SystemMetadata/0.1"}); |
358 | 354 |
params.put("qformat", new String[] {"xml"}); |
359 |
params.put("returnfield", new String[] {"dateUploaded", "originMemberNode",
|
|
360 |
"identifier", "objectFormat", "dateSysMetadataModified"}); |
|
355 |
params.put("returnfield", new String[] {"size", "originMemberNode",
|
|
356 |
"identifier", "objectFormat", "dateSysMetadataModified", "checksum"});
|
|
361 | 357 |
params.put("anyfield", new String[] {"%"}); |
362 | 358 |
|
363 | 359 |
System.out.println("listing objects"); |
364 | 360 |
MetacatResultSet rs = handler.query(metacatUrl, params, sessionData.getUserName(), |
365 | 361 |
sessionData.getGroupNames(), sessionData.getId()); |
366 | 362 |
List docs = rs.getDocuments(); |
367 |
System.out.println("docs size: " + docs.size()); |
|
363 |
|
|
368 | 364 |
for(int i=0; i<docs.size(); i++) |
369 | 365 |
{ |
366 |
//get the document from the results |
|
370 | 367 |
Document d = (Document)docs.get(i); |
368 |
ObjectFormat returnedObjectFormat = ObjectFormat.convert(d.getField("objectFormat")); |
|
369 |
if(!objectFormat.toString().trim().equals(returnedObjectFormat.toString().trim())) |
|
370 |
{ //make sure the objectFormat is the one specified |
|
371 |
continue; |
|
372 |
} |
|
373 |
Date dateSysMetadataModified = DateFormat.getDateTimeInstance().parse(d.getField("dateSysMetadataModified")); |
|
374 |
int startDateComparison = 0; |
|
375 |
int endDateComparison = 0; |
|
376 |
if(startTime != null) |
|
377 |
{ |
|
378 |
startDateComparison = dateSysMetadataModified.compareTo(startTime); |
|
379 |
} |
|
380 |
|
|
381 |
if(endTime != null) |
|
382 |
{ |
|
383 |
endDateComparison = dateSysMetadataModified.compareTo(endTime); |
|
384 |
} |
|
385 |
|
|
386 |
if(startDateComparison < 0 || endDateComparison > 0) |
|
387 |
{ //this date falls outside of the startTime and endTime params, so |
|
388 |
//skip it |
|
389 |
continue; |
|
390 |
} |
|
391 |
|
|
392 |
ObjectInfo info = new ObjectInfo(); |
|
393 |
//add the fields to the info object |
|
394 |
Checksum cs = new Checksum(); |
|
395 |
cs.setValue(d.getField("checksum")); |
|
396 |
info.setChecksum(cs); |
|
397 |
info.setDateSysMetadataModified(dateSysMetadataModified); |
|
398 |
Identifier id = new Identifier(); |
|
399 |
id.setValue(d.getField("identifier")); |
|
400 |
info.setIdentifier(id); |
|
401 |
info.setObjectFormat(returnedObjectFormat); |
|
402 |
info.setSize(d.getField("size")); |
|
403 |
//add the ObjectInfo to the ObjectList |
|
404 |
ol.addObjectInfo(info); |
|
405 |
|
|
371 | 406 |
//System.out.println(d.toString()); |
372 | 407 |
} |
373 | 408 |
|
Also available in: Unified diff
implementing getObjects in CrudService.