Revision 5286
Added by Matt Jones about 14 years ago
MCTestCase.java | ||
---|---|---|
59 | 59 |
import edu.ucsb.nceas.metacat.client.MetacatInaccessibleException; |
60 | 60 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
61 | 61 |
import edu.ucsb.nceas.metacat.shared.ServiceException; |
62 |
import edu.ucsb.nceas.metacat.util.DocumentUtil; |
|
62 | 63 |
import edu.ucsb.nceas.metacat.util.RequestUtil; |
63 | 64 |
import edu.ucsb.nceas.utilities.IOUtil; |
64 | 65 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
... | ... | |
515 | 516 |
} catch (InterruptedException ie) { |
516 | 517 |
debug("Could not sleep: " + ie.getMessage()); |
517 | 518 |
} |
518 |
|
|
519 |
StringBuffer docid = new StringBuffer(prefix); |
|
520 |
docid.append("."); |
|
521 | 519 |
|
522 |
// Create a calendar to get the date formatted properly |
|
523 |
String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000); |
|
524 |
SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]); |
|
525 |
pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); |
|
526 |
pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); |
|
527 |
Calendar calendar = new GregorianCalendar(pdt); |
|
528 |
Date trialTime = new Date(); |
|
529 |
calendar.setTime(trialTime); |
|
530 |
docid.append(calendar.get(Calendar.YEAR)); |
|
531 |
docid.append(calendar.get(Calendar.DAY_OF_YEAR)); |
|
532 |
docid.append(calendar.get(Calendar.HOUR_OF_DAY)); |
|
533 |
docid.append(calendar.get(Calendar.MINUTE)); |
|
534 |
docid.append(calendar.get(Calendar.SECOND)); |
|
535 |
|
|
536 |
return docid.toString(); |
|
520 |
return DocumentUtil.generateDocumentId(prefix, 0); |
|
537 | 521 |
} |
538 | 522 |
|
539 | 523 |
/** |
540 | 524 |
* Insert a document into metacat. The expected result is passed as result |
541 | 525 |
*/ |
542 |
|
|
543 | 526 |
protected String insertDocumentId(String docid, String docText, boolean result, |
544 | 527 |
boolean expectKarmaException) { |
545 | 528 |
debug("insertDocumentId() - docid=" + docid + " expectedResult=" + result |
Also available in: Unified diff
Added support to ResourceHandler to allow the putObject method to use
arbitrary guid strings as input. These strings are examined, and if they
match the Metacat docid format (scope.id.rev), they are used directly. If
the id is a string in another format, a new localId is generated based on
the current time. Either way, a mapping is made into the identifier table
to relate the original guid to the new localId. Modified DocumentUtil to
generate the ids, and MCTest case to use this new utility method (to stay DRY).
Tests were updated to expect these global identifiers in the putObject
method.