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