]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5504: Added proper update handling for refName updates for authority items...
authorRichard Millet <remillet@berkeley.edu>
Thu, 20 Sep 2012 23:08:39 +0000 (16:08 -0700)
committerRichard Millet <remillet@berkeley.edu>
Thu, 20 Sep 2012 23:08:39 +0000 (16:08 -0700)
services/IntegrationTests/src/test/resources/test-data/xmlreplay/collectionobject/collectionobject-hierarchy-refname.xml
services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/CommonList.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/RepositoryJavaClientImpl.java

index 722defb1b87795f6d77a7f15a70b1a51abb3817d..ef53bb79b7a0ae7fcd9df4bec7b40b162d325e6a 100644 (file)
             <uri>/cspace-services/collectionobjects/${CreateBlackRook.CSID}</uri>
             <filename>collectionobject/hierarchy/7-collectionobject-update-with-parent-child-refnames.xml</filename>
             <vars>
+                <var ID="objectNumber">CSPACE-5518-BlackRook</var>
                 <var ID="distinguishingFeatures">This black rook is nearly intact, save for two tiny fragments.</var>
                 <var ID="currentItemCSID">${CreateBlackRook.CSID}</var>
                 <var ID="currentItemObjectNumber">${CreateBlackRook.objectNumber}</var>
index 67065302fffd776b729d1c329affc4e7d91bb5ce..5268d340d6bbd1a481d34729eb2a046ee74d6381 100644 (file)
@@ -426,10 +426,10 @@ public class RefNameServiceUtils {
                     morePages = false;\r
                 }\r
 \r
