]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5488: Added code to put a refname in the CollectionSpace_Core schema for all...
authorRichard Millet <richard.millet@berkeley.edu>
Fri, 31 Aug 2012 07:23:36 +0000 (00:23 -0700)
committerRichard Millet <richard.millet@berkeley.edu>
Fri, 31 Aug 2012 07:23:36 +0000 (00:23 -0700)
3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/schemas/collectionspace_core.xsd
services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceClient.java
services/common-api/src/main/java/org/collectionspace/services/common/api/RefName.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java

index 3a557f64e4f342b7a0391a81738c2f440c385292..7c9389798f1c80253b95f81f26b437c63a7e79c9 100644 (file)
@@ -17,6 +17,7 @@
 \r
     <xs:element name="tenantId" type="xs:string"/>\r
     <xs:element name="uri" type="xs:string"/>\r
+    <xs:element name="refname" type="xs:string"/>\r
     <!--<xs:element name="createdAt" type="xs:string"/>-->\r
     <xs:element name="createdAt" type="xs:dateTime"/>\r
     <xs:element name="updatedAt" type="xs:dateTime"/>\r
index a1eb74d2eeb75d73f362b28a448feacc31c412dd..94098370818df99a9c5241d8806481b596da2dc3 100644 (file)
@@ -39,6 +39,7 @@ public interface CollectionSpaceClient<CLT, REQUEST_TYPE, RESPONSE_TYPE, P exten
     public final static String COLLECTIONSPACE_CORE_SCHEMA = "collectionspace_core";
     public final static String COLLECTIONSPACE_CORE_TENANTID = "tenantId";
     public final static String COLLECTIONSPACE_CORE_URI = "uri";
+    public final static String COLLECTIONSPACE_CORE_REFNAME = "refname";
     public final static String COLLECTIONSPACE_CORE_CREATED_AT = "createdAt";
     public final static String COLLECTIONSPACE_CORE_UPDATED_AT = "updatedAt";
     public final static String COLLECTIONSPACE_CORE_CREATED_BY = "createdBy";
index 5473dd35afce614ddc0045b989b84b5618e3592c..053d9bb4c2080206cacdfab260a0c28192ae521b 100644 (file)
@@ -97,6 +97,18 @@ public class RefName {
             String displaySuffix = (displayName != null && (!displayName.isEmpty())) ? '\'' + displayName + '\'' : "";\r
             return URN_PREFIX + tenantName + ':' + resource + ":" + "name" + "(" + shortIdentifier + ")" + displaySuffix;\r
         }\r
+\r
+        public static Authority buildAuthority(String tenantName, String serviceName, String authorityShortIdentifier, String authorityDisplayName) {\r
+            Authority authority = new Authority();\r
+            authority.tenantName = tenantName;\r
+            authority.resource = serviceName;\r
+            if (Tools.notEmpty(authority.resource)) {\r
+                authority.resource = authority.resource.toLowerCase();\r
+            }\r
+            authority.shortIdentifier = authorityShortIdentifier;\r
+            authority.displayName = authorityDisplayName;\r
+            return authority;\r
+        }\r
     }\r
 \r
     public static class AuthorityItem {\r
@@ -159,21 +171,9 @@ public class RefName {
         }\r
     }\r
 \r
-    public static Authority buildAuthority(String tenantName, String serviceName, String authorityShortIdentifier, String authorityDisplayName) {\r
-        Authority authority = new Authority();\r
-        authority.tenantName = tenantName;\r
-        authority.resource = serviceName;\r
-        if (Tools.notEmpty(authority.resource)) {\r
-            authority.resource = authority.resource.toLowerCase();\r
-        }\r
-        authority.shortIdentifier = authorityShortIdentifier;\r
-        authority.displayName = authorityDisplayName;\r
-        return authority;\r
-    }\r
-\r
     public static AuthorityItem buildAuthorityItem(String tenantName, String serviceName, String authorityShortIdentifier,\r
             String itemShortIdentifier, String itemDisplayName) {\r
-        Authority authority = buildAuthority(tenantName, serviceName, authorityShortIdentifier, "");\r
+        Authority authority = Authority.buildAuthority(tenantName, serviceName, authorityShortIdentifier, "");\r
         return buildAuthorityItem(authority, itemShortIdentifier, itemDisplayName);\r
     }\r
 \r
index cee119ce0c571feb1298e04f72972f8382a7125c..b6a3154686057249e755a0289d1f64ac55717ff8 100644 (file)
@@ -72,9 +72,10 @@ public abstract class DocHandlerBase<T> extends RemoteDocumentModelHandlerImpl<T
 \r
     private AbstractCommonList commonList;\r
     \r
-    protected static final int NUM_STANDARD_LIST_RESULT_FIELDS = 4;\r
+    protected static final int NUM_STANDARD_LIST_RESULT_FIELDS = 5;\r
     protected static final String STANDARD_LIST_CSID_FIELD = "csid";\r
     protected static final String STANDARD_LIST_URI_FIELD = CollectionSpaceClient.COLLECTIONSPACE_CORE_URI;\r
