roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r439490 - in /incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi: RollerMemberHandler.java RollerUserHandler.java RollerWeblogHandler.java
Date Fri, 01 Sep 2006 21:54:42 GMT
Author: jtb
Date: Fri Sep  1 14:54:42 2006
New Revision: 439490

URL: http://svn.apache.org/viewvc?rev=439490&view=rev
Log:
apply save,flush,invalidate pattern to Roller*Handler classes

Modified:
    incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi/RollerMemberHandler.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi/RollerMemberHandler.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi/RollerMemberHandler.java?rev=439490&r1=439489&r2=439490&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi/RollerMemberHandler.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi/RollerMemberHandler.java
Fri Sep  1 14:54:42 2006
@@ -268,9 +268,11 @@
                 MemberEntry entry = (MemberEntry)c.getEntries()[i];
                 PermissionsData pd = toPermissionsData(entry);
                 mgr.savePermissions(pd);
+                getRoller().flush();
+                CacheManager.invalidate(pd.getUser());
+                CacheManager.invalidate(pd.getWebsite());
                 permissionsDatas.add(pd);
             }
-            getRoller().flush();
             return toMemberEntrySet((PermissionsData[])permissionsDatas.toArray(new PermissionsData[0]));
         } catch (RollerException re) {
             throw new InternalException("ERROR: Could not create members", re);
@@ -312,24 +314,20 @@
     }
     
     private MemberEntrySet updateMembers(MemberEntrySet c) throws HandlerException {
-        try {
-            List permissionsDatas= new ArrayList();
-            for (int i = 0; i < c.getEntries().length; i++) {
-                MemberEntry entry = (MemberEntry)c.getEntries()[i];
-                PermissionsData pd = getPermissionsData(entry);
-                if (pd == null) {
-                    throw new NotFoundException("ERROR: Permissions do not exist for weblog
handle: " + entry.getHandle() + ", user name: " + entry.getName());
-                }
-                updatePermissionsData(pd, entry);
-                permissionsDatas.add(pd);
+        List permissionsDatas= new ArrayList();
+        for (int i = 0; i < c.getEntries().length; i++) {
+            MemberEntry entry = (MemberEntry)c.getEntries()[i];
+            PermissionsData pd = getPermissionsData(entry);
+            if (pd == null) {
+                throw new NotFoundException("ERROR: Permissions do not exist for weblog handle:
" + entry.getHandle() + ", user name: " + entry.getName());
             }
-            getRoller().flush();
-            return toMemberEntrySet((PermissionsData[])permissionsDatas.toArray(new PermissionsData[0]));
-        } catch (RollerException re) {
-            throw new InternalException("ERROR: Could not update members", re);
+            updatePermissionsData(pd, entry);
+            permissionsDatas.add(pd);
         }
+        return toMemberEntrySet((PermissionsData[])permissionsDatas.toArray(new PermissionsData[0]));
     }
     
+    
     private void updatePermissionsData(PermissionsData pd, MemberEntry entry) throws HandlerException
{
         // only permission can be updated
         
@@ -337,21 +335,18 @@
             pd.setPermissionMask(stringToMask(entry.getPermission()));
         }
         
-        // TODO: does the permissions data need to be invalidated?
-        
         try {
             UserData ud = getRoller().getUserManager().getUserByUserName(entry.getName());
-            CacheManager.invalidate(ud);
             WebsiteData wd = getRoller().getUserManager().getWebsiteByHandle(entry.getHandle());
-            CacheManager.invalidate(wd);
             
             UserManager mgr = getRoller().getUserManager();
             mgr.savePermissions(pd);
-            
+            getRoller().flush();
+            CacheManager.invalidate(ud);
+            CacheManager.invalidate(wd);
         } catch (RollerException re) {
             throw new InternalException("ERROR: Could not update permissions data", re);
         }
-        
     }
     
     private EntrySet deleteEntry() throws HandlerException {
@@ -374,12 +369,12 @@
             
             UserManager mgr = getRoller().getUserManager();
             mgr.removePermissions(pd);
+            getRoller().flush();
             
             UserData ud = getRoller().getUserManager().getUserByUserName(username);
             CacheManager.invalidate(ud);
             WebsiteData wd = getRoller().getUserManager().getWebsiteByHandle(handle);
             CacheManager.invalidate(wd);
-            getRoller().flush();
             
             EntrySet es = toMemberEntrySet(pds);
             return es;

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java?rev=439490&r1=439489&r2=439490&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java
Fri Sep  1 14:54:42 2006
@@ -167,16 +167,17 @@
                 }
                 UserData ud = toUserData(entry);
                 mgr.addUser(ud);
+                getRoller().flush();
+                CacheManager.invalidate(ud);
                 userDatas.add(ud);
             }
-            getRoller().flush();
             return toUserEntrySet((UserData[])userDatas.toArray(new UserData[0]));
         } catch (RollerException re) {
             throw new InternalException("ERROR: Could not create users: " + c, re);
         }
     }
     
