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