+    protected static final String STANDARD_LIST_REFNAME_FIELD = CollectionSpaceClient.COLLECTIONSPACE_CORE_REFNAME;\r
     protected static final String STANDARD_LIST_UPDATED_AT_FIELD = CollectionSpaceClient.COLLECTIONSPACE_CORE_UPDATED_AT;\r
     protected static final String STANDARD_LIST_WORKFLOW_FIELD = CollectionSpaceClient.COLLECTIONSPACE_CORE_WORKFLOWSTATE;\r
     protected static final String STANDARD_LIST_MARK_RT_FIELD = "related";\r
@@ -150,7 +151,13 @@ public abstract class DocHandlerBase<T> extends RemoteDocumentModelHandlerImpl<T
         throw new UnsupportedOperationException();\r
     }\r
 \r
-       public static String getUpdatedAtAsString(DocumentModel docModel) throws Exception {\r
+       protected static String getRefname(DocumentModel docModel) throws Exception {\r
+               String result = (String)docModel.getProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA,\r
+                               CollectionSpaceClient.COLLECTIONSPACE_CORE_REFNAME);\r
+               return result;\r
+       }\r
+       \r
+       protected static String getUpdatedAtAsString(DocumentModel docModel) throws Exception {\r
                        GregorianCalendar cal = (GregorianCalendar)\r
                                                                docModel.getProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA,\r
                                                                                CollectionSpaceClient.COLLECTIONSPACE_CORE_UPDATED_AT);\r
@@ -160,7 +167,6 @@ public abstract class DocHandlerBase<T> extends RemoteDocumentModelHandlerImpl<T
 \r
     @Override\r
     public AbstractCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {\r
-        String classname = getDocHandlerParams().getAbstractCommonListClassname();\r
        CommonList commonList = new CommonList();\r
         String markRtSbj = null;\r
        RepositoryInstance repoSession = null;\r
@@ -194,13 +200,14 @@ public abstract class DocHandlerBase<T> extends RemoteDocumentModelHandlerImpl<T
                        nFields++;\r
                        baseFields++;\r
                }\r
-               String fields[] = new String[nFields];\r
+               String fields[] = new String[nFields]; // REM - Why can't this just be a static array defined once at the top?  Then there'd be no need for these hardcoded "[x]" statements and no need for NUM_STANDARD_LIST_RESULT_FIELDS constant as well. \r
                fields[0] = STANDARD_LIST_CSID_FIELD;\r
                fields[1] = STANDARD_LIST_URI_FIELD;\r
-               fields[2] = STANDARD_LIST_UPDATED_AT_FIELD;\r
-               fields[3] = STANDARD_LIST_WORKFLOW_FIELD;\r
-               if(markRtSbj!=null) {\r
-                   fields[4] = STANDARD_LIST_MARK_RT_FIELD;\r
+               fields[2] = STANDARD_LIST_REFNAME_FIELD;\r
+               fields[3] = STANDARD_LIST_UPDATED_AT_FIELD;\r
+               fields[4] = STANDARD_LIST_WORKFLOW_FIELD;\r
+               if(markRtSbj != null) {\r
+                   fields[5] = STANDARD_LIST_MARK_RT_FIELD;\r
                }\r
                for(int i = baseFields; i < nFields; i++) {\r
                        ListResultField field = resultsFields.get(i - baseFields); \r
@@ -226,6 +233,7 @@ public abstract class DocHandlerBase<T> extends RemoteDocumentModelHandlerImpl<T
                        }\r
                                String uri = getUri(docModel);\r
                                item.put(STANDARD_LIST_URI_FIELD, uri);\r
+                               item.put(STANDARD_LIST_REFNAME_FIELD, getRefname(docModel));\r
                                item.put(STANDARD_LIST_UPDATED_AT_FIELD,\r
                                                getUpdatedAtAsString(docModel));\r
                                item.put(STANDARD_LIST_WORKFLOW_FIELD,\r
index 5cdd32abe0a5e34a1f1b2f278bbdc421daf74fb2..537f234eec0ed39ecb4e03f0ac86575a134b9519 100644 (file)
@@ -35,6 +35,7 @@ import org.collectionspace.services.client.IRelationsManager;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
+import org.collectionspace.services.common.api.RefName;
 import org.collectionspace.services.common.authorityref.AuthorityRefList;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.AbstractMultipartDocumentHandlerImpl;
@@ -317,6 +318,14 @@ public abstract class DocumentModelHandler<T, TL>
             //
             documentModel.setProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA,
                        CollectionSpaceClient.COLLECTIONSPACE_CORE_URI, getUri(documentModel));
+            //
+            // Add the resource's refname
+            //
+            String csid = documentModel.getName();
+            String refname = RefName.Authority.buildAuthority(ctx.getTenantName(), ctx.getServiceName(),
+                       csid, "" /*authorityDisplayName*/).toString();
+            documentModel.setProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA,
+                       CollectionSpaceClient.COLLECTIONSPACE_CORE_REFNAME, refname);            
                //
                // Add the CSID to the DublinCore title so we can see the CSID in the default
                // Nuxeo webapp.