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