]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
NOJIRA - Partial port of Laramie's 3178 branch. Still has some bugs, and key enabling...
authorPatrick Schmitz <pschmitz@berkeley.edu>
Mon, 9 May 2011 20:10:54 +0000 (20:10 +0000)
committerPatrick Schmitz <pschmitz@berkeley.edu>
Mon, 9 May 2011 20:10:54 +0000 (20:10 +0000)
Also extended Location and Media tests to exercise some other features.

services/authority/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java
services/authority/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java
services/authority/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java
services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameUtils.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java
services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java
services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceTest.java

index c389af556a76ad91b19b95f7d3523e97f946f705..e97d2a646a43674c3681e91f26280352d878eb48 100644 (file)
@@ -57,12 +57,14 @@ import org.collectionspace.services.common.document.JaxbUtils;
 import org.collectionspace.services.common.relation.IRelationsManager;
 import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
 import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
+import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
 import org.collectionspace.services.common.workflow.service.nuxeo.WorkflowDocumentModelHandler;
 import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
 import org.collectionspace.services.common.ClientType;
 import org.collectionspace.services.common.ServiceMain;
 import org.collectionspace.services.common.ServiceMessages;
+import org.collectionspace.services.common.api.RefName;
 import org.collectionspace.services.common.authorityref.AuthorityRefDocList;
 import org.collectionspace.services.common.authorityref.AuthorityRefList;
 import org.collectionspace.services.common.context.JaxRsContext;
@@ -72,6 +74,7 @@ import org.collectionspace.services.common.context.RemoteServiceContext;
 import org.collectionspace.services.common.context.ServiceBindingUtils;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.BadRequestException;
+import org.collectionspace.services.common.document.DocumentException;
 import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.document.DocumentHandler;
 import org.collectionspace.services.common.document.DocumentNotFoundException;
@@ -80,6 +83,7 @@ import org.collectionspace.services.common.repository.RepositoryClient;
 import org.collectionspace.services.common.security.UnauthorizedException;
 import org.collectionspace.services.common.query.QueryManager;
 import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
+import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.collectionspace.services.relation.RelationResource;
 import org.collectionspace.services.relation.RelationsCommon;
 import org.collectionspace.services.relation.RelationsCommonList;
@@ -110,6 +114,7 @@ public abstract class AuthorityResource<AuthCommon, AuthCommonList, AuthItemComm
        final static int URN_NAME_PREFIX_LEN = URN_PREFIX_LEN + URN_PREFIX_NAME.length();
        final static String URN_PREFIX_ID = "id(";
        final static int URN_ID_PREFIX_LEN = URN_PREFIX_LEN + URN_PREFIX_ID.length();
+       final static String FETCH_SHORT_ID = "_fetch_";
        
     final Logger logger = LoggerFactory.getLogger(AuthorityResource.class);
     
@@ -196,19 +201,67 @@ public abstract class AuthorityResource<AuthCommon, AuthCommonList, AuthItemComm
         * 
         * @throws Exception the exception
         */
