1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.service.impl;
17
18 import org.kuali.rice.krad.document.Document;
19 import org.kuali.rice.krad.service.DocumentSerializerService;
20 import org.kuali.rice.krad.service.XmlObjectSerializerService;
21 import org.kuali.rice.krad.util.documentserializer.AlwaysTruePropertySerializibilityEvaluator;
22 import org.kuali.rice.krad.util.documentserializer.PropertySerializabilityEvaluator;
23 import org.kuali.rice.krad.util.documentserializer.SerializationState;
24
25
26
27
28
29
30
31
32 public class DocumentSerializerServiceImpl extends SerializerServiceBase implements DocumentSerializerService {
33
34
35
36
37
38
39 public String serializeDocumentToXmlForRouting(Document document) {
40 PropertySerializabilityEvaluator propertySerizabilityEvaluator = document.getDocumentPropertySerizabilityEvaluator();
41 evaluators.set(propertySerizabilityEvaluator);
42 SerializationState state = createNewDocumentSerializationState(document);
43 serializationStates.set(state);
44
45 Object xmlWrapper = wrapDocumentWithMetadata(document);
46 String xml;
47 if (propertySerizabilityEvaluator instanceof AlwaysTruePropertySerializibilityEvaluator) {
48 xml = getXmlObjectSerializerService().toXml(xmlWrapper);
49 }
50 else {
51 xml = xstream.toXML(xmlWrapper);
52 }
53
54 evaluators.set(null);
55 serializationStates.set(null);
56 return xml;
57 }
58
59
60
61
62
63
64
65 protected Object wrapDocumentWithMetadata(Document document) {
66 return document.wrapDocumentWithMetadataForXmlSerialization();
67 }
68
69 @Override
70 protected PropertySerializabilityEvaluator getPropertySerizabilityEvaluator(Object dataObject) {
71 return null;
72 }
73 }