import org.apache.commons.cli.*;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.jexl2.JexlContext;
import org.apache.commons.jexl2.JexlEngine;
import org.collectionspace.services.common.api.Tools;
import org.dom4j.*;
-->
<!-- TODO: this almost works now:
- <run controlFile="./security.xml" testGroup="security" />
+ <run controlFile="security/security.xml" testGroup="security" />
-->
<!-- These all work with POX: -->
- <run controlFile="./security.xml" testGroup="deleteBug" />
+ <run controlFile="security/security.xml" testGroup="deleteBug" />
<run controlFile="objectexit/object-exit.xml" testGroup="makeone" />
<run controlFile="relation/relation.xml" testGroup="r2only" />
<run controlFile="person/person.xml" testGroup="postPerson" />
<email>elmo2018@DeleteBug.accountelemo.org</email>
<phone>1234567890</phone>
<userId>elmo2018</userId>
- <!-- Pass word is grover2018, base64 encoded -->
- <password>Z3JvdmVyMjAxOA==</password>
+ <!-- Pass word is elmo2018, base64 encoded -->
+ <password>ZWxtbzIwMTg=</password>
<tenants>
<tenant_id>1</tenant_id>
</tenants>
<role>
- <roleId>${permElmo.CSID}</roleId> <!-- It should be ok that role name is missing -->
+ <roleId>${simpleRoleId}</roleId> <!-- It should be ok that role name is missing -->
</role>
</ns2:accounts_common>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<ns2:role xmlns:ns2="http://collectionspace.org/services/authorization">
+ <roleName>xROLE_ADDTOEMPTYROLE</roleName>
+ <description>Role for CreateEmptyRoleAddPerms-simpleRole-30 create test.</description>
+</ns2:role>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<ns2:role xmlns:ns2="http://collectionspace.org/services/authorization" csid="${roleCsid}">
+ <displayName>xROLE_ADDTOEMPTYROLE</displayName>
+ <roleName>ROLE_1_XROLE_ADDTOEMPTYROLE</roleName>
+ <description>role for xROLE_ADDTOEMPTYROLE</description>
+ <tenant_id>1</tenant_id>
+ <permission>
+ <permissionId>1-groups-RL</permissionId>
+ <resourceName>groups</resourceName>
+ <actionGroup>RL</actionGroup>
+ </permission>
+ <permission>
+ <permissionId>1-vocabularies-RL</permissionId>
+ <resourceName>vocabularies</resourceName>
+ <actionGroup>RL</actionGroup>
+ </permission>
+</ns2:role>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<ns2:role xmlns:ns2="http://collectionspace.org/services/authorization">
+ <roleName>xROLE_ADDTOEMPTYROLE</roleName>
+ <description>role for xROLE_ADDTOEMPTYROLE</description>
+ <permission>
+ <permissionId>1-vocabularies-RL</permissionId>
+ <resourceName>vocabularies</resourceName>
+ <actionGroup>RL</actionGroup>
+ </permission>
+ <permission>
+ <permissionId>1-groups-RL</permissionId>
+ <resourceName>groups</resourceName>
+ <actionGroup>RL</actionGroup>
+ </permission>
+</ns2:role>
<auth ID="user1@museum1">dXNlcjFAbXVzZXVtMS5vcmc6dXNlcjFAbXVzZXVtMS5vcmc=</auth>
<auth ID="bigbird2010">YmlnYmlyZDIwMTA6YmlnYmlyZDIwMTA=</auth>
<auth ID="elmo2010">ZWxtbzIwMTA6ZWxtbzIwMTA=</auth>
+ <auth ID="elmo2018">ZWxtbzIwMTg6ZWxtbzIwMTg=</auth>
<auth ID="grover">Z3JvdmVyOmdyb3ZlcjIwMTg=</auth>
-
</auths>
-
+
+ <!-- Create an empty role, then update with a perm list -->
+
+ <testGroup ID="CreateEmptyRoleAddPerms" autoDeletePOSTS="true">
+ <test ID="simpleRole_30" auth="admin@core.collectionspace.org">
+ <method>POST</method>
+ <uri>/cspace-services/authorization/roles</uri>
+ <filename>security/CreateEmptyRoleAddPerms/createSimpleRole-30.xml</filename>
+ </test>
+ <test ID="updateSimpleRole_30">
+ <method>PUT</method>
+ <uri>/cspace-services/authorization/roles/${simpleRole_30.CSID}</uri>
+ <filename>security/CreateEmptyRoleAddPerms/updateSimpleRole-30.xml</filename>
+ </test>
+ <test ID="getSimpleRole_30">
+ <method>GET</method>
+ <uri>/cspace-services/authorization/roles/${simpleRole_30.CSID}?showPerms=true</uri>
+ <response>
+ <vars>
+ <var ID="roleCsid">${simpleRole_30.CSID}</var>
+ </vars>
+ <filename>security/CreateEmptyRoleAddPerms/responses/getSimpleRole-30.res.xml</filename>
+ </response>
+ </test>
+ </testGroup>
+
<testGroup ID="SimpleRoles" autoDeletePOSTS="true">
<test ID="simpleAccount-1">
<method>POST</method>
<method>POST</method>
<uri>/cspace-services/authorization/roles</uri>
<filename>security/BasicRoles/createSimpleRole-2.xml</filename>
- </test>
+ </test>
<test ID="simpleAccount-2">
<method>POST</method>
<uri>/cspace-services/accounts</uri>
<filename>security/BasicRoles/createSimpleAccount-2.xml</filename>
</test>
</testGroup>
-
+
<testGroup ID="SlipOut" autoDeletePOSTS="true">
<test ID="slipOutPerm">
<method>POST</method>
<filename>security/SlipOut/slipOutVocab-2.xml</filename>
</test>
</testGroup>
-
+
<testGroup ID="DefaultPermmissions" autoDeletePOSTS="true">
<test ID="get1-loansin-CRUDL">
<method>GET</method>
<uri>/cspace-services/authorization/permissions/1-loansin-CRUDL</uri>
<response>
- <expected level="TEXT" />
- <filename>security/res/get1-loansin-CRUDL.res.xml</filename>
+ <expected level="TEXT"></expected>
+ <filename>security/responses/get1-loansin-CRUDL.res.xml</filename>
<label>permission</label>
</response>
</test>
<uri>/cspace-services/authorization/permissions/1-loansin-CRUDL/permroles</uri>
</test>
</testGroup>
-
- <testGroup ID="DeleteBug" autoDeletePOSTS="false">
+ <testGroup ID="DeleteBug" autoDeletePOSTS="true" authForCleanup="admin@core.collectionspace.org">
<test ID="permElmo">
<method>POST</method>
<uri>/cspace-services/authorization/permissions</uri>
<uri>/cspace-services/authorization/permissions/${permElmo.CSID}/permroles</uri>
<filename>security/14-permissionroles-bogus.xml</filename>
</test>
+ <test ID="simpleRole">
+ <method>POST</method>
+ <uri>/cspace-services/authorization/roles</uri>
+ <filename>security/simple-role-template.xml</filename>
+ </test>
<test ID="accountElmo">
<method>POST</method>
<uri>/cspace-services/accounts</uri>
<filename>security/6-account-elmo.xml</filename>
+ <vars>
+ <var ID="simpleRoleId">${simpleRole.CSID}</var>
+ </vars>
</test>
-
- <test ID="dimension1" auth="admin@core.collectionspace.org">
+ <test ID="dimension1" auth="admin@core.collectionspace.org">
<method>POST</method>
<uri>/cspace-services/dimensions/</uri>
<filename>dimension/1.xml</filename>
</test>
- <test ID="dimensionElmoDELETE" auth="elmo2010">
+ <test ID="dimensionElmoDELETE" auth="elmo2018">
<expectedCodes>403</expectedCodes>
<method>DELETE</method>
<fromTestID>dimension1</fromTestID>
<fromTestID>accountElmo</fromTestID>
</test>
</testGroup>
-
-
- <testGroup ID="security" autoDeletePOSTS="false">
+
+
+ <testGroup ID="security" autoDeletePOSTS="true" authForCleanup="admin@core.collectionspace.org">
<!--First test that bigbird2010 does NOT have write access: -->
- <test ID="dimension0" auth="bigbird2010">
+ <test ID="dimension0" auth="bigbird2010">
<expectedCodes>401,500,501</expectedCodes>
<method>POST</method>
<uri>/cspace-services/dimensions/</uri>
<uri>/cspace-services/accounts</uri>
<filename>security/5-account-bigbird.xml</filename>
</test>
+ <test ID="simpleRole">
+ <method>POST</method>
+ <uri>/cspace-services/authorization/roles</uri>
+ <filename>security/simple-role-template.xml</filename>
+ </test>
<test ID="accountElmo">
<method>POST</method>
<uri>/cspace-services/accounts</uri>
<filename>security/6-account-elmo.xml</filename>
- </test>
+ <vars>
+ <var ID="simpleRoleId">${simpleRole.CSID}</var>
+ </vars>
+ </test>
<test ID="accountrolesBigbird">
<method>POST</method>
<uri>/cspace-services/accounts/${accountBigbird.CSID}/accountroles</uri>
<filename>security/10-permissionroles-elmo.xml</filename>
</test>
- <test ID="dimension1" auth="bigbird2010">
+ <test ID="dimension1" auth="bigbird2010">
<method>POST</method>
<uri>/cspace-services/dimensions/</uri>
<filename>dimension/1.xml</filename>
<uri>/cspace-services/dimensions/</uri>
<fromTestID>dimension1</fromTestID>
</test>
- <test ID="dimensionElmoPOST" auth="elmo2010">
+ <test ID="dimensionElmoPOST" auth="elmo2018">
<expectedCodes>403</expectedCodes>
<method>POST</method>
<uri>/cspace-services/dimensions/</uri>
<uri>/cspace-services/dimensions/${dimension1.CSID}</uri>
<filename>dimension/2-put.xml</filename>
</test>
- <test ID="dimensionElmoGET">
+ <test ID="dimensionElmoGET" auth="bigbird2010">
<method>GET</method>
<uri>/cspace-services/dimensions/</uri>
<fromTestID>dimension1</fromTestID>
</test>
- <test ID="dimensionElmoDELETE" auth="elmo2010">
+ <test ID="dimensionElmoDELETE" auth="elmo2018">
<expectedCodes>403</expectedCodes>
<method>DELETE</method>
<fromTestID>dimension1</fromTestID>
<method>DELETE</method>
<fromTestID>dimension1</fromTestID>
</test>
-
- <!-- The element: <action>SEARCH </action> implies LIST
- in C:\bin\xmlreplay\test-data\xmlReplay\security\1-bigbird-permission.xml
- Add DELETE, do CRUD for both, then switch roles and redo CRUD
- -->
-
-
<test ID="dimensionBigBirdDELETEpermroles" auth="admin@core.collectionspace.org">
<method>DELETE</method>
<uri>/cspace-services/authorization/permissions/${permBigbird.CSID}/permroles</uri>
- <!-- don't do <fromTestID>, no CSID of permrole on end of url, but deleteURL will put one there for you, so don't use it.
- wrong: <fromTestID>bigbirdPermroles</fromTestID>
- wrong: http://localhost:8280/cspace-services/authorization/permissions/28943d0f-efac-48d3-8c01-e4ef7e75e296/permroles/0891ca9a-ba34-4701-9662-4ab73757890e
- Create a <uri> element instead:
- right: http://localhost:8280/cspace-services/authorization/permissions/28943d0f-efac-48d3-8c01-e4ef7e75e296/permroles
- -->
</test>
<test>
<method>DELETE</method>
<uri>/cspace-services/authorization/permissions/${permElmo.CSID}/permroles</uri>
</test>
-
- <test ID="dimensionBigbirdPOSTAfterPermrolesDeleted" auth="bigbird2010">
- <msg>Removing all permissions from Bigbird's role</msg>
- <expectedCodes>403,404</expectedCodes>
+
+ <test ID="dimensionBigbirdPOSTAfterPermrolesDeleted" auth="bigbird2010">
+ <expectedCodes>403</expectedCodes>
<method>POST</method>
<uri>/cspace-services/dimensions/</uri>
<filename>dimension/1.xml</filename>
<filename>dimension/2-put.xml</filename>
</test>
-
<test ID="accountroles2" auth="admin@core.collectionspace.org">
<method>DELETE</method>
<uri>/cspace-services/accounts/${accountBigbird.CSID}/accountroles</uri>
<method>DELETE</method>
<fromTestID>accountElmo</fromTestID>
</test>
- <!-- delete permissions. Don't delete permissions, or Admin will get hosed. -->
</testGroup>
-
-
-
-
-
- <!-- ================================================================================ -->
-
- <testGroup ID="securityRemovingRoleperms" autoDeletePOSTS="false">
+
+ <!-- ================================================================================ -->
+
+ <testGroup ID="securityRemovingRoleperms" autoDeletePOSTS="false">
<!--First test that bigbird2010 does NOT have write access: -->
- <test ID="dimensionBeforePerms" auth="bigbird2010">
+ <test ID="dimensionBeforePerms" auth="bigbird2010">
<expectedCodes>401,403,500,501</expectedCodes>
<method>POST</method>
<uri>/cspace-services/dimensions/</uri>
<uri>/cspace-services/authorization/permissions</uri>
<filename>security/1-bigbird-permission.xml</filename>
</test>
- <test ID="roleTestCM" auth="admin@core.collectionspace.org">
+ <test ID="roleTestCM" auth="admin@core.collectionspace.org">
<method>POST</method>
<uri>/cspace-services/authorization/roles</uri>
<filename>security/3-role-test-cm.xml</filename>
<!-- bigbird2010 now has CRUD permissions, -->
<!-- so now try CRUDL by bigbird2010 -->
-
- <test ID="dimensionBigbird_POST" auth="bigbird2010">
+
+ <test ID="dimensionBigbird_POST" auth="bigbird2010">
<method>POST</method>
<uri>/cspace-services/dimensions/</uri>
- <filename>dimension/1.xml</filename>
+ <filename>dimension/1.xml</filename>
</test>
<!-- TODO: FAILING, BUT SHOULD SUCCEED. REMOVING TEST FOR NOW. -->
<test ID="dimensionBigbird_PUT">
<method>PUT</method>
<uri>/cspace-services/dimensions/${dimensionBigbird_POST.CSID}</uri>
- <filename>dimension/2-put.xml</filename>
+ <filename>dimension/2-put.xml</filename>
</test>
- <test ID="dimensionBigbird_GET">
+ <test ID="dimensionBigbird_GET">
<method>GET</method>
<uri>/cspace-services/dimensions/</uri>
<fromTestID>dimensionBigbird_POST</fromTestID>
<method>DELETE</method>
<fromTestID>dimensionBigbird_POST</fromTestID>
</test>
-
+
<!-- NOW **REMOVE** PERMROLES FROM BIGBIRD -->
-
+
<test ID="deletePermrolesBigbird" auth="admin@core.collectionspace.org">
<msg>Deleting permroles from bigbird2010</msg>
<method>DELETE</method>
<uri>/cspace-services/authorization/permissions/${permBigbird.CSID}/permroles</uri>
</test>
-
+
<!-- NOW TRY CRUDL BY BIGBIRD WITH NO PERMROLES -->
-
- <test ID="dimensionBigbird_POST_AfterPermrolesDeleted" auth="bigbird2010">
+
+ <test ID="dimensionBigbird_POST_AfterPermrolesDeleted" auth="bigbird2010">
<msg>Trying to POST after permroles removed from Bigbird</msg>
<expectedCodes>403,404</expectedCodes>
<method>POST</method>
<uri>/cspace-services/dimensions/</uri>
- <filename>dimension/1.xml</filename>
+ <filename>dimension/1.xml</filename>
</test>
<test ID="dimensionBigbird_PUT_AfterPermrolesDeleted">
- <expectedCodes>403,404,405</expectedCodes><!-- Expected failure because dimensionBigbird_POST_AfterPermrolesDeleted failed.-->
+ <expectedCodes>403,404,405</expectedCodes>
+ <!-- Expected failure because dimensionBigbird_POST_AfterPermrolesDeleted failed.-->
<method>PUT</method>
<uri>/cspace-services/dimensions/${dimensionBigbird_POST_AfterPermrolesDeleted.CSID}</uri>
- <filename>dimension/2-put.xml</filename>
+ <filename>dimension/2-put.xml</filename>
</test>
<test ID="dimensionBigbird_GET_AfterPermrolesDeleted">
<expectedCodes>403,404</expectedCodes>
<uri>/cspace-services/authorization/permissions/${permBigbird_CRU.CSID}/permroles</uri>
<filename>security/11-permissionroles-bigbird-CRU.xml</filename>
</test>
-
+
<!-- NOW TRY CRUDL BY BIGBIRD BUT WITH CRU ADDED -->
- <test ID="dimensionBigbird_POST_CRU" auth="bigbird2010">
+ <test ID="dimensionBigbird_POST_CRU" auth="bigbird2010">
<method>POST</method>
<uri>/cspace-services/dimensions/</uri>
- <filename>dimension/1.xml</filename>
+ <filename>dimension/1.xml</filename>
</test>
<test ID="dimensionBigbird_PUT_CRU">
<method>PUT</method>
<uri>/cspace-services/dimensions/${dimensionBigbird_POST_CRU.CSID}</uri>
- <filename>dimension/2-put.xml</filename>
+ <filename>dimension/2-put.xml</filename>
</test>
<test ID="dimensionBigbird_GET_CRU">
<method>GET</method>
</test>
<!-- NOW **REMOVE** PERMROLES FROM BIGBIRD -->
-
+
<test ID="deletePermrolesBigbird" auth="admin@core.collectionspace.org">
<msg>Deleting permroles from bigbird2010</msg>
<method>DELETE</method>
<uri>/cspace-services/authorization/permissions/${permBigbird_CRU.CSID}/permroles</uri>
</test>
-
+
<!-- NOW **ADD** PERMS R TO BIGBIRD -->
<test ID="permBigbird_R" auth="admin@core.collectionspace.org">
</test>
<!-- NOW TRY CRUDL BY BIGBIRD with R only -->
-
- <test ID="dimensionBigbird_POST_R" auth="bigbird2010">
+
+ <test ID="dimensionBigbird_POST_R" auth="bigbird2010">
<expectedCodes>403,404</expectedCodes>
<method>POST</method>
<uri>/cspace-services/dimensions/</uri>
- <filename>dimension/1.xml</filename>
+ <filename>dimension/1.xml</filename>
</test>
<test ID="dimensionBigbird_PUT_R">
<expectedCodes>403,404,405</expectedCodes>
<method>PUT</method>
<uri>/cspace-services/dimensions/${dimensionBigbird_POST_R.CSID}</uri>
- <filename>dimension/2-put.xml</filename>
+ <filename>dimension/2-put.xml</filename>
</test>
<test ID="dimensionBigbird_GET_R">
<method>GET</method>
<fromTestID>dimensionBigbird_POST_R</fromTestID>
</test>
<test ID="dimensionBigbird_DELETE_R">
- <!-- RESPONSE CODE 0 MEANS XmlReplay could not find a deleteURL or CSID, which is right, because the POST failed. -->
+ <!-- RESPONSE CODE 0 MEANS XmlReplay could not find a deleteURL or CSID, which is right, because the POST failed. -->
<expectedCodes>0,403,404</expectedCodes>
<method>DELETE</method>
<fromTestID>dimensionBigbird_POST_R</fromTestID>
</test>
-
+
<!-- CLEANUP -->
-
+
<test ID="deletePermrolesBigbird" auth="admin@core.collectionspace.org">
<msg>Deleting permroles already deleted in test ID="deletePermrolesBigbird"</msg>
<expectedCodes>404</expectedCodes>
<method>DELETE</method>
<uri>/cspace-services/authorization/permissions/${permBigbird.CSID}/permroles</uri>
</test>
- <test auth="admin@core.collectionspace.org">
+ <test auth="admin@core.collectionspace.org">
<method>DELETE</method>
<uri>/cspace-services/accounts/${accountBigbird.CSID}/accountroles</uri>
</test>
- <test ID="securityCleanupRoleTestCM">
+ <test ID="securityCleanupRoleTestCM">
<method>DELETE</method>
<fromTestID>roleTestCM</fromTestID>
</test>
<method>DELETE</method>
<fromTestID>accountBigbird</fromTestID>
</test>
-
+
</testGroup>
- <!-- proposed simplification for re-runs:
+ <!-- proposed simplification for re-runs:
<test rerunID="dimensionBigbird" testGroupID="dimensionCRUDL">
<expectedCodes>404</expectedCodes>
</test>
-->
</xmlReplay>
-
-
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<ns2:role xmlns:ns2="http://collectionspace.org/services/authorization">
+ <roleName>${Test.ID}</roleName>
+ <description>role for ${Test.ID}</description>
+ <permission>
+ <permissionId>1-vocabularies-RL</permissionId>
+ <resourceName>vocabularies</resourceName>
+ <actionGroup>RL</actionGroup>
+ </permission>
+ <permission>
+ <permissionId>1-groups-RL</permissionId>
+ <resourceName>groups</resourceName>
+ <actionGroup>RL</actionGroup>
+ </permission>
+</ns2:role>
<auth ID="admin@core.collectionspace.org">YWRtaW5AY29yZS5jb2xsZWN0aW9uc3BhY2Uub3JnOkFkbWluaXN0cmF0b3I=</auth>
</auths>
- <run controlFile="./security-oauth.xml" />
- <run controlFile="./security.xml" testGroup="deleteBug" />
+ <run controlFile="security/security-oauth.xml" />
+ <run controlFile="security/security.xml" />
<run controlFile="objectexit/object-exit.xml" testGroup="makeone" />
<run controlFile="objectexit/object-exit.xml" testGroup="checkList" />
<run controlFile="objectexit/object-exit-display.xml" testGroup="refNameDisplayNameOnly" />
<!-- run controlFile="relation/relation.xml" testGroup="r2only" / -->
<!-- This used to work, but for check-in, I'm commenting it out as it currently breaks if things are left around in DB. -->
- <!-- run controlFile="./security.xml" testGroup="security" / -->
+ <!-- run controlFile="security/security.xml" testGroup="security" / -->
<!--
This was working but is not now because security db hangs onto results from failed tests.
However, it is more complete than testGroup="security", so is the correct testGroup to run.
When the DB is cleaned with [ant create_db import] it runs OK.
-->
- <!-- run controlFile="./security.xml" testGroup="securityRemovingRoleperms" / -->
+ <!-- run controlFile="security/security.xml" testGroup="securityRemovingRoleperms" / -->
</xmlReplayMaster>
<artifactId>org.collectionspace.services.structureddate.service</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.systeminfo.service</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.media.service</artifactId>
<version>${project.version}</version>
for (TenantBindingType tenantBindings : tenantBindingsTable.values()) {
CSpaceTenant tenant = new CSpaceTenant(tenantBindings.getId(), tenantBindings.getName());
if (shouldInitializeAuthorities(tenant, reset) == true) {
+ logger.log(Level.INFO, String.format("Initializing vocabularies and authorities of tenant '%s'.",
+ tenant.getId()));
for (ServiceBindingType serviceBinding : tenantBindings.getServiceBindings()) {
AuthorityInstanceList element = serviceBinding.getAuthorityInstanceList();
if (element != null && element.getAuthorityInstance() != null) {
logger.log(Level.FINE, String.format("Authority of type '%s' with the short ID of '%s' existed already.",
serviceName, authorityInstance.getTitleRef()));
} else if (status == Response.Status.CREATED.getStatusCode()) {
- logger.log(Level.INFO, String.format("Created a new authority of type '%s' with the short ID of '%s'.",
+ logger.log(Level.FINE, String.format("Created a new authority of type '%s' with the short ID of '%s'.",
serviceName, authorityInstance.getTitleRef()));
} else {
logger.log(Level.WARNING, String.format("Unknown status '%d' encountered when creating or fetching authority of type '%s' with the short ID of '%s'.",
String xmlPayload = client.createAuthorityItemInstance(termShortId, termDisplayName);
try {
authorityResource.createAuthorityItem(resourceMap, null, authoritySpecifier, xmlPayload);
- logger.log(Level.FINE, String.format("Created a new term '%s:%s' in the authority of type '%s' with the short ID of '%s'.",
- termDisplayName, termShortId, serviceName, authorityInstance.getTitleRef()));
+ logger.log(Level.FINE, String.format("Tenant:%s:Created a new term '%s:%s' in the authority of type '%s' with the short ID of '%s'.",
+ tenant.getName(), termDisplayName, termShortId, serviceName, authorityInstance.getTitleRef()));
} catch (CSWebApplicationException e) {
response = e.getResponse();
status = response.getStatus();
import org.collectionspace.services.dimension.DimensionResource;
import org.collectionspace.services.servicegroup.ServiceGroupResource;
import org.collectionspace.services.structureddate.StructuredDateResource;
+import org.collectionspace.services.systeminfo.SystemInfoResource;
import org.collectionspace.services.contact.ContactResource;
import org.collectionspace.services.vocabulary.VocabularyResource;
import org.collectionspace.services.organization.OrgAuthorityResource;
singletons.add(new ServiceGroupResource());
singletons.add(new ImportsResource());
singletons.add(new StructuredDateResource());
+ singletons.add(new SystemInfoResource());
addResourceToMapAndSingletons(new VocabularyResource());
addResourceToMapAndSingletons(new PersonAuthorityResource());
# CollectionSpace loggers and default levels - all loggers using the rootLogger if not otherwise specified
#
log4j.logger.org.collectionspace=DEBUG
+log4j.logger.org.collectionspace.services.authorization.spring.SpringPermissionManager=ERROR
+log4j.logger.org.collectionspace.services.listener.AbstractUpdateObjectLocationValues=INFO
+log4j.logger.org.collectionspace.services.common.context.AbstractServiceContextImpl=ERROR
log4j.logger.org.collectionspace.services.common.ServiceMain=INFO
log4j.logger.org.collectionspace.authentication.realm.db.CSpaceDbRealm=ERROR
log4j.logger.org.collectionspace.services.nuxeo.client.java.CoreSessionWrapper=ERROR
<!-- Exclude the resource path to account process a password resets from AuthN and AuthZ. Lets us process password resets anonymous access. -->
<sec:intercept-url pattern="/accounts/processpasswordreset" access="permitAll" />
+ <!-- Exclude the resource path to request system info -->
+ <sec:intercept-url pattern="/systeminfo" access="permitAll" />
+
<!-- All other paths must be authenticated. -->
<sec:intercept-url pattern="/**" access="isFullyAuthenticated()" />
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-
-<!--
- Account schema (XSD)
-
- Entity : Account, Tenant
- Part : Common
- Used for: JAXB binding between XML and Java objects
-
- $LastChangedRevision: 916 $
- $LastChangedDate: 2009-11-05 16:59:20 -0800 (Fri, 06 Nov 2009) $
--->
-
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
jaxb:version="2.1" elementFormDefault="unqualified"
+ xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:hj="http://hyperjaxb3.jvnet.org/ejb/schemas/customizations"
xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
xmlns:ns="http://collectionspace.org/services/account"
xmlns="http://collectionspace.org/services/account"
targetNamespace="http://collectionspace.org/services/account"
- version="0.1"
- jaxb:extensionBindingPrefixes="hj orm"
+ version="0.1"
+ jaxb:extensionBindingPrefixes="hj orm xjc"
>
<!--
Avoid XmlRootElement nightmare:
See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
--->
+ -->
<xs:annotation>
<xs:appinfo>
</xs:appinfo>
</xs:annotation>
</xs:element>
- <xs:element name="role" type="ns:role_value" minOccurs="1" maxOccurs="unbounded"/>
+ <xs:element name="role" type="role_value" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="csid" type="xs:string">
<xs:annotation>
<xs:element name="tenantId" type="xs:string" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
-
- <!-- This is the base class for paginated lists -->
- <xs:complexType name="abstractCommonList">
- <xs:annotation>
- <xs:appinfo>
- <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
- </xs:appinfo>
- </xs:annotation>
- </xs:complexType>
-
- <xs:element name="accounts-common-list">
- <xs:complexType>
- <xs:annotation>
- <xs:documentation>
- AccountsCommonList contains information about one or more
- accounts. An instance of this type could be returned on
- index and search operations.
- </xs:documentation>
- <xs:appinfo>
- <hj:ignored/>
- </xs:appinfo>
- </xs:annotation>
- <xs:complexContent>
- <xs:extension base="abstractCommonList">
- <xs:sequence>
- <xs:element name="account-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:annotation>
- <xs:appinfo>
- <hj:ignored/>
- </xs:appinfo>
- </xs:annotation>
- <xs:sequence>
- <xs:element name="screenName" type="xs:string" minOccurs="1"/>
- <xs:element name="userid" type="xs:string" minOccurs="1" />
- <xs:element name="tenantid" type="xs:string" minOccurs="1" />
- <xs:element name="tenants" type="account_tenant" minOccurs="1" maxOccurs="unbounded">
- <xs:annotation>
- <xs:documentation>
- tenant association is usually not required to be provided by the
- service consumer. only in cases where a user in CollectionSpace
- has access to the spaces of multiple tenants, this is used
- to associate that user with more than one tenants
- </xs:documentation>
- </xs:annotation>
- </xs:element>
- <xs:element name="personRefName" type="xs:string" minOccurs="1" />
- <xs:element name="email" type="xs:string" minOccurs="1" />
- <xs:element name="status" type="status" minOccurs="1" />
- <!-- uri to retrive collection object details -->
- <xs:element name="uri" type="xs:anyURI" minOccurs="1" />
- <xs:element name="csid" type="xs:string" minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
<xs:simpleType name="status">
<xs:annotation>
</xs:sequence>
</xs:complexType>
</xs:element>
-
- <xs:element name="tenants-list">
- <xs:complexType>
- <xs:annotation>
- <xs:documentation>
- TenantsList contains information about one or more
- tenants. An instance of this type could be returned on
- index and search operations.
- </xs:documentation>
- <xs:appinfo>
- <hj:ignored/>
- </xs:appinfo>
- </xs:annotation>
- <xs:complexContent>
- <xs:extension base="abstractCommonList">
- <xs:sequence>
- <xs:element name="tenant-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:annotation>
- <xs:appinfo>
- <hj:ignored/>
- </xs:appinfo>
- </xs:annotation>
- <xs:sequence>
- <xs:element name="id" type="xs:string" minOccurs="1"/>
- <xs:element name="name" type="xs:string" minOccurs="1" />
- <xs:element name="disabled" type="xs:boolean" minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
-
</xs:schema>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+ jaxb:version="2.1" elementFormDefault="unqualified"
+ xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
+ xmlns:hj="http://hyperjaxb3.jvnet.org/ejb/schemas/customizations"
+ xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
+ xmlns:ns="http://collectionspace.org/services/account"
+ xmlns="http://collectionspace.org/services/account"
+ targetNamespace="http://collectionspace.org/services/account"
+ version="0.1"
+ jaxb:extensionBindingPrefixes="hj orm xjc"
+ >
+
+ <xs:include schemaLocation="accounts_common.xsd"/>
+
+ <!--
+ Avoid XmlRootElement nightmare:
+ See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
+ -->
+
+ <!-- This is the base class for paginated lists -->
+ <xs:complexType name="abstractCommonList">
+ <xs:annotation>
+ <xs:appinfo>
+ <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:complexType>
+
+ <xs:element name="accounts-common-list">
+ <xs:complexType>
+ <xs:annotation>
+ <xs:documentation>
+ AccountsCommonList contains information about one or more
+ accounts. An instance of this type could be returned on
+ index and search operations.
+ </xs:documentation>
+ <xs:appinfo>
+ <hj:ignored/>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <xs:element name="account-list-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:annotation>
+ <xs:appinfo>
+ <hj:ignored/>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="screenName" type="xs:string" minOccurs="1"/>
+ <xs:element name="userid" type="xs:string" minOccurs="1" />
+ <xs:element name="tenantid" type="xs:string" minOccurs="1" />
+ <xs:element name="tenants" type="account_tenant" minOccurs="1" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>
+ tenant association is usually not required to be provided by the
+ service consumer. only in cases where a user in CollectionSpace
+ has access to the spaces of multiple tenants, this is used
+ to associate that user with more than one tenants
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="personRefName" type="xs:string" minOccurs="1" />
+ <xs:element name="email" type="xs:string" minOccurs="1" />
+ <xs:element name="status" type="status" minOccurs="1" />
+ <!-- uri to retrive collection object details -->
+ <xs:element name="uri" type="xs:anyURI" minOccurs="1" />
+ <xs:element name="csid" type="xs:string" minOccurs="1" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="tenants-list">
+ <xs:complexType>
+ <xs:annotation>
+ <xs:documentation>
+ TenantsList contains information about one or more
+ tenants. An instance of this type could be returned on
+ index and search operations.
+ </xs:documentation>
+ <xs:appinfo>
+ <hj:ignored/>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <xs:element name="tenant-list-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:annotation>
+ <xs:appinfo>
+ <hj:ignored/>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="id" type="xs:string" minOccurs="1"/>
+ <xs:element name="name" type="xs:string" minOccurs="1" />
+ <xs:element name="disabled" type="xs:boolean" minOccurs="1" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
+
--- /dev/null
+<?xml version="1.0"?>
+<jxb:bindings version="1.0"
+ xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:namespace="http://jaxb2-commons.dev.java.net/namespace-prefix"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd
+ http://jaxb2-commons.dev.java.net/namespace-prefix https://raw.githubusercontent.com/Siggen/jaxb2-namespace-prefix/master/src/main/resources/prefix-namespace-schema.xsd">
+
+ <jxb:bindings schemaLocation="accounts_common.xsd">
+ <jxb:bindings>
+ <namespace:prefix name="act" />
+ <!-- Additional @XmlNs prefix declarations to take effect for this schema/package -->
+ <namespace:prefix name="xsi" namespaceURI="http://www.w3.org/2001/XMLSchema-instance" />
+ </jxb:bindings>
+ </jxb:bindings>
+
+</jxb:bindings>
\ No newline at end of file
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.document.BadRequestException;
import org.collectionspace.services.common.document.DocumentFilter;
+import org.collectionspace.services.common.document.DocumentNotFoundException;
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.document.JaxbUtils;
import org.collectionspace.services.common.security.SecurityUtils;
PermissionRoleSubResource subResource =
new PermissionRoleSubResource(PermissionRoleSubResource.ROLE_PERMROLE_SERVICE);
//
- // First, delete the existing permroles
+ // First, delete the existing permroles (if any)
//
- subResource.deletePermissionRole(ctx, roleFound.getCsid(), SubjectType.PERMISSION);
+ try {
+ subResource.deletePermissionRole(ctx, roleFound.getCsid(), SubjectType.PERMISSION);
+ } catch (DocumentNotFoundException dnf) {
+ // Catch and ignore. Just means the role has no existing relationships
+ }
//
// Next, create the new permroles
//
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
- jaxb:version="1.0" elementFormDefault="unqualified"
+ jaxb:version="2.1" elementFormDefault="unqualified"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:hj="http://hyperjaxb3.jvnet.org/ejb/schemas/customizations"
xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
</xs:appinfo>
</xs:annotation>
- <!--
- Notes for MySQL
- MySQL puts key length limit of 1000 bytes
- username - rolename constraint should be within 1000 bytes
- hbm2ddl makes column length >= 256 as long text, such as column cannot be used
- in defining a key (pk, fk or constraint)
- -->
-
<xs:element name="role" type="role"/>
<!-- role type has a name so that it could be referred from roles_list -->
<xs:complexType name="role">
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.claim.service</artifactId>
<name>services.claim.service</name>
<packaging>jar</packaging>
<dependency>
<groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.common</artifactId>
- <version>${project.version}</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.claim.jaxb</artifactId>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
- </dependency>
+ </dependency>
<!-- javax -->
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
- <version>1.6.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.nuxeo.ecm.core</groupId>
<artifactId>nuxeo-core-api</artifactId>
- <version>${nuxeo.core.version}</version>
<exclusions>
<exclusion>
<artifactId>jboss-remoting</artifactId>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<profilesXml xmlns="http://maven.apache.org/PROFILES/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/PROFILES/1.0.0 http://maven.apache.org/xsd/profiles-1.0.0.xsd">
-</profilesXml>
\ No newline at end of file
</exclusion>
</exclusions>
</dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jaxrs</artifactId>
- </dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
</plugins>
</build>
- <profiles>
- <profile>
- <id>samples</id>
- <modules>
- <module>sample</module>
- </modules>
- </profile>
- </profiles>
-
</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.collectionobject.client.samples</artifactId>
- <packaging>pom</packaging>
- <version>5.0-SNAPSHOT</version>
- <name>collectionobject.client.samples</name>
-
- <modules>
- <module>sample</module>
- </modules>
-</project>
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.collectionobject.client.sample</artifactId>
- <packaging>jar</packaging>
- <name>collectionobject.client.sample</name>
- <version>5.0-SNAPSHOT</version>
-
- <dependencies>
- <!-- keep slf4j dependencies on the top -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.5.2</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.5.2</version>
- </dependency>
-
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.collectionobject.jaxb</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.collectionobject.client</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <repositories>
- <repository>
- <id>libs-releases-local</id>
- <name>libs-releases-local</name>
- <url>http://nightly.collectionspace.org:8081/artifactory/libs-release-local</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>libs-snapshots-local</id>
- <name>libs-snapshots-local</name>
- <url>http://nightly.collectionspace.org:8081/artifactory/libs-snapshot-local</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
-
- <build>
- <finalName>collectionobject-client-sample</finalName>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>attached</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <descriptorRefs>
- <descriptorRef>jar-with-dependencies</descriptorRef>
- </descriptorRefs>
- <archive>
- <manifest>
- <mainClass>org.collectionspace.services.collectionobject.client.sample.Sample</mainClass>
- </manifest>
- </archive>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
-
+++ /dev/null
-/**
- * This document is a part of the source code and related artifacts
- * for CollectionSpace, an open source collections management system
- * for museums and related institutions:
- *
- * http://www.collectionspace.org
- * http://wiki.collectionspace.org
- *
- * Copyright © 2009 Regents of the University of California
- *
- * Licensed under the Educational Community License (ECL), Version 2.0.
- * You may not use this file except in compliance with this License.
- *
- * You may obtain a copy of the ECL 2.0 License at
- * https://source.collectionspace.org/collection-space/LICENSE.txt
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.collectionspace.services.collectionobject.client.sample;
-
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Marshaller;
-
-import org.collectionspace.services.client.CollectionObjectClient;
-import org.collectionspace.services.client.PayloadInputPart;
-import org.collectionspace.services.client.PayloadOutputPart;
-import org.collectionspace.services.client.PoxPayloadIn;
-import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
-import org.collectionspace.services.collectionobject.CollectionobjectsCommonList;
-import org.collectionspace.services.collectionobject.ResponsibleDepartmentList;
-import org.collectionspace.services.collectionobject.domain.naturalhistory.CollectionobjectsNaturalhistory;
-
-import org.jboss.resteasy.client.ClientResponse;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Sample, sample client code for creating and accessing
- * CollectionObject records.
- *
- * $LastChangedRevision: $
- * $LastChangedDate: $
- */
-public class Sample {
-
- private static final Logger logger =
- LoggerFactory.getLogger(Sample.class);
-
- // Instance variables specific to this test.
- private CollectionObjectClient client = new CollectionObjectClient();
- final String SERVICE_PATH_COMPONENT = "collectionobjects";
-
-
- // ---------------------------------------------------------------
- // Create
- // ---------------------------------------------------------------
-
- public String createCollectionObject() {
-
- // Create a CollectionObject record to submit to the service.
- PoxPayloadOut multipart = createCollectionObjectInstance();
-
- // Submit a 'create' request to the service, sending the new
- // CollectionObject record to be created, and store the response.
- ClientResponse<Response> res = client.create(multipart);
-
- // Get the status code from the response and check it against
- // the expected status code.
- if (res.getStatus() != Response.Status.CREATED.getStatusCode()) {
- logger.error("Error creating new CollectionObject. Status code = " +
- res.getStatus());
- return "";
- } else {
- logger.info("CollectionObject created successfully.");
- }
-
- // Return the new record number for the newly-created record.
- return extractId(res);
-
- }
-
- // ---------------------------------------------------------------
- // Read
- // ---------------------------------------------------------------
-
- public PoxPayloadIn readCollectionObject(String resourceId) throws Exception {
-
- if (resourceId == null || resourceId.trim().isEmpty()) {
- throw new IllegalArgumentException(
- "Resource ID must not be null or empty.");
- }
-
- // Submit the read ("get") request to the service and store the response.
- // The resourceId is a unique identifier for the CollectionObject
- // record we're reading.
- ClientResponse<String> res = client.read(resourceId);
-
- // Get the status code from the response and check it against
- // the expected status code.
- if (res.getStatus() != Response.Status.OK.getStatusCode()) {
- logger.error("Error reading CollectionObject with" +
- "resource ID " + resourceId + ". Status code = " +
- res.getStatus());
- return null;
- }
-
- // Get the entity body of the response from the service.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
-
- return input;
-
- }
-
- private CollectionobjectsCommonList readCollectionObjectList()
- throws Exception {
-
- // Submit the read list request to the service and store the response.
- ClientResponse<CollectionobjectsCommonList> res = client.readList();
-
- // Get the status code from the response and check it against
- // the expected status code.
- if (res.getStatus() != Response.Status.OK.getStatusCode()) {
- logger.error("Error reading list of CollectionObjects. Status code = " +
- res.getStatus());
- return null;
- }
-
- CollectionobjectsCommonList list = res.getEntity();
- return list;
-
-
- }
-
- // ---------------------------------------------------------------
- // Delete
- // ---------------------------------------------------------------
-
- private void deleteCollectionObject(String resourceId) {
-
- if (resourceId == null || resourceId.trim().isEmpty()) {
- throw new IllegalArgumentException(
- "Resource ID must not be null or empty.");
- }
-
- ClientResponse res = client.delete(resourceId);
-
- // Get the status code from the response and check it against
- // the expected status code.
- if (res.getStatus() != Response.Status.OK.getStatusCode()) {
- logger.error("Error deleting CollectionObject with" +
- "resource ID " + resourceId + ". Status code = " +
- res.getStatus());
- return;
- }
-
- }
-
- private void deleteAllCollectionObjects() throws Exception {
-
- int recordsDeleted = 0;
- for (String resourceId : getAllResourceIds()) {
-
- ClientResponse res = client.delete(resourceId);
-
- // Get the status code from the response and check it against
- // the expected status code.
- if (res.getStatus() != Response.Status.OK.getStatusCode()) {
- logger.error("Error deleting CollectionObject with" +
- "resource ID " + resourceId + ". Status code = " +
- res.getStatus());
- } else {
- recordsDeleted++;
- }
- }
-
- if (logger.isInfoEnabled()) {
- logger.info("Deleted " + recordsDeleted + " CollectionObject record(s).");
- }
-
- }
-
- // ---------------------------------------------------------------
- // Utility methods
- // ---------------------------------------------------------------
-
- private PoxPayloadOut createCollectionObjectInstance() {
-
- // Create the Common part of a CollectionObject and add data to its fields.
-
- CollectionobjectsCommon collectionObject = new CollectionobjectsCommon();
- collectionObject.setObjectNumber("some object number here");
- collectionObject.getObjectNameList().getObjectNameGroup().get(0).setObjectName("some object name here");
-
-
- ResponsibleDepartmentList deptList = new ResponsibleDepartmentList();
- List<String> depts = deptList.getResponsibleDepartment();
- // @TODO Use properly formatted refNames for representative departments
- // in this example test record. The following are mere placeholders.
- depts.add("urn:org.collectionspace.services.department:Registrar");
- depts.add("urn:org.walkerart.department:Fine Art");
- collectionObject.setAge(""); // Test using an empty String.
- collectionObject.getBriefDescriptions().getBriefDescription().add("Papier mache bird mask with horns, " +
- "painted red with black and yellow spots. " +
- "Puerto Rico. ca. 8" high, 6" wide, projects 10" (with horns).");
- PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = multipart.addPart(collectionObject,
- MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(getCommonPartName());
-
- if (logger.isInfoEnabled()) {
- logger.info("CollectionObject Common part to be created:");
- logger.info(objectAsXmlString(collectionObject,
- CollectionobjectsCommon.class));
- }
-
- // Create a "domain" part of a CollectionObject and add data to its fields.
- // This part might come from a community or consortia in a particular domain.
- // There could potentially be multiple "domain" parts in a CollectionObject record.
-
- // This example adds data to fields for a hypothetical Natural History domain,
- // as in the case of the test fields below ...
-
- CollectionobjectsNaturalhistory conh = new CollectionobjectsNaturalhistory();
- conh.setNhString("test-string");
- conh.setNhInt(999);
- conh.setNhLong(9999);
-
- PayloadOutputPart nhPart = multipart.addPart(conh, MediaType.APPLICATION_XML_TYPE);
- nhPart.setLabel(getNHPartName());
-
- if (logger.isInfoEnabled()) {
- logger.info("CollectionObject Natural History part to be created:");
- logger.info(objectAsXmlString(conh,
- CollectionobjectsNaturalhistory.class));
- }
-
- // Return the multipart entity body that will be submitted in the
- // 'create' request, above.
- return multipart;
- }
-
- static Object extractPart(PoxPayloadIn input, String label, Class clazz) {
- Object obj = null;
-
- PayloadInputPart payloadInputPart = input.getPart(label);
- if (payloadInputPart != null) {
- obj = payloadInputPart.getBody();
- }
-
- return obj;
- }
-
- public void displayCollectionObject(PoxPayloadIn input)
- throws Exception {
-
- if (input == null) {
- throw new IllegalArgumentException(
- "Could not display null CollectionObject record.");
- }
-
- // Extract each part of the record, and convert it from
- // its XML representation to its associated Java object.
-
- // Read the Common part of the record.
- CollectionobjectsCommon collectionObject =
- (CollectionobjectsCommon) extractPart(input,
- client.getCommonPartName(), CollectionobjectsCommon.class);
-
- if (logger.isInfoEnabled()) {
- logger.info("CollectionObject Common part read:");
- logger.info(objectAsXmlString(collectionObject,
- CollectionobjectsCommon.class));
- }
-
- // Read the Natural History part of the record.
- CollectionobjectsNaturalhistory conh =
- (CollectionobjectsNaturalhistory) extractPart(input,
- getNHPartName(), CollectionobjectsNaturalhistory.class);
-
- if (logger.isInfoEnabled()) {
- logger.info("CollectionObject Natural History part read:");
- logger.info(objectAsXmlString(conh,
- CollectionobjectsNaturalhistory.class));
- }
-
- }
-
-
- private String getCommonPartName() {
- return client.getCommonPartName();
- }
-
- private String getNHPartName() {
- return "collectionobjects_naturalhistory";
- }
-
- private List<String> getAllResourceIds() throws Exception {
-
- CollectionobjectsCommonList list = readCollectionObjectList();
- List<String> resourceIds = new ArrayList();
- List<CollectionobjectsCommonList.CollectionObjectListItem> items =
- list.getCollectionObjectListItem();
-
- for (CollectionobjectsCommonList.CollectionObjectListItem item : items) {
- resourceIds.add(item.getCsid());
- }
-
- return resourceIds;
- }
-
- private String extractId(ClientResponse<Response> res) {
- MultivaluedMap<String, Object> mvm = res.getMetadata();
- String uri = (String) ((ArrayList<Object>) mvm.get("Location")).get(0);
- if(logger.isInfoEnabled()){
- logger.info("extractId:uri=" + uri);
- }
- String[] segments = uri.split("/");
- String id = segments[segments.length - 1];
- if(logger.isInfoEnabled()){
- logger.info("id=" + id);
- }
- return id;
- }
-
- private String objectAsXmlString(Object o, Class clazz) {
- StringWriter sw = new StringWriter();
- try{
- JAXBContext jc = JAXBContext.newInstance(clazz);
- Marshaller m = jc.createMarshaller();
- m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
- Boolean.TRUE);
- m.marshal(o, sw);
- }catch(Exception e){
- e.printStackTrace();
- }
- return sw.toString();
- }
-
- public static void main(String[] args) throws Exception {
-
- Sample sample = new Sample();
-
- // Optionally first delete all existing collection object records.
- boolean ENABLE_DELETE_ALL = false;
- if (ENABLE_DELETE_ALL) {
- logger.info("Deleting all CollectionObject records ...");
- sample.deleteAllCollectionObjects();
- }
-
- logger.info("Creating a new CollectionObject record ...");
- String newRecordId = sample.createCollectionObject();
-
- if (newRecordId == null || newRecordId.trim().isEmpty()) {
- logger.error("Could not create new record.");
- return;
- }
-
- logger.info("Reading the new CollectionObject record ...");
- PoxPayloadIn corecord = sample.readCollectionObject(newRecordId);
- sample.displayCollectionObject(corecord);
-
- logger.info("Deleting the new CollectionObject record ...");
- sample.deleteCollectionObject(newRecordId);
-
- }
-
-}
+++ /dev/null
-#url of the collectionspace server
-cspace.url=http://localhost:8180/cspace-services/
-cspace.ssl=false
-cspace.auth=true
-cspace.user=test
-cspace.password=test
\ No newline at end of file
<groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.relation.client</artifactId>
<version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.systeminfo.client</artifactId>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.collectionspace.services</groupId>
<tenant:serviceBindings id="structureddates" merge:matcher="id" name="structureddates" requiresDocumentHandler="false" type="utility"
version="1.0">
<service:repositoryDomain xmlns:service="http://collectionspace.org/services/config/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/config/service">
- org.collectionspace.services.structureddate.StructureddateDocumentHandler
- </service:documentHandler>
</tenant:serviceBindings>
<!-- end structureddate service meta-data -->
+
+ <!-- begin systeminfo service meta-data -->
+ <!-- systeminfo is a task service that has no representation in the repo, but system meta data and version. -->
+ <tenant:serviceBindings id="systeminfo" merge:matcher="id" name="systeminfo" requiresDocumentHandler="false" type="utility"
+ version="1.0">
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/config/service">default-domain</service:repositoryDomain>
+ </tenant:serviceBindings>
+ <!-- end systeminfo service meta-data -->
<!-- begin blob service meta-data -->
<!-- This should likely be type="object" -->
import org.collectionspace.services.common.storage.jpa.JpaStorageUtils;
import org.collectionspace.services.common.security.SecurityUtils;
import org.collectionspace.services.config.tenant.TenantBindingType;
+import org.collectionspace.services.systeminfo.SystemInfoClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final String STRUCTURED_DATE_REQUEST = "structureddate";
private static final String PASSWORD_RESET = "accounts/requestpasswordreset";
private static final String PROCESS_PASSWORD_RESET = "accounts/processpasswordreset";
+ private static final String SYSTEM_INFO = SystemInfoClient.SERVICE_NAME;
private static final String NUXEO_ADMIN = null;
//
// Use this thread specific member instance to hold our login context with Nuxeo
private static final String ERROR_NUXEO_LOGOUT = "Attempt to logout when Nuxeo login context was null.";
private static final String ERROR_UNBALANCED_LOGINS = "The number of Logins vs Logouts to the Nuxeo framework was unbalanced.";
- private boolean isAnonymousRequest(HttpRequest request, ResourceMethodInvoker resourceMethodInvoker) {
+ private boolean isAnonymousRequest(HttpRequest request, ResourceMethodInvoker resourceMethodInvoker) { // see C:\dev\src\cspace\services\services\JaxRsServiceProvider\src\main\webapp\WEB-INF\applicationContext-security.xml
boolean result = false;
- String resName = SecurityUtils.getResourceName(request.getUri());
- if (resName.equalsIgnoreCase(PASSWORD_RESET) || resName.equals(PROCESS_PASSWORD_RESET)) {
- return true;
+ String resName = SecurityUtils.getResourceName(request.getUri()).toLowerCase();
+ switch (resName) {
+ case PASSWORD_RESET:
+ case PROCESS_PASSWORD_RESET:
+ case SYSTEM_INFO:
+ return true;
}
-
+
Class<?> resourceClass = resourceMethodInvoker.getResourceClass();
try {
CollectionSpaceResource resourceInstance = (CollectionSpaceResource)resourceClass.newInstance();
if (children != null && (children.size() > 0)) {
for (Property prop : children ) {
String propName = prop.getName();
- logger.debug(propName);
+ logger.trace(propName);
if (prop.isPhantom() == false) {
if (prop.isScalar() == false) {
setFieldsDirty(prop.getChildren(), fieldNameSet);
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.exhibition.service</artifactId>
<name>services.exhibition.service</name>
<packaging>jar</packaging>
<dependency>
<groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.common</artifactId>
- <version>${project.version}</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.exhibition.jaxb</artifactId>
<dependency>
<groupId>org.nuxeo.ecm.core</groupId>
<artifactId>nuxeo-core-api</artifactId>
- <version>${nuxeo.core.version}</version>
<exclusions>
<exclusion>
<artifactId>jboss-remoting</artifactId>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<profilesXml xmlns="http://maven.apache.org/PROFILES/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/PROFILES/1.0.0 http://maven.apache.org/xsd/profiles-1.0.0.xsd">
-</profilesXml>
<artifactId>org.collectionspace.services.organization</artifactId>
<name>services.organization</name>
<packaging>pom</packaging>
-
- <dependencies>
- <!--
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.authority</artifactId>
- <optional>true</optional>
- <version>${project.version}</version>
- </dependency>
- -->
- </dependencies>
<modules>
<module>jaxb</module>
<module>client</module>
</modules>
- <profiles>
- <profile>
- <id>samples</id>
- <modules>
- <module>sample</module>
- </modules>
- </profile>
- </profiles>
-
</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.organization.client.samples</artifactId>
- <packaging>pom</packaging>
- <version>5.0-SNAPSHOT</version>
- <name>organization.client.samples</name>
-
- <modules>
- <module>sample</module>
- </modules>
-</project>
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.organization.client.sample</artifactId>
- <packaging>jar</packaging>
- <version>5.0-SNAPSHOT</version>
- <name>organization.client.sample</name>
-
- <dependencies>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.organization.jaxb</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.organization.client</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <repositories>
- <repository>
- <id>libs-releases-local</id>
- <name>libs-releases-local</name>
- <url>http://nightly.collectionspace.org:8081/artifactory/libs-release-local</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
-
- <repository>
- <id>libs-snapshots-local</id>
- <name>libs-snapshots-local</name>
- <url>http://nightly.collectionspace.org:8081/artifactory/libs-snapshot-local</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>collectionspace-releases</id>
- <name>collectionspace-releases</name>
- <url>http://nightly.collectionspace.org:8081/artifactory/nuxeo-public</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>nuxeo-public-snapshot</id>
- <name>nuxeo-public-snapshot</name>
- <url>http://nightly.collectionspace.org:8081/artifactory/nuxeo-public-snapshot</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
-
- <build>
- <finalName>organization-client-sample</finalName>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>attached</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <descriptorRefs>
- <descriptorRef>jar-with-dependencies</descriptorRef>
- </descriptorRefs>
- <archive>
- <manifest>
- <mainClass>org.collectionspace.services.organization.client.sample.Sample</mainClass>
- </manifest>
- </archive>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
-
+++ /dev/null
-/**
- * This document is a part of the source code and related artifacts
- * for CollectionSpace, an open source collections management system
- * for museums and related institutions:
- *
- * http://www.collectionspace.org
- * http://wiki.collectionspace.org
- *
- * Copyright (c)) 2009 Regents of the University of California
- *
- * Licensed under the Educational Community License (ECL), Version 2.0.
- * You may not use this file except in compliance with this License.
- *
- * You may obtain a copy of the ECL 2.0 License at
- * https://source.collectionspace.org/collection-space/LICENSE.txt
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.collectionspace.services.organization.client.sample;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-
-import org.apache.log4j.BasicConfigurator;
-import org.collectionspace.services.OrganizationJAXBSchema;
-import org.collectionspace.services.client.OrgAuthorityClient;
-import org.collectionspace.services.client.OrgAuthorityClientUtils;
-import org.collectionspace.services.client.PayloadInputPart;
-import org.collectionspace.services.client.PoxPayloadIn;
-import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.client.test.ServiceRequestType;
-import org.collectionspace.services.organization.OrgauthoritiesCommon;
-import org.collectionspace.services.organization.OrgauthoritiesCommonList;
-import org.collectionspace.services.organization.OrganizationsCommon;
-import org.collectionspace.services.organization.OrganizationsCommonList;
-import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.plugins.providers.multipart.InputPart;
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * OrgAuthority Sample, carries out tests against a
- * deployed and running OrgAuthority Service.
- *
- * $LastChangedRevision: 1055 $
- * $LastChangedDate: 2009-12-09 12:25:15 -0800 (Wed, 09 Dec 2009) $
- */
-public class Sample {
- private static final Logger logger =
- LoggerFactory.getLogger(Sample.class);
-
- // Instance variables specific to this test.
- private OrgAuthorityClient client = new OrgAuthorityClient();
- final String SERVICE_PATH_COMPONENT = "organizations";
- final String ITEM_SERVICE_PATH_COMPONENT = "items";
-
-
- // ---------------------------------------------------------------
- // Create
- // ---------------------------------------------------------------
- protected String createOrgAuthRefName(String orgAuthorityName) {
- return "urn:cspace:org.collectionspace.demo:orgauthority:name("
- +orgAuthorityName+")";
- }
-
- protected String createOrganizationRefName(
- String orgAuthRefName, String orgName) {
- return orgAuthRefName+":organization:name("+orgName+")";
- }
-
-
-
- public void createOrgAuthority(String orgAuthName, List<Map<String,String>> orgInfos ) {
-
- // Expected status code: 201 Created
- int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
-
- logger.info("Import: Create orgAuthority: \"" + orgAuthName +"\"");
- String baseOrgAuthRefName = createOrgAuthRefName(orgAuthName);
- String fullOrgAuthRefName = baseOrgAuthRefName+"'"+orgAuthName+"'";
- PoxPayloadOut multipart =
- OrgAuthorityClientUtils.createOrgAuthorityInstance(
- orgAuthName, fullOrgAuthRefName,
- client.getCommonPartName());
- ClientResponse<Response> res = client.create(multipart);
-
- int statusCode = res.getStatus();
-
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not create enumeration: \""+orgAuthName
- +"\" "+ OrgAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when creating enumeration: \""
- +orgAuthName +"\", Status:"+ statusCode);
- }
-
- // Store the ID returned from this create operation
- // for additional tests below.
- String newOrgAuthId = OrgAuthorityClientUtils.extractId(res);
- logger.info("Import: Created orgAuthority: \"" + orgAuthName +"\" ID:"
- +newOrgAuthId );
-
- // Add items to the orgAuthority
- for(Map<String,String> orgInfo : orgInfos){
- createItemInOrgAuth(newOrgAuthId, baseOrgAuthRefName, orgInfo);
- }
-
- }
-
- private String createItemInOrgAuth(String vcsid,
- String orgAuthorityRefName, Map<String,String> orgInfo) {
- // Expected status code: 201 Created
- int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
- String shortName = orgInfo.get(OrganizationJAXBSchema.SHORT_NAME);
- String refName = createOrganizationRefName(
- orgAuthorityRefName, shortName)+"'"+shortName+"'";
-
-
- logger.info("Import: Create Item: \""+shortName+
- "\" in orgAuthority: \"" + orgAuthorityRefName +"\"");
- PoxPayloadOut multipart =
- OrgAuthorityClientUtils.createOrganizationInstance(refName, orgInfo, client.getItemCommonPartName() );
-
- ClientResponse<Response> res = client.createItem(vcsid, multipart);
-
- int statusCode = res.getStatus();
-
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not create Item: \""+shortName
- +"\" in orgAuthority: \"" + orgAuthorityRefName
- +"\" "+ OrgAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when creating Item: \""+shortName
- +"\" in orgAuthority: \"" + orgAuthorityRefName +
- "\", Status:"+ statusCode);
- }
-
- return OrgAuthorityClientUtils.extractId(res);
- }
-
-
- // ---------------------------------------------------------------
- // Read
- // ---------------------------------------------------------------
-
- private OrgauthoritiesCommonList readOrgAuthorities() {
-
- // Expected status code: 200 OK
- int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.READ;
-
- // Submit the request to the service and store the response.
- ClientResponse<OrgauthoritiesCommonList> res = client.readList();
- OrgauthoritiesCommonList list = res.getEntity();
-
- int statusCode = res.getStatus();
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not read list of orgAuthorities: "
- + OrgAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when reading " +
- "list of orgAuthorities, Status:"+ statusCode);
- }
-
- return list;
- }
-
- private List<String> readOrgAuthorityIds(OrgauthoritiesCommonList list) {
-
- List<String> ids = new ArrayList<String>();
- List<OrgauthoritiesCommonList.OrgauthorityListItem> orgAuthorities =
- list.getOrgauthorityListItem();
- for (OrgauthoritiesCommonList.OrgauthorityListItem orgAuthority : orgAuthorities) {
- ids.add(orgAuthority.getCsid());
- }
- return ids;
- }
-
- private OrgauthoritiesCommon readOrgAuthority(String orgAuthId) {
-
- // Expected status code: 200 OK
- int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.READ;
-
- // Submit the request to the service and store the response.
- OrgauthoritiesCommon orgAuthority = null;
- try {
- ClientResponse<String> res = client.read(orgAuthId);
- int statusCode = res.getStatus();
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not read orgAuthority"
- + OrgAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when reading " +
- "orgAuthority, Status:"+ statusCode);
- }
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- PayloadInputPart orgAuthorityPart = input.getPart(client.getCommonPartName());
- orgAuthority = (OrgauthoritiesCommon) orgAuthorityPart.getBody();
- } catch (Exception e) {
- throw new RuntimeException("Could not read orgAuthority: ", e);
- }
-
- return orgAuthority;
- }
-
- private OrganizationsCommonList readItemsInOrgAuth(String orgAuthId) {
-
- // Expected status code: 200 OK
- int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.READ;
-
- // Submit the request to the service and store the response.
-
- //was: ClientResponse<OrganizationsCommonList> res = client.readItemList(orgAuthId);
- //new API: readItemList(String inAuthority, String partialTerm, String keywords)
- ClientResponse<OrganizationsCommonList> res = client.readItemList(orgAuthId, "", "");//TODO: .New call, most certainly wrong. Just trying to get this to compile. Laramie20100728
-
- OrganizationsCommonList list = res.getEntity();
-
- int statusCode = res.getStatus();
-
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not read items in orgAuthority: "
- + OrgAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when reading " +
- "items in orgAuthority, Status:"+ statusCode);
- }
-
- return list;
- }
-
- private List<String> readOrganizationIds(OrganizationsCommonList list) {
-
- List<String> ids = new ArrayList<String>();
- List<OrganizationsCommonList.OrganizationListItem> items =
- list.getOrganizationListItem();
- for (OrganizationsCommonList.OrganizationListItem item : items) {
- ids.add(item.getCsid());
- }
- return ids;
- }
-
- // ---------------------------------------------------------------
- // Delete
- // ---------------------------------------------------------------
-
- private void deleteOrgAuthority(String vcsid) {
- // Expected status code: 200 OK
- int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.DELETE;
-
- ClientResponse<Response> res = client.delete(vcsid);
- int statusCode = res.getStatus();
-
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not delete orgAuthority: "
- + OrgAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when deleting " +
- "orgAuthority, Status:"+ statusCode);
- }
- }
-
- private void deleteAllOrgAuthorities() {
- List<String> ids = readOrgAuthorityIds(readOrgAuthorities());
- for (String id : ids) {
- deleteOrgAuthority(id);
- }
- }
-
- private void deleteOrganization(String vcsid, String itemcsid) {
- // Expected status code: 200 OK
- int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.DELETE;
-
- ClientResponse<Response> res = client.deleteItem(vcsid, itemcsid);
- int statusCode = res.getStatus();
-
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not delete orgAuthority item: "
- + OrgAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when deleting " +
- "orgAuthority item, Status:"+ statusCode);
- }
- }
-
- private void deleteAllItemsForOrgAuth(String orgAuthId) {
- List<String> itemIds = readOrganizationIds(readItemsInOrgAuth(orgAuthId));
- for (String itemId : itemIds) {
- deleteOrganization(orgAuthId, itemId);
- }
- }
-
- // ---------------------------------------------------------------
- // Utility methods used by tests above
- // ---------------------------------------------------------------
-
-
- // Retrieve individual fields of orgAuthority records.
-
- private String displayAllOrgAuthorities(OrgauthoritiesCommonList list) {
- StringBuffer sb = new StringBuffer();
- List<OrgauthoritiesCommonList.OrgauthorityListItem> orgAuthorities =
- list.getOrgauthorityListItem();
- int i = 0;
- for (OrgauthoritiesCommonList.OrgauthorityListItem orgAuthority : orgAuthorities) {
- sb.append("orgAuthority [" + i + "]" + "\n");
- sb.append(displayOrgAuthorityDetails(orgAuthority));
- i++;
- }
- return sb.toString();
- }
-
- private String displayOrgAuthorityDetails(
- OrgauthoritiesCommonList.OrgauthorityListItem orgAuthority) {
- StringBuffer sb = new StringBuffer();
- sb.append("displayName=" + orgAuthority.getDisplayName() + "\n");
- sb.append("vocabType=" + orgAuthority.getVocabType() + "\n");
- // sb.append("csid=" + orgAuthority.getCsid() + "\n");
- sb.append("URI=" + orgAuthority.getUri() + "\n");
- return sb.toString();
- }
-
- // Retrieve individual fields of organization records.
-
- private String displayAllOrganizations(OrganizationsCommonList list) {
- StringBuffer sb = new StringBuffer();
- List<OrganizationsCommonList.OrganizationListItem> items =
- list.getOrganizationListItem();
- int i = 0;
- for (OrganizationsCommonList.OrganizationListItem item : items) {
- sb.append("organization [" + i + "]" + "\n");
- sb.append(displayOrganizationDetails(item));
- i++;
- }
- return sb.toString();
- }
-
- private String displayOrganizationDetails(
- OrganizationsCommonList.OrganizationListItem item) {
- StringBuffer sb = new StringBuffer();
- sb.append("csid=" + item.getCsid() + "\n");
- sb.append("displayName=" + item.getDisplayName() + "\n");
- // sb.append("URI=" + item.getUri() + "\n");
- return sb.toString();
- }
-
-// private Object extractPart(PoxPayloadIn input, String label,
-// Class clazz) throws Exception {
-// Object obj = null;
-// for(PayloadInputPart part : input.getParts()){
-// String partLabel = part.getHeaders().getFirst("label");
-// if(label.equalsIgnoreCase(partLabel)){
-// String partStr = part.getBodyAsString();
-// if(logger.isDebugEnabled()){
-// logger.debug("extracted part str=\n" + partStr);
-// }
-// obj = part.getBody(clazz, null);
-// if(logger.isDebugEnabled()){
-// logger.debug("extracted part obj=\n", obj, clazz);
-// }
-// break;
-// }
-// }
-// return obj;
-// }
-
- public static void main(String[] args) {
-
- // Configure logging.
- BasicConfigurator.configure();
-
- logger.info("OrgAuthority Sample starting...");
-
- Sample sample = new Sample();
- OrgauthoritiesCommonList orgAuthorities;
- List<String> orgAuthIds;
- String details = "";
-
- // Optionally delete all orgAuthorities and organizations.
-
- boolean ENABLE_DELETE_ALL = false;
- if (ENABLE_DELETE_ALL) {
-
- logger.info("Deleting all organizations and orgAuthorities ...");
-
- // For each orgAuthority ...
- orgAuthorities = sample.readOrgAuthorities();
- orgAuthIds = sample.readOrgAuthorityIds(orgAuthorities);
- for (String orgAuthId : orgAuthIds) {
- logger.info("Deleting all organizations for orgAuthority ...");
- sample.deleteAllItemsForOrgAuth(orgAuthId);
- logger.info("Deleting orgAuthority ...");
- sample.deleteOrgAuthority(orgAuthId);
- }
-
- logger.info("Reading orgAuthorities after deletion ...");
- orgAuthorities = sample.readOrgAuthorities();
- details = sample.displayAllOrgAuthorities(orgAuthorities);
- logger.info(details);
-
- logger.info("Reading items in each orgAuthority after deletion ...");
- orgAuthIds = sample.readOrgAuthorityIds(orgAuthorities);
- for (String orgAuthId : orgAuthIds) {
- OrganizationsCommonList items = sample.readItemsInOrgAuth(orgAuthId);
- details = sample.displayAllOrganizations(items);
- logger.info(details);
- }
-
- }
-
- // Create new authorities, each populated with organizations.
- Map<String, String> mmiOrgMap = new HashMap<String,String>();
- mmiOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "MMI");
- mmiOrgMap.put(OrganizationJAXBSchema.LONG_NAME, "Museum of the Moving Image");
- //mmiOrgMap.put(OrganizationJAXBSchema.CONTACT_NAME, "Megan Forbes");
- mmiOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, "1984");
- mmiOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, "Astoria, NY");
- Map<String, String> pahmaOrgMap = new HashMap<String,String>();
- pahmaOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "PAHMA");
- pahmaOrgMap.put(OrganizationJAXBSchema.LONG_NAME, "Phoebe A. Hearst Museum of Anthropology");
- pahmaOrgMap.put(OrganizationJAXBSchema.NAME_ADDITIONS, "University of California, Berkeley");
- //pahmaOrgMap.put(OrganizationJAXBSchema.CONTACT_NAME, "Michael Black");
- pahmaOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, "1901");
- pahmaOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, "Berkeley, CA");
- Map<String, String> savoyOrgMap = new HashMap<String,String>();
- savoyOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "Savoy Theatre");
- savoyOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, "1900");
- savoyOrgMap.put(OrganizationJAXBSchema.DISSOLUTION_DATE, "1952");
- savoyOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, "New York, NY");
- List<Map<String, String>> orgMaps =
- Arrays.asList(mmiOrgMap, pahmaOrgMap, savoyOrgMap );
-
- sample.createOrgAuthority("Sample Org Authority", orgMaps);
-
- logger.info("OrgAuthority Sample complete.");
-
- logger.info("Reading orgAuthorities and items ...");
- // Get a list of orgAuthorities.
- orgAuthorities = sample.readOrgAuthorities();
- // For each orgAuthority ...
- for (OrgauthoritiesCommonList.OrgauthorityListItem
- orgAuthority : orgAuthorities.getOrgauthorityListItem()) {
- // Get its display name.
- logger.info(orgAuthority.getDisplayName());
- // Get a list of the organizations in this orgAuthority.
- OrganizationsCommonList items =
- sample.readItemsInOrgAuth(orgAuthority.getCsid());
- // For each organization ...
- for (OrganizationsCommonList.OrganizationListItem
- item : items.getOrganizationListItem()) {
- // Get its display name.
- logger.info(" " + item.getDisplayName());
- }
- }
-
- // Sample alternate methods of reading all orgAuthorities and
- // organizations separately.
- boolean RUN_ADDITIONAL_SAMPLES = false;
- if (RUN_ADDITIONAL_SAMPLES) {
-
- logger.info("Reading all orgAuthorities ...");
- details = sample.displayAllOrgAuthorities(orgAuthorities);
- logger.info(details);
-
- logger.info("Reading all organizations ...");
- orgAuthIds = sample.readOrgAuthorityIds(orgAuthorities);
- for (String orgAuthId : orgAuthIds) {
- OrganizationsCommonList items = sample.readItemsInOrgAuth(orgAuthId);
- details = sample.displayAllOrganizations(items);
- logger.info(details);
- }
-
- }
-
- }
-
-}
+++ /dev/null
-#url of the collectionspace server
-cspace.url=http://localhost:8180/cspace-services/
-cspace.ssl=false
-cspace.auth=false
-cspace.user=test
-cspace.password=test
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
-
- <appender name="console" class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.out" />
- <layout class="org.apache.log4j.TTCCLayout">
- <param name="DateFormat" value="ISO8601" />
- </layout>
- </appender>
-
- <logger name="org.apache.commons.httpclient" additivity="false">
- <level value="warn" />
- <appender-ref ref="console" />
- </logger>
-
- <logger name="httpclient.wire" additivity="false">
- <level value="info" />
- <appender-ref ref="console" />
- </logger>
-
-<!--
- <logger name="org.collectionspace.services.organization.client.sample.Sample" additivity="false">
- <level value="debug" />
- <appender-ref ref="console" />
- </logger>
--->
-
- <root>
- <priority value="debug" />
- <appender-ref ref="console" />
- </root>
-
-</log4j:configuration>
-
-
-
-
<module>3rdparty</module>
<module>client</module>
</modules>
-
- <profiles>
- <profile>
- <id>samples</id>
- <modules>
- <module>sample</module>
- </modules>
- </profile>
- </profiles>
-
+
</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.person.client.samples</artifactId>
- <packaging>pom</packaging>
- <version>1.0</version>
- <name>person.client.samples</name>
-
- <modules>
- <module>sample</module>
- </modules>
-</project>
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.person.client.sample</artifactId>
- <packaging>jar</packaging>
- <version>1.0</version>
- <name>person.client.sample</name>
-
- <dependencies>
- <!--
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.person.jaxb</artifactId>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.client</artifactId>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.person.client</artifactId>
- </dependency>
- -->
- </dependencies>
-
- <repositories>
- <repository>
- <id>libs-releases-local</id>
- <name>libs-releases-local</name>
- <url>http://nightly.collectionspace.org:8081/artifactory/libs-release-local</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
-
- <repository>
- <id>libs-snapshots-local</id>
- <name>libs-snapshots-local</name>
- <url>http://nightly.collectionspace.org:8081/artifactory/libs-snapshot-local</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>nuxeo-public</id>
- <name>nuxeo-public</name>
- <url>http://nightly.collectionspace.org:8081/artifactory/nuxeo-public</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>nuxeo-public-snapshot</id>
- <name>nuxeo-public-snapshot</name>
- <url>http://nightly.collectionspace.org:8081/artifactory/nuxeo-public-snapshot</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
-
- <build>
- <finalName>person-client-sample</finalName>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>attached</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <descriptorRefs>
- <descriptorRef>jar-with-dependencies</descriptorRef>
- </descriptorRefs>
- <archive>
- <manifest>
- <mainClass>org.collectionspace.services.person.client.sample.Sample</mainClass>
- </manifest>
- </archive>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
-
+++ /dev/null
-/**
- * This document is a part of the source code and related artifacts
- * for CollectionSpace, an open source collections management system
- * for museums and related institutions:
- *
- * http://www.collectionspace.org
- * http://wiki.collectionspace.org
- *
- * Copyright (c)) 2009 Regents of the University of California
- *
- * Licensed under the Educational Community License (ECL), Version 2.0.
- * You may not use this file except in compliance with this License.
- *
- * You may obtain a copy of the ECL 2.0 License at
- * https://source.collectionspace.org/collection-space/LICENSE.txt
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.collectionspace.services.person.client.sample;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-
-import org.apache.log4j.BasicConfigurator;
-import org.collectionspace.services.PersonJAXBSchema;
-import org.collectionspace.services.client.PersonAuthorityClient;
-import org.collectionspace.services.client.PersonAuthorityClientUtils;
-import org.collectionspace.services.client.PoxPayloadIn;
-import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.client.test.ServiceRequestType;
-import org.collectionspace.services.person.PersonauthoritiesCommon;
-import org.collectionspace.services.person.PersonauthoritiesCommonList;
-import org.collectionspace.services.person.PersonsCommon;
-import org.collectionspace.services.person.PersonsCommonList;
-import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.plugins.providers.multipart.InputPart;
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * PersonAuthority Sample, carries out tests against a
- * deployed and running PersonAuthority Service.
- *
- * $LastChangedRevision: 1055 $
- * $LastChangedDate: 2009-12-09 12:25:15 -0800 (Wed, 09 Dec 2009) $
- */
-public class Sample {
- private static final Logger logger =
- LoggerFactory.getLogger(Sample.class);
-
- // Instance variables specific to this test.
- private PersonAuthorityClient client = new PersonAuthorityClient();
- final String SERVICE_PATH_COMPONENT = "persons";
- final String ITEM_SERVICE_PATH_COMPONENT = "items";
-
-
- // ---------------------------------------------------------------
- // Create
- // ---------------------------------------------------------------
-
- public void createPersonAuthority(String personAuthorityName,
- List<Map<String, String>> personMaps ) {
-
- // Expected status code: 201 Created
- int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
-
- logger.info("Import: Create personAuthority: \"" + personAuthorityName +"\"");
-
-
- String displaySuffix = "displayName-" + System.currentTimeMillis(); //TODO: Laramie20100728 temp fix, made-up displaySuffix.
- String basePersonRefName = PersonAuthorityClientUtils.createPersonAuthRefName(personAuthorityName, displaySuffix);//TODO: Laramie20100728 temp fix was personAuthorityName, false
- String fullPersonRefName = PersonAuthorityClientUtils.createPersonAuthRefName(personAuthorityName, displaySuffix); //TODO: Laramie20100728 temp fix was personAuthorityName, true
- PoxPayloadOut multipart =
- PersonAuthorityClientUtils.createPersonAuthorityInstance(
- personAuthorityName, fullPersonRefName, client.getCommonPartName() );
- ClientResponse<Response> res = client.create(multipart);
-
- int statusCode = res.getStatus();
-
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not create enumeration: \""+personAuthorityName
- +"\" "+ PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when creating enumeration: \""
- +personAuthorityName +"\", Status:"+ statusCode);
- }
-
- // Store the ID returned from this create operation
- // for additional tests below.
- String newPersonAuthId = PersonAuthorityClientUtils.extractId(res);
- logger.info("Import: Created personAuthority: \"" + personAuthorityName +"\" ID:"
- +newPersonAuthId );
-
- // Add items to the personAuthority
- for(Map<String,String> personMap : personMaps){
- createItemInAuthority(newPersonAuthId, basePersonRefName, personMap);
- }
-
- }
-
- private String createItemInAuthority(String vcsid,
- String personAuthorityRefName, Map<String,String> personMap) {
- // Expected status code: 201 Created
- int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
- String foreName = personMap.get(PersonJAXBSchema.FORE_NAME);
- String middleName = personMap.get(PersonJAXBSchema.MIDDLE_NAME);
- String surName = personMap.get(PersonJAXBSchema.SUR_NAME);
- String birthDate = personMap.get(PersonJAXBSchema.BIRTH_DATE);
- String deathDate = personMap.get(PersonJAXBSchema.DEATH_DATE);
- StringBuilder builtName = new StringBuilder();
- if(foreName!=null)
- builtName.append(foreName);
- if(middleName!=null)
- builtName.append(middleName);
- if(surName!=null)
- builtName.append(surName);
- if(birthDate!=null)
- builtName.append(birthDate);
- builtName.append("-");
- if(deathDate!=null)
- builtName.append(deathDate);
-
- String displaySuffix = "displayName-" + System.currentTimeMillis(); //TODO: Laramie20100728 temp fix, made-up displaySuffix.
-
- String refName = PersonAuthorityClientUtils.createPersonRefName(personAuthorityRefName, builtName.toString(), displaySuffix); //TODO was ...,true);
- logger.info("Import: Create Item: \""+refName+"\" in personAuthority: \"" + personAuthorityRefName +"\"");
-
- if(logger.isDebugEnabled()){
- logger.debug("Import: Create Item: \""+builtName.toString()
- +"\" in personAuthorityulary: \"" + personAuthorityRefName +"\"");
- }
- PoxPayloadOut multipart = createPersonInstance( vcsid, refName,
- personMap );
- ClientResponse<Response> res = client.createItem(vcsid, multipart);
-
- int statusCode = res.getStatus();
-
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not create Item: \""+refName
- +"\" in personAuthority: \"" + personAuthorityRefName
- +"\" "+ PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when creating Item: \""+refName
- +"\" in personAuthority: \"" + personAuthorityRefName +"\", Status:"+ statusCode);
- }
-
- return PersonAuthorityClientUtils.extractId(res);
- }
-
-
- // ---------------------------------------------------------------
- // Read
- // ---------------------------------------------------------------
-
- private PersonauthoritiesCommonList readPersonAuthorities() {
-
- // Expected status code: 200 OK
- int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.READ;
-
- // Submit the request to the service and store the response.
- ClientResponse<PersonauthoritiesCommonList> res = client.readList();
- PersonauthoritiesCommonList list = res.getEntity();
-
- int statusCode = res.getStatus();
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not read list of personAuthorities: "
- + PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when reading " +
- "list of personAuthorities, Status:"+ statusCode);
- }
-
- return list;
- }
-
- private List<String> readPersonAuthorityIds(PersonauthoritiesCommonList list) {
-
- List<String> ids = new ArrayList<String>();
- List<PersonauthoritiesCommonList.PersonauthorityListItem> personAuthorities =
- list.getPersonauthorityListItem();
- for (PersonauthoritiesCommonList.PersonauthorityListItem personAuthority : personAuthorities) {
- ids.add(personAuthority.getCsid());
- }
- return ids;
- }
-
- private PersonauthoritiesCommon readPersonAuthority(String personAuthId) {
-
- // Expected status code: 200 OK
- int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.READ;
-
- // Submit the request to the service and store the response.
- PersonauthoritiesCommon personAuthority = null;
- try {
- ClientResponse<String> res = client.read(personAuthId);
- int statusCode = res.getStatus();
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not read personAuthority"
- + PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when reading " +
- "personAuthority, Status:"+ statusCode);
- }
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- personAuthority = (PersonauthoritiesCommon) extractPart(input,
- client.getCommonPartName(), PersonauthoritiesCommon.class);
- } catch (Exception e) {
- throw new RuntimeException("Could not read personAuthority: ", e);
- }
-
- return personAuthority;
- }
-
- private PersonsCommonList readItemsInPersonAuth(String personAuthId) {
-
- // Expected status code: 200 OK
- int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.READ;
-
- // Submit the request to the service and store the response.
- ClientResponse<PersonsCommonList> res = client.readItemList(personAuthId, "", ""); //TODO: Laramie201007289 added empty strings to satisfy api
- PersonsCommonList list = res.getEntity();
-
- int statusCode = res.getStatus();
-
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not read items in personAuthority: "
- + PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when reading " +
- "items in personAuthority, Status:"+ statusCode);
- }
-
- return list;
- }
-
- private List<String> readPersonIds(PersonsCommonList list) {
-
- List<String> ids = new ArrayList<String>();
- List<PersonsCommonList.PersonListItem> items =
- list.getPersonListItem();
- for (PersonsCommonList.PersonListItem item : items) {
- ids.add(item.getCsid());
- }
- return ids;
- }
-
- // ---------------------------------------------------------------
- // Delete
- // ---------------------------------------------------------------
-
- private void deletePersonAuthority(String vcsid) {
- // Expected status code: 200 OK
- int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.DELETE;
-
- ClientResponse<Response> res = client.delete(vcsid);
- int statusCode = res.getStatus();
-
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not delete personAuthority: "
- + PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when deleting " +
- "personAuthority, Status:"+ statusCode);
- }
- }
-
- private void deleteAllPersonAuthorities() {
- List<String> ids = readPersonAuthorityIds(readPersonAuthorities());
- for (String id : ids) {
- deletePersonAuthority(id);
- }
- }
-
- private void deletePerson(String vcsid, String itemcsid) {
- // Expected status code: 200 OK
- int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.DELETE;
-
- ClientResponse<Response> res = client.deleteItem(vcsid, itemcsid);
- int statusCode = res.getStatus();
-
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not delete personAuthority item: "
- + PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when deleting " +
- "personAuthority item, Status:"+ statusCode);
- }
- }
-
- private void deleteAllItemsForPersonAuth(String personAuthId) {
- List<String> itemIds = readPersonIds(readItemsInPersonAuth(personAuthId));
- for (String itemId : itemIds) {
- deletePerson(personAuthId, itemId);
- }
- }
-
- // ---------------------------------------------------------------
- // Utility methods used by tests above
- // ---------------------------------------------------------------
-
- /*
- private PoxPayloadOut createPersonAuthorityInstance(
- String displayName, String refName ) {
- PersonauthoritiesCommon personAuthority = new PersonauthoritiesCommon();
- personAuthority.setDisplayName(displayName);
- personAuthority.setRefName(refName);
- personAuthority.setVocabType("PersonAuthority");
- PoxPayloadOut multipart = new PoxPayloadOut();
- OutputPart commonPart = multipart.addPart(personAuthority, MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", client.getCommonPartName());
-
- if(logger.isDebugEnabled()){
- logger.debug("to be created, personAuthority common ",
- personAuthority, PersonauthoritiesCommon.class);
- }
-
- return multipart;
- }
- */
-
- private PoxPayloadOut createPersonInstance(String inAuthority,
- String refName, Map<String, String> personInfo ) {
- PersonsCommon person = new PersonsCommon();
- person.setInAuthority(inAuthority);
- person.setRefName(refName);
- String value = null;
- if((value = (String)personInfo.get(PersonJAXBSchema.FORE_NAME))!=null)
- person.setForeName(value);
- if((value = (String)personInfo.get(PersonJAXBSchema.MIDDLE_NAME))!=null)
- person.setMiddleName(value);
- if((value = (String)personInfo.get(PersonJAXBSchema.SUR_NAME))!=null)
- person.setSurName(value);
- if((value = (String)personInfo.get(PersonJAXBSchema.INITIALS))!=null)
- person.setInitials(value);
- if((value = (String)personInfo.get(PersonJAXBSchema.SALUTATIONS))!=null)
- person.setSalutation(value);
- if((value = (String)personInfo.get(PersonJAXBSchema.TITLE))!=null)
- person.setTitle(value);
- if((value = (String)personInfo.get(PersonJAXBSchema.NAME_ADDITIONS))!=null)
- person.setNameAdditions(value);
- if((value = (String)personInfo.get(PersonJAXBSchema.BIRTH_DATE))!=null) {
- StructuredDateGroup birthDate = new StructuredDateGroup();
- birthDate.setDateDisplayDate(value);
- person.setBirthDateGroup(birthDate);
- }
- if((value = (String)personInfo.get(PersonJAXBSchema.DEATH_DATE))!=null) {
- StructuredDateGroup deathDate = new StructuredDateGroup();
- deathDate.setDateDisplayDate(value);
- person.setDeathDateGroup(deathDate);
- }
- if((value = (String)personInfo.get(PersonJAXBSchema.BIRTH_PLACE))!=null)
- person.setBirthPlace(value);
- if((value = (String)personInfo.get(PersonJAXBSchema.DEATH_PLACE))!=null)
- person.setDeathPlace(value);
-
- /* TODO: Laramie20100728 removed missing member calls
- if((value = (String)personInfo.get(PersonJAXBSchema.GROUP))!=null)
- person.setGroup(value);
- if((value = (String)personInfo.get(PersonJAXBSchema.NATIONALITY))!=null)
- person.setNationality(value);
- if((value = (String)personInfo.get(PersonJAXBSchema.OCCUPATION))!=null)
- person.setOccupation(value);
- if((value = (String)personInfo.get(PersonJAXBSchema.SCHOOL_OR_STYLE))!=null)
- person.setSchoolOrStyle(value);
- */
-
- if((value = (String)personInfo.get(PersonJAXBSchema.GENDER))!=null)
- person.setGender(value);
- if((value = (String)personInfo.get(PersonJAXBSchema.BIO_NOTE))!=null)
- person.setBioNote(value);
- if((value = (String)personInfo.get(PersonJAXBSchema.NAME_NOTE))!=null)
- person.setNameNote(value);
- PoxPayloadOut multipart = new PoxPayloadOut();
- OutputPart commonPart = multipart.addPart(person,
- MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", client.getItemCommonPartName());
-
- if(logger.isDebugEnabled()){
- logger.debug("to be created, person common"+person);
- }
-
- return multipart;
- }
-
- // Retrieve individual fields of personAuthority records.
-
- private String displayAllPersonAuthorities(PersonauthoritiesCommonList list) {
- StringBuffer sb = new StringBuffer();
- List<PersonauthoritiesCommonList.PersonauthorityListItem> personAuthorities =
- list.getPersonauthorityListItem();
- int i = 0;
- for (PersonauthoritiesCommonList.PersonauthorityListItem personAuthority : personAuthorities) {
- sb.append("personAuthority [" + i + "]" + "\n");
- sb.append(displayPersonAuthorityDetails(personAuthority));
- i++;
- }
- return sb.toString();
- }
-
- private String displayPersonAuthorityDetails(
- PersonauthoritiesCommonList.PersonauthorityListItem personAuthority) {
- StringBuffer sb = new StringBuffer();
- sb.append("displayName=" + personAuthority.getDisplayName() + "\n");
- sb.append("vocabType=" + personAuthority.getVocabType() + "\n");
- // sb.append("csid=" + personAuthority.getCsid() + "\n");
- sb.append("URI=" + personAuthority.getUri() + "\n");
- return sb.toString();
- }
-
- // Retrieve individual fields of person records.
-
- private String displayAllPersons(PersonsCommonList list) {
- StringBuffer sb = new StringBuffer();
- List<PersonsCommonList.PersonListItem> items =
- list.getPersonListItem();
- int i = 0;
- for (PersonsCommonList.PersonListItem item : items) {
- sb.append("person [" + i + "]" + "\n");
- sb.append(displayPersonDetails(item));
- i++;
- }
- return sb.toString();
- }
-
- private String displayPersonDetails(
- PersonsCommonList.PersonListItem item) {
- StringBuffer sb = new StringBuffer();
- sb.append("csid=" + item.getCsid() + "\n");
- sb.append("displayName=" + item.getDisplayName() + "\n");
- // sb.append("URI=" + item.getUri() + "\n");
- return sb.toString();
- }
-
- private Object extractPart(PoxPayloadIn input, String label,
- Class clazz) throws Exception {
- Object obj = null;
- for(InputPart part : input.getParts()){
- String partLabel = part.getHeaders().getFirst("label");
- if(label.equalsIgnoreCase(partLabel)){
- String partStr = part.getBodyAsString();
- if(logger.isDebugEnabled()){
- logger.debug("extracted part str=\n" + partStr);
- }
- obj = part.getBody(clazz, null);
- if(logger.isDebugEnabled()){
- logger.debug("extracted part obj=\n", obj, clazz);
- }
- break;
- }
- }
- return obj;
- }
-
- public static void main(String[] args) {
-
- // Configure logging.
- BasicConfigurator.configure();
-
- logger.info("PersonAuthority Sample starting...");
-
- Sample sample = new Sample();
- PersonauthoritiesCommonList personAuthorities;
- List<String> personAuthIds;
- String details = "";
-
- // Optionally delete all personAuthorities and persons.
-
- boolean ENABLE_DELETE_ALL = false;
- if (ENABLE_DELETE_ALL) {
-
- logger.info("Deleting all persons and personAuthorities ...");
-
- // For each personAuthority ...
- personAuthorities = sample.readPersonAuthorities();
- personAuthIds = sample.readPersonAuthorityIds(personAuthorities);
- for (String personAuthId : personAuthIds) {
- logger.info("Deleting all persons for personAuthority ...");
- sample.deleteAllItemsForPersonAuth(personAuthId);
- logger.info("Deleting personAuthority ...");
- sample.deletePersonAuthority(personAuthId);
- }
-
- logger.info("Reading personAuthorities after deletion ...");
- personAuthorities = sample.readPersonAuthorities();
- details = sample.displayAllPersonAuthorities(personAuthorities);
- logger.info(details);
-
- logger.info("Reading items in each personAuthority after deletion ...");
- personAuthIds = sample.readPersonAuthorityIds(personAuthorities);
- for (String personAuthId : personAuthIds) {
- PersonsCommonList items = sample.readItemsInPersonAuth(personAuthId);
- details = sample.displayAllPersons(items);
- logger.info(details);
- }
-
- }
-
- // Create new authorities, each populated with persons.
-
- Map<String, String> johnWayneMap = new HashMap<String,String>();
- johnWayneMap.put(PersonJAXBSchema.FORE_NAME, "John");
- johnWayneMap.put(PersonJAXBSchema.SUR_NAME, "Wayne");
- johnWayneMap.put(PersonJAXBSchema.GENDER, "male");
- Map<String, String> patrickSchmitzMap = new HashMap<String,String>();
- patrickSchmitzMap.put(PersonJAXBSchema.FORE_NAME, "Patrick");
- patrickSchmitzMap.put(PersonJAXBSchema.SUR_NAME, "Schmitz");
- patrickSchmitzMap.put(PersonJAXBSchema.GENDER, "male");
- Map<String, String> janeDoeMap = new HashMap<String,String>();
- janeDoeMap.put(PersonJAXBSchema.FORE_NAME, "Jane");
- janeDoeMap.put(PersonJAXBSchema.SUR_NAME, "Doe");
- janeDoeMap.put(PersonJAXBSchema.GENDER, "female");
- List<Map<String, String>> personsMaps =
- Arrays.asList(johnWayneMap, patrickSchmitzMap, janeDoeMap );
-
- sample.createPersonAuthority("Sample Person Auth", personsMaps);
-
- logger.info("PersonAuthority Sample complete.");
-
- logger.info("Reading personAuthorities and items ...");
- // Get a list of personAuthorities.
- personAuthorities = sample.readPersonAuthorities();
- // For each personAuthority ...
- for (PersonauthoritiesCommonList.PersonauthorityListItem
- personAuthority : personAuthorities.getPersonauthorityListItem()) {
- // Get its display name.
- logger.info(personAuthority.getDisplayName());
- // Get a list of the persons in this personAuthority.
- PersonsCommonList items =
- sample.readItemsInPersonAuth(personAuthority.getCsid());
- // For each person ...
- for (PersonsCommonList.PersonListItem
- item : items.getPersonListItem()) {
- // Get its short name.
- logger.info(" " + item.getDisplayName());
- }
- }
-
- // Sample alternate methods of reading all personAuthorities and
- // persons separately.
- boolean RUN_ADDITIONAL_SAMPLES = false;
- if (RUN_ADDITIONAL_SAMPLES) {
-
- logger.info("Reading all personAuthorities ...");
- details = sample.displayAllPersonAuthorities(personAuthorities);
- logger.info(details);
-
- logger.info("Reading all persons ...");
- personAuthIds = sample.readPersonAuthorityIds(personAuthorities);
- for (String personAuthId : personAuthIds) {
- PersonsCommonList items = sample.readItemsInPersonAuth(personAuthId);
- details = sample.displayAllPersons(items);
- logger.info(details);
- }
-
- }
-
- }
-
-}
+++ /dev/null
-#url of the collectionspace server
-cspace.url=http://localhost:8180/cspace-services/
-cspace.ssl=false
-cspace.auth=false
-cspace.user=test
-cspace.password=test
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
-
- <appender name="console" class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.out" />
- <layout class="org.apache.log4j.TTCCLayout">
- <param name="DateFormat" value="ISO8601" />
- </layout>
- </appender>
-
- <logger name="org.apache.commons.httpclient" additivity="false">
- <level value="warn" />
- <appender-ref ref="console" />
- </logger>
-
- <logger name="httpclient.wire" additivity="false">
- <level value="info" />
- <appender-ref ref="console" />
- </logger>
-
-<!--
- <logger name="org.collectionspace.services.person.client.sample.Sample" additivity="false">
- <level value="debug" />
- <appender-ref ref="console" />
- </logger>
--->
-
- <root>
- <priority value="debug" />
- <appender-ref ref="console" />
- </root>
-
-</log4j:configuration>
-
-
-
-
<module>hyperjaxb</module>
<module>common</module>
<module>structureddate</module>
+ <module>systeminfo</module>
<module>authority</module>
<module>authorization-mgt</module> <!-- relies on authorization -->
<module>common-test</module>
<module>index</module>
<module>media</module>
<module>publicitem</module>
- <!--module>sdk</module-->
<module>IntegrationTests</module>
<module>PerformanceTests</module>
<module>security</module>
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.pottag.service</artifactId>
<name>services.pottag.service</name>
<packaging>jar</packaging>
<dependency>
<groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.common</artifactId>
- <version>${project.version}</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.pottag.jaxb</artifactId>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.1</version>
<scope>test</scope>
</dependency>
<dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
- <version>1.6.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.nuxeo.ecm.core</groupId>
<artifactId>nuxeo-core-api</artifactId>
- <version>${nuxeo.core.version}</version>
<exclusions>
<exclusion>
<artifactId>jboss-remoting</artifactId>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<profilesXml xmlns="http://maven.apache.org/PROFILES/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/PROFILES/1.0.0 http://maven.apache.org/xsd/profiles-1.0.0.xsd">
-</profilesXml>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<profilesXml xmlns="http://maven.apache.org/PROFILES/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/PROFILES/1.0.0 http://maven.apache.org/xsd/profiles-1.0.0.xsd">
-</profilesXml>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.sdk</artifactId>
- <packaging>pom</packaging>
- <name>services.sdk</name>
- <version>5.0-SNAPSHOT</version>
-
- <distributionManagement>
- <repository>
- <id>libs-releases-local</id>
- <name>libs-releases-local</name>
- <url>http://nightly.collectionspace.org:8081/artifactory/libs-release-local</url>
- </repository>
- <snapshotRepository>
- <id>libs-snapshots-local</id>
- <name>libs-snapshots-local</name>
- <url>http://nightly.collectionspace.org:8081/artifactory/libs-snapshot-local</url>
- </snapshotRepository>
- </distributionManagement>
-
- <profiles>
- <profile>
- <id>samples</id>
- <modules>
- <module>sample</module>
- </modules>
- </profile>
- </profiles>
-
-</project>
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services.client</groupId>
- <artifactId>org.collectionspace.services.client.sample</artifactId>
- <packaging>jar</packaging>
- <name>client.sample</name>
-
- <dependencies>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.collectionobject.client</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <version>1.5.2</version>
- </dependency>
- </dependencies>
-
- <repositories>
- <repository>
- <id>libs-releases-local</id>
- <name>libs-releases-local</name>
- <url>http://nightly.collectionspace.org:8081/artifactory/libs-release-local</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>libs-snapshots-local</id>
- <name>libs-snapshots-local</name>
- <url>http://nightly.collectionspace.org:8081/artifactory/libs-snapshot-local</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
-
- <build>
- <finalName>client-sample</finalName>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
-
+++ /dev/null
-/**
- * Sample.java
- *
- * {Purpose of This Class}
- *
- * {Other Notes Relating to This Class (Optional)}
- *
- * $LastChangedBy: $
- * $LastChangedRevision: $
- * $LastChangedDate: $
- *
- * This document is a part of the source code and related artifacts
- * for CollectionSpace, an open source collections management system
- * for museums and related institutions:
- *
- * http://www.collectionspace.org
- * http://wiki.collectionspace.org
- *
- * Copyright © 2009 {Contributing Institution}
- *
- * Licensed under the Educational Community License (ECL), Version 2.0.
- * You may not use this file except in compliance with this License.
- *
- * You may obtain a copy of the ECL 2.0 License at
- * https://source.collectionspace.org/collection-space/LICENSE.txt
- */
-package org.collectionspace.services.sdk.sample;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-
-import org.collectionspace.services.collectionobject.ObjectNameGroup;
-import org.collectionspace.services.collectionobject.ObjectNameList;
-import org.testng.Assert;
-
-import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.plugins.providers.multipart.InputPart;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
-
-import org.collectionspace.services.client.CollectionObjectClient;
-import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
-import org.collectionspace.services.collectionobject.CollectionobjectsCommonList;
-
-/**
- * The Class Sample.
- */
-public class Sample {
-
- /** The collection object client. */
- private static CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
-
- /**
- * @param args
- */
- public static void main(String[] args) {
-
- System.out.println("Base URL is: "
- + collectionObjectClient.getBaseURL());
-
- String csid = createCollectionObject();
- System.out.println("Created a new collection object with CSID=" + csid);
-
- CollectionobjectsCommon co = readCollectionObject(csid);
- System.out.println("Got a collection object with CSID=" + csid);
-
- int status = updateCollectionObject(csid);
- System.out.println("Updated the collection object with CSID=" + csid);
- }
-
- /**
- * Creates the collection object.
- *
- * @return the string
- */
- static String createCollectionObject() {
- String result = null;
-
- CollectionobjectsCommon co = new CollectionobjectsCommon();
- ObjectNameList onl = co.getObjectNameList();
- ObjectNameGroup ong = new ObjectNameGroup();
- ong.setObjectName("Keiko CollectionobjectsCommon");
- onl.getObjectNameGroup().add(ong);
-
- MultipartOutput multipart = new MultipartOutput();
- OutputPart commonPart = multipart.addPart(co,
- MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label",
- collectionObjectClient.getCommonPartName());
-
- ClientResponse<Response> response = collectionObjectClient
- .create(multipart);
- Assert.assertEquals(response.getStatus(), Response.Status.CREATED
- .getStatusCode());
- result = extractId(response);
-
- return result;
- }
-
- /**
- * Read collection object.
- *
- * @param csid
- * the csid
- *
- * @return the collectionobjects common
- */
- static CollectionobjectsCommon readCollectionObject(String csid) {
- CollectionobjectsCommon result = null;
-
- ClientResponse<MultipartInput> response = collectionObjectClient
- .read(csid);
- Assert.assertEquals(response.getStatus(), Response.Status.OK
- .getStatusCode());
- try {
- MultipartInput input = (MultipartInput) response.getEntity();
- result = (CollectionobjectsCommon) extractPart(input,
- collectionObjectClient.getCommonPartName(),
- CollectionobjectsCommon.class);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- return result;
- }
-
- /**
- * Update collection object.
- */
- static int updateCollectionObject(String csid) {
- ClientResponse<MultipartInput> response = collectionObjectClient
- .read(csid);
- Assert.assertEquals(response.getStatus(), Response.Status.OK
- .getStatusCode());
-
- MultipartInput input = (MultipartInput) response.getEntity();
- CollectionobjectsCommon collectionObject = (CollectionobjectsCommon) extractPart(
- input, collectionObjectClient.getCommonPartName(),
- CollectionobjectsCommon.class);
- Assert.assertNotNull(collectionObject);
-
- // Update the content of this resource.
- collectionObject.setObjectNumber("updated-"
- + collectionObject.getObjectNumber());
- String name = collectionObject.getObjectNameList().getObjectNameGroup().get(0).getObjectName();
- collectionObject.getObjectNameList().getObjectNameGroup().get(0).setObjectName("updated-"+ name);
-
- // Submit the request to the service and store the response.
- MultipartOutput output = new MultipartOutput();
- OutputPart commonPart = output.addPart(collectionObject,
- MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label",
- collectionObjectClient.getCommonPartName());
-
- response = collectionObjectClient.update(csid, output);
- int statusCode = response.getStatus();
-
- return statusCode;
- }
-
- //
- // Utility methods that belong somewhere in the SDK and NOT the sample.
- //
-
- /**
- * Extract id.
- *
- * @param res
- * the res
- *
- * @return the string
- */
- static String extractId(ClientResponse<Response> res) {
- String result = null;
-
- try {
- MultivaluedMap mvm = res.getMetadata();
- String uri = (String) ((ArrayList) mvm.get("Location")).get(0);
- String[] segments = uri.split("/");
- result = segments[segments.length - 1];
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return result;
- }
-
- /**
- * Extract part.
- *
- * @param input
- * the input
- * @param label
- * the label
- * @param clazz
- * the clazz
- *
- * @return the object
- *
- * @throws Exception
- * the exception
- */
- static Object extractPart(MultipartInput input, String label, Class clazz) {
- Object obj = null;
-
- try {
- for (InputPart part : input.getParts()) {
- String partLabel = part.getHeaders().getFirst("label");
- if (label.equalsIgnoreCase(partLabel)) {
- String partStr = part.getBodyAsString();
- obj = part.getBody(clazz, null);
- break;
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return obj;
- }
-
-}
+++ /dev/null
-#url of the collectionspace server
-cspace.url=http://localhost:8180/cspace-services/
-cspace.ssl=false
-cspace.auth=false
-cspace.user=test
-cspace.password=test
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.systeminfo</artifactId>
+ <version>5.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.collectionspace.services.systeminfo.client</artifactId>
+ <name>services.systeminfo.client</name>
+
+ <dependencies>
+ <!-- keep slf4j dependencies on the top -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- CollectionSpace dependencies -->
+
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- External dependencies -->
+
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <!-- filter out unwanted jars -->
+ <exclusions>
+ <exclusion>
+ <groupId>tjws</groupId>
+ <artifactId>webserver</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxb-provider</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>collectionspace-services-systeminfo-client</finalName>
+ </build>
+</project>
+
--- /dev/null
+package org.collectionspace.services.systeminfo;
+
+/**
+ * Client class for Structureddate service.
+ * @author remillet
+ *
+ */
+public class SystemInfoClient {
+ public static final String SERVICE_NAME = "systeminfo";
+ public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
+ public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
+ public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
+}
--- /dev/null
+log4j.rootLogger=debug, stdout, R
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+# Pattern to output the caller's file name and line number.
+log4j.appender.stdout.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n
+
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.File=target/test-client.log
+
+log4j.appender.R.MaxFileSize=100KB
+# Keep one backup file
+log4j.appender.R.MaxBackupIndex=1
+
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n
+
+#packages
+log4j.logger.org.collectionspace=DEBUG
+log4j.logger.org.apache=INFO
+log4j.logger.httpclient=INFO
+log4j.logger.org.jboss.resteasy=INFO
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>org.collectionspace.services.systeminfo</artifactId>
+ <groupId>org.collectionspace.services</groupId>
+ <version>5.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.collectionspace.services.systeminfo.jaxb</artifactId>
+ <name>services.systeminfo.jaxb</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>collectionspace-services-systeminfo-jaxb</finalName>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.jvnet.jaxb2.maven2</groupId>
+ <artifactId>maven-jaxb2-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+ SystemInfo schema (XSD)
+
+ Entity : SystemInfo
+ Part : Common
+ Used for: JAXB binding between XML and Java objects
+
+-->
+
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+ jaxb:version="1.0" elementFormDefault="unqualified"
+ xmlns:ns="http://collectionspace.org/services/systeminfo"
+ xmlns="http://collectionspace.org/services/systeminfo"
+ targetNamespace="http://collectionspace.org/services/systeminfo"
+ version="0.1"
+>
+
+<!--
+ Avoid XmlRootElement nightmare:
+ See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
+-->
+
+ <xs:element name="system_info_common">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="displayName" type="xs:string"/>
+ <xs:element name="instanceId" type="xs:string"/>
+ <xs:element name="versionString" type="xs:string"/>
+ <xs:element name="version" type="version"/>
+ <xs:element name="javaVersionString" type="xs:string"/>
+ <xs:element name="nuxeoVersionString" type="xs:string"/>
+ <xs:element name="postgresVersionString" type="xs:string"/>
+ <xs:element name="host" type="xs:string"/>
+ <xs:element name="hostTimezone" type="xs:string"/>
+ <xs:element name="hostLocale" type="xs:string"/>
+ <xs:element name="hostCharset" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:complexType name="version">
+ <xs:sequence>
+ <xs:element name="displayName" type="xs:string"/>
+ <xs:element name="major" type="xs:string"/>
+ <xs:element name="minor" type="xs:string"/>
+ <xs:element name="patch" type="xs:string"/>
+ <xs:element name="build" type="xs:string"/>
+ <xs:element name="buildDate" type="xs:date"/>
+ </xs:sequence>
+ </xs:complexType>
+
+</xs:schema>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.main</artifactId>
+ <version>5.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.collectionspace.services.systeminfo</artifactId>
+ <name>services.systeminfo</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>client</module>
+ <module>jaxb</module>
+ <module>service</module>
+ </modules>
+
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.systeminfo</artifactId>
+ <version>5.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.collectionspace.services.systeminfo.service</artifactId>
+ <name>services.systeminfo.service</name>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.systeminfo.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.systeminfo.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- External dependencies -->
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </dependency>
+
+ <!-- javax -->
+
+ <dependency>
+ <groupId>javax.security</groupId>
+ <artifactId>jaas</artifactId>
+ <version>1.0.01</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- jboss -->
+
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>tjws</groupId>
+ <artifactId>webserver</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxb-provider</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-multipart-provider</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>collectionspace-services-systeminfo-service</finalName>
+ </build>
+</project>
+
--- /dev/null
+package org.collectionspace.services.systeminfo;
+
+import java.util.List;
+
+import org.collectionspace.services.common.api.RefName.RefNameInterface;
+import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.document.AbstractMultipartDocumentHandlerImpl;
+import org.collectionspace.services.common.document.DocumentException;
+import org.collectionspace.services.common.document.DocumentFilter;
+import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.lifecycle.Lifecycle;
+import org.collectionspace.services.lifecycle.TransitionDef;
+import org.nuxeo.ecm.core.api.DocumentModel;
+
+/*
+ * The StructedDate service uses non of these method. It exists only because it is needed to create a proper ServiceContext instance.
+ */
+public class SystemInfoDocumentHandler extends AbstractMultipartDocumentHandlerImpl<SystemInfoCommon, List<SystemInfoCommon>, SystemInfoCommon, List<SystemInfoCommon>> {
+
+ @Override
+ public Lifecycle getLifecycle() {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ public Lifecycle getLifecycle(String serviceObjectName) {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ public void handleWorkflowTransition(ServiceContext ctx, DocumentWrapper<DocumentModel> wrapDoc,
+ TransitionDef transitionDef) throws Exception {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ public void handleCreate(DocumentWrapper<SystemInfoCommon> wrapDoc) throws Exception {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ public void handleUpdate(DocumentWrapper<SystemInfoCommon> wrapDoc) throws Exception {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ public void handleGet(DocumentWrapper<SystemInfoCommon> wrapDoc) throws Exception {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ public void handleGetAll(DocumentWrapper<List<SystemInfoCommon>> wrapDoc) throws Exception {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ public void extractAllParts(DocumentWrapper<SystemInfoCommon> wrapDoc) throws Exception {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ public void fillAllParts(DocumentWrapper<SystemInfoCommon> wrapDoc,
+ org.collectionspace.services.common.document.DocumentHandler.Action action) throws Exception {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ public SystemInfoCommon extractCommonPart(DocumentWrapper<SystemInfoCommon> wrapDoc) throws Exception {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ public void fillCommonPart(SystemInfoCommon obj, DocumentWrapper<SystemInfoCommon> wrapDoc)
+ throws Exception {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ public List<SystemInfoCommon> extractCommonPartList(DocumentWrapper<List<SystemInfoCommon>> wrapDoc)
+ throws Exception {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ public List<SystemInfoCommon> extractPagingInfo(List<SystemInfoCommon> theCommonList,
+ DocumentWrapper<List<SystemInfoCommon>> wrapDoc) throws Exception {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ public SystemInfoCommon getCommonPart() {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ public void setCommonPart(SystemInfoCommon obj) {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ public List<SystemInfoCommon> getCommonPartList() {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ public void setCommonPartList(List<SystemInfoCommon> obj) {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ public String getQProperty(String prop) throws DocumentException {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ protected String getRefnameDisplayName(DocumentWrapper<SystemInfoCommon> docWrapper) {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ protected RefNameInterface getRefName(DocumentWrapper<SystemInfoCommon> docWrapper, String tenantName,
+ String serviceName) {
+ throw new RuntimeException("Unimplemented method.");
+ }
+
+ @Override
+ public DocumentFilter createDocumentFilter() {
+ throw new RuntimeException("Unimplemented method.");
+ }
+}
--- /dev/null
+package org.collectionspace.services.systeminfo;
+
+import java.nio.charset.Charset;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.HttpMethod;
+
+import org.collectionspace.services.authorization.AuthZ;
+import org.collectionspace.services.authorization.CSpaceAction;
+import org.collectionspace.services.authorization.CSpaceResource;
+import org.collectionspace.services.authorization.URIResourceImpl;
+import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
+import org.collectionspace.services.common.CSWebApplicationException;
+import org.collectionspace.services.common.UriInfoWrapper;
+import org.collectionspace.services.common.context.RemoteServiceContextFactory;
+import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.context.ServiceContextFactory;
+import org.collectionspace.services.common.security.UnauthorizedException;
+
+@Path(SystemInfoClient.SERVICE_PATH)
+@Produces({"application/xml"})
+@Consumes({"application/xml"})
+public class SystemInfoResource extends AbstractCollectionSpaceResourceImpl<SystemInfoCommon, SystemInfoCommon> {
+
+ @Override
+ public Class<?> getCommonPartClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getServiceName() {
+ return SystemInfoClient.SERVICE_NAME;
+ }
+
+ @Override
+ protected String getVersionString() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ //
+ // API Endpoints
+ //
+
+ @GET
+ public SystemInfoCommon get(@Context UriInfo ui) {
+ SystemInfoCommon result = null;
+
+ try {
+ result = new SystemInfoCommon();
+ result.setInstanceId("_default");
+ result.setDisplayName("CollectionSpace Services v5.0 - remillet");
+ Version ver = new Version();
+ ver.setMajor("5");
+ ver.setMinor("0");
+ ver.setPatch("0");
+ ver.setBuild("1");
+ result.setVersion(ver);
+
+ result.setHostTimezone(TimeZone.getDefault().getID());
+ result.setHostLocale(Locale.getDefault().toLanguageTag());
+ result.setHostCharset(Charset.defaultCharset().name());
+ //
+ // To get the full set of the system information, we required the user be authenticated *and* have "DELETE" privs on the "systeminfo" resource
+ //
+ try {
+ ServiceContext<SystemInfoCommon, SystemInfoCommon> ctx = createServiceContext(getServiceName(), ui);
+ CSpaceResource res = new URIResourceImpl(ctx.getTenantId(), SystemInfoClient.SERVICE_NAME, HttpMethod.DELETE);
+ if (AuthZ.get().isAccessAllowed(res)) {
+ result.setNuxeoVersionString("7.10-HF17");
+ result.setHost(String.format("Architecture:%s Name:%s Version:%s",
+ System.getProperty("os.arch"), System.getProperty("os.name"), System.getProperty("os.version")));
+ result.setJavaVersionString(System.getProperty("java.version"));
+ result.setPostgresVersionString("9.5.7");
+ }
+ } catch (UnauthorizedException e) {
+ e.printStackTrace();
+ }
+
+ } catch(Exception e) {
+ Response response = Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).type("text/plain").build();
+ throw new CSWebApplicationException(response);
+ }
+
+ return result;
+ }
+
+ @Override
+ public ServiceContextFactory<SystemInfoCommon, SystemInfoCommon> getServiceContextFactory() {
+ return (ServiceContextFactory<SystemInfoCommon, SystemInfoCommon>) RemoteServiceContextFactory.get();
+ }
+}
</layout>
</appender>
+
+ <appender name="unit-tests"
+ class="org.apache.log4j.RollingFileAppender">
+ <param name="File" value="./target/unit-tests.log" />
+ <param name="MaxFileSize" value="10240KB" />
+ <param name="MaxBackupIndex" value="6" />
+ <layout class="org.apache.log4j.TTCCLayout">
+ <param name="DateFormat" value="ISO8601" />
+ </layout>
+ </appender>
+
<logger name="org.apache.commons.httpclient" additivity="false">
<level value="warn" />
<appender-ref ref="console" />
+ <appender-ref ref="unit-tests" />
</logger>
<logger name="httpclient.wire" additivity="false">
<level value="info" />
<appender-ref ref="console" />
+ <appender-ref ref="unit-tests" />
</logger>
-<!--
- <logger name="org.collectionspace.services.collectionobject.client.sample.Sample" additivity="false">
- <level value="debug" />
- <appender-ref ref="console" />
- </logger>
--->
-
<root>
<priority value="debug" />
<appender-ref ref="console" />
+ <appender-ref ref="unit-tests" />
</root>
</log4j:configuration>
<name>services.vocabulary</name>
<packaging>pom</packaging>
- <dependencies>
- <!--
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.authority</artifactId>
- <optional>true</optional>
- <version>${project.version}</version>
- </dependency>
- -->
- </dependencies>
-
<modules>
<module>jaxb</module>
<module>service</module>
<module>client</module>
</modules>
- <profiles>
- <profile>
- <id>samples</id>
- <modules>
- <module>sample</module>
- </modules>
- </profile>
- </profiles>
-
</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.vocabulary.client.samples</artifactId>
- <packaging>pom</packaging>
- <version>1.0</version>
- <name>vocabulary.client.samples</name>
-
- <modules>
- <module>sample</module>
- </modules>
-</project>
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.vocabulary.client.sample</artifactId>
- <packaging>jar</packaging>
- <version>5.0-SNAPSHOT</version>
- <name>vocabulary.client.sample</name>
-
- <dependencies>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.vocabulary.jaxb</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.vocabulary.client</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <repositories>
- <repository>
- <id>libs-releases-local</id>
- <name>libs-releases-local</name>
- <url>http://nightly.collectionspace.org:8081/artifactory/libs-release-local</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>libs-snapshots-local</id>
- <name>libs-snapshots-local</name>
- <url>http://nightly.collectionspace.org:8081/artifactory/libs-snapshot-local</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
-
- <repository>
- <id>collectionspace-releases</id>
- <name>collectionspace-releases</name>
- <url>http://nightly.collectionspace.org:8081/artifactory/nuxeo-public</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>nuxeo-public-snapshot</id>
- <name>nuxeo-public-snapshot</name>
- <url>http://nightly.collectionspace.org:8081/artifactory/nuxeo-public-snapshot</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
-<!--
- <repository>
- <id>nuxeo-public-snapshot</id>
- <url>http://maven.nuxeo.org/public-snapshot/</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>nuxeo-public</id>
- <url>http://maven.nuxeo.org/public/</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
--->
- </repositories>
-
- <build>
- <finalName>vocabulary-client-sample</finalName>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>attached</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <descriptorRefs>
- <descriptorRef>jar-with-dependencies</descriptorRef>
- </descriptorRefs>
- <archive>
- <manifest>
- <mainClass>org.collectionspace.services.vocabulary.client.sample.Sample</mainClass>
- </manifest>
- </archive>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
-
+++ /dev/null
-/**
- * This document is a part of the source code and related artifacts
- * for CollectionSpace, an open source collections management system
- * for museums and related institutions:
- *
- * http://www.collectionspace.org
- * http://wiki.collectionspace.org
- *
- * Copyright (c)) 2009 Regents of the University of California
- *
- * Licensed under the Educational Community License (ECL), Version 2.0.
- * You may not use this file except in compliance with this License.
- *
- * You may obtain a copy of the ECL 2.0 License at
- * https://source.collectionspace.org/collection-space/LICENSE.txt
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.collectionspace.services.vocabulary.client.sample;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-
-import org.apache.log4j.BasicConfigurator;
-//import org.collectionspace.services.VocabularyItemJAXBSchema;
-import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
-
-import org.collectionspace.services.client.PayloadInputPart;
-import org.collectionspace.services.client.PoxPayloadIn;
-import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.client.VocabularyClient;
-import org.collectionspace.services.client.VocabularyClientUtils;
-import org.collectionspace.services.client.test.ServiceRequestType;
-import org.collectionspace.services.vocabulary.VocabulariesCommon;
-import org.collectionspace.services.vocabulary.VocabulariesCommonList;
-import org.collectionspace.services.vocabulary.VocabularyitemsCommon;
-import org.collectionspace.services.vocabulary.VocabularyitemsCommonList;
-import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.plugins.providers.multipart.InputPart;
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * VocabularyServiceTest, carries out tests against a
- * deployed and running Vocabulary Service.
- *
- * $LastChangedRevision$
- * $LastChangedDate$
- */
-public class Sample {
- private static final Logger logger =
- LoggerFactory.getLogger(Sample.class);
-
- // Instance variables specific to this test.
- private VocabularyClient client = new VocabularyClient();
- final String SERVICE_PATH_COMPONENT = "vocabularies";
- final String ITEM_SERVICE_PATH_COMPONENT = "items";
-
-
- // ---------------------------------------------------------------
- // Create
- // ---------------------------------------------------------------
-
- public void createEnumeration(String vocabName, List<String> enumValues ) {
-
- // Expected status code: 201 Created
- int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
-
- if(logger.isDebugEnabled()){
- logger.debug("Import: Create vocabulary: \"" + vocabName +"\"");
- }
-
- String displaySuffix = "displayName-" + System.currentTimeMillis(); //TODO: Laramie20100728 temp fix, made-up displaySuffix.
- String baseVocabRefName = VocabularyClientUtils.createVocabularyRefName(vocabName, displaySuffix); //TODO: Laramie20100728 temp fix was vocabName, false
- String fullVocabRefName = VocabularyClientUtils.createVocabularyRefName(vocabName, displaySuffix); //TODO: Laramie20100728 temp fix was vocabName, true
- PoxPayloadOut multipart = VocabularyClientUtils.createEnumerationInstance(
- vocabName, fullVocabRefName, client.getCommonPartName());
- ClientResponse<Response> res = client.create(multipart);
-
- int statusCode = res.getStatus();
-
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not create enumeration: \""+vocabName
- +"\" "+ VocabularyClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when creating enumeration: \""
- +vocabName +"\", Status:"+ statusCode);
- }
-
- // Store the ID returned from this create operation
- // for additional tests below.
- String newVocabId = VocabularyClientUtils.extractId(res);
- if(logger.isDebugEnabled()){
- logger.debug("Import: Created vocabulary: \"" + vocabName +"\" ID:"
- +newVocabId );
- }
- for(String itemName : enumValues){
- HashMap<String, String> itemInfo = new HashMap<String, String>();
- itemInfo.put(AuthorityItemJAXBSchema.DISPLAY_NAME, itemName);
- VocabularyClientUtils.createItemInVocabulary(newVocabId,
- baseVocabRefName, itemInfo, client);
- }
- }
-
- // ---------------------------------------------------------------
- // Read
- // ---------------------------------------------------------------
-
- private VocabulariesCommonList readVocabularies() {
-
- // Expected status code: 200 OK
- int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.READ;
-
- // Submit the request to the service and store the response.
- ClientResponse<VocabulariesCommonList> res = client.readList();
- VocabulariesCommonList list = res.getEntity();
-
- int statusCode = res.getStatus();
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not read list of vocabularies: "
- + VocabularyClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when reading " +
- "list of vocabularies, Status:"+ statusCode);
- }
-
- return list;
- }
-
- private List<String> readVocabularyIds(VocabulariesCommonList list) {
-
- List<String> ids = new ArrayList<String>();
- List<VocabulariesCommonList.VocabularyListItem> vocabularies =
- list.getVocabularyListItem();
- for (VocabulariesCommonList.VocabularyListItem vocabulary : vocabularies) {
- ids.add(vocabulary.getCsid());
- }
- return ids;
- }
-
- private VocabulariesCommon readVocabulary(String vocabId) {
-
- // Expected status code: 200 OK
- int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.READ;
-
- // Submit the request to the service and store the response.
- VocabulariesCommon vocabulary = null;
- try {
- ClientResponse<String> res = client.read(vocabId);
- int statusCode = res.getStatus();
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not read vocabulary"
- + VocabularyClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when reading " +
- "vocabulary, Status:"+ statusCode);
- }
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- vocabulary = (VocabulariesCommon) extractPart(input,
- client.getCommonPartName(), VocabulariesCommon.class);
- } catch (Exception e) {
- throw new RuntimeException("Could not read vocabulary: ", e);
- }
-
- return vocabulary;
- }
-
- private VocabularyitemsCommonList readItemsInVocab(String vocabId) {
-
- // Expected status code: 200 OK
- int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.READ;
-
- // Submit the request to the service and store the response.
- // readItemList(String inAuthority, String partialTerm, String keywords)
- ClientResponse<VocabularyitemsCommonList> res = client.readItemList(vocabId, "", ""); //TODO: figure out these params. I just put in empty string to make it recompile after refactoring. Laramie20100728
- VocabularyitemsCommonList list = res.getEntity();
-
- int statusCode = res.getStatus();
-
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not read items in vocabulary: "
- + VocabularyClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when reading " +
- "items in vocabulary, Status:"+ statusCode);
- }
-
- return list;
- }
-
- private List<String> readVocabularyItemIds(VocabularyitemsCommonList list) {
-
- List<String> ids = new ArrayList<String>();
- List<VocabularyitemsCommonList.VocabularyitemListItem> items =
- list.getVocabularyitemListItem();
- for (VocabularyitemsCommonList.VocabularyitemListItem item : items) {
- ids.add(item.getCsid());
- }
- return ids;
- }
-
- // ---------------------------------------------------------------
- // Delete
- // ---------------------------------------------------------------
-
- private void deleteVocabulary(String vcsid) {
- // Expected status code: 200 OK
- int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.DELETE;
-
- ClientResponse<Response> res = client.delete(vcsid);
- int statusCode = res.getStatus();
-
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not delete vocabulary: "
- + VocabularyClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when deleting " +
- "vocabulary, Status:"+ statusCode);
- }
- }
-
- private void deleteAllVocabularies() {
- List<String> ids = readVocabularyIds(readVocabularies());
- for (String id : ids) {
- deleteVocabulary(id);
- }
- }
-
- private void deleteVocabularyItem(String vcsid, String itemcsid) {
- // Expected status code: 200 OK
- int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.DELETE;
-
- ClientResponse<Response> res = client.deleteItem(vcsid, itemcsid);
- int statusCode = res.getStatus();
-
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not delete vocabulary item: "
- + VocabularyClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when deleting " +
- "vocabulary item, Status:"+ statusCode);
- }
- }
-
- private void deleteAllItemsForVocab(String vocabId) {
- List<String> itemIds = readVocabularyItemIds(readItemsInVocab(vocabId));
- for (String itemId : itemIds) {
- deleteVocabularyItem(vocabId, itemId);
- }
- }
-
- // ---------------------------------------------------------------
- // Utility methods used by tests above
- // ---------------------------------------------------------------
-
- // Retrieve individual fields of vocabulary records.
-
- private String displayAllVocabularies(VocabulariesCommonList list) {
- StringBuffer sb = new StringBuffer();
- List<VocabulariesCommonList.VocabularyListItem> vocabularies =
- list.getVocabularyListItem();
- int i = 0;
- for (VocabulariesCommonList.VocabularyListItem vocabulary : vocabularies) {
- sb.append("vocabulary [" + i + "]" + "\n");
- sb.append(displayVocabularyDetails(vocabulary));
- i++;
- }
- return sb.toString();
- }
-
- private String displayVocabularyDetails(
- VocabulariesCommonList.VocabularyListItem vocabulary) {
- StringBuffer sb = new StringBuffer();
- sb.append("displayName=" + vocabulary.getDisplayName() + "\n");
- sb.append("vocabType=" + vocabulary.getVocabType() + "\n");
- // sb.append("csid=" + vocabulary.getCsid() + "\n");
- sb.append("URI=" + vocabulary.getUri() + "\n");
- return sb.toString();
- }
-
- // Retrieve individual fields of vocabulary item records.
-
- private String displayAllVocabularyItems(VocabularyitemsCommonList list) {
- StringBuffer sb = new StringBuffer();
- List<VocabularyitemsCommonList.VocabularyitemListItem> items =
- list.getVocabularyitemListItem();
- int i = 0;
- for (VocabularyitemsCommonList.VocabularyitemListItem item : items) {
- sb.append("vocabulary item [" + i + "]" + "\n");
- sb.append(displayVocabularyItemDetails(item));
- i++;
- }
- return sb.toString();
- }
-
- private String displayVocabularyItemDetails(
- VocabularyitemsCommonList.VocabularyitemListItem item) {
- StringBuffer sb = new StringBuffer();
- sb.append("csid=" + item.getCsid() + "\n");
- sb.append("displayName=" + item.getDisplayName() + "\n");
- // sb.append("URI=" + item.getUri() + "\n");
- return sb.toString();
- }
-
- // TODO this should be moved to a common utils class
- private Object extractPart(PoxPayloadIn input, String label,
- Class clazz) throws Exception {
- Object obj = null;
- obj = input.getPart(label);
- /*
- for(PayloadInputPart part : input.getParts()){
- String partLabel = part.getHeaders().getFirst("label");
- if(label.equalsIgnoreCase(partLabel)){
- String partStr = part.getBodyAsString();
- if(logger.isDebugEnabled()){
- logger.debug("extracted part str=\n" + partStr);
- }
- obj = part.getBody(clazz, null);
- if(logger.isDebugEnabled()){
- logger.debug("extracted part obj=\n", obj, clazz);
- }
- break;
- }
- }
- */
- return obj;
- }
-
- public static void main(String[] args) {
-
- // Configure logging.
- BasicConfigurator.configure();
-
- logger.info("VocabularyBaseImport starting...");
-
- Sample vbi = new Sample();
- VocabulariesCommonList vocabularies;
- List<String> vocabIds;
- String details = "";
-
- // Optionally delete all vocabularies and vocabulary items.
-
- boolean ENABLE_DELETE_ALL = false;
- if (ENABLE_DELETE_ALL) {
-
- logger.info("Deleting all vocabulary items and vocabularies ...");
-
- // For each vocabulary ...
- vocabularies = vbi.readVocabularies();
- vocabIds = vbi.readVocabularyIds(vocabularies);
- for (String vocabId : vocabIds) {
- logger.info("Deleting all vocabulary items for vocabulary ...");
- vbi.deleteAllItemsForVocab(vocabId);
- logger.info("Deleting vocabulary ...");
- vbi.deleteVocabulary(vocabId);
- }
-
- logger.info("Reading vocabularies after deletion ...");
- vocabularies = vbi.readVocabularies();
- details = vbi.displayAllVocabularies(vocabularies);
- logger.info(details);
-
- logger.info("Reading items in each vocabulary after deletion ...");
- vocabIds = vbi.readVocabularyIds(vocabularies);
- for (String vocabId : vocabIds) {
- VocabularyitemsCommonList items = vbi.readItemsInVocab(vocabId);
- details = vbi.displayAllVocabularyItems(items);
- logger.info(details);
- }
-
- }
-
- // Create new vocabularies, each populated with vocabulary items.
-
- final String acquisitionMethodsVocabName = "Acquisition Methods";
- final String entryMethodsVocabName = "Entry Methods";
- final String entryReasonsVocabName = "Entry Reasons";
- final String responsibleDeptsVocabName = "Responsible Departments";
-
- List<String> acquisitionMethodsEnumValues =
- Arrays.asList("Gift","Purchase","Exchange","Transfer","Treasure");
- List<String> entryMethodsEnumValues =
- Arrays.asList("In person","Post","Found on doorstep");
- List<String> entryReasonsEnumValues =
- Arrays.asList("Enquiry","Commission","Loan");
- List<String> respDeptNamesEnumValues =
- Arrays.asList("Antiquities","Architecture and Design","Decorative Arts",
- "Ethnography","Herpetology","Media and Performance Art",
- "Paintings and Sculpture","Paleobotany","Photographs",
- "Prints and Drawings");
-
- vbi.createEnumeration(acquisitionMethodsVocabName, acquisitionMethodsEnumValues);
- vbi.createEnumeration(entryMethodsVocabName, entryMethodsEnumValues);
- vbi.createEnumeration(entryReasonsVocabName, entryReasonsEnumValues);
- vbi.createEnumeration(responsibleDeptsVocabName, respDeptNamesEnumValues);
-
- logger.info("VocabularyBaseImport complete.");
-
- logger.info("Reading vocabularies and items ...");
- // Get a list of vocabularies.
- vocabularies = vbi.readVocabularies();
- // For each vocabulary ...
- for (VocabulariesCommonList.VocabularyListItem
- vocabulary : vocabularies.getVocabularyListItem()) {
- // Get its display name.
- logger.info(vocabulary.getDisplayName());
- // Get a list of the vocabulary items in this vocabulary.
- VocabularyitemsCommonList items =
- vbi.readItemsInVocab(vocabulary.getCsid());
- // For each vocabulary item ...
- for (VocabularyitemsCommonList.VocabularyitemListItem
- item : items.getVocabularyitemListItem()) {
- // Get its display name.
- logger.info(" " + item.getDisplayName());
- }
- }
-
- // Sample alternate methods of reading all vocabularies and
- // vocabulary items separately.
- boolean RUN_ADDITIONAL_SAMPLES = false;
- if (RUN_ADDITIONAL_SAMPLES) {
-
- logger.info("Reading all vocabularies ...");
- details = vbi.displayAllVocabularies(vocabularies);
- logger.info(details);
-
- logger.info("Reading all vocabulary items ...");
- vocabIds = vbi.readVocabularyIds(vocabularies);
- for (String vocabId : vocabIds) {
- VocabularyitemsCommonList items = vbi.readItemsInVocab(vocabId);
- details = vbi.displayAllVocabularyItems(items);
- logger.info(details);
- }
-
- }
-
- }
-
-}
+++ /dev/null
-#url of the collectionspace server
-cspace.url=http://localhost:8180/cspace-services/
-cspace.ssl=false
-cspace.auth=false
-cspace.user=test
-cspace.password=test
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
-
- <appender name="console" class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.out" />
- <layout class="org.apache.log4j.TTCCLayout">
- <param name="DateFormat" value="ISO8601" />
- </layout>
- </appender>
-
- <logger name="org.apache.commons.httpclient" additivity="false">
- <level value="warn" />
- <appender-ref ref="console" />
- </logger>
-
- <logger name="httpclient.wire" additivity="false">
- <level value="info" />
- <appender-ref ref="console" />
- </logger>
-
-<!--
- <logger name="org.collectionspace.services.vocabulary.client.sample.Sample" additivity="false">
- <level value="debug" />
- <appender-ref ref="console" />
- </logger>
--->
-
- <root>
- <priority value="debug" />
- <appender-ref ref="console" />
- </root>
-
-</log4j:configuration>
-
-
-
-