-       public DocumentHandler createItemDocumentHandler(
+       protected DocumentHandler createItemDocumentHandler(
                        ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
-                       String inAuthority)
+                       String inAuthority, String parentShortIdentifier)
        throws Exception {
-               AuthItemHandler docHandler;
+               String authorityRefNameBase;
+               AuthorityItemDocumentModelHandler<?,?> docHandler;
+               
+               if(parentShortIdentifier==null) {
+                       authorityRefNameBase = null;
+               } else {
+                       ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx = 
+                               createServiceContext(getServiceName());
+                       if(parentShortIdentifier.equals(FETCH_SHORT_ID)) {
+                               // Get from parent document
+                               parentShortIdentifier = getAuthShortIdentifier(parentCtx, inAuthority);
+                       }
+                       authorityRefNameBase = buildAuthorityRefNameBase(parentCtx, parentShortIdentifier);
+               }
 
-               docHandler = (AuthItemHandler)createDocumentHandler(ctx,
+               docHandler = (AuthorityItemDocumentModelHandler<?,?>)createDocumentHandler(ctx,
                                ctx.getCommonPartLabel(getItemServiceName()),
                                authCommonClass);       
-               ((AuthorityItemDocumentModelHandler<?,?>)docHandler).setInAuthority(inAuthority);
+               docHandler.setInAuthority(inAuthority);
+               docHandler.setAuthorityRefNameBase(authorityRefNameBase);
 
                return (DocumentHandler)docHandler;
        }
+       
+    public String getAuthShortIdentifier(
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String authCSID)
+            throws DocumentNotFoundException, DocumentException {
+        String shortIdentifier = null;
+        try {
+            DocumentWrapper<DocumentModel> wrapDoc = getRepositoryClient(ctx).getDocFromCsid(ctx, authCSID);
+            AuthorityDocumentModelHandler<?,?> handler = 
+               (AuthorityDocumentModelHandler<?,?>)createDocumentHandler(ctx);
+            shortIdentifier = handler.getShortIdentifier(wrapDoc, authorityCommonSchemaName);
+        } catch (DocumentNotFoundException dnfe) {
+            throw dnfe;
+        } catch (IllegalArgumentException iae) {
+            throw iae;
+        } catch (DocumentException de) {
+            throw de;
+        } catch (Exception e) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Caught exception ", e);
+            }
+            throw new DocumentException(e);
+        }
+        return shortIdentifier;
+    }
+
+       
+       protected String buildAuthorityRefNameBase(
+                       ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String shortIdentifier) {
+        RefName.Authority authority = RefName.buildAuthority(ctx.getTenantName(),
+                ctx.getServiceName(), shortIdentifier, null);
+        return authority.toString();
+       }
+
+
 
        /**
         * Creates the authority.
@@ -435,16 +488,22 @@ public abstract class AuthorityResource<AuthCommon, AuthCommonList, AuthItemComm
                        ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = null;
                        Specifier spec = getSpecifier(specifier, "createAuthorityItem", "CREATE_ITEM");
                        String parentcsid;
+                       String parentShortIdentifier;
                        if(spec.form==SpecifierForm.CSID) {
                                parentcsid = spec.value;
+                               // Uncomment when app layer is ready to integrate
+                               // parentShortIdentifier = FETCH_SHORT_ID;
+                               parentShortIdentifier = null;
                        } else {
+                               parentShortIdentifier = spec.value;
                                String whereClause = buildWhereForAuthByName(spec.value);
                    ctx = createServiceContext(getServiceName());
                                parentcsid = getRepositoryClient(ctx).findDocCSID(ctx, whereClause);
                        }
                        ctx = createServiceContext(getItemServiceName(), input);
             ctx.setUriInfo(ui);    //Laramie
-                       DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
+                       // Note: must have the parentShortId, to do the create.
+                       DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid, parentShortIdentifier);
                        String itemcsid = getRepositoryClient(ctx).create(ctx, handler);
                        UriBuilder path = UriBuilder.fromResource(resourceClass);
                        path.path(parentcsid + "/items/" + itemcsid);
@@ -458,7 +517,7 @@ public abstract class AuthorityResource<AuthCommon, AuthCommonList, AuthItemComm
             throw bigReThrow(e, ServiceMessages.CREATE_FAILED);
                }
        }
-
+       
     @GET
     @Path("{csid}/items/{itemcsid}" + WorkflowClient.SERVICE_PATH)
     public byte[] getItemWorkflow(
@@ -540,14 +599,11 @@ public abstract class AuthorityResource<AuthCommon, AuthCommonList, AuthItemComm
                        ctx = (RemoteServiceContext)createServiceContext(getItemServiceName(), queryParams);
                        ctx.setJaxRsContext(jaxRsContext);
 
+                       ctx.setUriInfo(ui); //ARG!   must pass this or subsequent calls will not have a ui.
 
-
-            // NEW laramie
-            ctx.setUriInfo(ui); //ARG!   must pass this or subsequent calls will not have a ui.
-            // NEW
-
-
-                       DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
+                       // We omit the parentShortId, only needed when doing a create...
+                       DocumentHandler handler = createItemDocumentHandler(ctx, 
+                                                                                       parentcsid, null);
                        if(itemSpec.form==SpecifierForm.CSID) {
                                getRepositoryClient(ctx).get(ctx, itemSpec.value, handler);
                        } else {
@@ -605,7 +661,9 @@ public abstract class AuthorityResource<AuthCommon, AuthCommonList, AuthItemComm
                                parentcsid = getRepositoryClient(ctx).findDocCSID(ctx, whereClause);
                        }
                        ctx = createServiceContext(getItemServiceName(), queryParams);
-                       DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
+                       // We omit the parentShortId, only needed when doing a create...
+                       DocumentHandler handler = createItemDocumentHandler(ctx, 
+                                                                               parentcsid, null);
                        DocumentFilter myFilter = handler.getDocumentFilter();
                        myFilter.appendWhereClause(authorityItemCommonSchemaName + ":" +
                                        AuthorityItemJAXBSchema.IN_AUTHORITY + "=" + 
@@ -679,7 +737,8 @@ public abstract class AuthorityResource<AuthCommon, AuthCommonList, AuthItemComm
                                itemcsid = getRepositoryClient(ctx).findDocCSID(ctx, itemWhereClause); //FIXME: REM - Should we be looking for the 'wf_deleted' query param and filtering on it?
                        }
                // Note that we have to create the service context for the Items, not the main service
-               DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
+                       // We omit the parentShortId, only needed when doing a create...
+               DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid, null);
                RepositoryClient repoClient = getRepositoryClient(ctx); 
                DocumentFilter myFilter = handler.getDocumentFilter();
                String serviceType = ServiceBindingUtils.SERVICE_TYPE_PROCEDURE;
@@ -740,8 +799,10 @@ public abstract class AuthorityResource<AuthCommon, AuthCommonList, AuthItemComm
                                parentcsid = getRepositoryClient(ctx).findDocCSID(ctx, whereClause);
                        }
             ctx = createServiceContext(getItemServiceName(), queryParams);
+                       // We omit the parentShortId, only needed when doing a create...
             RemoteDocumentModelHandlerImpl handler =
-                (RemoteDocumentModelHandlerImpl) createItemDocumentHandler(ctx, parentcsid);
+                (RemoteDocumentModelHandlerImpl) createItemDocumentHandler(ctx, 
+                                                                               parentcsid, null);
             String itemcsid;
                        if(itemSpec.form==SpecifierForm.CSID) {
                                itemcsid = itemSpec.value;
@@ -803,7 +864,9 @@ public abstract class AuthorityResource<AuthCommon, AuthCommonList, AuthItemComm
                                itemcsid = getRepositoryClient(ctx).findDocCSID(ctx, itemWhereClause);
                        }
                        // Note that we have to create the service context for the Items, not the main service
-                       DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
+                       // We omit the parentShortId, only needed when doing a create...
+                       DocumentHandler handler = createItemDocumentHandler(ctx, 
+                                                                                       parentcsid, null);
             ctx.setUriInfo(ui);
                        getRepositoryClient(ctx).update(ctx, itemcsid, handler);
                        result = ctx.getOutput();
index f910a13a1e52ea050857c95d21bedb60e3b7397c..fe26bbf72b4880bb34477da7eb4651c5f31156f8 100644 (file)
@@ -25,11 +25,22 @@ package org.collectionspace.services.common.vocabulary.nuxeo;
 
 import java.util.Map;
 
+import javax.management.RuntimeErrorException;
+
+import org.collectionspace.services.client.PoxPayloadIn;
+import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.api.RefName;
+import org.collectionspace.services.common.context.MultipartServiceContext;
+import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.document.DocumentException;
+import org.collectionspace.services.common.document.DocumentNotFoundException;
 import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.service.ObjectPartType;
+import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
 
 import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
+import org.nuxeo.ecm.core.api.ClientException;
 import org.nuxeo.ecm.core.api.DocumentModel;
 
 /**
@@ -128,5 +139,37 @@ public abstract class AuthorityDocumentModelHandler<AuthCommon, AuthCommonList>
        return unQObjectProperties;
     }
     
+    @Override
+    public void handleCreate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+       super.handleCreate(wrapDoc);
+        // Uncomment once debugged and App layer is read to integrate
+       //updateRefnameForAuthority(wrapDoc, authorityCommonSchemaName);//CSPACE-3178
+    }
+
+    protected void updateRefnameForAuthority(DocumentWrapper<DocumentModel> wrapDoc, String schemaName) throws Exception {
+        DocumentModel docModel = wrapDoc.getWrappedObject();
+        String shortIdentifier = (String)docModel.getProperty(schemaName, AuthorityJAXBSchema.SHORT_IDENTIFIER);
+        String displayName =     (String)docModel.getProperty(schemaName, AuthorityJAXBSchema.DISPLAY_NAME);
+        MultipartServiceContext ctx = (MultipartServiceContext)getServiceContext();
+        RefName.Authority authority = RefName.buildAuthority(ctx.getTenantName(),
+                                                             ctx.getServiceName(),
+                                                             shortIdentifier,
+                                                             displayName);
+        String refName = authority.toString();
+        docModel.setProperty(schemaName , AuthorityJAXBSchema.REF_NAME, refName);
+    }
+    
+
+    public String getShortIdentifier(DocumentWrapper<DocumentModel> wrapDoc, String schemaName) {
+        DocumentModel docModel = wrapDoc.getWrappedObject();
+        String shortIdentifier = null;
+        try {
+               shortIdentifier = (String)docModel.getProperty(schemaName, AuthorityJAXBSchema.SHORT_IDENTIFIER);
+        } catch (ClientException ce) {
+               throw new RuntimeException("AuthorityDocHandler Internal Error: cannot get shortId!", ce);
+        }
+        return shortIdentifier;
+    }
+
 }
 
index e4965263dc345c51ec271f096e426c27315013a3..63244eebd76dc7a560f138092933e1a08e26a24d 100644 (file)
@@ -38,6 +38,7 @@ import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.RelationClient;
 //import org.collectionspace.services.common.authority.AuthorityItemRelations;
 import org.collectionspace.services.common.api.CommonAPI;
+import org.collectionspace.services.common.api.RefName;
 import org.collectionspace.services.common.api.Tools;
 import org.collectionspace.services.common.context.MultipartServiceContext;
 import org.collectionspace.services.common.context.ServiceContext;
@@ -89,6 +90,7 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon, AICommonList>
      * inVocabulary is the parent Authority for this context
      */
     protected String inAuthority;
