You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2011/05/20 16:12:29 UTC
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
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 <a href="mailto:fmueller@opentext.com">Florian Müller</a>
- *
*/
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 <a href="mailto:fmueller@opentext.com">Florian Müller</a>
- *
*/
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;
}
}