Return-Path: Delivered-To: apmail-incubator-roller-commits-archive@www.apache.org Received: (qmail 36241 invoked from network); 4 Mar 2006 16:38:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Mar 2006 16:38:12 -0000 Received: (qmail 17919 invoked by uid 500); 4 Mar 2006 16:38:58 -0000 Delivered-To: apmail-incubator-roller-commits-archive@incubator.apache.org Received: (qmail 17891 invoked by uid 500); 4 Mar 2006 16:38:58 -0000 Mailing-List: contact roller-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: roller-dev@incubator.apache.org Delivered-To: mailing list roller-commits@incubator.apache.org Received: (qmail 17880 invoked by uid 99); 4 Mar 2006 16:38:58 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Mar 2006 08:38:58 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Sat, 04 Mar 2006 08:38:57 -0800 Received: (qmail 36169 invoked by uid 65534); 4 Mar 2006 16:37:50 -0000 Message-ID: <20060304163750.36168.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r383155 - /incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi/AtomServlet.java Date: Sat, 04 Mar 2006 16:37:50 -0000 To: roller-commits@incubator.apache.org From: snoopdave@apache.org X-Mailer: svnmailer-1.0.7 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: snoopdave Date: Sat Mar 4 08:37:49 2006 New Revision: 383155 URL: http://svn.apache.org/viewcvs?rev=383155&view=rev Log: Added check to see if client preserves foreign markup Modified: incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi/AtomServlet.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=383155&r1=383154&r2=383155&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 Sat Mar 4 08:37:49 2006 @@ -45,6 +45,7 @@ import com.sun.syndication.io.WireFeedInput; import com.sun.syndication.io.WireFeedOutput; import java.io.StringWriter; +import org.jdom.Namespace; /** * Atom Servlet implements Atom by calling a Roller independent handler. @@ -295,8 +296,7 @@ } /** - * Utility method to make up for a Rome shortcoming: - * Rome can only serialize entire feeds, not individual elements + * Serialize entry to writer. */ public static void serializeEntry(Entry entry, Writer writer) throws IllegalArgumentException, FeedException, IOException { @@ -313,20 +313,29 @@ // Grab entry element from feed and get JDOM to serialize it Element entryElement= (Element)feedDoc.getRootElement().getChildren().get(0); + + // Add our own namespaced element, so we can determine if we can + // count on client to preserve foreign markup as it should. + Element rollerElement = new Element("atom-draft", + "http://rollerweblogger.org/namespaces/app"); + rollerElement.setText("7"); + entryElement.addContent(rollerElement); + XMLOutputter outputter = new XMLOutputter(); outputter.setFormat(Format.getPrettyFormat()); - StringWriter sw = new StringWriter(); // DEBUG - outputter.output(entryElement, sw); // DEBUG - System.out.println(sw.toString()); // DEBUG - writer.write(sw.toString()); // DEBUG - - //outputter.output(entryElement, writer); + if (mLogger.isDebugEnabled()) { + StringWriter sw = new StringWriter(); + outputter.output(entryElement, sw); + mLogger.debug(sw.toString()); + writer.write(sw.toString()); + } else { + outputter.output(entryElement, writer); + } } /** - * Utility method to make up for a Rome shortcoming: - * Rome can only parse Atom data with XML document root 'feed' + * Parse entry from reader. */ public static Entry parseEntry(Reader rd) throws JDOMException, IOException, IllegalArgumentException, FeedException { @@ -342,6 +351,15 @@ WireFeedOutput wireFeedOutput = new WireFeedOutput(); Document feedDoc = wireFeedOutput.outputJDom(feed); feedDoc.getRootElement().addContent(fetchedEntryElement); + + // Check for our special namespaced element. If it's there, then we + // know that client is not preserving foreign markup. + Namespace ns = Namespace.getNamespace( + "http://rollerweblogger.org/namespaces/app"); + Element rollerElement = fetchedEntryElement.getChild("atom-draft", ns); + if (rollerElement == null) { + mLogger.debug("Client is NOT preserving foreign markup"); + } WireFeedInput input = new WireFeedInput(); Feed parsedFeed = (Feed)input.build(feedDoc);