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