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