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