]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
9df304abc249d2bcb45533bf296ade3475da45a5
[tmp/jakarta-migration.git] /
1 /**
2  * This document is a part of the source code and related artifacts
3  * for CollectionSpace, an open source collections management system
4  * for museums and related institutions:
5  *
6  * http://www.collectionspace.org
7  * http://wiki.collectionspace.org
8  *
9  * Copyright © 2009 Regents of the University of California
10  *
11  * Licensed under the Educational Community License (ECL), Version 2.0.
12  * You may not use this file except in compliance with this License.
13  *
14  * You may obtain a copy of the ECL 2.0 License at
15  * https://source.collectionspace.org/collection-space/LICENSE.txt
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 package org.collectionspace.services.client.test;
24
25 import java.util.ArrayList;
26 import java.util.HashMap;
27 import java.util.List;
28 import java.util.Map;
29
30 import javax.ws.rs.core.MediaType;
31 import javax.ws.rs.core.Response;
32
33 import org.collectionspace.services.OrganizationJAXBSchema;
34 import org.collectionspace.services.PersonJAXBSchema;
35 import org.collectionspace.services.client.CollectionObjectClient;
36 import org.collectionspace.services.client.CollectionSpaceClient;
37 import org.collectionspace.services.client.OrgAuthorityClient;
38 import org.collectionspace.services.client.OrgAuthorityClientUtils;
39 import org.collectionspace.services.client.PayloadOutputPart;
40 import org.collectionspace.services.client.PersonAuthorityClient;
41 import org.collectionspace.services.client.PersonAuthorityClientUtils;
42 import org.collectionspace.services.client.PoxPayloadIn;
43 import org.collectionspace.services.client.PoxPayloadOut;
44 import org.collectionspace.services.common.authorityref.AuthorityRefList;
45 import org.collectionspace.services.collectionobject.AssocEventOrganizationList;
46 import org.collectionspace.services.collectionobject.AssocEventPersonList;
47 import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
48 import org.collectionspace.services.collectionobject.ContentOrganizationList;
49 import org.collectionspace.services.collectionobject.ContentPersonList;
50 import org.collectionspace.services.collectionobject.OwnerList;
51 import org.collectionspace.services.collectionobject.FieldCollectionSourceList;
52 import org.collectionspace.services.collectionobject.FieldCollectorList;
53 import org.collectionspace.services.collectionobject.TitleGroup;
54 import org.collectionspace.services.collectionobject.TitleGroupList;
55 import org.collectionspace.services.jaxb.AbstractCommonList;
56 import org.collectionspace.services.person.PersonTermGroup;
57
58 import org.jboss.resteasy.client.ClientResponse;
59
60 import org.testng.Assert;
61 import org.testng.annotations.AfterClass;
62 import org.testng.annotations.Test;
63
64 import org.slf4j.Logger;
65 import org.slf4j.LoggerFactory;
66
67 /**
68  * CollectionObjectAuthRefsTest, carries out tests against a
69  * deployed and running CollectionObject Service.
70  *
71  * $LastChangedRevision: 1327 $
72  * $LastChangedDate: 2010-02-12 10:35:11 -0800 (Fri, 12 Feb 2010) $
73  */
74 public class CollectionObjectAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
75
76     @Override
77     protected CollectionSpaceClient getClientInstance() {
78         throw new UnsupportedOperationException(); //FIXME: REM - See http://issues.collectionspace.org/browse/CSPACE-3498
79     }
80     
81         @Override
82         protected String getServiceName() {
83                 throw new UnsupportedOperationException(); //FIXME: REM - See http://issues.collectionspace.org/browse/CSPACE-3498
84         }
85
86    /** The logger. */
87     private final String CLASS_NAME = CollectionObjectAuthRefsTest.class.getName();
88     private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
89
90     // Instance variables specific to this test.
91     /** The service path component. */
92     final String SERVICE_PATH_COMPONENT = "collectionobjects";
93     
94     /** The person authority name. */
95     final String PERSON_AUTHORITY_NAME = "TestPersonAuth";
96     final String PERSON_AUTHORITY_NAME_DISPLAY = "TestPersonAuth_DisplayName";
97
98     /** The organization authority name. */
99     final String ORG_AUTHORITY_NAME = "TestOrgAuth";
100     
101     /** The collection object ids created. */
102     private List<String> collectionObjectIdsCreated = new ArrayList<String>();
103     
104     /** The person ids created. */
105     private List<String> personIdsCreated = new ArrayList<String>();
106     
107     /** The person authority csid and refName. */
108     private String personAuthCSID = null; 
109     private String personAuthRefName = null;
110     
111     /** The organization ids created. */
112     private List<String> orgIdsCreated = new ArrayList<String>();
113
114     /** The org authority csid and refName. */
115     private String orgAuthCSID = null;
116     private String orgAuthRefName = null;
117     
118     private String contentOrganizationRefName = null;
119     private String contentPersonRefName = null;
120     private String assocEventOrganizationRefName = null;
121     private String assocEventPersonRefName = null;
122     private String ownerRefName = null;
123     private String fieldCollectionSourceRefName = null;
124     private String fieldCollectorRefName = null;
125
126     // FIXME: As of 2012-01-04, the two assocEvent... fields
127     // and the ownerRefName field have been commented out in
128     // the list of authRef fields in CollectionObject, in tenant bindings,
129     // because those fields fall within to-be-created repeatable groups,
130     // per CSPACE-3229.
131     // As a result, the number of authority references expected to be found
132     // is currently 4, rather than 7. - Aron
133     public String toString(){
134         String result = "CollectionObjectauthRefsTest: "
135                         + "\r\npersonAuthCSID: "+personAuthCSID
136                         + "\r\npersonAuthRefName: "+personAuthRefName
137                         + "\r\norgAuthCSID: "+orgAuthCSID
138                         + "\r\norgAuthRefName: "+orgAuthRefName
139                         + "\r\n"
140                         + "\r\n contentOrganizationRefName: "+contentOrganizationRefName
141                         + "\r\n contentPersonRefName: "+contentPersonRefName
142                         + "\r\n assocEventOrganizationRefName: "+assocEventOrganizationRefName
143                         + "\r\n assocEventPersonRefName: "+assocEventPersonRefName
144                         + "\r\n ownerRefName: "+ownerRefName
145                         + "\r\n fieldCollectionSourceRefName: "+fieldCollectionSourceRefName
146                         + "\r\n fieldCollectorRefName: "+fieldCollectorRefName;
147         StringBuffer buff = new StringBuffer();
148
149         return result;
150     }
151
152     /** The number of authority references expected. */
153     private final int NUM_AUTH_REFS_EXPECTED = 4;
154     
155     // ---------------------------------------------------------------
156     // CRUD tests : CREATE tests
157     // ---------------------------------------------------------------
158     // Success outcomes
159     /**
160      * Creates the with auth refs.
161      *
162      * @param testName the test name
163      * @throws Exception the exception
164      */
165     @Test(dataProvider="testName")
166     public void createWithAuthRefs(String testName) throws Exception {        
167         // Create all the person refs and entities
168         createPersonRefs();
169
170         // Create all the organization refs and entities
171         createOrganizationRefs();
172
173         // Create an object record payload, containing
174         // authority reference values in a number of its fields
175         String identifier = createIdentifier();
176         PoxPayloadOut multipart =
177             createCollectionObjectInstance(
178                 "Obj Title",
179                 "ObjNum" + "-" + identifier,
180                 contentOrganizationRefName,
181                 contentPersonRefName,
182                 assocEventOrganizationRefName,
183                 assocEventPersonRefName,
184                 ownerRefName,
185                 fieldCollectionSourceRefName,
186                 fieldCollectorRefName
187             );
188
189         // Submit the request to the service and store the response.
190         CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
191         testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
192         ClientResponse<Response> res = collectionObjectClient.create(multipart);
193         String newCsid = null;
194         try {
195                 assertStatusCode(res, testName);
196                 newCsid = extractId(res);
197         } finally {
198                 if (res != null) {
199                         res.releaseConnection();
200                 }
201         }
202         // Store the ID returned from the first resource created
203         // for additional tests below.
204         if (knownResourceId == null){
205             knownResourceId = newCsid;
206             if (logger.isDebugEnabled()) {
207                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
208             }
209         }
210         
211         // Store the IDs from every resource created by tests,
212         // so they can be deleted after tests have been run.
213         collectionObjectIdsCreated.add(extractId(res));
214     }
215
216     /**
217      * Creates a Person Authority.
218      *
219      * @param displayName the display name of the authority
220      * @param shortIdentifier the short identifier for the authority
221      */
222     private void createPersonAuthority(String displayName, String shortIdentifier) {
223         testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
224         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
225         PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
226                         displayName, shortIdentifier, personAuthClient.getCommonPartName());
227         ClientResponse<Response> res = personAuthClient.create(multipart);
228         int statusCode = res.getStatus();
229
230         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
231                 invalidStatusCodeMessage(testRequestType, statusCode));
232         Assert.assertEquals(statusCode, STATUS_CREATED);
233         personAuthCSID = extractId(res);
234         personAuthRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
235     }
236
237     /**
238      * Creates a person item.
239      *
240      * @param firstName the person's first name
241      * @param surName the person's surname
242      * @param shortIdentifier the short identifier for the item
243      * @return the CSID of the newly-created person record
244      */
245     protected String createPerson(String firstName, String surName, String shortIdentifier ) {
246         Map<String, String> personInfo = new HashMap<String,String>();
247         personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
248         personInfo.put(PersonJAXBSchema.SUR_NAME, surName);
249         personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortIdentifier);
250         List<PersonTermGroup> personTerms = new ArrayList<PersonTermGroup>();
251         PersonTermGroup term = new PersonTermGroup();
252         String termName = firstName + " " + surName;
253         term.setTermDisplayName(termName);
254         term.setTermName(termName);
255         personTerms.add(term);
256         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
257         PoxPayloadOut multipart =
258                 PersonAuthorityClientUtils.createPersonInstance(personAuthCSID,
259                                 personAuthRefName, personInfo, personTerms, personAuthClient.getItemCommonPartName());
260         ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
261         int statusCode = res.getStatus();
262
263         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
264                 invalidStatusCodeMessage(testRequestType, statusCode));
265         Assert.assertEquals(statusCode, STATUS_CREATED);
266         return extractId(res);
267     }
268
269     /**
270      * Creates multiple Person items within a Person Authority,
271      * and stores the refNames referring to each.
272      */
273     protected void createPersonRefs(){
274
275         createPersonAuthority(PERSON_AUTHORITY_NAME_DISPLAY, PERSON_AUTHORITY_NAME);
276
277         String csid = "";
278         
279         csid = createPerson("Connie", "ContactPerson", "connieContactPerson");
280         contentPersonRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
281         personIdsCreated.add(csid);
282         
283 //        csid = createPerson("Ingrid", "ContentInscriber", "ingridContentInscriber");
284 //        contentInscriberRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
285 //        personIdsCreated.add(csid);
286 //
287 //        csid = createPerson("Pacifico", "ProductionPerson", "pacificoProductionPerson");
288 //        objectProductionPersonRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
289 //        personIdsCreated.add(csid);
290 //
291 //        csid = createPerson("Dessie", "DescriptionInscriber", "dessieDescriptionInscriber");
292 //        descriptionInscriberRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
293 //        personIdsCreated.add(csid);
294
295         csid = createPerson("Asok", "AssociatedEventPerson", "asokAssociatedEventPerson");
296         assocEventPersonRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
297         personIdsCreated.add(csid);
298         
299 //        csid = createPerson("Andrew", "AssociatedPerson", "andrewAssociatedPerson");
300 //        assocPersonRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
301 //        personIdsCreated.add(csid);
302
303         csid = createPerson("Owen", "Owner", "owenOwner");
304         ownerRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
305         personIdsCreated.add(csid);
306
307         csid = createPerson("Sally", "Field-CollectionSource", "sallyFieldCollectionSource");
308         fieldCollectionSourceRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
309         personIdsCreated.add(csid);
310
311         csid = createPerson("Fred", "Lector", "fredLector");
312         fieldCollectorRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
313         personIdsCreated.add(csid);
314     }
315     
316     /**
317      * Creates an organization authority.
318      *
319      * @param displayName the display name of the authority
320      * @param shortIdentifier the short identifier for the authority
321      */
322     private void createOrgAuthority(String displayName, String shortIdentifier) {
323         testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
324         OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
325         PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance(
326                         displayName, shortIdentifier, orgAuthClient.getCommonPartName());
327         ClientResponse<Response> res = orgAuthClient.create(multipart);
328         int statusCode = res.getStatus();
329
330         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
331                 invalidStatusCodeMessage(testRequestType, statusCode));
332         Assert.assertEquals(statusCode, STATUS_CREATED);
333         orgAuthCSID = extractId(res);
334         orgAuthRefName = OrgAuthorityClientUtils.getAuthorityRefName(orgAuthCSID, null);
335     }
336
337     /**
338      * Creates an organization item.
339      *
340      * @param shortName the organization's short name
341      * @param foundingPlace the organization's founding place
342      * @param shortIdentifier the short identifier for the item
343      * @return the CSID of the newly-created organization record
344      */
345     protected String createOrganization(String shortName, String foundingPlace, String shortIdentifier ) {
346         Map<String, String> orgInfo = new HashMap<String,String>();
347         orgInfo.put(OrganizationJAXBSchema.SHORT_NAME, shortName);
348         orgInfo.put(OrganizationJAXBSchema.FOUNDING_PLACE, foundingPlace);
349         orgInfo.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortIdentifier);
350         OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
351         PoxPayloadOut multipart =
352                 OrgAuthorityClientUtils.createOrganizationInstance(
353                                 orgAuthRefName, orgInfo, orgAuthClient.getItemCommonPartName());
354         ClientResponse<Response> res = orgAuthClient.createItem(orgAuthCSID, multipart);
355         int statusCode = res.getStatus();
356
357         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
358                 invalidStatusCodeMessage(testRequestType, statusCode));
359         Assert.assertEquals(statusCode, STATUS_CREATED);
360         return extractId(res);
361     }
362     
363    /**
364      * Creates multiple Organization items within an Organization Authority,
365      * and stores the refNames referring to each.
366      */
367     private void createOrganizationRefs() {
368
369         createOrgAuthority(ORG_AUTHORITY_NAME, ORG_AUTHORITY_NAME);
370
371         String csid = "";
372
373         csid = createOrganization("Content Org", "Content Org Town", "contentOrg");
374         contentOrganizationRefName = OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, csid, null);
375         orgIdsCreated.add(csid);
376
377 //        csid = createOrganization("Production Org", "Production Org Town", "productionOrg");
378 //        objectProductionOrganizationRefName = OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, csid, null);
379 //        orgIdsCreated.add(csid);
380
381         csid = createOrganization("Associated Event Org", "Associated Event Org City", "associatedEventOrg");
382         assocEventOrganizationRefName = OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, csid, null);
383         orgIdsCreated.add(csid);
384
385 //        csid = createOrganization("Associated Org", "Associated Org City", "associatedOrg");
386 //        assocOrganizationRefName = OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, csid, null);
387 //        orgIdsCreated.add(csid);
388     }
389
390
391     // Success outcomes
392     /**
393      * Read and check auth refs.
394      *
395      * @param testName the test name
396      * @throws Exception the exception
397      */
398     @Test(dataProvider="testName",
399         dependsOnMethods = {"createWithAuthRefs"})
400     public void readAndCheckAuthRefs(String testName) throws Exception {
401         // Perform setup.
402         testSetup(STATUS_OK, ServiceRequestType.READ);
403         //
404         // First read the object
405         //
406         CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
407         ClientResponse<String> res = collectionObjectClient.read(knownResourceId);
408         CollectionobjectsCommon collectionObject = null;
409         try {
410                 assertStatusCode(res, testName);
411                 PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
412                 collectionObject = (CollectionobjectsCommon) extractPart(input,
413                                 collectionObjectClient.getCommonPartName(), CollectionobjectsCommon.class);
414                 Assert.assertNotNull(collectionObject);
415         } finally {
416                 if (res != null) {
417                 res.releaseConnection();
418             }
419         }
420         //
421         // Next, get all of the auth refs and check that the expected number is returned
422         //
423         ClientResponse<AuthorityRefList> res2 = collectionObjectClient.getAuthorityRefs(knownResourceId);
424         AuthorityRefList list = null;
425         try {
426                 assertStatusCode(res2, testName);        
427                 list = res2.getEntity();
428         } finally {
429                 if (res2 != null) {
430                         res2.releaseConnection();
431             }
432         }
433         
434         List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
435         int numAuthRefsFound = items.size();
436         if(logger.isDebugEnabled()){
437             logger.debug("Expected " + NUM_AUTH_REFS_EXPECTED +
438                 " authority references, found " + numAuthRefsFound);
439         }
440         Assert.assertEquals(numAuthRefsFound, NUM_AUTH_REFS_EXPECTED,
441             "Did not find all expected authority references! " +
442             "Expected " + NUM_AUTH_REFS_EXPECTED + ", found " + numAuthRefsFound);
443                
444         // Check a sample of one or more person authority ref fields
445         // Assert.assertEquals(collectionObject.getAssocPersons().getAssocPerson().get(0), assocPersonRefName);
446         Assert.assertEquals(collectionObject.getOwners().getOwner().get(0), ownerRefName);
447         Assert.assertEquals(collectionObject.getFieldCollectionSources().getFieldCollectionSource().get(0), fieldCollectionSourceRefName);
448
449         // Check a sample of one or more organization authority ref fields
450         Assert.assertEquals(collectionObject.getContentOrganizations().getContentOrganization().get(0), contentOrganizationRefName);
451         Assert.assertEquals(collectionObject.getAssocEventOrganizations().getAssocEventOrganization().get(0), assocEventOrganizationRefName);
452
453         // Optionally output additional data about list members for debugging.
454         logger.info(this.toString());
455         boolean iterateThroughList = true;
456         if(iterateThroughList && logger.isDebugEnabled()){;
457             int i = 0;
458             for(AuthorityRefList.AuthorityRefItem item : items){
459                 logger.debug(testName + ": list-item[" + i + "] Field:" +
460                                 item.getSourceField() + " =" +
461                         " item display name = " + item.getAuthDisplayName() +
462                         " auth display name = " + item.getItemDisplayName());
463                 logger.debug(testName + ": list-item[" + i + "] refName=" +
464                         item.getRefName());
465                 logger.debug(testName + ": list-item[" + i + "] URI=" +
466                         item.getUri());
467                 i++;
468             }
469         }
470     }
471
472
473     // ---------------------------------------------------------------
474     // Cleanup of resources created during testing
475     // ---------------------------------------------------------------
476
477     /**
478      * Deletes all resources created by tests, after all tests have been run.
479      *
480      * This cleanup method will always be run, even if one or more tests fail.
481      * For this reason, it attempts to remove all resources created
482      * at any point during testing, even if some of those resources
483      * may be expected to be deleted by certain tests.
484      */
485     @AfterClass(alwaysRun=true)
486     public void cleanUp() {
487         String noTest = System.getProperty("noTestCleanup");
488         if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
489             if (logger.isDebugEnabled()) {
490                 logger.debug("Skipping Cleanup phase ...");
491             }
492             return;
493         }
494         if (logger.isDebugEnabled()) {
495             logger.debug("Cleaning up temporary resources created for testing ...");
496         }
497         CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
498         for (String resourceId : collectionObjectIdsCreated) {
499             // Note: Any non-success responses are ignored and not reported.
500             collectionObjectClient.delete(resourceId).releaseConnection();
501         }
502         // Note: Any non-success response is ignored and not reported.
503         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
504         // Delete persons before PersonAuth
505         for (String resourceId : personIdsCreated) {
506             // Note: Any non-success responses are ignored and not reported.
507             personAuthClient.deleteItem(personAuthCSID, resourceId).releaseConnection();
508         }
509         personAuthClient.delete(personAuthCSID).releaseConnection();
510         // Note: Any non-success response is ignored and not reported.
511         OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
512         // Delete organizations before OrgAuth
513         for (String resourceId : orgIdsCreated) {
514             // Note: Any non-success responses are ignored and not reported.
515             orgAuthClient.deleteItem(orgAuthCSID, resourceId).releaseConnection();
516         }
517         orgAuthClient.delete(orgAuthCSID).releaseConnection();
518     }
519
520     // ---------------------------------------------------------------
521     // Utility methods used by tests above
522     // ---------------------------------------------------------------
523     /* (non-Javadoc)
524      * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
525      */
526     @Override
527     public String getServicePathComponent() {
528         return SERVICE_PATH_COMPONENT;
529     }
530
531    /**
532     * Creates the collection object instance.
533     *
534     * @param title the title
535     * @param objNum the obj num
536     * @param contentOrganization the content organization
537     * @param contentPeople the content people
538     * @param contentPerson the content person
539     * @param inscriber the inscriber
540     * @return the multipart output
541     */
542    private PoxPayloadOut createCollectionObjectInstance(
543                 String title,
544                 String objNum,
545                 String contentOrganization,
546                 String contentPerson,
547                 String assocEventOrganization,
548                 String assocEventPerson,
549                 String owner,
550                 String fieldCollectionSource,
551                 String fieldCollector ) {
552         CollectionobjectsCommon collectionObject = new CollectionobjectsCommon();
553         TitleGroupList titleGroupList = new TitleGroupList();
554         List<TitleGroup> titleGroups = titleGroupList.getTitleGroup();
555         TitleGroup titleGroup = new TitleGroup();
556         titleGroup.setTitle("a title");
557         titleGroups.add(titleGroup);
558         collectionObject.setTitleGroupList(titleGroupList);
559         collectionObject.setObjectNumber(objNum);
560
561         ContentOrganizationList contentOrganizationList = new ContentOrganizationList();
562         List<String> contentOrganizations = contentOrganizationList.getContentOrganization();
563         contentOrganizations.add(contentOrganization);
564         collectionObject.setContentOrganizations(contentOrganizationList);
565
566         ContentPersonList contentPersonList = new ContentPersonList();
567         List<String> contentPersons = contentPersonList.getContentPerson();
568         contentPersons.add(contentPerson);
569         collectionObject.setContentPersons(contentPersonList);
570
571         AssocEventOrganizationList assocEventOrganizationList = new AssocEventOrganizationList();
572         List<String> assocEventOrganizations = assocEventOrganizationList.getAssocEventOrganization();
573         assocEventOrganizations.add(assocEventOrganization);
574         collectionObject.setAssocEventOrganizations(assocEventOrganizationList);
575
576         AssocEventPersonList assocEventPersonList = new AssocEventPersonList();
577         List<String> assocEventPersons = assocEventPersonList.getAssocEventPerson();
578         assocEventPersons.add(assocEventPerson);
579         collectionObject.setAssocEventPersons(assocEventPersonList);
580
581 //        AssocOrganizationList assocOrganizationList = new AssocOrganizationList();
582 //        List<String> assocOrganizations = assocOrganizationList.getAssocOrganization();
583 //        assocOrganizations.add(assocOrganization);
584 //        collectionObject.setAssocOrganizations(assocOrganizationList);
585 //
586 //        AssocPersonList assocPersonList = new AssocPersonList();
587 //        List<String> assocPersons = assocPersonList.getAssocPerson();
588 //        assocPersons.add(assocPerson);
589 //        collectionObject.setAssocPersons(assocPersonList);
590         
591         OwnerList ownerList = new OwnerList();
592         List<String> owners = ownerList.getOwner();
593         owners.add(owner);
594         collectionObject.setOwners(ownerList);
595         
596         FieldCollectionSourceList fieldCollectionSourceList = new FieldCollectionSourceList();
597         List<String> fieldCollectionSources = fieldCollectionSourceList.getFieldCollectionSource();
598         fieldCollectionSources.add(fieldCollectionSource);
599         collectionObject.setFieldCollectionSources(fieldCollectionSourceList);
600         
601         FieldCollectorList FieldCollectorList = new FieldCollectorList();
602         List<String> fieldCollectors = FieldCollectorList.getFieldCollector();
603         fieldCollectors.add(fieldCollector);
604         collectionObject.setFieldCollectors(FieldCollectorList);
605
606         PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
607         PayloadOutputPart commonPart =
608             multipart.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE);
609         commonPart.setLabel(new CollectionObjectClient().getCommonPartName());
610
611         if(logger.isDebugEnabled()){
612             logger.debug("to be created, collectionObject common");
613             logger.debug(objectAsXmlString(collectionObject, CollectionobjectsCommon.class));
614         }
615
616         return multipart;
617     }
618
619 }