r7522 - in dumbhippo/trunk: openfire/src/plugins/hippo/src/java/com/dumbhippo/jive server/src/com/dumbhippo/server server/src/com/dumbhippo/server/impl server/web/javascript/dh



Author: marinaz
Date: 2008-11-03 15:31:39 -0600 (Mon, 03 Nov 2008)
New Revision: 7522

Modified:
   dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/AnnotatedIQMethod.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/HttpMethods.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/impl/HttpMethodsBean.java
   dumbhippo/trunk/server/web/javascript/dh/account.js
Log:
Make the set methods for blog and website take an account id, so that their signature is consistent with all other external account set methods. This ensures that setting the blog will work for the Facebook application and that setting the blog or website will work from Online Accounts service on the desktop.

AnnotatedIQMethod.java: Improve an error print out to display a stack trace of the error that got thrown. 


Modified: dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/AnnotatedIQMethod.java
===================================================================
--- dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/AnnotatedIQMethod.java	2008-10-28 17:45:46 UTC (rev 7521)
+++ dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/AnnotatedIQMethod.java	2008-11-03 21:31:39 UTC (rev 7522)
@@ -185,7 +185,7 @@
 			logger.error("Failure during IQ request run {}", e.getMessage());			
 			throw e;
 		} catch (Exception e) {
-			logger.error("General failure during IQ request run {}", e);			
+			logger.error("General failure during IQ request run " + e.getStackTrace());			
 			throw new RuntimeException("Unexpected exception running IQ method in transaction", e);
 		}
 		logger.debug("Completed IQ request run in {}s", (new Date().getTime() - iqStartTime)/1000);		

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/HttpMethods.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/HttpMethods.java	2008-10-28 17:45:46 UTC (rev 7521)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/HttpMethods.java	2008-11-03 21:31:39 UTC (rev 7522)
@@ -400,16 +400,16 @@
 	public void doSetOnlineAccountValue(XmlBuilder xml, UserViewpoint viewpoint, String type, String id, String value) throws XmlMethodException;
 	
 	@HttpContentTypes(HttpResponseData.XMLMETHOD)
-	@HttpParams( { "url" })
-	public void doSetWebsiteAccount(XmlBuilder xml, UserViewpoint viewpoint, String url) throws XmlMethodException;
+	@HttpParams( { "id", "url" })
+	public void doSetWebsiteAccount(XmlBuilder xml, UserViewpoint viewpoint, String id, String url) throws XmlMethodException;
 	
 	@HttpContentTypes(HttpResponseData.XMLMETHOD)
 	@HttpParams( { "id", "url" })
 	public void doSetRhapsodyAccount(XmlBuilder xml, UserViewpoint viewpoint, String id, String url) throws XmlMethodException, RetryException;
     
 	@HttpContentTypes(HttpResponseData.XMLMETHOD)
