roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r1081183 - in /roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/webservices: atomprotocol/RollerAtomService.java xmlrpc/BaseAPIHandler.java
Date Sun, 13 Mar 2011 18:21:07 GMT
Author: snoopdave
Date: Sun Mar 13 18:21:06 2011
New Revision: 1081183

URL: http://svn.apache.org/viewvc?rev=1081183&view=rev
Log:
Fix for ROL-1913, cannot disable client APIs at site-wide level

Modified:
    roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/RollerAtomService.java
    roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/webservices/xmlrpc/BaseAPIHandler.java

Modified: roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/RollerAtomService.java
URL: http://svn.apache.org/viewvc/roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/RollerAtomService.java?rev=1081183&r1=1081182&r2=1081183&view=diff
==============================================================================
--- roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/RollerAtomService.java
(original)
+++ roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/RollerAtomService.java
Sun Mar 13 18:21:06 2011
@@ -18,23 +18,17 @@
 
 package org.apache.roller.weblogger.webservices.atomprotocol;
 
-import com.sun.syndication.feed.atom.Category;
-import com.sun.syndication.propono.atom.common.AtomService;
-import com.sun.syndication.propono.atom.common.Categories;
-import com.sun.syndication.propono.atom.common.Collection;
-import com.sun.syndication.propono.atom.common.Workspace;
-import com.sun.syndication.propono.atom.server.AtomException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
-import java.util.TreeMap;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.MediaFileManager;
 import org.apache.roller.weblogger.business.Weblogger;
 import org.apache.roller.weblogger.business.WebloggerFactory;
+import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
 import org.apache.roller.weblogger.pojos.MediaFileDirectory;
 import org.apache.roller.weblogger.pojos.RuntimeConfigProperty;
 import org.apache.roller.weblogger.pojos.User;
@@ -43,16 +37,23 @@ import org.apache.roller.weblogger.pojos
 import org.apache.roller.weblogger.pojos.WeblogPermission;
 import org.apache.roller.weblogger.util.Utilities;
 
+import com.sun.syndication.feed.atom.Category;
+import com.sun.syndication.propono.atom.common.AtomService;
+import com.sun.syndication.propono.atom.common.Categories;
+import com.sun.syndication.propono.atom.common.Collection;
+import com.sun.syndication.propono.atom.common.Workspace;
+import com.sun.syndication.propono.atom.server.AtomException;
+
 
 /**
  * Roller's Atom service.
  */
 public class RollerAtomService extends AtomService {
 
-    private Map workspaceMap = new TreeMap();
-    private Map collectionMap = new TreeMap();
-    private static Properties cacheProps = new Properties();
-    private boolean firstTime = true;
+    //private Map workspaceMap = new TreeMap();
+    //private Map collectionMap = new TreeMap();
+    //private static Properties cacheProps = new Properties();
+    //private boolean firstTime = true;
 
     /**
      * Creates a new instance of FileBasedAtomService.
@@ -60,6 +61,11 @@ public class RollerAtomService extends A
     public RollerAtomService(User user, String atomURL) throws WebloggerException, AtomException
{
         Weblogger roller = WebloggerFactory.getWeblogger();
         List perms = null;
+        
+        if (!WebloggerRuntimeConfig.getBooleanProperty("webservices.enableAtomPub")) {
+        	throw new AtomException("AtomPub not enabled for this Roller installation");
+        }
+        
         try {
             perms = roller.getUserManager().getWeblogPermissions(user);
         } catch (WebloggerException re) {

Modified: roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/webservices/xmlrpc/BaseAPIHandler.java
URL: http://svn.apache.org/viewvc/roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/webservices/xmlrpc/BaseAPIHandler.java?rev=1081183&r1=1081182&r2=1081183&view=diff
==============================================================================
--- roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/webservices/xmlrpc/BaseAPIHandler.java
(original)
+++ roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/webservices/xmlrpc/BaseAPIHandler.java
Sun Mar 13 18:21:06 2011
@@ -26,6 +26,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.xmlrpc.XmlRpcException;
 import org.apache.roller.weblogger.config.WebloggerConfig;
+import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.UserManager;
 import org.apache.roller.weblogger.business.WeblogManager;
@@ -126,7 +127,8 @@ public class BaseAPIHandler implements S
             if (website != null) {
                 weblogFound = true;
                 weblogEnabled = website.getEnabled().booleanValue();
-                apiEnabled = website.getEnableBloggerApi().booleanValue();
+                apiEnabled = website.getEnableBloggerApi().booleanValue() 
+                	&& WebloggerRuntimeConfig.getBooleanProperty("webservices.enableXmlRpc");
             }
             
             if (user != null) {
@@ -172,6 +174,7 @@ public class BaseAPIHandler implements S
     throws Exception {
         boolean authenticated = false;
         boolean enabled = false;
+        boolean apiEnabled = false;
         User user = null;
         try {
             
@@ -190,9 +193,8 @@ public class BaseAPIHandler implements S
                 }
                 //System.out.println("is now [" + password + "]");
                 authenticated = user.getPassword().equals(password);
-                if (authenticated) {
-                    //WebloggerFactory.getWeblogger().setUser(user);
-                }
+                
+                apiEnabled = WebloggerRuntimeConfig.getBooleanProperty("webservices.enableXmlRpc");
             }
         } catch (Exception e) {
             mLogger.error("ERROR internal error validating user", e);
@@ -205,6 +207,11 @@ public class BaseAPIHandler implements S
         if ( !authenticated ) {
             throw new XmlRpcNotAuthorizedException(AUTHORIZATION_EXCEPTION_MSG);
         }
+        
+        if ( !apiEnabled ) {
+            throw new XmlRpcNotAuthorizedException(BLOGGERAPI_DISABLED_MSG);
+        }        
+        
         return authenticated;
     }
     



Mime
View raw message