+    protected String authorityRefNameBase;
     
     public AuthorityItemDocumentModelHandler(String authorityItemCommonSchemaName) {
        this.authorityItemCommonSchemaName = authorityItemCommonSchemaName;
@@ -108,6 +110,14 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon, AICommonList>
     }
 
 
+    public String getAuthorityRefNameBase(){
+        return this.authorityRefNameBase;
+    }
+
+    public void setAuthorityRefNameBase(String value){
+        this.authorityRefNameBase = value;
+    }
+
     /* (non-Javadoc)
      * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleCreate(org.collectionspace.services.common.document.DocumentWrapper)
      */
@@ -116,8 +126,34 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon, AICommonList>
        // first fill all the parts of the document
        super.handleCreate(wrapDoc);            
        handleInAuthority(wrapDoc.getWrappedObject());
+        // Uncomment once debugged and App layer is read to integrate
+        //handleDisplayNameAsShortIdentifier(wrapDoc.getWrappedObject(), authorityItemCommonSchemaName);
+        //updateRefnameForAuthorityItem(wrapDoc, authorityItemCommonSchemaName, getAuthorityRefNameBase());  //CSPACE-3178
     }
     
+    private void handleDisplayNameAsShortIdentifier(DocumentModel docModel, String schemaName) throws Exception {
+        String shortIdentifier = (String)docModel.getProperty(schemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
+        String displayName =     (String)docModel.getProperty(schemaName, AuthorityItemJAXBSchema.DISPLAY_NAME);
+        if (Tools.isEmpty(shortIdentifier) && Tools.notEmpty(displayName)){
+            String cookedShortIdentifier = Tools.squeeze(displayName)+'-'+Tools.now().toString();
+            docModel.setProperty(schemaName , AuthorityItemJAXBSchema.SHORT_IDENTIFIER, cookedShortIdentifier);
+        }
+    }
+
+    protected void updateRefnameForAuthorityItem(DocumentWrapper<DocumentModel> wrapDoc,
+            String schemaName,
+            String authorityRefBaseName) throws Exception {
+       DocumentModel docModel = wrapDoc.getWrappedObject();
+       String shortIdentifier = (String)docModel.getProperty(schemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
+       String displayName =     (String)docModel.getProperty(schemaName, AuthorityItemJAXBSchema.DISPLAY_NAME);
+       if (Tools.isEmpty(authorityRefBaseName)){
+               throw new Exception("updateRefnameForAuthorityItem requires an authorityRefBaseName, but none was supplied.");
+       }
+       RefName.Authority authority = RefName.Authority.parse(authorityRefBaseName);
+       String refName = RefName.buildAuthorityItem(authority, shortIdentifier, displayName).toString();
+       docModel.setProperty(schemaName , AuthorityItemJAXBSchema.REF_NAME, refName);
+    }
+
     /**
      * Check the logic around the parent pointer. Note that we only need do this on
      * create, since we have logic to make this read-only on update. 
index 209ed79d6ca43c7170973de730fff3aef6cbd6e7..ae255a0544ce4aebe45cedc044b40b782f2f70a2 100644 (file)
@@ -70,7 +70,7 @@ public class RefNameUtils {
         public String name;\r
         public String displayName;\r
         \r
-        public AuthorityInfo(String refNameTokens[]) throws Exception {\r
+        public AuthorityInfo(String refNameTokens[]) throws IllegalArgumentException {\r
                try {\r
                        if(refNameTokens.length < MIN_TOKENS) {\r
                                throw new IllegalArgumentException("Malformed refName for Authority (too few tokens)");\r
@@ -94,7 +94,7 @@ public class RefNameUtils {
                        this.displayName = \r
                                ((idTokens.length<INSTANCE_TOKENS_MAX)||(idTokens[INSTANCE_DISPLAYNAME_TOKEN].length()<3))? null:\r
                                idTokens[INSTANCE_DISPLAYNAME_TOKEN].substring(1, idTokens[INSTANCE_DISPLAYNAME_TOKEN].length()-1);\r
-               } catch (Exception e) {\r
+               } catch (IllegalArgumentException e) {\r
                    if (logger.isDebugEnabled()) {\r
                        logger.debug("Problem Building AuthorityInfo from tokens: " \r
                                        + RefNameUtils.implodeStringArray(refNameTokens, ", "));\r
@@ -134,7 +134,7 @@ public class RefNameUtils {
        public String name;\r
        public String displayName;\r
         \r
-        public AuthorityTermInfo(String refNameTokens[]) throws Exception {\r
+        public AuthorityTermInfo(String refNameTokens[]) throws IllegalArgumentException {\r
                try {\r
                        if(refNameTokens.length < MIN_TOKENS) {\r
                                throw new IllegalArgumentException("Malformed refName for AuthorityTerm (too few tokens)");\r
@@ -160,7 +160,7 @@ public class RefNameUtils {
                        this.displayName = \r
                                ((idTokens.length<INSTANCE_TOKENS_MAX)||(idTokens[INSTANCE_DISPLAYNAME_TOKEN].length()<3))? null:\r
                                idTokens[INSTANCE_DISPLAYNAME_TOKEN].substring(1, idTokens[INSTANCE_DISPLAYNAME_TOKEN].length()-1);\r
-               } catch (Exception e) {\r
+               } catch (IllegalArgumentException e) {\r
                    if (logger.isDebugEnabled()) {\r
                        logger.debug("Problem Building AuthorityTermInfo from tokens: " \r
                                        + RefNameUtils.implodeStringArray(refNameTokens, ", "));\r
@@ -183,16 +183,16 @@ public class RefNameUtils {
     };\r
 \r
     public static AuthorityInfo parseAuthorityInfo(String refName)\r
-            throws Exception {\r
+            throws IllegalArgumentException {\r
        if(refName==null || !refName.startsWith(URN_PREFIX))\r
-               throw new RuntimeException( "Null or invalid refName syntax");\r
+               throw new IllegalArgumentException( "Null or invalid refName syntax");\r
        return new AuthorityInfo(refName.substring(URN_PREFIX_LEN).split(SEPARATOR));\r
     }\r
 \r
     public static AuthorityTermInfo parseAuthorityTermInfo(String refName)\r
-            throws Exception {\r
+            throws IllegalArgumentException {\r
        if(refName==null || !refName.startsWith(URN_PREFIX))\r
-               throw new RuntimeException( "Null or invalid refName syntax");\r
+               throw new IllegalArgumentException( "Null or invalid refName syntax");\r
        return new AuthorityTermInfo(refName.substring(URN_PREFIX_LEN).split(SEPARATOR));\r
     }\r
 \r
index dba9ab816735012b367beeef0a21b55e1493577a..3421583a1607f02dd89633c3a3a478c52e7c0c31 100755 (executable)
@@ -168,35 +168,6 @@ public abstract class DocHandlerBase<T> extends RemoteDocumentModelHandlerImpl<T
     public AbstractCommonList extractCommonPartListPATRICK(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {\r
         //String label = getServiceContext().getCommonPartLabel();\r
         \r
-        /*\r
-        AbstractCommonList commonList = createAbstractCommonListImpl();\r
-        extractPagingInfo(((TL)commonList), wrapDoc);\r
-        commonList.setFieldsReturned(getSummaryFields(commonList));\r
-        List list = createItemsList(commonList);\r
-        Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();\r
-        while(iter.hasNext()){\r
-            DocumentModel docModel = iter.next();\r
-            String id = NuxeoUtils.getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());\r
-            Object item = createItemForCommonList(docModel, label, id);\r
-            list.add(item);\r
-        }\r
-        */\r
-        /* Rewrite\r
-         * Create the CommonList\r
-         * List<ListResultField> resultsFields = getListItemsArray();\r
-         * Construct array of strings of resultsFields\r
-         *   add csid and uri\r
-         * Set the fieldNames for CommonList\r
-         * For each doc in list:\r
-         *   Create HashMap of values\r
-         *   get csid, set csid hashmap value\r
-         *   get uri, set uri hashmap value\r
-         *   for (ListResultField field : resultsFields ){\r
-         *        get String value from Xpath\r
-         *        set hashMap value\r
-         *   AddItem to CommonList\r
-         * \r
-         */\r
        String commonSchema = getServiceContext().getCommonPartLabel();\r
        CommonList commonList = new CommonList();\r
         extractPagingInfo(commonList, wrapDoc);\r
@@ -273,7 +244,6 @@ public abstract class DocHandlerBase<T> extends RemoteDocumentModelHandlerImpl<T
     }\r
 \r
     //================== UTILITY METHODS ================================================\r
-\r
     public static ReflectionMapper.STATUS callPropertySetterWithXPathValue(DocumentModel docModel,\r
                            Object listItem,\r
                            String setterName,\r
index 76d3cf95d9ab5f178ff50c3fc1411e598fac1b36..aa9def8c696edae791c491e6e2a8bf892f9593e9 100644 (file)
@@ -394,6 +394,9 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI
                        (LocationauthoritiesCommon) extractPart(input,
                            client.getCommonPartName(), LocationauthoritiesCommon.class);
                    Assert.assertNotNull(locationAuthority);
+                   Assert.assertNotNull(locationAuthority.getDisplayName());
+                   Assert.assertNotNull(locationAuthority.getShortIdentifier());
+                   Assert.assertNotNull(locationAuthority.getRefName());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
index 3253d4bda26f05105e4106438207f8d4eee34e90..a56d00e7449f6a6bcbbfb84036203859f1457860 100644 (file)
@@ -24,6 +24,7 @@ package org.collectionspace.services.client.test;
 
 import java.io.File;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.List;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -34,7 +35,9 @@ import org.collectionspace.services.client.PayloadOutputPart;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.media.LanguageList;
 import org.collectionspace.services.media.MediaCommon;
+import org.collectionspace.services.media.SubjectList;
 
 import org.jboss.resteasy.client.ClientResponse;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput;
@@ -381,6 +384,19 @@ public class MediaServiceTest extends AbstractServiceTestImpl {
         String identifier = "media.title-" + title;
         MediaCommon media = new MediaCommon();
         media.setTitle(identifier);
+        media.setContributor("Joe-bob briggs");
+        media.setCoverage("Lots of stuff");
+        media.setPublisher("Ludicrum Enterprises");
+        SubjectList subjects = new SubjectList();
+        List<String> subjList = subjects.getSubject();
+        subjList.add("Pints of blood");
+        subjList.add("Much skin");
+        media.setSubjectList(subjects);
+        LanguageList languages = new LanguageList();
+        List<String> langList = languages.getLanguage();
+        langList.add("English");
+        langList.add("German");
+        media.setLanguageList(languages);
         PoxPayloadOut multipart = new PoxPayloadOut(MediaClient.SERVICE_PAYLOAD_NAME);
         PayloadOutputPart commonPart = multipart.addPart(media, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(new MediaClient().getCommonPartName());