-	@HttpParams( { "url" })
-	public void doSetBlogAccount(XmlBuilder xml, UserViewpoint viewpoint, String url) throws XmlMethodException, RetryException;	
+	@HttpParams( { "id", "url" })
+	public void doSetBlogAccount(XmlBuilder xml, UserViewpoint viewpoint, String id, 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	2008-10-28 17:45:46 UTC (rev 7521)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/HttpMethodsBean.java	2008-11-03 21:31:39 UTC (rev 7522)
@@ -1656,10 +1656,10 @@
 	private ExternalAccount getOrCreateExternalAccount(UserViewpoint viewpoint, ExternalAccountType externalAccountType, String id) {
 		OnlineAccountType onlineAccountType = externalAccountSystem.getOnlineAccountType(externalAccountType);
 	    ExternalAccount external = null;
-	    if (id == "mugshot") {
+	    if (id.equals("mugshot")) {
 	    	// id = "mugshot" means we want to set the value for the mugshot enabled account
 	    	external = externalAccountSystem.getOrCreateExternalAccount(viewpoint, externalAccountType);
-	    } else if (id == "") {
+	    } else if (id.trim().equals("")) {
 		    try {
 		        ExternalAccount existingExternal = externalAccountSystem.lookupExternalAccount(viewpoint, viewpoint.getViewer(), externalAccountType);
 		        // we can reuse an account with INDIFFERENT sentiment if one exists
@@ -2172,17 +2172,29 @@
 		xml.appendTextNode("username", external.getHandle());		
 	}
 	
-	public void doSetWebsiteAccount(XmlBuilder xml, UserViewpoint viewpoint, String urlStr) throws XmlMethodException {
+	public void doSetWebsiteAccount(XmlBuilder xml, UserViewpoint viewpoint, String id, 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 (urlStr == null || urlStr.trim().length() == 0) {
-			try {
-				ExternalAccount external = externalAccountSystem.lookupExternalAccount(viewpoint, viewpoint.getViewer(), ExternalAccountType.WEBSITE);
+			ExternalAccount external = null;
+			if (id.equals("mugshot")) {
+				try {
+					// this will get a Mugshot enabled account or an indifferent account if a Mugshot enabled one doesn't exist 
+					external = externalAccountSystem.lookupExternalAccount(viewpoint, viewpoint.getViewer(), ExternalAccountType.WEBSITE);
+				} catch (NotFoundException e) {
+				}
+			} else if (!id.trim().equals("")) {		
+			    try {
+				    external = externalAccountSystem.lookupExternalAccount(viewpoint, id);
+	            } catch (NotFoundException e) {
+		            throw new RuntimeException(e.getMessage());
+	            }
+			}
+			if (external != null) {
 				externalAccountSystem.setSentiment(external, Sentiment.INDIFFERENT);
 				// otherwise the website url would keep "coming back" since there's no visual indication of hate/indifferent status
 				external.setHandle(null);
-			} catch (NotFoundException e) {
 			}
 			return;
 		}
@@ -2201,7 +2213,7 @@
 		
 		// the rest of this is more typical of a "set external account" http method
 				
-		ExternalAccount external = externalAccountSystem.getOrCreateExternalAccount(viewpoint, ExternalAccountType.WEBSITE);
+		ExternalAccount external = getOrCreateExternalAccount(viewpoint, ExternalAccountType.WEBSITE, id);
 		try {
 			external.setHandleValidating(url.toExternalForm());
 		} catch (ValidationException e) {
@@ -2210,21 +2222,32 @@
 		externalAccountSystem.setSentiment(external, Sentiment.LOVE);
 	}
 
-	public void doSetBlogAccount(XmlBuilder xml, UserViewpoint viewpoint, String urlStr) throws XmlMethodException, RetryException {
-		
+	public void doSetBlogAccount(XmlBuilder xml, UserViewpoint viewpoint, String id, 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 (urlStr == null || urlStr.trim().length() == 0) {
-			try {
-				ExternalAccount external = externalAccountSystem.lookupExternalAccount(viewpoint, viewpoint.getViewer(), ExternalAccountType.BLOG);
-				externalAccountSystem.setSentiment(external, Sentiment.INDIFFERENT);	
+			ExternalAccount external = null;
+			if (id.equals("mugshot")) {
+				try {
+					// this will get a Mugshot enabled account or an indifferent account if a Mugshot enabled one doesn't exist 
+					external = externalAccountSystem.lookupExternalAccount(viewpoint, viewpoint.getViewer(), ExternalAccountType.BLOG);
+				} catch (NotFoundException e) {
+				}
+			} else if (!id.trim().equals("")) {		
+			    try {
+				    external = externalAccountSystem.lookupExternalAccount(viewpoint, id);
+	            } catch (NotFoundException e) {
+		            throw new RuntimeException(e.getMessage());
+	            }
+			}
+			if (external != null) {
+				externalAccountSystem.setSentiment(external, Sentiment.INDIFFERENT);
 				// otherwise the blog url would keep "coming back" since there's no visual indication of hate/indifferent status
 				external.setHandle(null);
-			} catch (NotFoundException e) {
 			}
 			return;
-		}
+		}   
 		
 		URL url = null;
 		
@@ -2241,7 +2264,7 @@
 		Feed feed = feedSystem.scrapeFeedFromUrl(url);
 		EJBUtil.forceInitialization(feed.getAccounts());
 		
-		ExternalAccount external = externalAccountSystem.getOrCreateExternalAccount(viewpoint, ExternalAccountType.BLOG);
+		ExternalAccount external = getOrCreateExternalAccount(viewpoint, ExternalAccountType.BLOG, id);
 		
 		try {
 			external.setHandleValidating(url.toExternalForm());

Modified: dumbhippo/trunk/server/web/javascript/dh/account.js
===================================================================
--- dumbhippo/trunk/server/web/javascript/dh/account.js	2008-10-28 17:45:46 UTC (rev 7521)
+++ dumbhippo/trunk/server/web/javascript/dh/account.js	2008-11-03 21:31:39 UTC (rev 7522)
@@ -877,13 +877,15 @@
 	if (dh.util.exists('dhWebsiteEntry')) {
 		var websiteEntry = new dh.formtable.ExpandableTextInput('dhWebsiteEntry', 'Your website URL');
 		websiteEntry.setDescription("Your website will be linked from your Mugshot page.");
-		websiteEntry.setChangedXmlMethod('setwebsiteaccount', 'url');
+		var fixedArgs = { 'id' : 'mugshot' };
+		websiteEntry.setChangedXmlMethod('setwebsiteaccount', 'url', fixedArgs);
 	}
 	
 	if (dh.util.exists('dhBlogEntry')) {
 		var blogEntry = new dh.formtable.ExpandableTextInput('dhBlogEntry', 'Your blog URL');
-		blogEntry.setDescription("Your friends will get updates when you post to your blog.")
-		blogEntry.setChangedXmlMethod('setblogaccount', 'url');
+		blogEntry.setDescription("Your friends will get updates when you post to your blog.");
+		var fixedArgs = { 'id' : 'mugshot' };
+		blogEntry.setChangedXmlMethod('setblogaccount', 'url', fixedArgs);
 	}
 	
 	if (dh.util.exists('dhPictureEntry')) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]