|
9 | 9 | */ |
10 | 10 | package org.openmrs.module.reporting.serializer; |
11 | 11 |
|
12 | | -import com.thoughtworks.xstream.XStream; |
13 | | -import com.thoughtworks.xstream.converters.ConverterLookup; |
14 | | -import com.thoughtworks.xstream.converters.DataHolder; |
15 | | -import com.thoughtworks.xstream.core.MapBackedDataHolder; |
16 | | -import com.thoughtworks.xstream.io.HierarchicalStreamReader; |
17 | | -import com.thoughtworks.xstream.io.xml.DomDriver; |
18 | | -import com.thoughtworks.xstream.mapper.Mapper; |
19 | | -import com.thoughtworks.xstream.mapper.MapperWrapper; |
| 12 | +import java.io.OutputStream; |
| 13 | +import java.io.OutputStreamWriter; |
| 14 | +import java.io.UnsupportedEncodingException; |
| 15 | +import java.lang.reflect.Method; |
20 | 16 |
|
| 17 | +import org.openmrs.api.APIException; |
21 | 18 | import org.openmrs.api.context.Context; |
22 | 19 | import org.openmrs.module.serialization.xstream.XStreamShortSerializer; |
23 | 20 | import org.openmrs.module.serialization.xstream.mapper.CGLibMapper; |
|
27 | 24 | import org.openmrs.serialization.SerializationException; |
28 | 25 | import org.openmrs.serialization.SimpleXStreamSerializer; |
29 | 26 |
|
30 | | -import java.io.OutputStream; |
31 | | -import java.io.OutputStreamWriter; |
32 | | -import java.io.UnsupportedEncodingException; |
33 | | -import java.lang.reflect.Method; |
| 27 | +import com.thoughtworks.xstream.XStream; |
| 28 | +import com.thoughtworks.xstream.converters.ConverterLookup; |
| 29 | +import com.thoughtworks.xstream.converters.DataHolder; |
| 30 | +import com.thoughtworks.xstream.core.MapBackedDataHolder; |
| 31 | +import com.thoughtworks.xstream.io.HierarchicalStreamReader; |
| 32 | +import com.thoughtworks.xstream.io.xml.DomDriver; |
| 33 | +import com.thoughtworks.xstream.mapper.Mapper; |
| 34 | +import com.thoughtworks.xstream.mapper.MapperWrapper; |
34 | 35 |
|
35 | 36 |
|
36 | 37 | public class ReportingSerializer extends XStreamShortSerializer { |
@@ -118,15 +119,20 @@ public void serializeToStream(Object object, OutputStream out) { |
118 | 119 | } |
119 | 120 |
|
120 | 121 | private void setupXStreamSecurity(XStream xstream) throws SerializationException { |
121 | | - SimpleXStreamSerializer serializer = Context.getRegisteredComponent("simpleXStreamSerializer", SimpleXStreamSerializer.class); |
122 | | - if (serializer != null) { |
123 | | - try { |
124 | | - Method method = serializer.getClass().getMethod("initXStream", XStream.class); |
125 | | - method.invoke(serializer, xstream); |
126 | | - } |
127 | | - catch (Exception ex) { |
128 | | - throw new SerializationException("Failed to set up XStream Security", ex); |
| 122 | + try { |
| 123 | + SimpleXStreamSerializer serializer = Context.getRegisteredComponent("simpleXStreamSerializer", SimpleXStreamSerializer.class); |
| 124 | + if (serializer != null) { |
| 125 | + try { |
| 126 | + Method method = serializer.getClass().getMethod("initXStream", XStream.class); |
| 127 | + method.invoke(serializer, xstream); |
| 128 | + } |
| 129 | + catch (Exception ex) { |
| 130 | + throw new SerializationException("Failed to set up XStream Security", ex); |
| 131 | + } |
129 | 132 | } |
130 | | - } |
| 133 | + } |
| 134 | + catch (APIException ex) { |
| 135 | + //Ignore APIException("Error during getting registered component) for platform versions below 2.7.0 |
| 136 | + } |
131 | 137 | } |
132 | 138 | } |
0 commit comments