roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r448278 [1/2] - in /incubator/roller/trunk: ./ src/org/apache/roller/webservices/adminapi/ src/org/apache/roller/webservices/adminapi/sdk/ tests/org/apache/roller/webservices/adminapi/ tests/org/apache/roller/webservices/adminapi/sdk/
Date Wed, 20 Sep 2006 17:52:26 GMT
Author: jtb
Date: Wed Sep 20 10:52:25 2006
New Revision: 448278

URL: http://svn.apache.org/viewvc?view=rev&rev=448278
Log:
- added set/get enabled support in AAPP
- made most fields in AAPP objects optional to support sparse upates. rely on roller erroring when required fields are missing

Added:
    incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/HandlerBaseTest.java
Removed:
    incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/MissingElementException.java
Modified:
    incubator/roller/trunk/build.xml
    incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/Handler.java
    incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/IntrospectionHandler.java
    incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerMemberHandler.java
    incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java
    incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java
    incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/MemberEntry.java
    incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/MemberEntrySet.java
    incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/UnexpectedRootElementException.java
    incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/UserEntry.java
    incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/UserEntrySet.java
    incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/WeblogEntry.java
    incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/WeblogEntrySet.java
    incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/AappTest.java
    incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/MemberHandlerTest.java
    incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/UserHandlerTest.java
    incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/WeblogHandlerTest.java
    incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/MemberEntryTest.java
    incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/UserEntryTest.java
    incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/WeblogEntryTest.java

Modified: incubator/roller/trunk/build.xml
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/build.xml?view=diff&rev=448278&r1=448277&r2=448278
==============================================================================
--- incubator/roller/trunk/build.xml (original)
+++ incubator/roller/trunk/build.xml Wed Sep 20 10:52:25 2006
@@ -1030,7 +1030,7 @@
 
     <target name="test-aapp" depends="test-aapp-sdk, test-aapp-handler"/>
    
-    <target name="test-aapp-sdk" depends="build-tests">
+    <target name="test-aapp-sdk">
         <mkdir dir="${build.reports}/webservices/adminapi/sdk/xml"/>
         <mkdir dir="${build.reports}/webservices/adminapi/sdk/html"/>
 
@@ -1056,7 +1056,7 @@
         </junitreport>
     </target>
     
-    <target name="test-aapp-handler" depends="build-tests">
+    <target name="test-aapp-handler">
         <mkdir dir="${build.reports}/webservices/adminapi/xml"/>
         <mkdir dir="${build.reports}/webservices/adminapi/html"/>
 

Modified: incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/Handler.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/Handler.java?view=diff&rev=448278&r1=448277&r2=448278
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/Handler.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/Handler.java Wed Sep 20 10:52:25 2006
@@ -27,11 +27,13 @@
 import org.apache.roller.model.RollerFactory;
 import org.apache.roller.ui.core.RollerContext;
 import org.apache.roller.webservices.adminapi.sdk.EntrySet;
-
 import java.util.regex.Pattern;
 import java.util.regex.Matcher;
+import org.apache.roller.RollerException;
 import org.apache.roller.config.RollerRuntimeConfig;
-import org.apache.roller.webservices.adminapi.sdk.MissingElementException;
+import org.apache.roller.model.UserManager;
+import org.apache.roller.pojos.UserData;
+import org.apache.roller.pojos.WebsiteData;
 import org.apache.roller.webservices.adminapi.sdk.UnexpectedRootElementException;
 import org.jdom.Document;
 import org.jdom.JDOMException;
@@ -184,7 +186,7 @@
         return urlPrefix;
     }
     
-    protected abstract EntrySet getEntrySet(Document d) throws MissingElementException, UnexpectedRootElementException;
+    protected abstract EntrySet getEntrySet(Document d) throws UnexpectedRootElementException;
     
     protected EntrySet getEntrySet(Reader r) throws HandlerException {
         try {
@@ -195,13 +197,45 @@
             return c;
         } catch (UnexpectedRootElementException ure) {
             throw new BadRequestException("ERROR: Failed to parse content", ure);            
-        } catch (MissingElementException mee) {
-            throw new BadRequestException("ERROR: Failed to parse content", mee);            
         } catch (JDOMException jde) {
             throw new BadRequestException("ERROR: Failed to parse content", jde);
         } catch (IOException ioe) {
             throw new InternalException("ERROR: Failed to parse content", ioe);
         }
-    }    
+    }
+    
+    protected WebsiteData getWebsiteData(String handle) throws NotFoundException, InternalException {
+        try {
+            WebsiteData wd = getRoller().getUserManager().getWebsiteByHandle(handle, Boolean.TRUE);
+            if (wd == null) {
+                wd = getRoller().getUserManager().getWebsiteByHandle(handle, Boolean.FALSE);
+            }
+            if (wd == null) {
+                throw new NotFoundException("ERROR: Unknown weblog handle: " + handle);
+            }
+            
+            return wd;
+        } catch (RollerException re) {
+            throw new InternalException("ERROR: Could not get weblog: " + handle, re);
+        }
+    }
+
+    protected UserData getUserData(String name) throws NotFoundException, InternalException {
+        try {
+            UserManager mgr = getRoller().getUserManager();
+            UserData ud = mgr.getUserByUserName(name, Boolean.TRUE);
+            if (ud == null) {
+                ud = mgr.getUserByUserName(name, Boolean.FALSE);
+            }
+            if (ud == null) {
+                throw new NotFoundException("ERROR: Unknown user: " + name);
+            }
+            
+            return ud;
+        } catch (RollerException re) {
+            throw new InternalException("ERROR: Could not get user: " + name, re);
+        }
+    }
+    
 }
 

Modified: incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/IntrospectionHandler.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/IntrospectionHandler.java?view=diff&rev=448278&r1=448277&r2=448278
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/IntrospectionHandler.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/IntrospectionHandler.java Wed Sep 20 10:52:25 2006
@@ -24,7 +24,6 @@
 
 import org.apache.roller.webservices.adminapi.sdk.Entry;
 import org.apache.roller.webservices.adminapi.sdk.EntrySet;
-import org.apache.roller.webservices.adminapi.sdk.MissingElementException;
 import org.apache.roller.webservices.adminapi.sdk.Service;
 import org.apache.roller.webservices.adminapi.sdk.UnexpectedRootElementException;
 import org.jdom.Document;
@@ -40,7 +39,7 @@
         super(request);
     }
     