-                int nRefsFoundThisPage = processRefObjsDocList(docList, ctx.getTenantId(), oldRefName, queriedServiceBindings, authRefFieldsByService,\r
+                int nRefsFoundThisPage = processRefObjsDocList(docList, ctx.getTenantId(), oldRefName, queriedServiceBindings, authRefFieldsByService, // Perform the refName updates on the list of document models\r
                         null, newRefName);\r
                 if (nRefsFoundThisPage > 0) {\r
-                    ((RepositoryJavaClientImpl) repoClient).saveDocListWithoutHandlerProcessing(ctx, repoSession, docList, true);\r
+                    ((RepositoryJavaClientImpl) repoClient).saveDocListWithoutHandlerProcessing(ctx, repoSession, docList, true); // Flush the document model list out to Nuxeo storage\r
                     nRefsFound += nRefsFoundThisPage;\r
                 }\r
 \r
@@ -556,7 +556,7 @@ public class RefNameServiceUtils {
      * Runs through the list of found docs, processing them. If list is\r
      * non-null, then processing means gather the info for items. If list is\r
      * null, and newRefName is non-null, then processing means replacing and\r
-     * updating. If processing/updating, this must be called in teh context of\r
+     * updating. If processing/updating, this must be called in the context of\r
      * an open session, and caller must release Session after calling this.\r
      *\r
      */\r
index 6dde0577570ed5da330a5d38c33e1edd188d06d7..629dfd00ccf2e5602c999a4ebf6ca722f71b356a 100644 (file)
@@ -121,6 +121,7 @@ public class CommonList extends AbstractCommonList {
                                el.setTextContent((String)value);\r
                                anyList.add(el);\r
                        } else if (value instanceof List<?>) {\r
+                               @SuppressWarnings("unchecked") // We expect and assume String values only here\r
                                List<String> valueList = (List<String>)value;\r
                                for (String val : valueList) {\r
                                        addItem(anyList, key, val);\r
index b8cdda1a5d3b65cd253cf7a990e8907e48c7f9bf..1064fa4a85950d6b27dd88f750cfbbfe62b16287 100644 (file)
@@ -228,17 +228,23 @@ public abstract class DocHandlerBase<T> extends RemoteDocumentModelHandlerImpl<T
                                DocumentModel docModel = iter.next();\r
                                String id = NuxeoUtils.getCsid(docModel);\r
                                item.put(STANDARD_LIST_CSID_FIELD, id);\r
-                       if(markRtSbj!=null) {\r
-                           String relationClause = RelationsUtils.buildWhereClause(markRtSbj, null, null, id, null);\r
-                           String whereClause = relationClause + IQueryManager.SEARCH_QUALIFIER_AND + \r
-                                                                       NuxeoUtils.buildWorkflowNotDeletedWhereClause();\r
-                           QueryContext queryContext = new QueryContext(sc, whereClause);\r
-                           queryContext.setDocType(IRelationsManager.DOC_TYPE);\r
-                           String query = NuxeoUtils.buildNXQLQuery(sc, queryContext);\r
-                           // Search for 1 relation that matches. 1 is enough to fail the filter\r
-                           DocumentModelList docList = repoSession.query(query, null, 1, 0, false);\r
-                       item.put(STANDARD_LIST_MARK_RT_FIELD, docList.isEmpty()?"false":"true");\r
-                       }\r
+                               if (markRtSbj != null) {\r
+                                       String relationClause = RelationsUtils.buildWhereClause(\r
+                                                       markRtSbj, null, null, id, null);\r
+                                       String whereClause = relationClause\r
+                                                       + IQueryManager.SEARCH_QUALIFIER_AND\r
+                                                       + NuxeoUtils.buildWorkflowNotDeletedWhereClause();\r
+                                       QueryContext queryContext = new QueryContext(sc,\r
+                                                       whereClause);\r
+                                       queryContext.setDocType(IRelationsManager.DOC_TYPE);\r
+                                       String query = NuxeoUtils.buildNXQLQuery(sc, queryContext);\r
+                                       // Search for 1 relation that matches. 1 is enough to fail\r
+                                       // the filter\r
+                                       DocumentModelList docList = repoSession.query(query, null,\r
+                                                       1, 0, false);\r
+                                       item.put(STANDARD_LIST_MARK_RT_FIELD,\r
+                                                       docList.isEmpty() ? "false" : "true");\r
+                               }\r
                                String uri = getUri(docModel);\r
                                item.put(STANDARD_LIST_URI_FIELD, uri);\r
                                item.put(STANDARD_LIST_REFNAME_FIELD, getRefname(docModel));\r
@@ -246,13 +252,19 @@ public abstract class DocHandlerBase<T> extends RemoteDocumentModelHandlerImpl<T
                                                getUpdatedAtAsString(docModel));\r
                                item.put(STANDARD_LIST_WORKFLOW_FIELD,\r
                                                docModel.getCurrentLifeCycleState());\r
-       \r
+\r
                                for (ListResultField field : resultsFields) {\r
                                        String schema = field.getSchema();\r
                                        if (schema == null || schema.trim().isEmpty()) {\r
                                                schema = commonSchema;\r
                                        }\r
-                                       Object value = getStringValue(docModel, schema, field);\r
+                                       Object value = getListResultValue(docModel, schema, field);\r
+                                       if (value != null && value instanceof String) { // If it is String that is either null or empty, we set our value to null\r
+                                               String strValue = (String) value;\r
+                                               if (strValue.trim().isEmpty() == true) {\r
+                                                       value = null; // We found an "empty" string value, so just set the value to null so we don't return anything.\r
+                                               }\r
+                                       }\r
                                        if (value != null) {\r
                                                item.put(field.getElement(), value);\r
                                        }\r
index b68c2ad9801a20ff567feac2d69fae8355e99d4c..7c186f17d916b53fe83b57817581ddf1af6b9038 100644 (file)
@@ -1057,7 +1057,6 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             boolean fSaveSession)
             throws ClientException, DocumentException {
         try {
-            repoSession = getRepositorySession(ctx);
             DocumentModel[] docModelArray = new DocumentModel[docList.size()];
             repoSession.saveDocuments(docList.toArray(docModelArray));
             if (fSaveSession) {