r7118 - in dumbhippo/trunk/server/src/com/dumbhippo: server server/impl web/servlets
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7118 - in dumbhippo/trunk/server/src/com/dumbhippo: server server/impl web/servlets
- Date: Fri, 21 Dec 2007 15:05:52 -0600 (CST)
Author: marinaz
Date: 2007-12-21 15:05:44 -0600 (Fri, 21 Dec 2007)
New Revision: 7118
Modified:
dumbhippo/trunk/server/src/com/dumbhippo/server/HttpMethods.java
dumbhippo/trunk/server/src/com/dumbhippo/server/impl/HttpMethodsBean.java
dumbhippo/trunk/server/src/com/dumbhippo/web/servlets/FacebookServlet.java
Log:
Add a root element to xml returned from setting accounts, so that it is always valid.
(We otherwise just had two sibling nodes like
<username>twitterUsername</username><message>Your votes are not public</message>
which was not a well-formed xml according to the parser.)
Make doSetBlogAccount() and doSetWebsiteAccount() take String argument instead of
a URL argument, so that they have the same set of arguments as all other methods
for setting accounts.
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/HttpMethods.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/HttpMethods.java 2007-12-21 19:31:51 UTC (rev 7117)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/HttpMethods.java 2007-12-21 21:05:44 UTC (rev 7118)
@@ -393,7 +393,7 @@
@HttpContentTypes(HttpResponseData.XMLMETHOD)
@HttpParams( { "url" })
- public void doSetWebsiteAccount(XmlBuilder xml, UserViewpoint viewpoint, URL url) throws XmlMethodException;
+ public void doSetWebsiteAccount(XmlBuilder xml, UserViewpoint viewpoint, String url) throws XmlMethodException;
@HttpContentTypes(HttpResponseData.XMLMETHOD)
@HttpParams( { "url" })
@@ -401,7 +401,7 @@
@HttpContentTypes(HttpResponseData.XMLMETHOD)
@HttpParams( { "url" })
- public void doSetBlogAccount(XmlBuilder xml, UserViewpoint viewpoint, URL url) throws XmlMethodException, RetryException;
+ public void doSetBlogAccount(XmlBuilder xml, UserViewpoint viewpoint, String url) throws XmlMethodException, RetryException;
@HttpContentTypes(HttpResponseData.XMLMETHOD)
@HttpParams( { "filename" })
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/HttpMethodsBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/HttpMethodsBean.java 2007-12-21 19:31:51 UTC (rev 7117)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/HttpMethodsBean.java 2007-12-21 21:05:44 UTC (rev 7118)
@@ -2087,11 +2087,11 @@
xml.closeElement();
}
- public void doSetWebsiteAccount(XmlBuilder xml, UserViewpoint viewpoint, URL url) throws XmlMethodException {
+ public void doSetWebsiteAccount(XmlBuilder xml, UserViewpoint viewpoint, String urlStr) throws XmlMethodException {
// DO NOT cut and paste this block into similar external account methods. It's only here because
// we don't use the "love hate" widget on /account for the website, and the javascript glue
// for the plain entries assumes this works.
- if (url == null) {
+ if (urlStr == null) {
doRemoveExternalAccount(xml, viewpoint, "WEBSITE");
try {
ExternalAccount external = externalAccountSystem.lookupExternalAccount(viewpoint, viewpoint.getViewer(), ExternalAccountType.WEBSITE);
@@ -2102,6 +2102,14 @@
return;
}
+ URL url = null;
+
+ try {
+ url = new URL(urlStr);
+ } catch (MalformedURLException e) {
+ throw new XmlMethodException(XmlMethodErrorCode.PARSE_ERROR, e.getMessage());
+ }
+
throwIfUrlNotHttp(url);
// the rest of this is more typical of a "set external account" http method
@@ -2115,12 +2123,12 @@
externalAccountSystem.setSentiment(external, Sentiment.LOVE);
}
- public void doSetBlogAccount(XmlBuilder xml, UserViewpoint viewpoint, URL url) throws XmlMethodException, RetryException {
+ public void doSetBlogAccount(XmlBuilder xml, UserViewpoint viewpoint, String urlStr) throws XmlMethodException, RetryException {
// DO NOT cut and paste this block into similar external account methods. It's only here because
// we don't use the "love hate" widget on /account for the website, and the javascript glue
// for the plain entries assumes this works.
- if (url == null) {
+ if (urlStr == null) {
doRemoveExternalAccount(xml, viewpoint, "BLOG");
try {
ExternalAccount external = externalAccountSystem.lookupExternalAccount(viewpoint, viewpoint.getViewer(), ExternalAccountType.BLOG);
@@ -2131,6 +2139,14 @@
return;
}
+ URL url = null;
+
+ try {
+ url = new URL(urlStr);
+ } catch (MalformedURLException e) {
+ throw new XmlMethodException(XmlMethodErrorCode.PARSE_ERROR, e.getMessage());
+ }
+
throwIfUrlNotHttp(url);
Feed feed = feedSystem.scrapeFeedFromUrl(url);
Modified: dumbhippo/trunk/server/src/com/dumbhippo/web/servlets/FacebookServlet.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/web/servlets/FacebookServlet.java 2007-12-21 19:31:51 UTC (rev 7117)
+++ dumbhippo/trunk/server/src/com/dumbhippo/web/servlets/FacebookServlet.java 2007-12-21 21:05:44 UTC (rev 7118)
@@ -201,10 +201,12 @@
// we can change this
if (entry.getKey().equals(ExternalAccountType.FLICKR)) {
XmlBuilder xmlForFlickr = new XmlBuilder();
+ xmlForFlickr.openElement("result");
httpMethods.doFindFlickrAccount(xmlForFlickr, userViewpoint, entryValue);
+ xmlForFlickr.closeElement(); // result
Document doc = factory.newDocumentBuilder().parse(new ByteArrayInputStream(xmlForFlickr.getBytes()));
XPath xpath = XPathFactory.newInstance().newXPath();
- String nsid = ((Node)xpath.evaluate("/flickrUser/nsid", doc, XPathConstants.NODE)).getTextContent();
+ String nsid = ((Node)xpath.evaluate("/result/flickrUser/nsid", doc, XPathConstants.NODE)).getTextContent();
logger.debug("Got nsid {} when setting Flickr account", nsid);
httpMethods.doSetFlickrAccount(new XmlBuilder(), userViewpoint, nsid, entryValue);
accountsSetSuccessful.add(ExternalAccountType.FLICKR);
@@ -212,7 +214,9 @@
Method setAccount = httpMethods.getClass().getMethod("doSet" + entry.getKey().getDomNodeIdName() + "Account",
new Class[] {XmlBuilder.class, UserViewpoint.class, String.class});
XmlBuilder resultXml = new XmlBuilder();
+ resultXml.openElement("result");
setAccount.invoke(httpMethods, new Object[] {resultXml, userViewpoint, entryValue});
+ resultXml.closeElement(); // result
// we have messages telling the user about certain limitations of their account
// for MySpace, Twitter, Reddit, and Amazon
accountsSetSuccessful.add(entry.getKey());
@@ -220,7 +224,7 @@
try {
Document doc = factory.newDocumentBuilder().parse(new ByteArrayInputStream(resultXml.getBytes()));
XPath xpath = XPathFactory.newInstance().newXPath();
- Node node = (Node)xpath.evaluate("/message", doc, XPathConstants.NODE);
+ Node node = (Node)xpath.evaluate("/result/message", doc, XPathConstants.NODE);
if (node != null) {
String message = node.getTextContent();
if (message.trim().length() > 0) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]