<?xml version="1.0" encoding="UTF-8"?>
<xmlReplay>
- <auths>
- <!-- IMPORTANT: THESE ARE STICKY :: THEY STICK AROUND UNTIL RESET, IN EXEC ORDER OF THIS FILE. -->
- <auth ID="admin@core.collectionspace.org">YWRtaW5AY29yZS5jb2xsZWN0aW9uc3BhY2Uub3JnOkFkbWluaXN0cmF0b3I=</auth>
- <auth ID="testAdministator">YWRtaW5AY29sbGVjdGlvbnNwYWNlLm9yZzpBZG1pbmlzdHJhdG9y</auth>
- </auths>
+ <auths>
+ <!-- IMPORTANT: THESE ARE STICKY :: THEY STICK AROUND UNTIL RESET, IN EXEC ORDER OF THIS FILE. -->
+ <auth ID="admin@core.collectionspace.org">YWRtaW5AY29yZS5jb2xsZWN0aW9uc3BhY2Uub3JnOkFkbWluaXN0cmF0b3I=</auth>
+ <auth ID="testAdministator">YWRtaW5AY29sbGVjdGlvbnNwYWNlLm9yZzpBZG1pbmlzdHJhdG9y</auth>
+ </auths>
- <!--
+ <!--
========================================================
testGroup :: refNameDisplayNameOnly
Creates a record using only displayName and not shortIdentifier.
========================================================
-->
-
- <testGroup ID="refNameDisplayNameOnly" autoDeletePOSTS="false">
- <test ID="oePersonauthority">
- <method>POST</method>
- <uri>/cspace-services/personauthorities/</uri>
- <filename>objectexit/oePersonauthority.xml</filename>
- </test>
- <test ID="oePerson">
- <method>POST</method>
- <uri>/cspace-services/personauthorities/${oePersonauthority.CSID}/items/</uri>
- <filename>objectexit/oePersonDisplayOnly.xml</filename>
- <vars>
- <var ID="displayName">Finbar the DisplayName</var>
- <var ID="shortIdentifier">Finbar_the_shortIdentifier</var>
- </vars>
- </test>
- <test ID="oePersonGET">
- <method>GET</method>
- <uri>/cspace-services/personauthorities/${oePersonauthority.CSID}/items/${oePerson.CSID}</uri>
- <response>
- <expected level="ADDOK" /><!--server adds the csid -->
- <label>persons_common</label>
- <filename>objectexit/res/oePersonDisplayGET.res.xml</filename>
- <vars>
- <!-- TODO: .got is not namespace aware yet, so you must make the xpath work around it for now.-->
- <var ID="csidGot">${oePersonGET.got("//csid")}</var>
- <var ID="inAuthority">${oePersonauthority.CSID}</var>
- <var ID="inAuthorityShortIdentifier">${oePersonauthority.sent("//shortIdentifier")}</var>
- <var ID="displayName">${oePerson.sent("//displayName")}</var>
- <var ID="shortIdentifier">${oePerson.sent("//shortIdentifier")}</var>
- <var ID="refName">urn:cspace:core.collectionspace.org:personauthorities:name(${inAuthorityShortIdentifier}):item:name(${shortIdentifier})'${displayName}'</var>
- </vars>
- </response>
- </test>
- </testGroup>
+
+ <testGroup ID="refNameDisplayNameOnly" autoDeletePOSTS="false">
+ <test ID="oePersonauthority">
+ <method>POST</method>
+ <uri>/cspace-services/personauthorities/</uri>
+ <filename>objectexit/oePersonauthority.xml</filename>
+ </test>
+ <test ID="oePerson">
+ <method>POST</method>
+ <uri>/cspace-services/personauthorities/${oePersonauthority.CSID}/items/</uri>
+ <filename>objectexit/oePersonDisplayOnly.xml</filename>
+ <vars>
+ <var ID="displayName">Finbar the DisplayName</var>
+ <var ID="shortIdentifier">Finbar_the_shortIdentifier</var>
+ </vars>
+ </test>
+ <test ID="oePersonGET">
+ <method>GET</method>
+ <uri>/cspace-services/personauthorities/${oePersonauthority.CSID}/items/${oePerson.CSID}</uri>
+ <response>
+ <expected level="ADDOK"></expected>
+ <!--server adds the csid -->
+ <label>persons_common</label>
+ <filename>objectexit/res/oePersonDisplayGET.res.xml</filename>
+ <vars>
+ <!-- TODO: .got is not namespace aware yet, so you must make the xpath work around it for now.-->
+ <var ID="csidGot">${oePersonGET.got("//csid")}</var>
+ <var ID="inAuthority">${oePersonauthority.CSID}</var>
+ <var ID="inAuthorityShortIdentifier">${oePersonauthority.sent("//shortIdentifier")}</var>
+ <var ID="displayName">${oePerson.sent("//displayName")}</var>
+ <var ID="shortIdentifier">${oePerson.sent("//shortIdentifier")}</var>
+ <var ID="refName">urn:cspace:core.collectionspace.org:personauthorities:name(${inAuthorityShortIdentifier}):item:name(${shortIdentifier})'${displayName}'</var>
+ </vars>
+ </response>
+ </test>
+ <test ID="delete-oePerson">
+ <method>DELETE</method>
+ <uri>/cspace-services/personauthorities/${oePersonauthority.CSID}/items/${oePerson.CSID}</uri>
+ </test>
+ <test ID="delete-oePersonauthority">
+ <method>DELETE</method>
+ <uri>/cspace-services/personauthorities/${oePersonauthority.CSID}</uri>
+ </test>
+ </testGroup>
</xmlReplay>
-
-
<label>objectexit_common</label>
</response>
</test>
+ <test ID="cleanup" auth="test">
+ <method>DELETE</method>
+ <uri>/cspace-services/objectexit/${oe1.CSID}</uri>
+ </test>
</testGroup>
<testGroup ID="testStartName" autoDeletePOSTS="false">
- <test ID="oe1" auth="test">
+ <test ID="oe1x" auth="test">
<method>POST</method>
<uri>/cspace-services/objectexit/</uri>
<filename>objectexit/oe1.xml</filename>
</test>
- <test ID="oe2">
+ <test ID="oe2x">
<method>GET</method>
<uri>/cspace-services/objectexit/${oe1.CSID}</uri>
<response>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<document name="personauthorities">
-<ns2:personauthorities_common
-xmlns:ns2="http://collectionspace.org/services/person"
-xmlns:ns3="http://collectionspace.org/services/jaxb">
- <displayName>Default Person Authority</displayName>
- <shortIdentifier>defaultPersonAuthority</shortIdentifier>
- <vocabType>PersonAuthority</vocabType>
-</ns2:personauthorities_common>
+ <ns2:personauthorities_common xmlns:ns2="http://collectionspace.org/services/person" xmlns:ns3="http://collectionspace.org/services/jaxb">
+ <displayName>Default Person Authority</displayName>
+ <shortIdentifier>TestPersonAuthForObjectExitTest</shortIdentifier>
+ <vocabType>PersonAuthority</vocabType>
+ </ns2:personauthorities_common>
</document>
-
-
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
- <version>2.2.2</version>
+ <version>2.2.7</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
public String getRelativeUri() {
StringBuilder uri = new StringBuilder();
- // FIXME This should not be hard-coded.
+ // FIXME This should not be hard-coded -see https://issues.collectionspace.org/browse/CSPACE-5987
if(resource.equals("vocabulary")) {
uri.append("/vocabularies/");
} else if(resource.equals("personauthority")) {
|| resource.equals("locationauthorities")
|| resource.equals("placeauthorities")
|| resource.equals("vocabularies"))) {
- logger.error("Unrecognized Authority Type: " + resource);
+ logger.warn("Unrecognized Authority Type: " + resource);
}
uri.append("/"+resource+"/");
}
//
if (repository != null) {
result = getCoreSessionWrapper(repository);
- logger.trace(String.format("A new transaction was started on thread '%d' : %s.",
- Thread.currentThread().getId(), startedTransaction ? "true" : "false"));
- logger.trace(String.format("Added a new repository instance to our repo list. Current count is now: %d",
- repositoryInstances.size()));
- } else {
+ if (result != null) {
+ logger.trace(String.format("A new transaction was started on thread '%d' : %s.",
+ Thread.currentThread().getId(), startedTransaction ? "true" : "false"));
+ logger.trace(String.format("Added a new repository instance to our repo list. Current count is now: %d",
+ repositoryInstances.size()));
+ }
+ }
+
+ if (repository == null || result == null) {
//
// If we couldn't open a repo session, we need to close the transaction we started.
//
* Nuxeo repository and check for network related failures. We will retry all calls to the Nuxeo repo that fail because
* of network erros.
*/
- private CoreSessionInterface getCoreSessionWrapper(Repository repository) throws Exception {
+ private CoreSessionInterface getCoreSessionWrapper(Repository repository) {
CoreSessionInterface result = null;
- CoreSession coreSession = CoreInstance.openCoreSession(repository.getName(), getSystemPrincipal()); // A Nuxeo repo instance handler proxy
+ CoreSession coreSession = null;
+ try {
+ coreSession = CoreInstance.openCoreSession(repository.getName(), getSystemPrincipal()); // A Nuxeo repo instance handler proxy
+ } catch (Exception e) {
+ logger.warn(String.format("Could not open a session to the '%s' repository. The current request to the CollectionSpace services API will fail.",
+ repository != null ? repository.getName() : "not specified"), e);
+ }
if (coreSession != null) {
result = this.getAOPProxy(coreSession); // This is our AOP proxy
String key = result.getSessionId();
repositoryInstances.put(key, result);
} else {
+ //
+ // Since we couldn't get an AOP proxy, we need to close the core session.
+ //
+ CoreInstance.closeCoreSession(coreSession);
String errMsg = String.format("Could not instantiate a Spring AOP proxy for class '%s'.",
CoreSessionWrapper.class.getName());
logger.error(errMsg);
- throw new Exception(errMsg);
}
- } else {
- String errMsg = String.format("Could not create a new repository instance for '%s' repository.", repository.getName());
- logger.error(errMsg);
- throw new Exception(errMsg);
}
return result;
private String oliveObjectRefName = UNINITIALIZED_REFNAME;
private String personAuthCSID = null;
- private String personShortId = PERSON_AUTHORITY_NAME;
+ private String personAuthShortId = PERSON_AUTHORITY_NAME + System.currentTimeMillis();
+ private String personAuthDisplayName = personAuthShortId;
/** The SERVICE path component. */
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
- PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
+ personAuthDisplayName, personAuthShortId, personAuthClient.getCommonPartName());
Response res = personAuthClient.create(multipart);
try {
int statusCode = res.getStatus();