chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1448428 - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/util/ chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/c...
Date Wed, 20 Feb 2013 21:34:37 GMT
Author: fmui
Date: Wed Feb 20 21:34:37 2013
New Revision: 1448428

URL: http://svn.apache.org/r1448428
Log:
more XML stuff (trying to fix Jenkins build)

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/util/TypeUtils.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AbstractXMLConverterTest.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/util/TypeUtils.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/util/TypeUtils.java?rev=1448428&r1=1448427&r2=1448428&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/util/TypeUtils.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/util/TypeUtils.java
Wed Feb 20 21:34:37 2013
@@ -18,10 +18,7 @@
  */
 package org.apache.chemistry.opencmis.client.util;
 
-import static org.apache.chemistry.opencmis.commons.impl.Converter.convert;
-
 import java.io.BufferedWriter;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
@@ -31,8 +28,8 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-import javax.xml.bind.JAXBException;
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.FolderTypeDefinition;
@@ -52,10 +49,11 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.enums.Cardinality;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.enums.PropertyType;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
-import org.apache.chemistry.opencmis.commons.impl.JaxBHelper;
+import org.apache.chemistry.opencmis.commons.impl.XMLConstants;
 import org.apache.chemistry.opencmis.commons.impl.XMLConverter;
 import org.apache.chemistry.opencmis.commons.impl.XMLUtils;
 import org.apache.chemistry.opencmis.commons.impl.json.parser.JSONParser;
@@ -79,11 +77,11 @@ public class TypeUtils {
             throw new IllegalArgumentException("Output stream must be set!");
         }
 
-        try {
-            JaxBHelper.marshal(JaxBHelper.CMIS_EXTRA_OBJECT_FACTORY.createTypeDefinition(convert(type)),
stream, false);
-        } catch (JAXBException e) {
-            throw new IOException("Marshaling failed!", e);
-        }
+        XMLStreamWriter writer = XMLUtils.createWriter(stream);
+        XMLUtils.startXmlDocument(writer);
+        XMLConverter.writeTypeDefinition(writer, CmisVersion.CMIS_1_1, XMLConstants.NAMESPACE_CMIS,
type);
+        XMLUtils.endXmlDocument(writer);
+        writer.close();
     }
 
     /**

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java?rev=1448428&r1=1448427&r2=1448428&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java
Wed Feb 20 21:34:37 2013
@@ -49,6 +49,7 @@ public class XMLUtils {
      */
     public static XMLStreamWriter createWriter(OutputStream out) throws XMLStreamException
{
         XMLOutputFactory factory = XMLOutputFactory.newInstance();
+        factory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
         return factory.createXMLStreamWriter(out, "UTF-8");
     }
 
@@ -56,6 +57,7 @@ public class XMLUtils {
      * Starts a XML document.
      */
     public static void startXmlDocument(XMLStreamWriter writer) throws XMLStreamException
{
+        writer.setPrefix(PREFIX_XSI, XMLConstants.NAMESPACE_XSI);
         writer.setPrefix(PREFIX_ATOM, XMLConstants.NAMESPACE_ATOM);
         writer.setPrefix(PREFIX_CMIS, XMLConstants.NAMESPACE_CMIS);
         writer.setPrefix(PREFIX_RESTATOM, XMLConstants.NAMESPACE_RESTATOM);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AbstractXMLConverterTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AbstractXMLConverterTest.java?rev=1448428&r1=1448427&r2=1448428&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AbstractXMLConverterTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/AbstractXMLConverterTest.java
Wed Feb 20 21:34:37 2013
@@ -55,7 +55,7 @@ import javax.xml.validation.Validator;
 import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.impl.XMLConstants;
 import org.apache.chemistry.opencmis.commons.impl.XMLUtils;
-import org.junit.BeforeClass;
+import org.junit.Before;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.SAXException;
@@ -65,7 +65,7 @@ public abstract class AbstractXMLConvert
     protected final static String TEST_NAMESPACE = "http://chemistry.apache.org/test/schema";
     protected final static String TEST_PREFIX = "test";
 
-    private Logger LOG = LoggerFactory.getLogger(AbstractXMLConverterTest.class);
+    private final static Logger LOG = LoggerFactory.getLogger(AbstractXMLConverterTest.class);
 
     private final static long SEED = 1234567890;
 
@@ -90,25 +90,25 @@ public abstract class AbstractXMLConvert
             + "<xs:element name=\"test\" type=\"test:testType\"/>" //
             + "</xs:schema>";
 
-    protected static Schema schema10;
-    protected static Schema schema11;
-    protected static Random rnd;
+    protected Schema schema10;
+    protected Schema schema11;
+    protected Random rnd;
 
     /**
      * Sets up the schema.
      */
-    @BeforeClass
-    public static void init() throws SAXException, UnsupportedEncodingException {
+    @Before
+    public void init() throws SAXException, UnsupportedEncodingException {
         SchemaFactory sf = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
 
-        InputStream schema10stream = AbstractXMLConverterTest.class.getResourceAsStream("/schema/cmis10/CMIS-core.xsd");
+        InputStream schema10stream = this.getClass().getResourceAsStream("/schema/cmis10/CMIS-core.xsd");
         if (schema10stream == null) {
             throw new RuntimeException("Cannot find CMIS 1.0 schema file!");
         }
         StreamSource core10 = new StreamSource(schema10stream);
         StreamSource test10 = new StreamSource(new ByteArrayInputStream(TEST_SCHEMA.getBytes("UTF-8")));
 
-        InputStream schema11stream = AbstractXMLConverterTest.class.getResourceAsStream("/schema/cmis11/CMIS-core.xsd");
+        InputStream schema11stream = this.getClass().getResourceAsStream("/schema/cmis11/CMIS-core.xsd");
         if (schema11stream == null) {
             throw new RuntimeException("Cannot find CMIS 1.1 schema file!");
         }



Mime
View raw message