]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5433: Left most of the code alone, but added a synchronization flag to the...
authorRichard Millet <remillet@berkeley.edu>
Wed, 1 Aug 2012 21:21:29 +0000 (14:21 -0700)
committerRichard Millet <remillet@berkeley.edu>
Wed, 1 Aug 2012 21:21:29 +0000 (14:21 -0700)
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java
services/config/src/main/resources/service.xsd

index 56dff860ef2ec8295c280360f6c5f2962acf30cd..22919c7aa04215ba8e64eca2ba8f0be9c676fb5e 100644 (file)
@@ -186,52 +186,70 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
        return AuthorityItemJAXBSchema.TERM_DISPLAY_NAME.equals(elName) || VocabularyItemJAXBSchema.DISPLAY_NAME.equals(elName);
     }
     
+    /*
+     * (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocHandlerBase#getListItemsArray()
+     * 
+     * Note: We're updating the "global" service and tenant bindings instance here -the list instance here is
+     * a reference to the tenant bindings instance in the singleton ServiceMain.
+     */
     @Override
     public List<ListResultField> getListItemsArray() throws DocumentException {
         List<ListResultField> list = super.getListItemsArray();
-        int nFields = list.size();
-        // Ensure that each item in a list of Authority items includes
-        // a set of common fields, so we do not depend upon configuration
-        // for general logic.
-        boolean hasDisplayName = false;
-        boolean hasShortId = false;
-        boolean hasRefName = false;
-        boolean hasTermStatus = false;
-        for (int i = 0; i < nFields; i++) {
-            ListResultField field = list.get(i);
-            String elName = field.getElement();
-            if (isTermDisplayName(elName) == true) {
-                hasDisplayName = true;
-            } else if (AuthorityItemJAXBSchema.SHORT_IDENTIFIER.equals(elName)) {
-                hasShortId = true;
-            } else if (AuthorityItemJAXBSchema.REF_NAME.equals(elName)) {
-                hasRefName = true;
-            } else if (AuthorityItemJAXBSchema.TERM_STATUS.equals(elName)) {
-                hasTermStatus = true;
-            }
-        }
-        ListResultField field;
-        if (!hasDisplayName) {
-               field = getListResultsDisplayNameField();
-            list.add(field);  //Note: We're updating the "global" service and tenant bindings instance here -the list instance here is a reference to the tenant bindings instance in the singleton ServiceMain.
-        }
-        if (!hasShortId) {
-            field = new ListResultField();
-            field.setElement(AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
-            field.setXpath(AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
-            list.add(field);
-        }
-        if (!hasRefName) {
-            field = new ListResultField();
-            field.setElement(AuthorityItemJAXBSchema.REF_NAME);
-            field.setXpath(AuthorityItemJAXBSchema.REF_NAME);
-            list.add(field);
-        }
-        if (!hasTermStatus) {
-            field = getListResultsTermStatusField();
-            list.add(field);
+        
+        // One-time initialization for each authority item service.
+        if (isListItemArrayExtended() == false) {
+               synchronized(AuthorityItemDocumentModelHandler.class) {
+                       if (isListItemArrayExtended() == false) {                               
+                       int nFields = list.size();
+                       // Ensure that each item in a list of Authority items includes
+                       // a set of common fields, so we do not depend upon configuration
+                       // for general logic.
+                       boolean hasDisplayName = false;
+                       boolean hasShortId = false;
+                       boolean hasRefName = false;
+                       boolean hasTermStatus = false;
+                       for (int i = 0; i < nFields; i++) {
+                           ListResultField field = list.get(i);
+                           String elName = field.getElement();
+                           if (isTermDisplayName(elName) == true) {
+                               hasDisplayName = true;
+                           } else if (AuthorityItemJAXBSchema.SHORT_IDENTIFIER.equals(elName)) {
+                               hasShortId = true;
+                           } else if (AuthorityItemJAXBSchema.REF_NAME.equals(elName)) {
+                               hasRefName = true;
+                           } else if (AuthorityItemJAXBSchema.TERM_STATUS.equals(elName)) {
+                               hasTermStatus = true;
+                           }
+                       }
+                               
+                       ListResultField field;
+                       if (!hasDisplayName) {
+                               field = getListResultsDisplayNameField();
+                           list.add(field);
+                       }
+                       if (!hasShortId) {
+                           field = new ListResultField();
+                           field.setElement(AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
+                           field.setXpath(AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
+                           list.add(field);
+                       }
+                       if (!hasRefName) {
+                           field = new ListResultField();
+                           field.setElement(AuthorityItemJAXBSchema.REF_NAME);
+                           field.setXpath(AuthorityItemJAXBSchema.REF_NAME);
+                           list.add(field);
+                       }
+                       if (!hasTermStatus) {
+                           field = getListResultsTermStatusField();
+                           list.add(field);
+                       }
+                       }
+                       
+                       setListItemArrayExtended(true);
+               } // end of synchronized block
         }
-                
+
         return list;
     }
     
index a709869179fa32b8518929359ac85841cc1ead63..d4dd49b9573951ba69d4a4e790115cab869d0f38 100644 (file)
@@ -141,6 +141,14 @@ public abstract class DocHandlerBase<T> extends RemoteDocumentModelHandlerImpl<T
         return getDocHandlerParams().getSummaryFields();\r
     }\r
 \r
+    public void setListItemArrayExtended(boolean isExtended) throws DocumentException {\r
+       getDocHandlerParams().getListResultsFields().setExtended(isExtended);\r
+    }\r
+    \r
+    public boolean isListItemArrayExtended() throws DocumentException {\r
+               return getDocHandlerParams().getListResultsFields().isExtended();\r
+    }\r
+    \r
     public List<ListResultField> getListItemsArray() throws DocumentException {\r
         return getDocHandlerParams().getListResultsFields().getListResultField();\r
     }\r
index 1c30a8f37474200b259e8e2a31abeb2dc443931c..f059239c006ce8bd4c0509b7ca092bf16d894326 100644 (file)
                         <xs:element name="ListResultsFields" minOccurs="1" maxOccurs="1">
                             <xs:complexType>
                                 <xs:sequence>
+                                       <xs:element name="Extended" type="xs:boolean" minOccurs="1" default="false"/>
                                     <xs:element name="ListResultField" type="ListResultField" minOccurs="0" maxOccurs="unbounded"/>
                                 </xs:sequence>
                             </xs:complexType>