]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
a4e8a655defddd975b9e450e26c3d1ec49ad8956
[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.organization.OrgTermGroup;
57 import org.collectionspace.services.person.PersonTermGroup;
58
59 import org.jboss.resteasy.client.ClientResponse;
60
61 import org.testng.Assert;
62 import org.testng.annotations.AfterClass;
63 import org.testng.annotations.Test;
64
65 import org.slf4j.Logger;
66 import org.slf4j.LoggerFactory;
67
68 /**
69  * CollectionObjectAuthRefsTest, carries out tests against a
70  * deployed and running CollectionObject Service.
71  *
72  * $LastChangedRevision: 1327 $
73  * $LastChangedDate: 2010-02-12 10:35:11 -0800 (Fri, 12 Feb 2010) $
74  */
75 public class CollectionObjectAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
76
77     @Override
78     protected CollectionSpaceClient getClientInstance() {
79         throw new UnsupportedOperationException(); //FIXME: REM - See http://issues.collectionspace.org/browse/CSPACE-3498
80     }
81     
82         @Override
83         protected String getServiceName() {
84                 throw new UnsupportedOperationException(); //FIXME: REM - See http://issues.collectionspace.org/browse/CSPACE-3498
85         }
86
87    /** The logger. */
88     private final String CLASS_NAME = CollectionObjectAuthRefsTest.class.getName();
89     private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
90
91     // Instance variables specific to this test.
92     /** The service path component. */
93     final String SERVICE_PATH_COMPONENT = "collectionobjects";
94     
95     /** The person authority name. */
96     final String PERSON_AUTHORITY_NAME = "TestPersonAuth";
97     final String PERSON_AUTHORITY_NAME_DISPLAY = "TestPersonAuth_DisplayName";
98
99     /** The organization authority name. */
100     final String ORG_AUTHORITY_NAME = "TestOrgAuth";
101     
102     /** The collection object ids created. */
103     private List<String> collectionObjectIdsCreated = new ArrayList<String>();
104     
105     /** The person ids created. */
106     private List<String> personIdsCreated = new ArrayList<String>();
107     
108     /** The person authority csid and refName. */
109     private String personAuthCSID = null; 
110     private String personAuthRefName = null;
111     
112     /** The organization ids created. */
113     private List<String> orgIdsCreated = new ArrayList<String>();
114
115     /** The org authority csid and refName. */
116     private String orgAuthCSID = null;
117     private String orgAuthRefName = null;
118     
119     private String contentOrganizationRefName = null;
120     private String contentPersonRefName = null;
121     private String assocEventOrganizationRefName = null;
122     private String assocEventPersonRefName = null;
123     private String ownerRefName = null;
124     private String fieldCollectionSourceRefName = null;
125     private String fieldCollectorRefName = null;
126
127     // FIXME: As of 2012-01-04, the two assocEvent... fields
128     // and the ownerRefName field have been commented out in
129     // the list of authRef fields in CollectionObject, in tenant bindings,
130     // because those fields fall within to-be-created repeatable groups,
131     // per CSPACE-3229.
132     // As a result, the number of authority references expected to be found
133     // is currently 4, rather than 7. - Aron
134     public String toString(){
135         String result = "CollectionObjectauthRefsTest: "
136                         + "\r\npersonAuthCSID: "+personAuthCSID
137                         + "\r\npersonAuthRefName: "+personAuthRefName
138                         + "\r\norgAuthCSID: "+orgAuthCSID
139                         + "\r\norgAuthRefName: "+orgAuthRefName
140                         + "\r\n"
141                         + "\r\n contentOrganizationRefName: "+contentOrganizationRefName
142                         + "\r\n contentPersonRefName: "+contentPersonRefName
143                         + "\r\n assocEventOrganizationRefName: "+assocEventOrganizationRefName
144                         + "\r\n assocEventPersonRefName: "+assocEventPersonRefName
145                         + "\r\n ownerRefName: "+ownerRefName
146                         + "\r\n fieldCollectionSourceRefName: "+fieldCollectionSourceRefName
147                         + "\r\n fieldCollectorRefName: "+fieldCollectorRefName;
148
149         return result;
150     }
151
152     /** The number of authority references expected. */
153     private final int NUM_AUTH_REFS_EXPECTED = 7;
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         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.close();
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         Response res = personAuthClient.create(multipart);
228         int statusCode = res.getStatus();
229         try {
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         } finally {
236                 res.close();
237         }
238     }
239
240     /**
241      * Creates a person item.
242      *
243      * @param firstName the person's first name
244      * @param surName the person's surname
245      * @param shortIdentifier the short identifier for the item
246      * @return the CSID of the newly-created person record
247      */
248     protected String createPerson(String firstName, String surName, String shortIdentifier ) {
249         String result = null;
250         
251         Map<String, String> personInfo = new HashMap<String,String>();
252         personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
253         personInfo.put(PersonJAXBSchema.SUR_NAME, surName);
254         personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortIdentifier);
255         List<PersonTermGroup> personTerms = new ArrayList<PersonTermGroup>();
256         PersonTermGroup term = new PersonTermGroup();
257         String termName = firstName + " " + surName;
258         term.setTermDisplayName(termName);
259         term.setTermName(termName);
260         personTerms.add(term);
261         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
262         PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonInstance(personAuthCSID,
263                                 personAuthRefName, personInfo, personTerms, personAuthClient.getItemCommonPartName());
264         Response res = personAuthClient.createItem(personAuthCSID, multipart);
265         try {
266                 int statusCode = res.getStatus();
267         
268                 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
269                         invalidStatusCodeMessage(testRequestType, statusCode));
270                 Assert.assertEquals(statusCode, STATUS_CREATED);
271                 result = extractId(res);
272         } finally {
273                 res.close();
274         }
275         
276         return result;
277     }
278
279     /**
280      * Creates multiple Person items within a Person Authority,
281      * and stores the refNames referring to each.
282      */
283     protected void createPersonRefs(){
284
285         createPersonAuthority(PERSON_AUTHORITY_NAME_DISPLAY, PERSON_AUTHORITY_NAME);
286
287         String csid = "";
288         
289         csid = createPerson("Connie", "ContactPerson", "connieContactPerson");
290         contentPersonRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
291         personIdsCreated.add(csid);
292         
293 //        csid = createPerson("Ingrid", "ContentInscriber", "ingridContentInscriber");
294 //        contentInscriberRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
295 //        personIdsCreated.add(csid);
296 //
297 //        csid = createPerson("Pacifico", "ProductionPerson", "pacificoProductionPerson");
298 //        objectProductionPersonRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
299 //        personIdsCreated.add(csid);
300 //
301 //        csid = createPerson("Dessie", "DescriptionInscriber", "dessieDescriptionInscriber");
302 //        descriptionInscriberRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
303 //        personIdsCreated.add(csid);
304
305         csid = createPerson("Asok", "AssociatedEventPerson", "asokAssociatedEventPerson");
306         assocEventPersonRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
307         personIdsCreated.add(csid);
308         
309 //        csid = createPerson("Andrew", "AssociatedPerson", "andrewAssociatedPerson");
310 //        assocPersonRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
311 //        personIdsCreated.add(csid);
312
313         csid = createPerson("Owen", "Owner", "owenOwner");
314         ownerRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
315         personIdsCreated.add(csid);
316
317         csid = createPerson("Sally", "Field-CollectionSource", "sallyFieldCollectionSource");
318         fieldCollectionSourceRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
319         personIdsCreated.add(csid);
320
321         csid = createPerson("Fred", "Lector", "fredLector");
322         fieldCollectorRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
323         personIdsCreated.add(csid);
324     }
325     
326     /**
327      * Creates an organization authority.
328      *
329      * @param displayName the display name of the authority
330      * @param shortIdentifier the short identifier for the authority
331      */
332     private void createOrgAuthority(String displayName, String shortIdentifier) {
333         testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
334         OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
335         PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance(
336                         displayName, shortIdentifier, orgAuthClient.getCommonPartName());
337         Response res = orgAuthClient.create(multipart);
338         try {
339                 int statusCode = res.getStatus();
340         
341                 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
342                         invalidStatusCodeMessage(testRequestType, statusCode));
343                 Assert.assertEquals(statusCode, STATUS_CREATED);
344                 orgAuthCSID = extractId(res);
345                 orgAuthRefName = OrgAuthorityClientUtils.getAuthorityRefName(orgAuthCSID, null);
346         } finally {
347                 res.close();
348         }
349     }
350
351     /**
352      * Creates an organization item.
353      *
354      * @param shortName the organization's short name
355      * @param foundingPlace the organization's founding place
356      * @param shortIdentifier the short identifier for the item
357      * @return the CSID of the newly-created organization record
358      */
359     protected String createOrganization(String shortName, String foundingPlace, String shortIdentifier ) {
360         String result = null;
361         
362         Map<String, String> orgInfo = new HashMap<String,String>();
363         orgInfo.put(OrganizationJAXBSchema.FOUNDING_PLACE, foundingPlace);
364         orgInfo.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortIdentifier);
365         
366         List<OrgTermGroup> orgTerms = new ArrayList<OrgTermGroup>();
367         OrgTermGroup term = new OrgTermGroup();
368         term.setTermDisplayName(shortName);
369         term.setTermName(shortName);
370         orgTerms.add(term);
371         
372         OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
373         PoxPayloadOut multipart =
374                 OrgAuthorityClientUtils.createOrganizationInstance(orgAuthRefName, orgInfo, orgTerms, orgAuthClient.getItemCommonPartName());
375         Response res = orgAuthClient.createItem(orgAuthCSID, multipart);
376         try {
377                 int statusCode = res.getStatus();
378         
379                 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
380                         invalidStatusCodeMessage(testRequestType, statusCode));
381                 Assert.assertEquals(statusCode, STATUS_CREATED);
382                 result = extractId(res);
383         } finally {
384                 res.close();
385         }
386         
387         return result;
388     }
389     
390    /**
391      * Creates multiple Organization items within an Organization Authority,
392      * and stores the refNames referring to each.
393      */
394     private void createOrganizationRefs() {
395
396         createOrgAuthority(ORG_AUTHORITY_NAME, ORG_AUTHORITY_NAME);
397
398         String csid = "";
399
400         csid = createOrganization("Content Org", "Content Org Town", "contentOrg");
401         contentOrganizationRefName = OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, csid, null);
402         orgIdsCreated.add(csid);
403
404 //        csid = createOrganization("Production Org", "Production Org Town", "productionOrg");
405 //        objectProductionOrganizationRefName = OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, csid, null);
406 //        orgIdsCreated.add(csid);
407
408         csid = createOrganization("Associated Event Org", "Associated Event Org City", "associatedEventOrg");
409         assocEventOrganizationRefName = OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, csid, null);
410         orgIdsCreated.add(csid);
411
412 //        csid = createOrganization("Associated Org", "Associated Org City", "associatedOrg");
413 //        assocOrganizationRefName = OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, csid, null);
414 //        orgIdsCreated.add(csid);
415     }
416
417
418     // Success outcomes
419     /**
420      * Read and check auth refs.
421      *
422      * @param testName the test name
423      * @throws Exception the exception
424      */
425     @Test(dataProvider="testName",
426         dependsOnMethods = {"createWithAuthRefs"})
427     public void readAndCheckAuthRefs(String testName) throws Exception {
428         // Perform setup.
429         testSetup(STATUS_OK, ServiceRequestType.READ);
430         //
431         // First read the object
432         //
433         CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
434         Response res = collectionObjectClient.read(knownResourceId);
435         CollectionobjectsCommon collectionObject = null;
436         try {
437                 assertStatusCode(res, testName);
438                 PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
439                 collectionObject = (CollectionobjectsCommon) extractPart(input,
440                                 collectionObjectClient.getCommonPartName(), CollectionobjectsCommon.class);
441                 Assert.assertNotNull(collectionObject);
442         } finally {
443                 if (res != null) {
444                 res.close();
445             }
446         }
447         //
448         // Next, get all of the auth refs and check that the expected number is returned
449         //
450         res = collectionObjectClient.getAuthorityRefs(knownResourceId);
451         AuthorityRefList list = null;
452         try {
453                 assertStatusCode(res, testName);        
454                 list = (AuthorityRefList)res.getEntity();
455         } finally {
456                 if (res != null) {
457                         res.close();
458             }
459         }
460         
461         List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
462         int numAuthRefsFound = items.size();
463         if(logger.isDebugEnabled()){
464             logger.debug("Expected " + NUM_AUTH_REFS_EXPECTED +
465                 " authority references, found " + numAuthRefsFound);
466         }
467         Assert.assertEquals(numAuthRefsFound, NUM_AUTH_REFS_EXPECTED,
468             "Did not find all expected authority references! " +
469             "Expected " + NUM_AUTH_REFS_EXPECTED + ", found " + numAuthRefsFound);
470                
471         // Check a sample of one or more person authority ref fields
472         // Assert.assertEquals(collectionObject.getAssocPersons().getAssocPerson().get(0), assocPersonRefName);
473         Assert.assertEquals(collectionObject.getOwners().getOwner().get(0), ownerRefName);
474         Assert.assertEquals(collectionObject.getFieldCollectionSources().getFieldCollectionSource().get(0), fieldCollectionSourceRefName);
475
476         // Check a sample of one or more organization authority ref fields
477         Assert.assertEquals(collectionObject.getContentOrganizations().getContentOrganization().get(0), contentOrganizationRefName);
478         Assert.assertEquals(collectionObject.getAssocEventOrganizations().getAssocEventOrganization().get(0), assocEventOrganizationRefName);
479
480         // Optionally output additional data about list members for debugging.
481         logger.info(this.toString());
482         boolean iterateThroughList = true;
483         if(iterateThroughList && logger.isDebugEnabled()){;
484             int i = 0;
485             for(AuthorityRefList.AuthorityRefItem item : items){
486                 logger.debug(testName + ": list-item[" + i + "] Field:" +
487                                 item.getSourceField() + " =" +
488                         " item display name = " + item.getAuthDisplayName() +
489                         " auth display name = " + item.getItemDisplayName());
490                 logger.debug(testName + ": list-item[" + i + "] refName=" +
491                         item.getRefName());
492                 logger.debug(testName + ": list-item[" + i + "] URI=" +
493                         item.getUri());
494                 i++;
495             }
496         }
497     }
498
499
500     // ---------------------------------------------------------------
501     // Cleanup of resources created during testing
502     // ---------------------------------------------------------------
503
504     /**
505      * Deletes all resources created by tests, after all tests have been run.
506      *
507      * This cleanup method will always be run, even if one or more tests fail.
508      * For this reason, it attempts to remove all resources created
509      * at any point during testing, even if some of those resources
510      * may be expected to be deleted by certain tests.
511      */
512     @AfterClass(alwaysRun=true)
513     public void cleanUp() {
514         String noTest = System.getProperty("noTestCleanup");
515         if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
516             if (logger.isDebugEnabled()) {
517                 logger.debug("Skipping Cleanup phase ...");
518             }
519             return;
520         }
521         if (logger.isDebugEnabled()) {
522             logger.debug("Cleaning up temporary resources created for testing ...");
523         }
524         CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
525         for (String resourceId : collectionObjectIdsCreated) {
526             // Note: Any non-success responses are ignored and not reported.
527             collectionObjectClient.delete(resourceId).close();
528         }
529         // Note: Any non-success response is ignored and not reported.
530         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
531         // Delete persons before PersonAuth
532         for (String resourceId : personIdsCreated) {
533             // Note: Any non-success responses are ignored and not reported.
534             personAuthClient.deleteItem(personAuthCSID, resourceId).close();
535         }
536         personAuthClient.delete(personAuthCSID).close();
537         // Note: Any non-success response is ignored and not reported.
538         OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
539         // Delete organizations before OrgAuth
540         for (String resourceId : orgIdsCreated) {
541             // Note: Any non-success responses are ignored and not reported.
542             orgAuthClient.deleteItem(orgAuthCSID, resourceId).close();
543         }
544         orgAuthClient.delete(orgAuthCSID).close();
545     }
546
547     // ---------------------------------------------------------------
548     // Utility methods used by tests above
549     // ---------------------------------------------------------------
550     /* (non-Javadoc)
551      * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
552      */
553     @Override
554     public String getServicePathComponent() {
555         return SERVICE_PATH_COMPONENT;
556     }
557
558    /**
559     * Creates the collection object instance.
560     *
561     * @param title the title
562     * @param objNum the obj num
563     * @param contentOrganization the content organization
564     * @param contentPeople the content people
565     * @param contentPerson the content person
566     * @param inscriber the inscriber
567     * @return the multipart output
568     */
569    private PoxPayloadOut createCollectionObjectInstance(
570                 String title,
571                 String objNum,
572                 String contentOrganization,
573                 String contentPerson,
574                 String assocEventOrganization,
575                 String assocEventPerson,
576                 String owner,
577                 String fieldCollectionSource,
578                 String fieldCollector ) {
579         CollectionobjectsCommon collectionObject = new CollectionobjectsCommon();
580         TitleGroupList titleGroupList = new TitleGroupList();
581         List<TitleGroup> titleGroups = titleGroupList.getTitleGroup();
582         TitleGroup titleGroup = new TitleGroup();
583         titleGroup.setTitle("a title");
584         titleGroups.add(titleGroup);
585         collectionObject.setTitleGroupList(titleGroupList);
586         collectionObject.setObjectNumber(objNum);
587
588         ContentOrganizationList contentOrganizationList = new ContentOrganizationList();
589         List<String> contentOrganizations = contentOrganizationList.getContentOrganization();
590         contentOrganizations.add(contentOrganization);
591         collectionObject.setContentOrganizations(contentOrganizationList);
592
593         ContentPersonList contentPersonList = new ContentPersonList();
594         List<String> contentPersons = contentPersonList.getContentPerson();
595         contentPersons.add(contentPerson);
596         collectionObject.setContentPersons(contentPersonList);
597
598         AssocEventOrganizationList assocEventOrganizationList = new AssocEventOrganizationList();
599         List<String> assocEventOrganizations = assocEventOrganizationList.getAssocEventOrganization();
600         assocEventOrganizations.add(assocEventOrganization);
601         collectionObject.setAssocEventOrganizations(assocEventOrganizationList);
602
603         AssocEventPersonList assocEventPersonList = new AssocEventPersonList();
604         List<String> assocEventPersons = assocEventPersonList.getAssocEventPerson();
605         assocEventPersons.add(assocEventPerson);
606         collectionObject.setAssocEventPersons(assocEventPersonList);
607
608 //        AssocOrganizationList assocOrganizationList = new AssocOrganizationList();
609 //        List<String> assocOrganizations = assocOrganizationList.getAssocOrganization();
610 //        assocOrganizations.add(assocOrganization);
611 //        collectionObject.setAssocOrganizations(assocOrganizationList);
612 //
613 //        AssocPersonList assocPersonList = new AssocPersonList();
614 //        List<String> assocPersons = assocPersonList.getAssocPerson();
615 //        assocPersons.add(assocPerson);
616 //        collectionObject.setAssocPersons(assocPersonList);
617         
618         OwnerList ownerList = new OwnerList();
619         List<String> owners = ownerList.getOwner();
620         owners.add(owner);
621         collectionObject.setOwners(ownerList);
622         
623         FieldCollectionSourceList fieldCollectionSourceList = new FieldCollectionSourceList();
624         List<String> fieldCollectionSources = fieldCollectionSourceList.getFieldCollectionSource();
625         fieldCollectionSources.add(fieldCollectionSource);
626         collectionObject.setFieldCollectionSources(fieldCollectionSourceList);
627         
628         FieldCollectorList FieldCollectorList = new FieldCollectorList();
629         List<String> fieldCollectors = FieldCollectorList.getFieldCollector();
630         fieldCollectors.add(fieldCollector);
631         collectionObject.setFieldCollectors(FieldCollectorList);
632
633         PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
634         PayloadOutputPart commonPart =
635             multipart.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE);
636         commonPart.setLabel(new CollectionObjectClient().getCommonPartName());
637
638         if(logger.isDebugEnabled()){
639             logger.debug("to be created, collectionObject common");
640             logger.debug(objectAsXmlString(collectionObject, CollectionobjectsCommon.class));
641         }
642
643         return multipart;
644     }
645
646 }