From: Patrick Schmitz Date: Thu, 17 May 2012 16:57:20 +0000 (-0700) Subject: CSPACE-4084 Fixed problem with refObjs call that did not set fieldsReturned. Helps... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=b730c93431ba608ceb9b99c72e66725151c9ae6b;p=tmp%2Fjakarta-migration.git CSPACE-4084 Fixed problem with refObjs call that did not set fieldsReturned. Helps preclude fan-out. --- diff --git a/services/common-api/src/main/java/org/collectionspace/services/common/api/Tools.java b/services/common-api/src/main/java/org/collectionspace/services/common/api/Tools.java index c56016185..905127f37 100644 --- a/services/common-api/src/main/java/org/collectionspace/services/common/api/Tools.java +++ b/services/common-api/src/main/java/org/collectionspace/services/common/api/Tools.java @@ -157,6 +157,26 @@ public class Tools { public static String getStackTrace(Throwable e){ return getStackTrace(e, -1); } + + public static String implode(String strings[], String sep) { + String implodedString; + if (strings.length == 0) { + implodedString = ""; + } else { + StringBuffer sb = new StringBuffer(); + sb.append(strings[0]); + for (int i = 1; i < strings.length; i++) { + if (strings[i] != null && !strings[i].trim().isEmpty()) { + sb.append(sep); + sb.append(strings[i]); + } + } + implodedString = sb.toString(); + } + return implodedString; + } + + /** @param includeLines if zero, returns all lines */ diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java index 14e3193c0..4c381d690 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java @@ -235,6 +235,20 @@ public class RefNameServiceUtils { commonList.setItemsInPage(docList.size()); // set the total result size commonList.setTotalItems(docList.totalSize()); + // set the fieldsReturned list. Even though this is a fixed schema, app layer treats + // this like other abstract common lists + /* + + + + + + + + + */ + String fieldList = "docType|docId|docNumber|docName|sourceField|uri|updatedAt|workflowState"; + commonList.setFieldsReturned(fieldList); int nRefsFound = processRefObjsDocList(docList, refName, queriedServiceBindings, authRefFieldsByService, list, null); diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/CommonList.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/CommonList.java index df6bfbfa3..6dde05775 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/CommonList.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/CommonList.java @@ -28,6 +28,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; +import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.jaxb.AbstractCommonList; import org.apache.commons.lang.builder.ToStringBuilder; @@ -109,29 +110,10 @@ public class CommonList extends AbstractCommonList { */ public void setFieldsReturned(String[] fieldKeys) { this.fieldKeys = fieldKeys; - String fieldsImploded = implode(fieldKeys, "|"); + String fieldsImploded = Tools.implode(fieldKeys, "|"); setFieldsReturned(fieldsImploded); } - // TODO This should be in common, but then we have mutual dependencies. Sigh. - private String implode(String strings[], String sep) { - String implodedString; - if (strings.length == 0) { - implodedString = ""; - } else { - StringBuffer sb = new StringBuffer(); - sb.append(strings[0]); - for (int i = 1; i < strings.length; i++) { - if (strings[i] != null && !strings[i].trim().isEmpty()) { - sb.append(sep); - sb.append(strings[i]); - } - } - implodedString = sb.toString(); - } - return implodedString; - } - private void addItem(List anyList, String key, Object value) { if (value != null ) { Element el = doc.createElement(key);