abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1195583 [2/2] - in /abdera/abdera2: activities/src/main/java/org/apache/abdera2/activities/model/ activities/src/main/java/org/apache/abdera2/activities/protocol/managed/ common/src/main/java/org/apache/abdera2/common/ common/src/main/java...
Date Mon, 31 Oct 2011 17:42:22 GMT
Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/FOMResponseContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/FOMResponseContext.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/FOMResponseContext.java
(original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/FOMResponseContext.java
Mon Oct 31 17:42:21 2011
@@ -28,6 +28,7 @@ import org.apache.abdera2.model.Document
 import org.apache.abdera2.model.Element;
 import org.apache.abdera2.model.Element.Helper;
 import org.apache.abdera2.protocol.server.AtompubResponseContext;
+import org.apache.abdera2.common.mediatype.MimeTypeHelper;
 import org.apache.abdera2.common.protocol.AbstractResponseContext;
 import org.apache.abdera2.writer.Writer;
 
@@ -51,7 +52,8 @@ public class FOMResponseContext<T extend
         this.chunked = chunked;
         try {
             MimeType type = getContentType();
-            String charset = type.getParameter("charset");
+            String charset = 
+              type.getParameter("charset");
             if (charset == null)
                 charset = getCharsetFromBase(base);
             if (charset == null)
@@ -63,82 +65,81 @@ public class FOMResponseContext<T extend
     }
 
     private String getCharsetFromBase(Base base) {
-        if (base == null)
-            return null;
-        if (base instanceof Document) {
-            return ((Document<?>)base).getCharset();
-        } else if (base instanceof Element) {
-            return getCharsetFromBase(((Element)base).getDocument());
-        }
-        return null;
+      return base == null ?
+        null :
+        base instanceof Document ?
+          ((Document<?>)base).getCharset() :
+          base instanceof Element ?
+              getCharsetFromBase(((Element)base).getDocument()) :
+              null;
     }
 
     public T getBase() {
-        return base;
+      return base;
     }
 
     public boolean hasEntity() {
-        return (base != null);
+      return (base != null);
     }
 
     public void writeTo(java.io.Writer javaWriter) throws IOException {
-        if (hasEntity()) {
-            if (writer == null)
-                base.writeTo(javaWriter);
-            else
-                writeTo(javaWriter, writer);
-        }
+      if (hasEntity())
+        if (writer == null)
+          base.writeTo(javaWriter);
+        else
+          writeTo(javaWriter, writer);
     }
 
     public void writeTo(OutputStream out) throws IOException {
-        if (hasEntity()) {
-            if (writer == null)
-                base.writeTo(out);
-            else
-                writeTo(out, writer);
-        }
+      if (hasEntity())
+        if (writer == null)
+          base.writeTo(out);
+        else
+          writeTo(out, writer);
     }
 
     @Override
     public MimeType getContentType() {
-        try {
-            MimeType t = super.getContentType();
-            if (t == null) {
-                String type = Helper.getMimeType(base);
-                if (type != null)
-                    t = new MimeType(type);
-            }
-            return t;
-        } catch (javax.activation.MimeTypeParseException e) {
-            throw new org.apache.abdera2.common.mediatype.MimeTypeParseException(e);
-        }
+      MimeType t = super.getContentType();
+      if (t == null) {
+        String type = Helper.getMimeType(base);
+        if (type != null)
+          t = MimeTypeHelper.create(type);
+      }
+      return t;
     }
 
     @Override
     public long getContentLength() {
-        long len = super.getContentLength();
-        if (hasEntity() && len == -1 && !chunked) {
-            try {
-                ByteArrayOutputStream out = new ByteArrayOutputStream();
-                base.writeTo(out);
-                len = out.size();
-                super.setContentLength(len);
-            } catch (Exception e) {
-            }
-        }
-        return len;
-    }
-
-    public void writeTo(OutputStream out, Writer writer) throws IOException {
-        writer.writeTo(base, out);
-    }
-
-    public void writeTo(java.io.Writer javaWriter, Writer abderaWriter) throws IOException
{
-        abderaWriter.writeTo(base, javaWriter);
+      long len = super.getContentLength();
+      if (hasEntity() && len == -1 && !chunked) {
+        try {
+          ByteArrayOutputStream out = 
+            new ByteArrayOutputStream();
+          base.writeTo(out);
+          len = out.size();
+          super.setContentLength(len);
+        } catch (Exception e) {}
+      }
+      return len;
+    }
+
+    public void writeTo(
+      OutputStream out, 
+      Writer writer) 
+        throws IOException {
+      writer.writeTo(base, out);
+    }
+
+    public void writeTo(
+      java.io.Writer javaWriter, 
+      Writer abderaWriter) 
+        throws IOException {
+      abderaWriter.writeTo(base, javaWriter);
     }
     
     public AtompubResponseContext setWriter(Writer writer) {
       this.writer = writer;
       return this;
-  }
+    }
 }

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/ResponseContextWrapper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/ResponseContextWrapper.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/ResponseContextWrapper.java
(original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/ResponseContextWrapper.java
Mon Oct 31 17:42:21 2011
@@ -24,9 +24,11 @@ import org.apache.abdera2.protocol.serve
 import org.apache.abdera2.writer.Writer;
 
 public class ResponseContextWrapper 
-  extends BaseResponseContextWrapper implements AtompubResponseContext {
+  extends BaseResponseContextWrapper 
+  implements AtompubResponseContext {
 
-    public ResponseContextWrapper(AtompubResponseContext response) {
+    public ResponseContextWrapper(
+      AtompubResponseContext response) {
         super(response);
     }
 
@@ -34,16 +36,25 @@ public class ResponseContextWrapper 
       return (AtompubResponseContext)response;
     }
     
-    public AtompubResponseContext setWriter(Writer writer) {
+    public AtompubResponseContext setWriter(
+      Writer writer) {
         getResponse().setWriter(writer);
         return this;
     }
 
-    public void writeTo(OutputStream out, Writer writer) throws IOException {
-        getResponse().writeTo(out, writer);
+    public void writeTo(
+      OutputStream out, 
+      Writer writer) 
+        throws IOException {
+      getResponse().writeTo(out, writer);
     }
 
-    public void writeTo(java.io.Writer javaWriter, Writer abderaWriter) throws IOException
{
-        getResponse().writeTo(javaWriter, abderaWriter);
+    public void writeTo(
+      java.io.Writer javaWriter, 
+      Writer abderaWriter) 
+        throws IOException {
+      getResponse().writeTo(
+        javaWriter, 
+        abderaWriter);
     }
 }

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterManager.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterManager.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterManager.java
(original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterManager.java
Mon Oct 31 17:42:21 2011
@@ -95,9 +95,8 @@ public class CollectionAdapterManager {
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
         Class<?> adapterClass = cl.loadClass(config.getAdapterClassName());
         Constructor<?>[] ctors = adapterClass.getConstructors();
-        for (Constructor<?> element : ctors) {
-            logger.finest("Public constructor found: " + element.toString());
-        }
+        for (Constructor<?> element : ctors)
+          logger.finest("Public constructor found: " + element.toString());
         Constructor<?> c = adapterClass.getConstructor(new Class[] {Abdera.class, FeedConfiguration.class});
         c.setAccessible(true);
         CollectionAdapter adapterInstance = (CollectionAdapter)c.newInstance(abdera, config);



Mime
View raw message