]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
a763fc206f2da1ec8762cca8eabfc0b90f21b187
[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.List;
27 import javax.ws.rs.core.MediaType;
28 import javax.ws.rs.core.Response;
29
30 import org.collectionspace.services.client.RelationClient;
31 import org.collectionspace.services.relation.RelationsCommon;
32 import org.collectionspace.services.relation.RelationsCommonList;
33 import org.collectionspace.services.relation.RelationshipType;
34
35 import org.jboss.resteasy.client.ClientResponse;
36
37 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
38 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
39 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
40 import org.testng.Assert;
41 import org.testng.annotations.AfterClass;
42 import org.testng.annotations.Test;
43
44 import org.slf4j.Logger;
45 import org.slf4j.LoggerFactory;
46
47 /**
48  * RelationServiceTest, carries out tests against a
49  * deployed and running Relation Service.
50  * 
51  * $LastChangedRevision$
52  * $LastChangedDate$
53  */
54 public class RelationServiceTest extends AbstractServiceTestImpl {
55
56    private final Logger logger =
57         LoggerFactory.getLogger(RelationServiceTest.class);
58
59     private RelationClient client = new RelationClient();
60     final String SERVICE_PATH_COMPONENT = "relations";
61     private String knownResourceId = null;
62     private List<String> allResourceIdsCreated = new ArrayList();
63
64     // ---------------------------------------------------------------
65     // CRUD tests : CREATE tests
66     // ---------------------------------------------------------------
67     // Success outcomes
68     @Override
69     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
70     public void create(String testName) throws Exception {
71
72         // Perform setup, such as initializing the type of service request
73         // (e.g. CREATE, DELETE), its valid and expected status codes, and
74         // its associated HTTP method name (e.g. POST, DELETE).
75         setupCreate(testName);
76
77         // Submit the request to the service and store the response.
78         String identifier = createIdentifier();
79         MultipartOutput multipart = createRelationInstance(identifier);
80         ClientResponse<Response> res = client.create(multipart);
81         int statusCode = res.getStatus();
82
83         // Check the status code of the response: does it match
84         // the expected response(s)?
85         //
86         // Does it fall within the set of valid status codes?
87         // Does it exactly match the expected status code?
88         if(logger.isDebugEnabled()){
89             logger.debug(testName + ": status = " + statusCode);
90         }
91         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
92                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
93         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
94
95         // Store the ID returned from the first resource created
96         // for additional tests below.
97         if (knownResourceId == null){
98             knownResourceId = extractId(res);
99             if (logger.isDebugEnabled()) {
100                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
101             }
102         }
103
104         // Store the IDs from every resource created by tests,
105         // so they can be deleted after tests have been run.
106         allResourceIdsCreated.add(extractId(res));
107     }
108
109     @Override
110     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
111         dependsOnMethods = {"create"})
112     public void createList(String testName) throws Exception {
113         for(int i = 0; i < 3; i++){
114             create(testName);
115         }
116     }
117
118     // Failure outcomes
119     // Placeholders until the three tests below can be uncommented.
120     // See Issue CSPACE-401.
121     public void createWithEmptyEntityBody(String testName) throws Exception {
122     }
123
124     public void createWithMalformedXml(String testName) throws Exception {
125     }
126
127     public void createWithWrongXmlSchema(String testName) throws Exception {
128     }
129
130     /*
131     @Override
132     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
133         dependsOnMethods = {"create", "testSubmitRequest"})
134     public void createWithEmptyEntityBody(String testName) throws Exception {
135     
136     // Perform setup.
137     setupCreateWithEmptyEntityBody(testName);
138
139     // Submit the request to the service and store the response.
140     String method = REQUEST_TYPE.httpMethodName();
141     String url = getServiceRootURL();
142     String mediaType = MediaType.APPLICATION_XML;
143     final String entity = "";
144     int statusCode = submitRequest(method, url, mediaType, entity);
145
146     // Check the status code of the response: does it match
147     // the expected response(s)?
148     if(logger.isDebugEnabled()){
149         logger.debug(testName + ": url=" + url +
150             " status=" + statusCode);
151      }
152     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
153     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
154     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
155     }
156
157     @Override
158     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
159         dependsOnMethods = {"create", "testSubmitRequest"})
160     public void createWithMalformedXml(String testName) throws Exception {
161     
162     // Perform setup.
163     setupCreateWithMalformedXml(testName);
164
165     // Submit the request to the service and store the response.
166     String method = REQUEST_TYPE.httpMethodName();
167     String url = getServiceRootURL();
168     String mediaType = MediaType.APPLICATION_XML;
169     final String entity = MALFORMED_XML_DATA; // Constant from base class.
170     int statusCode = submitRequest(method, url, mediaType, entity);
171
172     // Check the status code of the response: does it match
173     // the expected response(s)?
174     if(logger.isDebugEnabled()){
175         logger.debug(testName + ": url=" + url +
176             " status=" + statusCode);
177      }
178     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
179     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
180     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
181     }
182
183     @Override
184     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
185         dependsOnMethods = {"create", "testSubmitRequest"})
186     public void createWithWrongXmlSchema(String testName) throws Exception {
187     
188     // Perform setup.
189     setupCreateWithWrongXmlSchema(testName);
190
191     // Submit the request to the service and store the response.
192     String method = REQUEST_TYPE.httpMethodName();
193     String url = getServiceRootURL();
194     String mediaType = MediaType.APPLICATION_XML;
195     final String entity = WRONG_XML_SCHEMA_DATA;
196     int statusCode = submitRequest(method, url, mediaType, entity);
197
198     // Check the status code of the response: does it match
199     // the expected response(s)?
200     if(logger.isDebugEnabled()){
201       logger.debug(testName + ": url=" + url +
202           " status=" + statusCode);
203      }
204     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
205     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
206     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
207     }
208      */
209
210     // ---------------------------------------------------------------
211     // CRUD tests : READ tests
212     // ---------------------------------------------------------------
213     // Success outcomes
214     @Override
215     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
216         dependsOnMethods = {"create"})
217     public void read(String testName) throws Exception {
218
219         // Perform setup.
220         setupRead(testName);
221
222         // Submit the request to the service and store the response.
223         ClientResponse<MultipartInput> res = client.read(knownResourceId);
224         int statusCode = res.getStatus();
225
226         // Check the status code of the response: does it match
227         // the expected response(s)?
228         if(logger.isDebugEnabled()){
229             logger.debug(testName + ": status = " + statusCode);
230         }
231         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
232                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
233         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
234
235         // Verify that the resource identifier ...
236         MultipartInput input = (MultipartInput) res.getEntity();
237         RelationsCommon relation = (RelationsCommon) extractPart(input,
238                 client.getCommonPartName(), RelationsCommon.class);
239         Assert.assertNotNull(relation);
240
241     }
242
243     // Failure outcomes
244     @Override
245     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
246         dependsOnMethods = {"read"})
247     public void readNonExistent(String testName) throws Exception {
248
249         // Perform setup.
250         setupReadNonExistent(testName);
251
252         // Submit the request to the service and store the response.
253         ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
254         int statusCode = res.getStatus();
255
256         // Check the status code of the response: does it match
257         // the expected response(s)?
258         if(logger.isDebugEnabled()){
259             logger.debug(testName + ": status = " + statusCode);
260         }
261         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
262                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
263         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
264     }
265
266     // ---------------------------------------------------------------
267     // CRUD tests : READ_LIST tests
268     // ---------------------------------------------------------------
269     // Success outcomes
270     @Override
271     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
272         dependsOnMethods = {"createList", "read"})
273     public void readList(String testName) throws Exception {
274
275         // Perform setup.
276         setupReadList(testName);
277
278         // Submit the request to the service and store the response.
279         ClientResponse<RelationsCommonList> res = client.readList();
280         RelationsCommonList list = res.getEntity();
281         int statusCode = res.getStatus();
282
283         // Check the status code of the response: does it match
284         // the expected response(s)?
285         if(logger.isDebugEnabled()){
286             logger.debug(testName + ": status = " + statusCode);
287         }
288         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
289                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
290         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
291
292         // Optionally output additional data about list members for debugging.
293         boolean iterateThroughList = false;
294         if(iterateThroughList && logger.isDebugEnabled()){
295             List<RelationsCommonList.RelationListItem> items =
296                     list.getRelationListItem();
297             int i = 0;
298             for(RelationsCommonList.RelationListItem item : items){
299                 logger.debug(testName + ": list-item[" + i + "] csid=" +
300                         item.getCsid());
301                 logger.debug(testName + ": list-item[" + i + "] URI=" +
302                         item.getUri());
303                 i++;
304             }
305         }
306
307     }
308
309     // Failure outcomes
310     // None at present.
311
312     // ---------------------------------------------------------------
313     // CRUD tests : UPDATE tests
314     // ---------------------------------------------------------------
315
316     // Success outcomes
317     @Override
318     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
319         dependsOnMethods = {"read"})
320     public void update(String testName) throws Exception {
321
322         // Perform setup.
323         setupUpdate(testName);
324
325         // Retrieve an existing resource that we can update.
326         ClientResponse<MultipartInput> res =
327                 client.read(knownResourceId);
328         if(logger.isDebugEnabled()){
329             logger.debug(testName + ": read status = " + res.getStatus());
330         }
331         Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
332         if(logger.isDebugEnabled()){
333             logger.debug("Got object to update with ID: " + knownResourceId);
334         }
335         MultipartInput input = (MultipartInput) res.getEntity();
336         RelationsCommon relation = (RelationsCommon) extractPart(input,
337                 client.getCommonPartName(), RelationsCommon.class);
338         Assert.assertNotNull(relation);
339
340         // Update the content of this resource.
341         relation.setDocumentId1("updated-" + relation.getDocumentId1());
342         relation.setDocumentType1("updated-" + relation.getDocumentType1());
343         relation.setDocumentId2("updated-" + relation.getDocumentId2());
344         relation.setDocumentType2("updated-" + relation.getDocumentType2());
345         if(logger.isDebugEnabled()){
346             logger.debug("updated object");
347             logger.debug(objectAsXmlString(relation, RelationsCommon.class));
348         }
349
350         // Submit the request to the service and store the response.
351         MultipartOutput output = new MultipartOutput();
352         OutputPart commonPart = output.addPart(relation, MediaType.APPLICATION_XML_TYPE);
353         commonPart.getHeaders().add("label", client.getCommonPartName());
354         res = client.update(knownResourceId, output);
355         int statusCode = res.getStatus();
356
357         // Check the status code of the response: does it match the expected response(s)?
358         if(logger.isDebugEnabled()){
359             logger.debug(testName + ": status = " + statusCode);
360         }
361         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
362                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
363         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
364
365         input = (MultipartInput) res.getEntity();
366         RelationsCommon updatedObject = (RelationsCommon) extractPart(
367                 input, client.getCommonPartName(),
368                 RelationsCommon.class);
369         Assert.assertNotNull(updatedObject);
370
371         final String msg =
372                 "Data in updated object did not match submitted data.";
373         Assert.assertEquals(
374                 updatedObject.getDocumentId1(), relation.getDocumentId1(), msg);
375         Assert.assertEquals(
376                 updatedObject.getDocumentType1(), relation.getDocumentType1(), msg);
377         Assert.assertEquals(
378                 updatedObject.getDocumentId2(), relation.getDocumentId2(), msg);
379         Assert.assertEquals(
380                 updatedObject.getDocumentType2(), relation.getDocumentType2(), msg);
381
382     }
383
384     // Failure outcomes
385     // Placeholders until the three tests below can be uncommented.
386     // See Issue CSPACE-401.
387     public void updateWithEmptyEntityBody(String testName) throws Exception {
388     }
389
390     public void updateWithMalformedXml(String testName) throws Exception {
391     }
392
393     public void updateWithWrongXmlSchema(String testName) throws Exception {
394     }
395
396     /*
397     @Override
398     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
399         dependsOnMethods = {"create", "update", "testSubmitRequest"})
400     public void updateWithEmptyEntityBody(String testName) throws Exception {
401     
402     // Perform setup.
403     setupUpdateWithEmptyEntityBody(testName);
404
405     // Submit the request to the service and store the response.
406     String method = REQUEST_TYPE.httpMethodName();
407     String url = getResourceURL(knownResourceId);
408     String mediaType = MediaType.APPLICATION_XML;
409     final String entity = "";
410     int statusCode = submitRequest(method, url, mediaType, entity);
411
412     // Check the status code of the response: does it match
413     // the expected response(s)?
414     if(logger.isDebugEnabled()){
415        logger.debug(testName + ": url=" + url +
416            " status=" + statusCode);
417      }
418     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
419     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
420     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
421     }
422
423     @Override
424     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
425         dependsOnMethods = {"create", "update", "testSubmitRequest"})
426     public void updateWithMalformedXml(String testName) throws Exception {
427
428     // Perform setup.
429     setupUpdateWithMalformedXml(testName);
430
431     // Submit the request to the service and store the response.
432     String method = REQUEST_TYPE.httpMethodName();
433     String url = getResourceURL(knownResourceId);
434     String mediaType = MediaType.APPLICATION_XML;
435     final String entity = MALFORMED_XML_DATA; // Constant from abstract base class.
436     int statusCode = submitRequest(method, url, mediaType, entity);
437
438     // Check the status code of the response: does it match
439     // the expected response(s)?
440     if(logger.isDebugEnabled()){
441         logger.debug(testName + ": url=" + url +
442         " status=" + statusCode);
443      }
444     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
445     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
446     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
447     }
448
449     @Override
450     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
451         dependsOnMethods = {"create", "update", "testSubmitRequest"})
452     public void updateWithWrongXmlSchema(String testName) throws Exception {
453     
454     // Perform setup.
455     setupUpdateWithWrongXmlSchema(testName);
456
457     // Submit the request to the service and store the response.
458     String method = REQUEST_TYPE.httpMethodName();
459     String url = getResourceURL(knownResourceId);
460     String mediaType = MediaType.APPLICATION_XML;
461     final String entity = WRONG_XML_SCHEMA_DATA; // Constant from abstract base class.
462     int statusCode = submitRequest(method, url, mediaType, entity);
463
464     // Check the status code of the response: does it match
465     // the expected response(s)?
466     if(logger.isDebugEnabled()){
467         logger.debug(testName + ": url=" + url +
468         " status=" + statusCode);
469      }
470     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
471     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
472     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
473     }
474      */
475
476     @Override
477     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
478         dependsOnMethods = {"update", "testSubmitRequest"})
479     public void updateNonExistent(String testName) throws Exception {
480
481         // Perform setup.
482         setupUpdateNonExistent(testName);
483
484         // Submit the request to the service and store the response.
485         // Note: The ID used in this 'create' call may be arbitrary.
486         // The only relevant ID may be the one used in update(), below.
487         MultipartOutput multipart = createRelationInstance(NON_EXISTENT_ID);
488         ClientResponse<MultipartInput> res =
489                 client.update(NON_EXISTENT_ID, multipart);
490         int statusCode = res.getStatus();
491
492         // Check the status code of the response: does it match
493         // the expected response(s)?
494         if(logger.isDebugEnabled()){
495             logger.debug(testName + ": status = " + statusCode);
496         }
497         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
498                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
499         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
500     }
501
502     // ---------------------------------------------------------------
503     // CRUD tests : DELETE tests
504     // ---------------------------------------------------------------
505     // Success outcomes
506     @Override
507     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
508         dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
509     public void delete(String testName) throws Exception {
510
511         // Perform setup.
512         setupDelete(testName);
513
514         // Submit the request to the service and store the response.
515         ClientResponse<Response> res = client.delete(knownResourceId);
516         int statusCode = res.getStatus();
517
518         // Check the status code of the response: does it match
519         // the expected response(s)?
520         if(logger.isDebugEnabled()){
521             logger.debug(testName + ": status = " + statusCode);
522         }
523         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
524                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
525         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
526     }
527
528     // Failure outcomes
529     @Override
530     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
531         dependsOnMethods = {"delete"})
532     public void deleteNonExistent(String testName) throws Exception {
533
534         // Perform setup.
535         setupDeleteNonExistent(testName);
536
537         // Submit the request to the service and store the response.
538         ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
539         int statusCode = res.getStatus();
540
541         // Check the status code of the response: does it match
542         // the expected response(s)?
543         if(logger.isDebugEnabled()){
544             logger.debug(testName + ": status = " + statusCode);
545         }
546         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
547                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
548         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
549     }
550
551     // ---------------------------------------------------------------
552     // RELATE_OBJECT tests
553     // ---------------------------------------------------------------
554     @Test(dependsOnMethods = {"create"})
555     public void relateObjects() {
556     }
557
558     // ---------------------------------------------------------------
559     // Utility tests : tests of code used in tests above
560     // ---------------------------------------------------------------
561     /**
562      * Tests the code for manually submitting data that is used by several
563      * of the methods above.
564      */
565     @Test(dependsOnMethods = {"create", "read"})
566     public void testSubmitRequest() {
567
568         // Expected status code: 200 OK
569         final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
570
571         // Submit the request to the service and store the response.
572         String method = ServiceRequestType.READ.httpMethodName();
573         String url = getResourceURL(knownResourceId);
574         int statusCode = submitRequest(method, url);
575
576         // Check the status code of the response: does it match
577         // the expected response(s)?
578         if(logger.isDebugEnabled()){
579             logger.debug("testSubmitRequest: url=" + url +
580                 " status=" + statusCode);
581         }
582         Assert.assertEquals(statusCode, EXPECTED_STATUS);
583
584     }
585
586     // ---------------------------------------------------------------
587     // Cleanup of resources created during testing
588     // ---------------------------------------------------------------
589
590     /**
591      * Deletes all resources created by tests, after all tests have been run.
592      *
593      * This cleanup method will always be run, even if one or more tests fail.
594      * For this reason, it attempts to remove all resources created
595      * at any point during testing, even if some of those resources
596      * may be expected to be deleted by certain tests.
597      */
598     @AfterClass(alwaysRun=true)
599     public void cleanUp() {
600         if (logger.isDebugEnabled()) {
601             logger.debug("Cleaning up temporary resources created for testing ...");
602         }
603         for (String resourceId : allResourceIdsCreated) {
604             // Note: Any non-success responses are ignored and not reported.
605             ClientResponse<Response> res = client.delete(resourceId);
606         }
607     }
608
609     // ---------------------------------------------------------------
610     // Utility methods used by tests above
611     // ---------------------------------------------------------------
612     @Override
613     public String getServicePathComponent() {
614         return SERVICE_PATH_COMPONENT;
615     }
616
617     private MultipartOutput createRelationInstance(String identifier) {
618         RelationsCommon relation = new RelationsCommon();
619         fillRelation(relation, identifier);
620
621         MultipartOutput multipart = new MultipartOutput();
622         OutputPart commonPart =
623                 multipart.addPart(relation, MediaType.APPLICATION_XML_TYPE);
624         commonPart.getHeaders().add("label", client.getCommonPartName());
625         if(logger.isDebugEnabled()){
626           logger.debug("to be created, relation common");
627           logger.debug(objectAsXmlString(relation, RelationsCommon.class));
628         }
629         return multipart;
630     }
631
632     /**
633      * Fills the relation.
634      * 
635      * @param identifier the identifier
636      * 
637      * @return the relation
638      */
639     private void fillRelation(RelationsCommon relation, String identifier) {
640         fillRelation(relation, "Subject-" + identifier,
641                 "SubjectType-" + identifier + "-type",
642                 "Object-" + identifier,
643                 "ObjectType-" + identifier + "-type",
644                 RelationshipType.COLLECTIONOBJECT_INTAKE);
645     }
646
647     /**
648      * Fills the relation.
649      * 
650      * @param documentId1 the document id1
651      * @param documentType1 the document type1
652      * @param documentId2 the document id2
653      * @param documentType2 the document type2
654      * @param rt the rt
655      * 
656      * @return the relation
657      */
658     private void fillRelation(RelationsCommon relation,
659             String documentId1, String documentType1,
660             String documentId2, String documentType2,
661             RelationshipType rt) {
662         relation.setDocumentId1(documentId1);
663         relation.setDocumentType1(documentType1);
664         relation.setDocumentId2(documentId2);
665         relation.setDocumentType2(documentType2);
666
667         relation.setRelationshipType(rt);
668     }
669 }