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