Return-Path: X-Original-To: apmail-chemistry-commits-archive@www.apache.org Delivered-To: apmail-chemistry-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B384E6436 for ; Fri, 20 May 2011 14:12:54 +0000 (UTC) Received: (qmail 64170 invoked by uid 500); 20 May 2011 14:12:54 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 64139 invoked by uid 500); 20 May 2011 14:12:54 -0000 Mailing-List: contact commits-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list commits@chemistry.apache.org Received: (qmail 64126 invoked by uid 99); 20 May 2011 14:12:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 May 2011 14:12:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 May 2011 14:12:51 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 73BCC2388A60; Fri, 20 May 2011 14:12:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1125408 - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub: AtomDocumentBase.java XMLDocumentBase.java Date: Fri, 20 May 2011 14:12:29 -0000 To: commits@chemistry.apache.org From: fmui@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110520141229.73BCC2388A60@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fmui Date: Fri May 20 14:12:29 2011 New Revision: 1125408 URL: http://svn.apache.org/viewvc?rev=1125408&view=rev Log: - CMIS-377: set AtomPub XML encoding to UTF-8 - code clean up Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomDocumentBase.java chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/XMLDocumentBase.java Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomDocumentBase.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomDocumentBase.java?rev=1125408&r1=1125407&r2=1125408&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomDocumentBase.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomDocumentBase.java Fri May 20 14:12:29 2011 @@ -34,27 +34,24 @@ import org.apache.commons.codec.binary.B /** * Atom base class. - * - * @author Florian Müller - * */ public abstract class AtomDocumentBase extends XMLDocumentBase { - private static final String ID_PREFIX = "http://opencmis.org/"; - private static final String ID_DUMMY = "http://opencmis.org/no-id"; + private static final String ID_PREFIX = "http://chemistry.apache.org/"; + private static final String ID_DUMMY = "http://chemistry.apache.org/no-id"; - private SimpleDateFormat fDateFormater; + private SimpleDateFormat dateFormater; /** * Formats a DateTime. */ public String formatDate(long millis) { - if (fDateFormater == null) { - fDateFormater = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); - fDateFormater.setTimeZone(TimeZone.getTimeZone("UTC")); + if (dateFormater == null) { + dateFormater = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); + dateFormater.setTimeZone(TimeZone.getTimeZone("UTC")); } - return fDateFormater.format(millis); + return dateFormater.format(millis); } /** Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/XMLDocumentBase.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/XMLDocumentBase.java?rev=1125408&r1=1125407&r2=1125408&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/XMLDocumentBase.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/XMLDocumentBase.java Fri May 20 14:12:29 2011 @@ -28,9 +28,6 @@ import org.apache.chemistry.opencmis.com /** * Base class for XML documents. - * - * @author Florian Müller - * */ public abstract class XMLDocumentBase { @@ -40,24 +37,24 @@ public abstract class XMLDocumentBase { public static final String PREFIX_APP = "app"; public static final String PREFIX_XSI = "xsi"; - private XMLStreamWriter fWriter; + private XMLStreamWriter writer; /** * Sets the namespaces for the document. */ public void setNamespaces() throws XMLStreamException { - fWriter.setPrefix(PREFIX_ATOM, Constants.NAMESPACE_ATOM); - fWriter.setPrefix(PREFIX_CMIS, Constants.NAMESPACE_CMIS); - fWriter.setPrefix(PREFIX_RESTATOM, Constants.NAMESPACE_RESTATOM); - fWriter.setPrefix(PREFIX_APP, Constants.NAMESPACE_APP); - fWriter.setPrefix(PREFIX_XSI, Constants.NAMESPACE_XSI); + writer.setPrefix(PREFIX_ATOM, Constants.NAMESPACE_ATOM); + writer.setPrefix(PREFIX_CMIS, Constants.NAMESPACE_CMIS); + writer.setPrefix(PREFIX_RESTATOM, Constants.NAMESPACE_RESTATOM); + writer.setPrefix(PREFIX_APP, Constants.NAMESPACE_APP); + writer.setPrefix(PREFIX_XSI, Constants.NAMESPACE_XSI); } /** * Writes the namespace declaration of the given URI to the current tag. */ public void writeNamespace(String namespaceUri) throws XMLStreamException { - fWriter.writeNamespace(fWriter.getPrefix(namespaceUri), namespaceUri); + writer.writeNamespace(writer.getPrefix(namespaceUri), namespaceUri); } /** @@ -66,10 +63,10 @@ public abstract class XMLDocumentBase { public void startDocument(OutputStream out) throws XMLStreamException { // create a writer XMLOutputFactory factory = XMLOutputFactory.newInstance(); - fWriter = factory.createXMLStreamWriter(out); + writer = factory.createXMLStreamWriter(out, "UTF-8"); // start the document - fWriter.writeStartDocument(); + writer.writeStartDocument("UTF-8", "1.0"); setNamespaces(); } @@ -77,28 +74,28 @@ public abstract class XMLDocumentBase { * Finishes the document. */ public void endDocument() throws XMLStreamException { - if (fWriter == null) { + if (writer == null) { return; } // end the document - fWriter.writeEndDocument(); + writer.writeEndDocument(); // we are done. - fWriter.close(); + writer.close(); } /** * Returns the writer object. */ public XMLStreamWriter getWriter() { - return fWriter; + return writer; } /** * Sets the writer object. */ protected void setWriter(XMLStreamWriter writer) { - fWriter = writer; + this.writer = writer; } }