]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
dc5eeb6a68d617530ddbb7d5d94c96dcda66e6da
[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         StringBuffer buff = new StringBuffer();
149
150         return result;
151     }
152
153     /** The number of authority references expected. */
154     private final int NUM_AUTH_REFS_EXPECTED = 7;
155     
156     // ---------------------------------------------------------------
157     // CRUD tests : CREATE tests
158     // ---------------------------------------------------------------
159     // Success outcomes
160     /**
161      * Creates the with auth refs.
162      *
163      * @param testName the test name
164      * @throws Exception the exception
165      */
166     @Test(dataProvider="testName")
167     public void createWithAuthRefs(String testName) throws Exception {        
168         // Create all the person refs and entities
169         createPersonRefs();
170
171         // Create all the organization refs and entities
172         createOrganizationRefs();
173
174         // Create an object record payload, containing
175         // authority reference values in a number of its fields
176         String identifier = createIdentifier();
177         PoxPayloadOut multipart =
178             createCollectionObjectInstance(
179                 "Obj Title",
180                 "ObjNum" + "-" + identifier,
181                 contentOrganizationRefName,
182                 contentPersonRefName,
183                 assocEventOrganizationRefName,
184                 assocEventPersonRefName,
185                 ownerRefName,
186                 fieldCollectionSourceRefName,
187                 fieldCollectorRefName
188             );
189
190         // Submit the request to the service and store the response.
191         CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
192         testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
193         Response res = collectionObjectClient.create(multipart);
194         String newCsid = null;
195         try {
196                 assertStatusCode(res, testName);
197                 newCsid = extractId(res);
198         } finally {
199                 if (res != null) {
200                         res.close();
201                 }
202         }
203         // Store the ID returned from the first resource created
204         // for additional tests below.
205         if (knownResourceId == null){
206             knownResourceId = newCsid;
207             if (logger.isDebugEnabled()) {
208                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
209             }
210         }
211         
212         // Store the IDs from every resource created by tests,
213         // so they can be deleted after tests have been run.
214         collectionObjectIdsCreated.add(extractId(res));
215     }
216
217     /**
218      * Creates a Person Authority.
219      *
220      * @param displayName the display name of the authority
221      * @param shortIdentifier the short identifier for the authority
222      */
223     private void createPersonAuthority(String displayName, String shortIdentifier) {
224         testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
225         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
226         PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
227                         displayName, shortIdentifier, personAuthClient.getCommonPartName());
228         Response res = personAuthClient.create(multipart);
229         int statusCode = res.getStatus();
230         try {
231                 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
232                         invalidStatusCodeMessage(testRequestType, statusCode));
233                 Assert.assertEquals(statusCode, STATUS_CREATED);
234                 personAuthCSID = extractId(res);
235                 personAuthRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
236         } finally {
237                 res.close();
238         }
239     }
240
241     /**
242      * Creates a person item.
243      *
244      * @param firstName the person's first name
245      * @param surName the person's surname
246      * @param shortIdentifier the short identifier for the item
247      * @return the CSID of the newly-created person record
248      */
249     protected String createPerson(String firstName, String surName, String shortIdentifier ) {
250         Map<String, String> personInfo = new HashMap<String,String>();
251         personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
252         personInfo.put(PersonJAXBSchema.SUR_NAME, surName);
253         personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortIdentifier);
254         List<PersonTermGroup> personTerms = new ArrayList<PersonTermGroup>();
255         PersonTermGroup term = new PersonTermGroup();
256         String termName = firstName + " " + surName;
257         term.setTermDisplayName(termName);
258         term.setTermName(termName);
259         personTerms.add(term);
260         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
261         PoxPayloadOut multipart =
262                 PersonAuthorityClientUtils.createPersonInstance(personAuthCSID,
263                                 personAuthRefName, personInfo, personTerms, personAuthClient.getItemCommonPartName());
264         ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
265         int statusCode = res.getStatus();
266
267         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
268                 invalidStatusCodeMessage(testRequestType, statusCode));
269         Assert.assertEquals(statusCode, STATUS_CREATED);
270         return extractId(res);
271     }
272
273     /**
274      * Creates multiple Person items within a Person Authority,
275      * and stores the refNames referring to each.
276      */
277     protected void createPersonRefs(){
278
279         createPersonAuthority(PERSON_AUTHORITY_NAME_DISPLAY, PERSON_AUTHORITY_NAME);
280
281         String csid = "";
282         
283         csid = createPerson("Connie", "ContactPerson", "connieContactPerson");
284         contentPersonRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
285         personIdsCreated.add(csid);
286         
287 //        csid = createPerson("Ingrid", "ContentInscriber", "ingridContentInscriber");
288 //        contentInscriberRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
289 //        personIdsCreated.add(csid);
290 //
291 //        csid = createPerson("Pacifico", "ProductionPerson", "pacificoProductionPerson");
292 //        objectProductionPersonRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
293 //        personIdsCreated.add(csid);
294 //
295 //        csid = createPerson("Dessie", "DescriptionInscriber", "dessieDescriptionInscriber");
296 //        descriptionInscriberRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
297 //        personIdsCreated.add(csid);
298
299         csid = createPerson("Asok", "AssociatedEventPerson", "asokAssociatedEventPerson");
300         assocEventPersonRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
301         personIdsCreated.add(csid);
302         
303 //        csid = createPerson("Andrew", "AssociatedPerson", "andrewAssociatedPerson");
304 //        assocPersonRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
305 //        personIdsCreated.add(csid);
306
307         csid = createPerson("Owen", "Owner", "owenOwner");
308         ownerRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
309         personIdsCreated.add(csid);
310
311         csid = createPerson("Sally", "Field-CollectionSource", "sallyFieldCollectionSource");
312         fieldCollectionSourceRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
313         personIdsCreated.add(csid);
314
315         csid = createPerson("Fred", "Lector", "fredLector");
316         fieldCollectorRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
317         personIdsCreated.add(csid);
318     }
319     
320     /**
321      * Creates an organization authority.
322      *
323      * @param displayName the display name of the authority
324      * @param shortIdentifier the short identifier for the authority
325      */
326     private void createOrgAuthority(String displayName, String shortIdentifier) {
327         testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
328         OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
329         PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance(
330                         displayName, shortIdentifier, orgAuthClient.getCommonPartName());
331         Response res = orgAuthClient.create(multipart);
332         try {
333                 int statusCode = res.getStatus();
334         
335                 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
336                         invalidStatusCodeMessage(testRequestType, statusCode));
337                 Assert.assertEquals(statusCode, STATUS_CREATED);
338                 orgAuthCSID = extractId(res);
339                 orgAuthRefName = OrgAuthorityClientUtils.getAuthorityRefName(orgAuthCSID, null);
340         } finally {
341                 res.close();
342         }
343     }
344
345     /**
346      * Creates an organization item.
347      *
348      * @param shortName the organization's short name
349      * @param foundingPlace the organization's founding place
350      * @param shortIdentifier the short identifier for the item
351      * @return the CSID of the newly-created organization record
352      */
353     protected String createOrganization(String shortName, String foundingPlace, String shortIdentifier ) {
354         Map<String, String> orgInfo = new HashMap<String,String>();
355         orgInfo.put(OrganizationJAXBSchema.FOUNDING_PLACE, foundingPlace);
356         orgInfo.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortIdentifier);
357         
358         List<OrgTermGroup> orgTerms = new ArrayList<OrgTermGroup>();
359         OrgTermGroup term = new OrgTermGroup();
360         term.setTermDisplayName(shortName);
361         term.setTermName(shortName);
362         orgTerms.add(term);
363         
364         OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
365         PoxPayloadOut multipart =
366                 OrgAuthorityClientUtils.createOrganizationInstance(orgAuthRefName, orgInfo, orgTerms, orgAuthClient.getItemCommonPartName());
367         ClientResponse<Response> res = orgAuthClient.createItem(orgAuthCSID, multipart);
368         int statusCode = res.getStatus();
369
370         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
371                 invalidStatusCodeMessage(testRequestType, statusCode));
372         Assert.assertEquals(statusCode, STATUS_CREATED);
373         return extractId(res);
374     }
375     
376    /**
377      * Creates multiple Organization items within an Organization Authority,
378      * and stores the refNames referring to each.
379      */
380     private void createOrganizationRefs() {
381
382         createOrgAuthority(ORG_AUTHORITY_NAME, ORG_AUTHORITY_NAME);
383
384         String csid = "";
385
386         csid = createOrganization("Content Org", "Content Org Town", "contentOrg");
387         contentOrganizationRefName = OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, csid, null);
388         orgIdsCreated.add(csid);
389
390 //        csid = createOrganization("Production Org", "Production Org Town", "productionOrg");
391 //        objectProductionOrganizationRefName = OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, csid, null);
392 //        orgIdsCreated.add(csid);
393
394         csid = createOrganization("Associated Event Org", "Associated Event Org City", "associatedEventOrg");
395         assocEventOrganizationRefName = OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, csid, null);
396         orgIdsCreated.add(csid);
397
398 //        csid = createOrganization("Associated Org", "Associated Org City", "associatedOrg");
399 //        assocOrganizationRefName = OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, csid, null);
400 //        orgIdsCreated.add(csid);
401     }
402
403
404     // Success outcomes
405     /**
406      * Read and check auth refs.
407      *
408      * @param testName the test name
409      * @throws Exception the exception
410      */
411     @Test(dataProvider="testName",
412         dependsOnMethods = {"createWithAuthRefs"})
413     public void readAndCheckAuthRefs(String testName) throws Exception {
414         // Perform setup.
415         testSetup(STATUS_OK, ServiceRequestType.READ);
416         //
417         // First read the object
418         //
419         CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
420         ClientResponse<String> res = collectionObjectClient.read(knownResourceId);
421         CollectionobjectsCommon collectionObject = null;
422         try {
423                 assertStatusCode(res, testName);
424                 PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
425                 collectionObject = (CollectionobjectsCommon) extractPart(input,
426                                 collectionObjectClient.getCommonPartName(), CollectionobjectsCommon.class);
427                 Assert.assertNotNull(collectionObject);
428         } finally {
429                 if (res != null) {
430                 res.releaseConnection();
431             }
432         }
433         //
434         // Next, get all of the auth refs and check that the expected number is returned
435         //
436         ClientResponse<AuthorityRefList> res2 = collectionObjectClient.getAuthorityRefs(knownResourceId);
437         AuthorityRefList list = null;
438         try {
439                 assertStatusCode(res2, testName);        
440                 list = res2.getEntity();
441         } finally {
442                 if (res2 != null) {
443                         res2.releaseConnection();
444             }
445         }
446         
447         List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
448         int numAuthRefsFound = items.size();
449         if(logger.isDebugEnabled()){
450             logger.debug("Expected " + NUM_AUTH_REFS_EXPECTED +
451                 " authority references, found " + numAuthRefsFound);
452         }
453         Assert.assertEquals(numAuthRefsFound, NUM_AUTH_REFS_EXPECTED,
454             "Did not find all expected authority references! " +
455             "Expected " + NUM_AUTH_REFS_EXPECTED + ", found " + numAuthRefsFound);
456                
457         // Check a sample of one or more person authority ref fields
458         // Assert.assertEquals(collectionObject.getAssocPersons().getAssocPerson().get(0), assocPersonRefName);
459         Assert.assertEquals(collectionObject.getOwners().getOwner().get(0), ownerRefName);
460         Assert.assertEquals(collectionObject.getFieldCollectionSources().getFieldCollectionSource().get(0), fieldCollectionSourceRefName);
461
462         // Check a sample of one or more organization authority ref fields
463         Assert.assertEquals(collectionObject.getContentOrganizations().getContentOrganization().get(0), contentOrganizationRefName);
464         Assert.assertEquals(collectionObject.getAssocEventOrganizations().getAssocEventOrganization().get(0), assocEventOrganizationRefName);
465
466         // Optionally output additional data about list members for debugging.
467         logger.info(this.toString());
468         boolean iterateThroughList = true;
469         if(iterateThroughList && logger.isDebugEnabled()){;
470             int i = 0;
471             for(AuthorityRefList.AuthorityRefItem item : items){
472                 logger.debug(testName + ": list-item[" + i + "] Field:" +
473                                 item.getSourceField() + " =" +
474                         " item display name = " + item.getAuthDisplayName() +
475                         " auth display name = " + item.getItemDisplayName());
476                 logger.debug(testName + ": list-item[" + i + "] refName=" +
477                         item.getRefName());
478                 logger.debug(testName + ": list-item[" + i + "] URI=" +
479                         item.getUri());
480                 i++;
481             }
482         }
483     }
484
485
486     // ---------------------------------------------------------------
487     // Cleanup of resources created during testing
488     // ---------------------------------------------------------------
489
490     /**
491      * Deletes all resources created by tests, after all tests have been run.
492      *
493      * This cleanup method will always be run, even if one or more tests fail.
494      * For this reason, it attempts to remove all resources created
495      * at any point during testing, even if some of those resources
496      * may be expected to be deleted by certain tests.
497      */
498     @AfterClass(alwaysRun=true)
499     public void cleanUp() {
500         String noTest = System.getProperty("noTestCleanup");
501         if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
502             if (logger.isDebugEnabled()) {
503                 logger.debug("Skipping Cleanup phase ...");
504             }
505             return;
506         }
507         if (logger.isDebugEnabled()) {
508             logger.debug("Cleaning up temporary resources created for testing ...");
509         }
510         CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
511         for (String resourceId : collectionObjectIdsCreated) {
512             // Note: Any non-success responses are ignored and not reported.
513             collectionObjectClient.delete(resourceId).releaseConnection();
514         }
515         // Note: Any non-success response is ignored and not reported.
516         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
517         // Delete persons before PersonAuth
518         for (String resourceId : personIdsCreated) {
519             // Note: Any non-success responses are ignored and not reported.
520             personAuthClient.deleteItem(personAuthCSID, resourceId).releaseConnection();
521         }
522         personAuthClient.delete(personAuthCSID).releaseConnection();
523         // Note: Any non-success response is ignored and not reported.
524         OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
525         // Delete organizations before OrgAuth
526         for (String resourceId : orgIdsCreated) {
527             // Note: Any non-success responses are ignored and not reported.
528             orgAuthClient.deleteItem(orgAuthCSID, resourceId).releaseConnection();
529         }
530         orgAuthClient.delete(orgAuthCSID).releaseConnection();
531     }
532
533     // ---------------------------------------------------------------
534     // Utility methods used by tests above
535     // ---------------------------------------------------------------
536     /* (non-Javadoc)
537      * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
538      */
539     @Override
540     public String getServicePathComponent() {
541         return SERVICE_PATH_COMPONENT;
542     }
543
544    /**
545     * Creates the collection object instance.
546     *
547     * @param title the title
548     * @param objNum the obj num
549     * @param contentOrganization the content organization
550     * @param contentPeople the content people
551     * @param contentPerson the content person
552     * @param inscriber the inscriber
553     * @return the multipart output
554     */
555    private PoxPayloadOut createCollectionObjectInstance(
556                 String title,
557                 String objNum,
558                 String contentOrganization,
559                 String contentPerson,
560                 String assocEventOrganization,
561                 String assocEventPerson,
562                 String owner,
563                 String fieldCollectionSource,
564                 String fieldCollector ) {
565         CollectionobjectsCommon collectionObject = new CollectionobjectsCommon();
566         TitleGroupList titleGroupList = new TitleGroupList();
567         List<TitleGroup> titleGroups = titleGroupList.getTitleGroup();
568         TitleGroup titleGroup = new TitleGroup();
569         titleGroup.setTitle("a title");
570         titleGroups.add(titleGroup);
571         collectionObject.setTitleGroupList(titleGroupList);
572         collectionObject.setObjectNumber(objNum);
573
574         ContentOrganizationList contentOrganizationList = new ContentOrganizationList();
575         List<String> contentOrganizations = contentOrganizationList.getContentOrganization();
576         contentOrganizations.add(contentOrganization);
577         collectionObject.setContentOrganizations(contentOrganizationList);
578
579         ContentPersonList contentPersonList = new ContentPersonList();
580         List<String> contentPersons = contentPersonList.getContentPerson();
581         contentPersons.add(contentPerson);
582         collectionObject.setContentPersons(contentPersonList);
583
584         AssocEventOrganizationList assocEventOrganizationList = new AssocEventOrganizationList();
585         List<String> assocEventOrganizations = assocEventOrganizationList.getAssocEventOrganization();
586         assocEventOrganizations.add(assocEventOrganization);
587         collectionObject.setAssocEventOrganizations(assocEventOrganizationList);
588
589         AssocEventPersonList assocEventPersonList = new AssocEventPersonList();
590         List<String> assocEventPersons = assocEventPersonList.getAssocEventPerson();
591         assocEventPersons.add(assocEventPerson);
592         collectionObject.setAssocEventPersons(assocEventPersonList);
593
594 //        AssocOrganizationList assocOrganizationList = new AssocOrganizationList();
595 //        List<String> assocOrganizations = assocOrganizationList.getAssocOrganization();
596 //        assocOrganizations.add(assocOrganization);
597 //        collectionObject.setAssocOrganizations(assocOrganizationList);
598 //
599 //        AssocPersonList assocPersonList = new AssocPersonList();
600 //        List<String> assocPersons = assocPersonList.getAssocPerson();
601 //        assocPersons.add(assocPerson);
602 //        collectionObject.setAssocPersons(assocPersonList);
603         
604         OwnerList ownerList = new OwnerList();
605         List<String> owners = ownerList.getOwner();
606         owners.add(owner);
607         collectionObject.setOwners(ownerList);
608         
609         FieldCollectionSourceList fieldCollectionSourceList = new FieldCollectionSourceList();
610         List<String> fieldCollectionSources = fieldCollectionSourceList.getFieldCollectionSource();
611         fieldCollectionSources.add(fieldCollectionSource);
612         collectionObject.setFieldCollectionSources(fieldCollectionSourceList);
613         
614         FieldCollectorList FieldCollectorList = new FieldCollectorList();
615         List<String> fieldCollectors = FieldCollectorList.getFieldCollector();
616         fieldCollectors.add(fieldCollector);
617         collectionObject.setFieldCollectors(FieldCollectorList);
618
619         PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
620         PayloadOutputPart commonPart =
621             multipart.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE);
622         commonPart.setLabel(new CollectionObjectClient().getCommonPartName());
623
624         if(logger.isDebugEnabled()){
625             logger.debug("to be created, collectionObject common");
626             logger.debug(objectAsXmlString(collectionObject, CollectionobjectsCommon.class));
627         }
628
629         return multipart;
630     }
631
632 }