-    protected EntrySet getEntrySet(Document d) throws MissingElementException, UnexpectedRootElementException {
+    protected EntrySet getEntrySet(Document d) throws UnexpectedRootElementException {
         throw new UnsupportedOperationException();
     }
     

Modified: incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerMemberHandler.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerMemberHandler.java?view=diff&rev=448278&r1=448277&r2=448278
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerMemberHandler.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerMemberHandler.java Wed Sep 20 10:52:25 2006
@@ -36,7 +36,6 @@
 import org.apache.roller.webservices.adminapi.sdk.EntrySet;
 import org.apache.roller.webservices.adminapi.sdk.MemberEntry;
 import org.apache.roller.webservices.adminapi.sdk.MemberEntrySet;
-import org.apache.roller.webservices.adminapi.sdk.MissingElementException;
 import org.apache.roller.webservices.adminapi.sdk.UnexpectedRootElementException;
 
 /**
@@ -93,7 +92,7 @@
         memberUri = new MemberURI(request);
     }
     
-    protected EntrySet getEntrySet(Document d) throws MissingElementException, UnexpectedRootElementException {
+    protected EntrySet getEntrySet(Document d) throws UnexpectedRootElementException {
         return new MemberEntrySet(d, getUrlPrefix());
     }
     
@@ -140,7 +139,7 @@
     private EntrySet getCollection() throws HandlerException {
         // get all permissions: for all users, for all websites
         try {
-            List users = getRoller().getUserManager().getUsers(0, -1);
+            List users = getRoller().getUserManager().getUsers(null, null, null, 0, -1);
             List perms = new ArrayList();
             for (Iterator i = users.iterator(); i.hasNext(); ) {
                 UserData user = (UserData)i.next();
@@ -166,18 +165,18 @@
             List perms;
             if (username == null) {
                 //get all entries for the given website handle
-                WebsiteData wd = getRoller().getUserManager().getWebsiteByHandle(handle);
+                WebsiteData wd = getWebsiteData(handle);
                 if (wd == null) {
                     throw new NotFoundException("ERROR: Unknown weblog handle: " + handle);
                 }
                 perms = getRoller().getUserManager().getAllPermissions(wd);
             } else {
                 //get all entries for the given website handle & username
-                WebsiteData wd = getRoller().getUserManager().getWebsiteByHandle(handle);
+                WebsiteData wd = getWebsiteData(handle);
                 if (wd == null) {
                     throw new NotFoundException("ERROR: Unknown weblog handle: " + handle);
                 }
-                UserData ud = getRoller().getUserManager().getUserByUserName(username);
+                UserData ud = getUserData(username);
                 if (ud == null) {
                     throw new NotFoundException("ERROR: Unknown user name: " + username);
                 }
@@ -280,20 +279,15 @@
     }
     
     private PermissionsData toPermissionsData(MemberEntry entry) throws HandlerException {
-        try {
-            UserManager mgr = getRoller().getUserManager();
-            UserData ud = mgr.getUserByUserName(entry.getName());
-            WebsiteData wd = mgr.getWebsiteByHandle(entry.getHandle());
-            PermissionsData pd = new PermissionsData();
-            pd.setUser(ud);
-            pd.setWebsite(wd);
-            pd.setPermissionMask(stringToMask(entry.getPermission()));
-            pd.setPending(false);
-            
-            return pd;
-        } catch (RollerException re) {
-            throw new InternalException("ERROR: Could not convert to permissions data", re);
-        }
+        UserData ud = getUserData(entry.getName());
+        WebsiteData wd = getWebsiteData(entry.getHandle());
+        PermissionsData pd = new PermissionsData();
+        pd.setUser(ud);
+        pd.setWebsite(wd);
+        pd.setPermissionMask(stringToMask(entry.getPermission()));
+        pd.setPending(false);
+        
+        return pd;
     }
     
     private PermissionsData getPermissionsData(MemberEntry entry) throws HandlerException {
@@ -302,14 +296,13 @@
     
     private PermissionsData getPermissionsData(String handle, String username) throws HandlerException {
         try {
-            UserManager mgr = getRoller().getUserManager();
-            UserData ud = mgr.getUserByUserName(username);
-            WebsiteData wd = mgr.getWebsiteByHandle(handle);
-            PermissionsData pd = mgr.getPermissions(wd, ud);
+            UserData ud = getUserData(username);
+            WebsiteData wd = getWebsiteData(handle);
+            PermissionsData pd = getRoller().getUserManager().getPermissions(wd, ud);
             
             return pd;
         } catch (RollerException re) {
-            throw new InternalException("ERROR: Could not get permissions data", re);
+            throw new InternalException("ERROR: Could not get permissions data for weblog handle: " + handle + ", user name: " + username, re);
         }
     }
     
@@ -336,8 +329,8 @@
         }
         
         try {
-            UserData ud = getRoller().getUserManager().getUserByUserName(entry.getName());
-            WebsiteData wd = getRoller().getUserManager().getWebsiteByHandle(entry.getHandle());
+            UserData ud = getUserData(entry.getName());
+            WebsiteData wd = getWebsiteData(entry.getHandle());
             
             UserManager mgr = getRoller().getUserManager();
             mgr.savePermissions(pd);
@@ -371,9 +364,9 @@
             mgr.removePermissions(pd);
             getRoller().flush();
             
-            UserData ud = getRoller().getUserManager().getUserByUserName(username);
+            UserData ud = getUserData(username);
             CacheManager.invalidate(ud);
-            WebsiteData wd = getRoller().getUserManager().getWebsiteByHandle(handle);
+            WebsiteData wd = getWebsiteData(handle);
             CacheManager.invalidate(wd);
             
             EntrySet es = toMemberEntrySet(pds);

Modified: incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java?view=diff&rev=448278&r1=448277&r2=448278
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java Wed Sep 20 10:52:25 2006
@@ -31,7 +31,6 @@
 import org.apache.roller.util.cache.CacheManager;
 import org.apache.roller.webservices.adminapi.sdk.Entry;
 import org.apache.roller.webservices.adminapi.sdk.EntrySet;
-import org.apache.roller.webservices.adminapi.sdk.MissingElementException;
 import org.apache.roller.webservices.adminapi.sdk.UnexpectedRootElementException;
 import org.apache.roller.webservices.adminapi.sdk.UserEntry;
 import org.apache.roller.webservices.adminapi.sdk.UserEntrySet;
@@ -46,7 +45,7 @@
         super(request);
     }
     
-    protected EntrySet getEntrySet(Document d) throws MissingElementException, UnexpectedRootElementException {
+    protected EntrySet getEntrySet(Document d) throws UnexpectedRootElementException {
         return new UserEntrySet(d, getUrlPrefix());
     }
     
@@ -88,7 +87,7 @@
     
     private EntrySet getCollection() throws HandlerException {
         try {
-            List users = getRoller().getUserManager().getUsers(0, -1);
+            List users = getRoller().getUserManager().getUsers(null, null, null, 0, -1);
             if (users == null) {
                 users = java.util.Collections.EMPTY_LIST;
             }
@@ -101,18 +100,11 @@
     }
     
     private EntrySet getEntry() throws HandlerException {
-        try {
-            UserData ud = getRoller().getUserManager().getUserByUserName(getUri().getEntryId());
-            if (ud == null) {
-                throw new NotFoundException("ERROR: Unknown user: " + getUri().getEntryId());
-            }
-            UserData[] uds = new UserData[] { ud };
-            
-            EntrySet c = toUserEntrySet(uds);
-            return c;
-        } catch (RollerException re) {
-            throw new InternalException("ERROR: Could not get user collection", re);
-        }
+        UserData ud = getUserData(getUri().getEntryId());
+        UserData[] uds = new UserData[] { ud };
+        
+        EntrySet c = toUserEntrySet(uds);
+        return c;
     }
     
     private EntrySet postCollection(Reader r) throws HandlerException {
@@ -176,25 +168,16 @@
             throw new InternalException("ERROR: Could not create users: " + c, re);
         }
     }
-    
+        
     private UserEntrySet updateUsers(UserEntrySet c) throws HandlerException {
-        try {
-            UserManager mgr = getRoller().getUserManager();
-            
-            List userDatas = new ArrayList();
-            for (int i = 0; i < c.getEntries().length; i++) {
-                UserEntry entry = (UserEntry)c.getEntries()[i];
-                UserData ud = mgr.getUserByUserName(entry.getName());
-                if (ud == null) {
-                    throw new NotFoundException("ERROR: Unknown user: " + entry.getName());
-                }
-                updateUserData(ud, entry);
-                userDatas.add(ud);
-            }
-            return toUserEntrySet((UserData[])userDatas.toArray(new UserData[0]));
-        } catch (RollerException re) {
-            throw new InternalException("ERROR: Could not update users: " + c, re);
+        List userDatas = new ArrayList();
+        for (int i = 0; i < c.getEntries().length; i++) {
+            UserEntry entry = (UserEntry)c.getEntries()[i];
+            UserData ud = getUserData(entry.getName());
+            updateUserData(ud, entry);
+            userDatas.add(ud);
         }
+        return toUserEntrySet((UserData[])userDatas.toArray(new UserData[0]));
     }
     
     private void updateUserData(UserData ud, UserEntry entry) throws HandlerException {
@@ -215,6 +198,9 @@
         if (entry.getEmailAddress() != null) {
             ud.setEmailAddress(entry.getEmailAddress());
         }
+        if (entry.getEnabled() != null) {
+            ud.setEnabled(entry.getEnabled());
+        }
         
         try {
             UserManager mgr = getRoller().getUserManager();
@@ -227,28 +213,25 @@
     }
     
     private EntrySet deleteEntry() throws HandlerException {
+        UserData ud = getUserData(getUri().getEntryId());
+        
+        // don't allow deletion of the currently authenticated user
+        if (ud.getUserName().equals(getUserName())) {
+            throw new NotAllowedException("ERROR: Can't delete authenticated user: " + getUserName());
+        }
+        
+        UserData[] uds = new UserData[] { ud };
+        
         try {
-            UserManager mgr = getRoller().getUserManager();
-            UserData ud = mgr.getUserByUserName(getUri().getEntryId());
-            
-            if (ud == null) {
-                throw new NotFoundException("ERROR: Unknown user: " + getUri().getEntryId());
-            }
-            // don't allow deletion of the currently authenticated user
-            if (ud.getUserName().equals(getUserName())) {
-                throw new NotAllowedException("ERROR: Can't delete authenticated user: " + getUserName());
-            }
-            
-            UserData[] uds = new UserData[] { ud };
-            mgr.removeUser(ud);
-            getRoller().flush();            
+            getRoller().getUserManager().removeUser(ud);
+            getRoller().flush();
             CacheManager.invalidate(ud);
-
-            EntrySet es = toUserEntrySet(uds);
-            return es;
         } catch (RollerException re) {
-            throw new InternalException("ERROR: Could not delete entry: " + getUri().getEntryId(), re);
+            throw new InternalException("ERROR: could not delete user data", re);
         }
+        
+        EntrySet es = toUserEntrySet(uds);
+        return es;
     }
     
     private UserEntry toUserEntry(UserData ud) {
@@ -265,6 +248,7 @@
         ue.setTimezone(ud.getTimeZone());
         ue.setEmailAddress(ud.getEmailAddress());
         ue.setDateCreated(ud.getDateCreated());
+        ue.setEnabled(ud.getEnabled());
         
         return ue;
     }
@@ -298,13 +282,28 @@
         //
         UserData ud = new UserData();
         ud.setUserName(ue.getName());
-        ud.setFullName(ue.getFullName());
-        ud.setPassword(ue.getPassword());
-        ud.setEmailAddress(ue.getEmailAddress());
-        ud.setLocale(ue.getLocale().toString());
-        ud.setTimeZone(ue.getTimezone().getID());
-        ud.setDateCreated(ue.getDateCreated());
         
+        if (ue.getFullName() != null) {
+            ud.setFullName(ue.getFullName());
+        }
+        if (ue.getPassword() != null) {
+            ud.setPassword(ue.getPassword());
+        }
+        if (ue.getEmailAddress() != null) {
+            ud.setEmailAddress(ue.getEmailAddress());
+        }
+        if (ue.getLocale() != null) {
+            ud.setLocale(ue.getLocale().toString());
+        }
+        if (ue.getTimezone() != null) {
+            ud.setTimeZone(ue.getTimezone().getID());
+        }
+        if (ue.getDateCreated() != null) {
+            ud.setDateCreated(ue.getDateCreated());
+        }
+        if (ue.getEnabled() != null) {
+            ud.setEnabled(ue.getEnabled());
+        }
         return ud;
     }
 }

Modified: incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java?view=diff&rev=448278&r1=448277&r2=448278
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java Wed Sep 20 10:52:25 2006
@@ -39,7 +39,6 @@
 import org.apache.roller.util.Utilities;
 import org.apache.roller.webservices.adminapi.sdk.Entry;
 import org.apache.roller.webservices.adminapi.sdk.EntrySet;
-import org.apache.roller.webservices.adminapi.sdk.MissingElementException;
 import org.apache.roller.webservices.adminapi.sdk.UnexpectedRootElementException;
 import org.apache.roller.webservices.adminapi.sdk.WeblogEntry;
 import org.apache.roller.webservices.adminapi.sdk.WeblogEntrySet;
@@ -58,7 +57,7 @@
         super(request);
     }
     
-    protected EntrySet getEntrySet(Document d) throws MissingElementException, UnexpectedRootElementException {
+    protected EntrySet getEntrySet(Document d) throws UnexpectedRootElementException {
         return new WeblogEntrySet(d, getUrlPrefix());
     }
     
@@ -100,7 +99,7 @@
     
     private EntrySet getCollection() throws HandlerException {
         try {
-            List users = getRoller().getUserManager().getUsers(0, -1);
+            List users = getRoller().getUserManager().getUsers(null, null, null, 0, -1);
             if (users == null) {
                 users = Collections.EMPTY_LIST;
             }
@@ -111,21 +110,14 @@
             throw new InternalException("ERROR: Could not get weblog collection", re);
         }
     }
-    
+        
     private EntrySet getEntry() throws HandlerException {
         String handle = getUri().getEntryId();
-        try {
-            WebsiteData wd = getRoller().getUserManager().getWebsiteByHandle(handle);
-            if (wd == null) {
-                throw new NotFoundException("ERROR: Unknown weblog handle: " + handle);
-            }
-            WebsiteData[] wds = new WebsiteData[] { wd };
-            EntrySet c = toWeblogEntrySet(wds);
-            
-            return c;
-        } catch (RollerException re) {
-            throw new InternalException("ERROR: Could not get weblog collection", re);
-        }
+        WebsiteData wd = getWebsiteData(handle);
+        WebsiteData[] wds = new WebsiteData[] { wd };
+        EntrySet c = toWeblogEntrySet(wds);
+        
+        return c;
     }
     
     private EntrySet postCollection(Reader r) throws HandlerException {
@@ -193,6 +185,11 @@
                 }
                 wd.setDateCreated(dateCreated);
                 
+                Boolean enabled = entry.getEnabled();
+                if (enabled != null) {
+                    wd.setEnabled(enabled);
+                }
+                
                 try {
                     String def = RollerRuntimeConfig.getProperty("users.editor.pages");
                     String[] defs = Utilities.stringToStringArray(def,",");
@@ -203,11 +200,11 @@
                 
                 mgr.addWebsite(wd);
                 getRoller().flush();
-                CacheManager.invalidate(wd);                
+                CacheManager.invalidate(wd);
                 websiteDatas.add(wd);
             }
             
-            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);
         }
@@ -224,10 +221,7 @@
             List websiteDatas = new ArrayList();
             for (int i = 0; i < c.getEntries().length; i++) {
                 WeblogEntry entry = (WeblogEntry)c.getEntries()[i];
-                WebsiteData wd = mgr.getWebsiteByHandle(entry.getHandle());
-                if (wd == null) {
-                    throw new NotFoundException("ERROR: Unknown weblog: " + entry.getHandle());
-                }
+                WebsiteData wd = getWebsiteData(entry.getHandle());
                 updateWebsiteData(wd, entry);
                 websiteDatas.add(wd);
             }
@@ -253,11 +247,14 @@
         if (entry.getEmailAddress() != null) {
             wd.setEmailAddress(entry.getEmailAddress());
         }
+        if (entry.getEnabled() != null) {
+            wd.setEnabled(entry.getEnabled());
+        }
         
         try {
             UserManager mgr = getRoller().getUserManager();
             mgr.saveWebsite(wd);
-            getRoller().flush();            
+            getRoller().flush();
             CacheManager.invalidate(wd);
         } catch (RollerException re) {
             throw new InternalException("ERROR: Could not update website data", re);
@@ -270,16 +267,12 @@
         try {
             UserManager mgr = getRoller().getUserManager();
             
-            WebsiteData wd = mgr.getWebsiteByHandle(handle);
-            if (wd == null) {
-                throw new NotFoundException("ERROR: Unknown weblog handle: " + handle);
-            }
-            
+            WebsiteData wd = getWebsiteData(handle);
             WebsiteData[] wds = new WebsiteData[] { wd };
             EntrySet es = toWeblogEntrySet(wds);
             
             mgr.removeWebsite(wd);
-            getRoller().flush();            
+            getRoller().flush();
             CacheManager.invalidate(wd);
             
             return es;
@@ -300,6 +293,8 @@
         we.setCreatingUser(wd.getCreator().getUserName());
         we.setEmailAddress(wd.getEmailAddress());
         we.setDateCreated(wd.getDateCreated());
+        we.setEnabled(wd.getEnabled());
+        
         try {
             AppUrl appUrl = new AppUrl(RollerRuntimeConfig.getAbsoluteContextURL(), wd.getHandle());
             we.setAppEntriesUrl(appUrl.getEntryUrl().toString());

Modified: incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/MemberEntry.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/MemberEntry.java?view=diff&rev=448278&r1=448277&r2=448278
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/MemberEntry.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/MemberEntry.java Wed Sep 20 10:52:25 2006
@@ -1,24 +1,19 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-*  contributor license agreements.  The ASF licenses this file to You
-* under the Apache License, Version 2.0 (the "License"); you may not
-* use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.  For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
-/*
- * MemberEntry.java
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- * Created on January 17, 2006, 12:44 PM
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  */
 
 package org.apache.roller.webservices.adminapi.sdk;
@@ -34,7 +29,7 @@
 import org.apache.roller.webservices.adminapi.sdk.Entry.Types;
 
 /**
- * This class describes a member entry. 
+ * This class describes a member entry.
  * A member entry is a triple consisting of a user name, a weblog handle,
  * and a permission.
  */
@@ -51,58 +46,56 @@
         public static final String NAME = "name";
         public static final String HANDLE = "handle";
         public static final String PERMISSION = "permission";
-    }     
+    }
     
     private String name;
     private String handle;
     private String permission;
     
