You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by sn...@apache.org on 2005/12/30 05:08:54 UTC

svn commit: r359982 - in /incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi: AtomServlet.java RollerAtomHandler.java

Author: snoopdave
Date: Thu Dec 29 20:08:50 2005
New Revision: 359982

URL: http://svn.apache.org/viewcvs?rev=359982&view=rev
Log:
Sandbox: APP implementation now sets response content types, defaults to non-draft for new entries and no longer throws exception on a successful file upload

Modified:
    incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi/AtomServlet.java
    incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi/RollerAtomHandler.java

Modified: incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi/AtomServlet.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi/AtomServlet.java?rev=359982&r1=359981&r2=359982&view=diff
==============================================================================
--- incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi/AtomServlet.java (original)
+++ incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi/AtomServlet.java Thu Dec 29 20:08:50 2005
@@ -15,7 +15,6 @@
  */
 package org.roller.presentation.atomapi;
 
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.Reader;
@@ -38,7 +37,6 @@
 import org.jdom.input.SAXBuilder;
 import org.jdom.output.Format;
 import org.jdom.output.XMLOutputter;
-import org.roller.util.Utilities;
 
 import com.sun.syndication.feed.atom.Entry;
 import com.sun.syndication.feed.atom.Feed;
@@ -84,6 +82,7 @@
                     // return an Atom Service document
                     AtomService service = handler.getIntrospection(pathInfo);
                     Document doc = AtomService.serviceToDocument(service);
+                    res.setContentType("application/xml; charset=utf8");
                     Writer writer = res.getWriter();
                     XMLOutputter outputter = new XMLOutputter();
                     outputter.setFormat(Format.getPrettyFormat());
@@ -96,6 +95,7 @@
                     col.setFeedType(FEED_TYPE);
                     WireFeedOutput wireFeedOutput = new WireFeedOutput();
                     Document feedDoc = wireFeedOutput.outputJDom(col);
+                    res.setContentType("application/atom+xml; charset=utf8");
                     Writer writer = res.getWriter();
                     XMLOutputter outputter = new XMLOutputter();
                     outputter.setFormat(Format.getPrettyFormat());
@@ -107,6 +107,7 @@
                     Entry entry = handler.getEntry(pathInfo);
                     if (entry != null) {
                         Writer writer = res.getWriter();
+                        res.setContentType("application/atom+xml; charset=utf8");
                         serializeEntry(entry, writer);
                         writer.close();
                     } else {
@@ -117,6 +118,7 @@
                     Entry entry = handler.getMedia(pathInfo);
                     if (entry != null) {
                         Writer writer = res.getWriter();
+                        res.setContentType("application/atom+xml; charset=utf8");
                         serializeEntry(entry, writer);
                         writer.close();
                     } else {
@@ -148,6 +150,7 @@
             String[] pathInfo = getPathInfo(req);
             try {
                 if (handler.isEntryCollectionURI(pathInfo)) {
+                            
                     // parse incoming entry
                     Entry unsavedEntry = parseEntry(
                         new InputStreamReader(req.getInputStream()));
@@ -166,6 +169,7 @@
                     }
                     // write entry back out to response
                     res.setStatus(HttpServletResponse.SC_CREATED);
+                    res.setContentType("application/atom+xml; charset=utf8");
                     Writer writer = res.getWriter();
                     serializeEntry(savedEntry, writer);
                     writer.close(); 
@@ -217,6 +221,7 @@
                     Entry updatedEntry = handler.putEntry(pathInfo, unsavedEntry);
                     
                     // write entry back out to response
+                    res.setContentType("application/atom+xml; charset=utf8");
                     Writer writer = res.getWriter();
                     serializeEntry(updatedEntry, writer);
                     res.setStatus(HttpServletResponse.SC_OK);
@@ -227,6 +232,7 @@
                         pathInfo, req.getContentType(), req.getInputStream());
                                         
                     // write entry back out to response
+                    res.setContentType("application/atom+xml; charset=utf8");
                     Writer writer = res.getWriter();
                     serializeEntry(updatedEntry, writer);
                     writer.close();

Modified: incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi/RollerAtomHandler.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi/RollerAtomHandler.java?rev=359982&r1=359981&r2=359982&view=diff
==============================================================================
--- incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi/RollerAtomHandler.java (original)
+++ incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi/RollerAtomHandler.java Thu Dec 29 20:08:50 2005
@@ -463,7 +463,7 @@
                 throw new Exception(msg);
             }
         }
-        throw new Exception("ERROR not authorized to edit website");
+        else throw new Exception("ERROR not authorized to edit website");
     }
     
     //------------------------------------------------------------------ URI testers
@@ -770,15 +770,13 @@
         rollerEntry.setPubTime(pubTime);
         rollerEntry.setUpdateTime(updateTime);
         rollerEntry.setWebsite(website);
-        
+               
         PubControlModule control = 
             (PubControlModule)entry.getModule("http://purl.org/atom/app#");
-        if (control != null && control.getDraft() != null) {
-            if (!control.getDraft().booleanValue()) {
-                rollerEntry.setStatus(WeblogEntryData.PUBLISHED);
-            }
-        } else {
+        if (control!=null && control.getDraft()!=null && control.getDraft().booleanValue()) {
             rollerEntry.setStatus(WeblogEntryData.DRAFT);
+        } else {
+            rollerEntry.setStatus(WeblogEntryData.PUBLISHED);
         }
         
         // Atom supports multiple cats, Roller supports one/entry