-    private UserEntrySet updateUsers(UserEntrySet c) throws NotFoundException, InternalException
{
+    private UserEntrySet updateUsers(UserEntrySet c) throws HandlerException {
         try {
             UserManager mgr = getRoller().getUserManager();
             
@@ -188,19 +189,15 @@
                     throw new NotFoundException("ERROR: Unknown user: " + entry.getName());
                 }
                 updateUserData(ud, entry);
-                
-                mgr.saveUser(ud);
-                CacheManager.invalidate(ud);
                 userDatas.add(ud);
             }
-            getRoller().flush();
             return toUserEntrySet((UserData[])userDatas.toArray(new UserData[0]));
         } catch (RollerException re) {
             throw new InternalException("ERROR: Could not update users: " + c, re);
         }
     }
     
-    private void updateUserData(UserData ud, UserEntry entry) {
+    private void updateUserData(UserData ud, UserEntry entry) throws HandlerException {
         // user name cannot be updated
         
         if (entry.getFullName() != null) {
@@ -218,6 +215,15 @@
         if (entry.getEmailAddress() != null) {
             ud.setEmailAddress(entry.getEmailAddress());
         }
+        
+        try {
+            UserManager mgr = getRoller().getUserManager();
+            mgr.saveUser(ud);
+            getRoller().flush();
+            CacheManager.invalidate(ud);
+        } catch (RollerException re) {
+            throw new InternalException("ERROR: could not update user data", re);
+        }
     }
     
     private EntrySet deleteEntry() throws HandlerException {
@@ -235,9 +241,9 @@
             
             UserData[] uds = new UserData[] { ud };
             mgr.removeUser(ud);
-            
+            getRoller().flush();            
             CacheManager.invalidate(ud);
-            getRoller().flush();
+
             EntrySet es = toUserEntrySet(uds);
             return es;
         } catch (RollerException re) {

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java?rev=439490&r1=439489&r2=439490&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java
Fri Sep  1 14:54:42 2006
@@ -202,12 +202,12 @@
                 }
                 
                 mgr.addWebsite(wd);
+                getRoller().flush();
+                CacheManager.invalidate(wd);                
                 websiteDatas.add(wd);
             }
             
-            getRoller().flush();
-            return toWeblogEntrySet((WebsiteData[])websiteDatas.toArray(new WebsiteData[0]));
-            
+            return toWeblogEntrySet((WebsiteData[])websiteDatas.toArray(new WebsiteData[0]));
           
         } catch (RollerException re) {
             throw new InternalException("ERROR: Could not create weblogs: " + c, re);
         }
@@ -231,7 +231,6 @@
                 updateWebsiteData(wd, entry);
                 websiteDatas.add(wd);
             }
-            getRoller().flush();
             return toWeblogEntrySet((WebsiteData[])websiteDatas.toArray(new WebsiteData[0]));
         } catch (RollerException re) {
             throw new InternalException("ERROR: Could not update weblogs: " + c, re);
@@ -258,7 +257,7 @@
         try {
             UserManager mgr = getRoller().getUserManager();
             mgr.saveWebsite(wd);
-            
+            getRoller().flush();            
             CacheManager.invalidate(wd);
         } catch (RollerException re) {
             throw new InternalException("ERROR: Could not update website data", re);
@@ -280,9 +279,8 @@
             EntrySet es = toWeblogEntrySet(wds);
             
             mgr.removeWebsite(wd);
-            
+            getRoller().flush();            
             CacheManager.invalidate(wd);
-            getRoller().flush();
             
             return es;
         } catch (RollerException re) {



Mime
View raw message