-    public MemberEntry(Element e, String urlPrefix) throws MissingElementException {
+    public MemberEntry(Element e, String urlPrefix) {
         populate(e, urlPrefix);
     }
     
     public MemberEntry(String handle, String userName, String urlPrefix) {
-        String href = urlPrefix + "/" + EntrySet.Types.MEMBERS + "/" + handle + "/" + userName;       
-	setHref(href);
+        String href = urlPrefix + "/" + EntrySet.Types.MEMBERS + "/" + handle + "/" + userName;
+        setHref(href);
         setHandle(handle);
         setName(userName);
     }
-
-    public MemberEntry(InputStream stream, String urlPrefix) throws JDOMException, IOException, MissingElementException {               
+    
+    public MemberEntry(InputStream stream, String urlPrefix) throws JDOMException, IOException {
         SAXBuilder sb = new SAXBuilder();
         Document d = sb.build(stream);
         Element e = d.detachRootElement();
         
-        populate(e, urlPrefix);        
+        populate(e, urlPrefix);
     }
-
-    private void populate(Element e, String urlPrefix) throws MissingElementException {
+    
+    private void populate(Element e, String urlPrefix) {
+        // all required
+        
         // name
         Element nameElement = e.getChild(Tags.NAME, NAMESPACE);
-        if (nameElement == null) {
-            throw new MissingElementException("ERROR: Missing element", e.getName(), Tags.NAME);
+        if (nameElement != null) {
+            setName(nameElement.getText());
         }
-        setName(nameElement.getText());
-                
+        
         // handle
         Element handleElement = e.getChild(Tags.HANDLE, NAMESPACE);
-        if (handleElement == null) {
-            throw new MissingElementException("ERROR: Missing element", e.getName(), Tags.HANDLE);
+        if (handleElement != null) {
+            setHandle(handleElement.getText());
         }
-        setHandle(handleElement.getText());
-
+        
         // href
-        setHref(urlPrefix + "/" + EntrySet.Types.MEMBERS + "/" + getHandle() + "/" + getName()); 
+        setHref(urlPrefix + "/" + EntrySet.Types.MEMBERS + "/" + getHandle() + "/" + getName());
         
-        // password
+        // permission
         Element permissionElement = e.getChild(Tags.PERMISSION, NAMESPACE);
-        if (permissionElement == null) {
-            throw new MissingElementException("ERROR: Missing element", e.getName(), Tags.PERMISSION);
+        if (permissionElement != null) {
+            setPermission(permissionElement.getText());
         }
-        setPermission(permissionElement.getText());
     }
     
-    
     public String getType() {
         return Types.MEMBER;
     }
@@ -113,31 +106,40 @@
         
         // href
         member.setAttribute(Attributes.HREF, getHref());
-               
+        
         // name
-        Element name = new Element(Tags.NAME, Service.NAMESPACE);
-        Text nameText = new Text(getName());
-        name.addContent(nameText);
-        member.addContent(name);
-       
+        String name = getName();
+        if (name != null) {
+            Element nameElement = new Element(Tags.NAME, Service.NAMESPACE);
+            Text nameText = new Text(name);
+            nameElement.addContent(nameText);
+            member.addContent(nameElement);
+        }
+        
         // handle
-        Element handle = new Element(Tags.HANDLE, NAMESPACE);
-        Text handleText = new Text(getHandle());
-        handle.addContent(handleText);
-        member.addContent(handle);
+        String handle = getHandle();
+        if (handle != null) {
+            Element handleElement = new Element(Tags.HANDLE, NAMESPACE);
+            Text handleText = new Text(handle);
+            handleElement.addContent(handleText);
+            member.addContent(handleElement);
+        }
         
         // permission
-        Element permission = new Element(Tags.PERMISSION, NAMESPACE);
-        Text permissionText = new Text(getPermission());
-        permission.addContent(permissionText);
-        member.addContent(permission);
-                
+        String perm = getPermission();
+        if (perm != null) {
+            Element permissionElement = new Element(Tags.PERMISSION, NAMESPACE);
+            Text permissionText = new Text(perm);
+            permissionElement.addContent(permissionText);
+            member.addContent(permissionElement);
+        }
+        
         return doc;
     }
-
+    
     public boolean equals(Object o) {
-        if ( o == null || o.getClass() != this.getClass()) { 
-            return false;        
+        if ( o == null || o.getClass() != this.getClass()) {
+            return false;
         }
         
         MemberEntry other = (MemberEntry)o;
@@ -155,23 +157,23 @@
         return super.equals(o);
     }
     
-
+    
     public String getName() {
         return name;
     }
-
+    
     public void setName(String name) {
         this.name = name;
     }
-
+    
     public String getHandle() {
         return handle;
     }
-
+    
     public void setHandle(String handle) {
         this.handle = handle;
     }
-
+    
     public String getPermission() {
         return permission;
     }

Modified: incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/MemberEntrySet.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/MemberEntrySet.java?view=diff&rev=448278&r1=448277&r2=448278
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/MemberEntrySet.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/MemberEntrySet.java Wed Sep 20 10:52:25 2006
@@ -48,18 +48,18 @@
         setHref(urlPrefix + "/" + Types.MEMBERS);        
     }    
 
-    public MemberEntrySet(Document d, String urlPrefix) throws MissingElementException, UnexpectedRootElementException {
+    public MemberEntrySet(Document d, String urlPrefix) throws UnexpectedRootElementException {
         populate(d, urlPrefix);
     }
     
-    public MemberEntrySet(InputStream stream, String urlPrefix) throws JDOMException, IOException, MissingElementException, UnexpectedRootElementException {               
+    public MemberEntrySet(InputStream stream, String urlPrefix) throws JDOMException, IOException, UnexpectedRootElementException {               
         SAXBuilder sb = new SAXBuilder();
         Document d = sb.build(stream);
 
         populate(d, urlPrefix);        
     }    
     
-    private void populate(Document d, String urlPrefix) throws MissingElementException, UnexpectedRootElementException {
+    private void populate(Document d, String urlPrefix) throws UnexpectedRootElementException {
         Element root = d.getRootElement();
         String rootName = root.getName();
         if (!rootName.equals(Tags.MEMBERS)) {

Modified: incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/UnexpectedRootElementException.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/UnexpectedRootElementException.java?view=diff&rev=448278&r1=448277&r2=448278
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/UnexpectedRootElementException.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/UnexpectedRootElementException.java Wed Sep 20 10:52:25 2006
@@ -22,6 +22,7 @@
     private String actual;
     
     public UnexpectedRootElementException(String msg, String expected, String actual) {
+        super(msg);
         this.expected = expected;
         this.actual = actual;
     }

Modified: incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/UserEntry.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/UserEntry.java?view=diff&rev=448278&r1=448277&r2=448278
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/UserEntry.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/UserEntry.java Wed Sep 20 10:52:25 2006
@@ -1,26 +1,20 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-*  contributor license agreements.  The ASF licenses this file to You
-* under the Apache License, Version 2.0 (the "License"); you may not
-* use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.  For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
-/*
- * UserEntry.java
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- * Created on January 17, 2006, 12:44 PM
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  */
-
 package org.apache.roller.webservices.adminapi.sdk;
 
 import java.io.IOException;
@@ -51,6 +45,7 @@
         public static final String LOCALE = "locale";
         public static final String TIMEZONE = "timezone";
         public static final String DATE_CREATED = "date-created";
+        public static final String ENABLED = "enabled";
     }
     
     private String name;
@@ -60,34 +55,34 @@
     private TimeZone timezone;
     private Date dateCreated;
     private String emailAddress;
+    private Boolean enabled;
     
     /** Construct an empty user entry */
     public UserEntry(String name, String urlPrefix) {
         setName(name);
-        String href = urlPrefix + "/" + EntrySet.Types.USERS + "/" + name;                
+        String href = urlPrefix + "/" + EntrySet.Types.USERS + "/" + name;
         setHref(href);
     }
     
     /** Construct a user entry from a JDOM element. */
-    public UserEntry(Element e, String urlPrefix) throws MissingElementException {
+    public UserEntry(Element e, String urlPrefix) {
         populate(e, urlPrefix);
     }
     
-    public UserEntry(InputStream stream, String urlPrefix) throws JDOMException, IOException, MissingElementException {               
+    public UserEntry(InputStream stream, String urlPrefix) throws JDOMException, IOException {
         SAXBuilder sb = new SAXBuilder();
         Document d = sb.build(stream);
         Element e = d.detachRootElement();
         
-        populate(e, urlPrefix);        
+        populate(e, urlPrefix);
     }
     
-    private void populate(Element e, String urlPrefix) throws MissingElementException {
-        // name
+    private void populate(Element e, String urlPrefix) {
+        // name (required)
         Element nameElement = e.getChild(Tags.NAME, NAMESPACE);
-        if (nameElement == null) {
-            throw new MissingElementException("ERROR: Missing element", e.getName(), Tags.NAME);
+        if (nameElement != null) {
+            setName(nameElement.getText());
         }
-        setName(nameElement.getText());
         
         // href
         String href = urlPrefix + "/" + EntrySet.Types.USERS + "/" + getName();
@@ -95,47 +90,48 @@
         
         // full name
         Element fullNameElement = e.getChild(Tags.FULL_NAME, NAMESPACE);
-        if (fullNameElement == null) {
-            throw new MissingElementException("ERROR: Missing element", e.getName(), Tags.FULL_NAME);
+        if (fullNameElement != null) {
+            setFullName(fullNameElement.getText());
         }
-        setFullName(fullNameElement.getText());
         
         // password
-        // this is optional
         Element passwordElement = e.getChild(Tags.PASSWORD, NAMESPACE);
         if (passwordElement != null) {
-            setPassword(passwordElement.getText());            
+            setPassword(passwordElement.getText());
         }
         
         // locale
         Element localeElement = e.getChild(Tags.LOCALE, Service.NAMESPACE);
-        if (localeElement == null) {
-            throw new MissingElementException("ERROR: Missing element", e.getName(), Tags.LOCALE);
+        if (localeElement != null) {
+            setLocale(localeElement.getText());
         }
-        setLocale(localeElement.getText());
         
         // timezone
         Element tzElement = e.getChild(Tags.TIMEZONE, Service.NAMESPACE);
-        if (tzElement == null) {
-            throw new MissingElementException("ERROR: Missing element", e.getName(), Tags.TIMEZONE);
+        if (tzElement != null) {
+            setTimezone(tzElement.getText());
         }
-        setTimezone(tzElement.getText());
         
         // email address
         Element emailElement = e.getChild(Tags.EMAIL_ADDRESS, Service.NAMESPACE);
-        if (emailElement == null) {
-            throw new MissingElementException("ERROR: Missing element", e.getName(), Tags.EMAIL_ADDRESS);
+        if (emailElement != null) {
+            setEmailAddress(emailElement.getText());
         }
-        setEmailAddress(emailElement.getText());
         
         // created (optional)
         Element createdElement = e.getChild(Tags.DATE_CREATED, Service.NAMESPACE);
         if (createdElement != null) {
             setDateCreated(new Date(Long.valueOf(createdElement.getText()).longValue()));
         }
+        
+        // enabled
+        Element enabledElement = e.getChild(Tags.ENABLED, Service.NAMESPACE);
+        if (enabledElement != null) {
+            setEnabled(Boolean.valueOf(enabledElement.getText()));
+        }
     }
     
-        
+    
     public String getType() {
         return Types.USER;
     }
@@ -154,7 +150,7 @@
         String name = getName();
         if (name != null) {
             Element nameElement = new Element(Tags.NAME, Service.NAMESPACE);
-            Text nameText = new Text(getName());
+            Text nameText = new Text(name);
             nameElement.addContent(nameText);
             userElement.addContent(nameElement);
         }
@@ -163,7 +159,7 @@
         String fullName = getFullName();
         if (fullName != null) {
             Element fullNameElement = new Element(Tags.FULL_NAME, NAMESPACE);
-            Text fullNameText = new Text(getFullName());
+            Text fullNameText = new Text(fullName);
             fullNameElement.addContent(fullNameText);
             userElement.addContent(fullNameElement);
         }
@@ -172,14 +168,14 @@
         String password = getPassword();
         if (password != null) {
             Element passwordElement = new Element(Tags.PASSWORD, NAMESPACE);
-            Text passwordText = new Text(getPassword());
+            Text passwordText = new Text(password);
             passwordElement.addContent(passwordText);
             userElement.addContent(passwordElement);
         }
         
         // locale
         Locale locale = getLocale();
-        if (locale != null ) {
+        if (locale != null) {
             Element localeElement = new Element(Tags.LOCALE, Service.NAMESPACE);
             Text localeText = new Text(getLocale().toString());
             localeElement.addContent(localeText);
@@ -199,12 +195,12 @@
         String emailAddress = getEmailAddress();
         if (emailAddress != null) {
             Element emailAddressElement = new Element(Tags.EMAIL_ADDRESS, Service.NAMESPACE);
-            Text emailAddressText = new Text(String.valueOf(emailAddress));
+            Text emailAddressText = new Text(emailAddress);
             emailAddressElement.addContent(emailAddressText);
             userElement.addContent(emailAddressElement);
         }
         
-        // creation date (optional)
+        // creation date
         Date datedCreated = getDateCreated();
         if (dateCreated != null) {
             Element dateCreatedElement = new Element(Tags.DATE_CREATED, Service.NAMESPACE);
@@ -213,6 +209,15 @@
             userElement.addContent(dateCreatedElement);
         }
         
+        // enabled
+        Boolean enabled = getEnabled();
+        if (enabled != null) {
+            Element enabledElement = new Element(Tags.ENABLED, NAMESPACE);
+            Text enabledText = new Text(enabled.toString());
+            enabledElement.addContent(enabledText);
+            userElement.addContent(enabledElement);
+        }
+        
         return doc;
     }
     
@@ -259,7 +264,7 @@
     /** Set the locale string of this user entry. */
     public void setLocale(String localeString) {
         this.locale = new LocaleString(localeString).getLocale();
-    }    
+    }
     
     /** Get the timezone string of this user entry. */
     public TimeZone getTimezone() {
@@ -270,7 +275,7 @@
     public void setTimezone(TimeZone timezone) {
         this.timezone = timezone;
     }
-
+    
     /** Set the timezone string of this user entry. */
     public void setTimezone(String timezoneString) {
         this.timezone = TimeZone.getTimeZone(timezoneString);
@@ -298,8 +303,8 @@
     
     /** Test if a user entry is equal to this user entry. */
     public boolean equals(Object o) {
-        if ( o == null || o.getClass() != this.getClass()) { 
-            return false;        
+        if ( o == null || o.getClass() != this.getClass()) {
+            return false;
         }
         
         UserEntry other = (UserEntry)o;
@@ -319,8 +324,19 @@
         if (!areEqual(getTimezone(), other.getTimezone())) {
             return false;
         }
+        if (!areEqual(getEnabled(), other.getEnabled())) {
+            return false;
+        }
         
         return super.equals(o);
+    }
+    
+    public Boolean getEnabled() {
+        return enabled;
+    }
+    
+    public void setEnabled(Boolean enabled) {
+        this.enabled = enabled;
     }
     
 }

Modified: incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/UserEntrySet.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/UserEntrySet.java?view=diff&rev=448278&r1=448277&r2=448278
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/UserEntrySet.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/UserEntrySet.java Wed Sep 20 10:52:25 2006
@@ -50,18 +50,18 @@
     }
     
     /** Construct based on a JDOM Document object. */
-    public UserEntrySet(Document d, String urlPrefix) throws MissingElementException, UnexpectedRootElementException {
+    public UserEntrySet(Document d, String urlPrefix) throws UnexpectedRootElementException {
         populate(d, urlPrefix);
     }
     
-    public UserEntrySet(InputStream stream, String urlPrefix) throws JDOMException, IOException, MissingElementException, UnexpectedRootElementException {               
+    public UserEntrySet(InputStream stream, String urlPrefix) throws JDOMException, IOException, UnexpectedRootElementException {               
         SAXBuilder sb = new SAXBuilder();
         Document d = sb.build(stream);
 
         populate(d, urlPrefix);        
     }        
     
-    private void populate(Document d, String urlPrefix) throws MissingElementException, UnexpectedRootElementException {
+    private void populate(Document d, String urlPrefix) throws UnexpectedRootElementException {
         Element root = d.getRootElement();
         String rootName = root.getName();
         if (!rootName.equals(Tags.USERS)) {

Modified: incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/WeblogEntry.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/WeblogEntry.java?view=diff&rev=448278&r1=448277&r2=448278
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/WeblogEntry.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/WeblogEntry.java Wed Sep 20 10:52:25 2006
@@ -1,20 +1,20 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-*  contributor license agreements.  The ASF licenses this file to You
-* under the Apache License, Version 2.0 (the "License"); you may not
-* use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.  For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
 package org.apache.roller.webservices.adminapi.sdk;
 /*
  * WeblogEntry.java
@@ -36,7 +36,7 @@
 import org.apache.roller.webservices.adminapi.sdk.Entry.Types;
 
 /**
- * This class describes a weblog entry. 
+ * This class describes a weblog entry.
  */
 public class WeblogEntry extends Entry {
     static interface Tags {
@@ -49,8 +49,9 @@
         public static final String DATE_CREATED = "date-created";
         public static final String CREATING_USER = "creating-user";
         public static final String EMAIL_ADDRESS = "email-address";
-        public static final String APP_ENTRIES_URL = "app-entries-url";        
-        public static final String APP_RESOURCES_URL = "app-resources-url";                
+        public static final String APP_ENTRIES_URL = "app-entries-url";
+        public static final String APP_RESOURCES_URL = "app-resources-url";
+        public static final String ENABLED = "enabled";
     }
     
     private String handle;
@@ -63,95 +64,95 @@
     private String emailAddress;
     private String appEntriesUrl;
     private String appResourcesUrl;
+    private Boolean enabled;
     
-    public WeblogEntry(Element e, String urlPrefix) throws MissingElementException {
+    public WeblogEntry(Element e, String urlPrefix) {
         populate(e, urlPrefix);
     }
     
-    public WeblogEntry(InputStream stream, String urlPrefix) throws JDOMException, IOException, MissingElementException {               
+    public WeblogEntry(InputStream stream, String urlPrefix) throws JDOMException, IOException {
         SAXBuilder sb = new SAXBuilder();
         Document d = sb.build(stream);
         Element e = d.detachRootElement();
         
-        populate(e, urlPrefix);        
+        populate(e, urlPrefix);
     }
     
-    private void populate(Element e, String urlPrefix) throws MissingElementException {
-        // handle
+    private void populate(Element e, String urlPrefix) {
+        // handle (required)
         Element handleElement = e.getChild(Tags.HANDLE, Service.NAMESPACE);
-        if (handleElement == null) {
-            throw new MissingElementException("ERROR: Missing element", e.getName(), Tags.HANDLE);
+        if (handleElement != null) {
+            setHandle(handleElement.getText());
         }
-        setHandle(handleElement.getText());
         
         // href
-        String href = urlPrefix + "/" + EntrySet.Types.WEBLOGS + "/" + getHandle();        
-        setHref(href);        
+        String href = urlPrefix + "/" + EntrySet.Types.WEBLOGS + "/" + getHandle();
+        setHref(href);
         
         // name
         Element nameElement = e.getChild(Tags.NAME, Service.NAMESPACE);
-        if (nameElement == null) {
-            throw new MissingElementException("ERROR: Missing element", e.getName(), Tags.NAME);
+        if (nameElement != null) {
+            setName(nameElement.getText());
         }
-        setName(nameElement.getText());
         
         // description
         Element descElement = e.getChild(Tags.DESCRIPTION, Service.NAMESPACE);
-        if (descElement == null) {
-            throw new MissingElementException("ERROR: Missing element", e.getName(), Tags.DESCRIPTION);
+        if (descElement != null) {
+            setDescription(descElement.getText());
         }
-        setDescription(descElement.getText());
         
         // locale
         Element localeElement = e.getChild(Tags.LOCALE, Service.NAMESPACE);
-        if (localeElement == null) {
-            throw new MissingElementException("ERROR: Missing element", e.getName(), Tags.LOCALE);
+        if (localeElement != null) {
+            setLocale(localeElement.getText());
         }
-        setLocale(localeElement.getText());
         
         // timezone
         Element tzElement = e.getChild(Tags.TIMEZONE, Service.NAMESPACE);
-        if (tzElement == null) {
-            throw new MissingElementException("ERROR: Missing element", e.getName(), Tags.TIMEZONE);
+        if (tzElement != null) {
+            setTimezone(tzElement.getText());
         }
-        setTimezone(tzElement.getText());
         
         // creator
         Element creatorElement = e.getChild(Tags.CREATING_USER, Service.NAMESPACE);
-        if (creatorElement == null) {
-            throw new MissingElementException("ERROR: Missing element", e.getName(), Tags.CREATING_USER);
+        if (creatorElement != null) {
+            setCreatingUser(creatorElement.getText());
         }
-        setCreatingUser(creatorElement.getText());
         
         // email address
         Element emailElement = e.getChild(Tags.EMAIL_ADDRESS, Service.NAMESPACE);
-        if (emailElement == null) {
-            throw new MissingElementException("ERROR: Missing element: ", e.getName(), Tags.EMAIL_ADDRESS);
+        if (emailElement != null) {
+            setEmailAddress(emailElement.getText());
         }
-        setEmailAddress(emailElement.getText());        
         
-        // created (optional)
+        // created
         Element createdElement = e.getChild(Tags.DATE_CREATED, Service.NAMESPACE);
         if (createdElement != null) {
             setDateCreated(new Date(Long.valueOf(createdElement.getText()).longValue()));
-        }              
+        }
         
-        // APP entries URL (optional)
+        // APP entries URL
         Element appEntriesUrlElement = e.getChild(Tags.APP_ENTRIES_URL, Service.NAMESPACE);
         if (appEntriesUrlElement != null) {
             setAppEntriesUrl(appEntriesUrlElement.getText());
-        }                      
+        }
         
-        // APP resources URL (optional)
+        // APP resources URL
         Element appResourcesUrlElement = e.getChild(Tags.APP_RESOURCES_URL, Service.NAMESPACE);
         if (appResourcesUrlElement != null) {
             setAppResourcesUrl(appResourcesUrlElement.getText());
-        }                              
+        }
+        
+        // enabled
+        Element enabledElement = e.getChild(Tags.ENABLED, Service.NAMESPACE);
+        if (enabledElement != null) {
+            setEnabled(Boolean.valueOf(enabledElement.getText()));
+        }
     }
     
     
     public WeblogEntry(String handle, String urlPrefix) {
-        String href = urlPrefix + "/" + EntrySet.Types.WEBLOGS + "/" + handle;        
+        String href = urlPrefix + "/" + EntrySet.Types.WEBLOGS + "/" + handle;
         setHref(href);
         setHandle(handle);
     }
@@ -160,65 +161,86 @@
         return Types.WEBLOG;
     }
     
-    public Document toDocument() {        
+    public Document toDocument() {
         Element weblog = new Element(Tags.WEBLOG, Service.NAMESPACE);
         Document doc = new Document(weblog);
         
         // link
         weblog.setAttribute(Attributes.HREF, getHref());
         
-        // handle
-        Element handle = new Element(Tags.HANDLE, Service.NAMESPACE);
-        Text handleText = new Text(getHandle());
-        handle.addContent(handleText);
-        weblog.addContent(handle);
+        // handle (required)
+        String handle = getHandle();
+        if (handle != null && handle.length() > 0) {
+            Element handleElement = new Element(Tags.HANDLE, Service.NAMESPACE);
+            Text handleText = new Text(handle);
+            handleElement.addContent(handleText);
+            weblog.addContent(handleElement);
+        }
         
         // name
-        Element name = new Element(Tags.NAME, Service.NAMESPACE);
-        Text nameText = new Text(getName());
-        name.addContent(nameText);
-        weblog.addContent(name);
+        String name = getName();
+        if (name != null) {
+            Element nameElement = new Element(Tags.NAME, Service.NAMESPACE);
+            Text nameText = new Text(name);
+            nameElement.addContent(nameText);
+            weblog.addContent(nameElement);
+        }
         
         // description
-        Element desc = new Element(Tags.DESCRIPTION, Service.NAMESPACE);
-        Text descText = new Text(getDescription());
-        desc.addContent(descText);
-        weblog.addContent(desc);
+        String desc = getDescription();
+        if (desc != null) {
+            Element descElement = new Element(Tags.DESCRIPTION, Service.NAMESPACE);
+            Text descText = new Text(desc);
+            descElement.addContent(descText);
+            weblog.addContent(descElement);
+        }
         
         // locale
-        Element locale = new Element(Tags.LOCALE, Service.NAMESPACE);
-        Text localeText = new Text(getLocale().toString());
-        locale.addContent(localeText);
-        weblog.addContent(locale);
+        Locale locale = getLocale();
+        if (locale != null) {
+            Element localeElement = new Element(Tags.LOCALE, Service.NAMESPACE);
+            Text localeText = new Text(locale.toString());
+            localeElement.addContent(localeText);
+            weblog.addContent(localeElement);
+        }
         
         // timezone
-        Element tz = new Element(Tags.TIMEZONE, Service.NAMESPACE);
-        Text tzText = new Text(getTimezone().getID());
-        tz.addContent(tzText);
-        weblog.addContent(tz);
+        TimeZone tz = getTimezone();
+        if (tz != null) {
+            Element tzElement = new Element(Tags.TIMEZONE, Service.NAMESPACE);
+            Text tzText = new Text(tz.getID());
+            tzElement.addContent(tzText);
+            weblog.addContent(tzElement);
+        }
         
         // creating user
-        Element creator = new Element(Tags.CREATING_USER, Service.NAMESPACE);
-        Text creatorText = new Text(String.valueOf(getCreatingUser()));
-        creator.addContent(creatorText);
-        weblog.addContent(creator);
+        String creator = getCreatingUser();
+        if (creator != null) {
+            Element creatorElement = new Element(Tags.CREATING_USER, Service.NAMESPACE);
+            Text creatorText = new Text(creator);
+            creatorElement.addContent(creatorText);
+            weblog.addContent(creatorElement);
+        }
         
         // email address
-        Element email = new Element(Tags.EMAIL_ADDRESS, Service.NAMESPACE);
-        Text emailText = new Text(String.valueOf(getEmailAddress()));
-        email.addContent(emailText);
-        weblog.addContent(email);        
+        String email = getEmailAddress();
+        if (email != null) {
+            Element emailElement = new Element(Tags.EMAIL_ADDRESS, Service.NAMESPACE);
+            Text emailText = new Text(email);
+            emailElement.addContent(emailText);
+            weblog.addContent(emailElement);
+        }
         
-        // creation date (optional)
-        Element created = new Element(Tags.DATE_CREATED, Service.NAMESPACE);
+        // creation date
+        Element dateCreatedElement = new Element(Tags.DATE_CREATED, Service.NAMESPACE);
         Date datedCreated = getDateCreated();
         if (dateCreated != null) {
             Text createdText = new Text(String.valueOf(dateCreated.getTime()));
-            created.addContent(createdText);
-            weblog.addContent(created);
+            dateCreatedElement.addContent(createdText);
+            weblog.addContent(dateCreatedElement);
         }
-
-        // APP entries URL (optional)
+        
+        // APP entries URL
         Element appEntriesUrlElement = new Element(Tags.APP_ENTRIES_URL, Service.NAMESPACE);
         String appEntriesUrl = getAppEntriesUrl();
         if (appEntriesUrl != null) {
@@ -226,8 +248,8 @@
             appEntriesUrlElement.addContent(appEntriesUrlText);
             weblog.addContent(appEntriesUrlElement);
         }
-
-        // APP entries URL (optional)
+        
+        // APP entries URL
         Element appResourcesUrlElement = new Element(Tags.APP_RESOURCES_URL, Service.NAMESPACE);
         String appResourcesUrl = getAppResourcesUrl();
         if (appResourcesUrl != null) {
@@ -236,13 +258,22 @@
             weblog.addContent(appResourcesUrlElement);
         }
         
+        // enabled
+        Element enabledElement = new Element(Tags.ENABLED, Service.NAMESPACE);
+        Boolean enabled = getEnabled();
+        if (enabled != null) {
+            Text enabledText = new Text(getEnabled().toString());
+            enabledElement.addContent(enabledText);
+            weblog.addContent(enabledElement);
+        }
+        
         return doc;
-    }    
-
+    }
+    
     /** Test if a user entry is equal to this user entry. */
     public boolean equals(Object o) {
-        if ( o == null || o.getClass() != this.getClass()) { 
-            return false;        
+        if ( o == null || o.getClass() != this.getClass()) {
+            return false;
         }
         
         WeblogEntry other = (WeblogEntry)o;
@@ -265,6 +296,9 @@
         if (!areEqual(getTimezone(), other.getTimezone())) {
             return false;
         }
+        if (!areEqual(getEnabled(), other.getEnabled())) {
+            return false;
+        }
         
         return super.equals(o);
     }
@@ -295,7 +329,7 @@
     
     public void setLocale(String localeString) {
         this.locale = new LocaleString(localeString).getLocale();
-    }    
+    }
     
     
     public TimeZone getTimezone() {
@@ -305,7 +339,7 @@
     public void setTimezone(TimeZone timezone) {
         this.timezone = timezone;
     }
-
+    
     public void setTimezone(String timezoneString) {
         this.timezone = TimeZone.getTimeZone(timezoneString);
     }
@@ -333,28 +367,36 @@
     public void setCreatingUser(String creatingUser) {
         this.creatingUser = creatingUser;
     }
-
+    
     public String getEmailAddress() {
         return emailAddress;
     }
-
+    
     public void setEmailAddress(String emailAddress) {
         this.emailAddress = emailAddress;
     }
-
+    
     public String getAppEntriesUrl() {
         return appEntriesUrl;
     }
-
+    
     public void setAppEntriesUrl(String appEntriesUrl) {
         this.appEntriesUrl = appEntriesUrl;
     }
-
+    
     public String getAppResourcesUrl() {
         return appResourcesUrl;
     }
-
+    
     public void setAppResourcesUrl(String appResourcesUrl) {
         this.appResourcesUrl = appResourcesUrl;
+    }
+    
+    public Boolean getEnabled() {
+        return enabled;
+    }
+    
+    public void setEnabled(Boolean enabled) {
+        this.enabled = enabled;
     }
 }

Modified: incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/WeblogEntrySet.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/WeblogEntrySet.java?view=diff&rev=448278&r1=448277&r2=448278
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/WeblogEntrySet.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/sdk/WeblogEntrySet.java Wed Sep 20 10:52:25 2006
@@ -47,18 +47,18 @@
         setHref(urlPrefix + "/" + Types.WEBLOGS);
     }
     
-    public WeblogEntrySet(Document d, String urlPrefix) throws MissingElementException, UnexpectedRootElementException {
+    public WeblogEntrySet(Document d, String urlPrefix) throws UnexpectedRootElementException {
         populate(d, urlPrefix);
     }
     
-    public WeblogEntrySet(InputStream stream, String urlPrefix) throws JDOMException, IOException, MissingElementException, UnexpectedRootElementException {               
+    public WeblogEntrySet(InputStream stream, String urlPrefix) throws JDOMException, IOException, UnexpectedRootElementException {               
         SAXBuilder sb = new SAXBuilder();
         Document d = sb.build(stream);
 
         populate(d, urlPrefix);        
     }    
     
-    private void populate(Document d, String urlPrefix) throws MissingElementException, UnexpectedRootElementException {
+    private void populate(Document d, String urlPrefix) throws UnexpectedRootElementException {
         Element root = d.getRootElement();
         String rootName = root.getName();
         if (!rootName.equals(Tags.WEBLOGS)) {



Mime
View raw message