diff --git a/src/com/silverwrist/util/DOMElementHelper.java b/src/com/silverwrist/util/DOMElementHelper.java index 28ee6ae..c5cef6b 100644 --- a/src/com/silverwrist/util/DOMElementHelper.java +++ b/src/com/silverwrist/util/DOMElementHelper.java @@ -271,6 +271,27 @@ public final class DOMElementHelper } // end getAttributeInt + public final Boolean getAttributeBoolean(String name) + { + String tmp = elt.getAttribute(name); + if (StringUtil.isBooleanTrue(tmp)) + return Boolean.TRUE; + else if (StringUtil.isBooleanFalse(tmp)) + return Boolean.FALSE; + else + return null; + + } // end getAttributeBoolean + + public final Boolean getAttributeBoolean(String name, boolean default_val) + { + if (this.hasAttribute(name)) + return this.getAttributeBoolean(name); + else + return (default_val ? Boolean.TRUE : Boolean.FALSE); + + } // end getAttributeBoolean + } // end DOMElementHelper diff --git a/src/com/silverwrist/venice/core/AdminOperations.java b/src/com/silverwrist/venice/core/AdminOperations.java index 5f51bb5..52fd357 100644 --- a/src/com/silverwrist/venice/core/AdminOperations.java +++ b/src/com/silverwrist/venice/core/AdminOperations.java @@ -11,7 +11,7 @@ * * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are - * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ @@ -36,12 +36,17 @@ public interface AdminOperations public abstract AdminUserContext getUserContext(String username) throws DataException; + public abstract CommunityContext getCommunityContext(int cid) throws DataException; + + public abstract CommunityContext getCommunityContext(String alias) throws DataException; + public abstract GlobalProperties getProperties(); public abstract void setProperties(GlobalProperties props) throws DataException; public abstract AdminUserContext createNewAccount(String username, String password, String reminder, boolean verify_email, boolean lockout, Role base_role, - String description) throws DataException, AccessError; + String description, boolean auto_join) + throws DataException, AccessError; } // end interface AdminOperations diff --git a/src/com/silverwrist/venice/core/impl/AdminOperationsImpl.java b/src/com/silverwrist/venice/core/impl/AdminOperationsImpl.java index e7cee63..9431515 100644 --- a/src/com/silverwrist/venice/core/impl/AdminOperationsImpl.java +++ b/src/com/silverwrist/venice/core/impl/AdminOperationsImpl.java @@ -140,6 +140,18 @@ class AdminOperationsImpl implements AdminOperations } // end getUserContext + public CommunityContext getCommunityContext(int cid) throws DataException + { + return CommunityUserContextImpl.getCommunityContext(env,cid,true); + + } // end getCommunityContext + + public CommunityContext getCommunityContext(String alias) throws DataException + { + return CommunityUserContextImpl.getCommunityContext(env,alias,true); + + } // end getCommunityContext + public GlobalProperties getProperties() { return env.getEngine().getProperties(); @@ -154,7 +166,8 @@ class AdminOperationsImpl implements AdminOperations public AdminUserContext createNewAccount(String username, String password, String reminder, boolean verify_email, boolean lockout, Role base_role, - String description) throws DataException, AccessError + String description, boolean auto_join) + throws DataException, AccessError { if (logger.isDebugEnabled()) logger.debug("createNewAccount(\"" + username + "\",,)..."); @@ -166,11 +179,14 @@ class AdminOperationsImpl implements AdminOperations ReturnNewUser rnu = UserContextImpl.createAccount(env,env.getRemoteAddress(),username,password,reminder, verify_email,lockout,0,base_role,description); - // Need to create a normal user context here for just a minute to autojoin the communities. - UserContextImpl rc = new UserContextImpl(env.getGlobalSite(),env); - rc.loadNewUser("0.0.0.0",rnu.getUserID(),base_role.getLevel(),username,0,rnu.getCreationDate(), - rnu.getCreationDate()); - rc.autoJoinCommunities(); + if (auto_join) + { // Need to create a normal user context here for just a minute to autojoin the communities. + UserContextImpl rc = new UserContextImpl(env.getGlobalSite(),env); + rc.loadNewUser("0.0.0.0",rnu.getUserID(),base_role.getLevel(),username,0,rnu.getCreationDate(), + rnu.getCreationDate()); + rc.autoJoinCommunities(); + + } // end if // Now reload the user context and return it. return AdminUserContextImpl.getAdminUserContext(env,rnu.getUserID()); diff --git a/src/com/silverwrist/venice/core/impl/CommunityUserContextImpl.java b/src/com/silverwrist/venice/core/impl/CommunityUserContextImpl.java index 76fc760..e0ded1c 100644 --- a/src/com/silverwrist/venice/core/impl/CommunityUserContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/CommunityUserContextImpl.java @@ -231,19 +231,23 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend } // end testConferenceAccess - private static final CommunityUserContextImpl getCommunityPrivate(EnvUser env, Connection conn, int cid) + private static final CommunityUserContextImpl getCommunityPrivate(EnvUser env, Connection conn, int cid, + boolean allow_null) throws DataException { Statement stmt = null; + ResultSet rs = null; try { // create the query to find the community in the table stmt = conn.createStatement(); StringBuffer sql = new StringBuffer("SELECT signame, alias FROM sigs WHERE sigid = "); sql.append(cid).append(';'); - ResultSet rs = stmt.executeQuery(sql.toString()); + rs = stmt.executeQuery(sql.toString()); if (!(rs.next())) { // the community entry was not found + if (allow_null) + return null; logger.error("Community " + String.valueOf(cid) + " not found in database"); throw new DataException("Community #" + String.valueOf(cid) + " was not found in the database."); @@ -251,7 +255,6 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend // initialize the object and check membership info CommunityUserContextImpl sc = new CommunityUserContextImpl(env,cid,rs.getString(1),rs.getString(2)); - SQLUtil.shutdown(rs); sc.checkMembership(conn); return sc; @@ -264,6 +267,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend } // end catch finally { // shut down statement to conserve resources + SQLUtil.shutdown(rs); SQLUtil.shutdown(stmt); } // end finally @@ -1674,7 +1678,8 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend } // end getMemberCommunityEntries - static final CommunityContext getCommunityContext(EnvUser env, int cid) throws DataException + static final CommunityContext getCommunityContext(EnvUser env, int cid, boolean allow_null) + throws DataException { Connection conn = null; // pooled database connection @@ -1683,7 +1688,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend conn = env.getConnection(); // return the community we want - return getCommunityPrivate(env,conn,cid); + return getCommunityPrivate(env,conn,cid,allow_null); } // end try catch (SQLException e) @@ -1700,10 +1705,12 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend } // end getCommunityContext - static final CommunityContext getCommunityContext(EnvUser env, String alias) throws DataException + static final CommunityContext getCommunityContext(EnvUser env, String alias, boolean allow_null) + throws DataException { Connection conn = null; // pooled database connection Statement stmt = null; + ResultSet rs = null; try { // get a database connection @@ -1713,9 +1720,11 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend stmt = conn.createStatement(); StringBuffer sql = new StringBuffer("SELECT sigid, signame FROM sigs WHERE alias = '"); sql.append(SQLUtil.encodeString(alias)).append("';"); - ResultSet rs = stmt.executeQuery(sql.toString()); + rs = stmt.executeQuery(sql.toString()); if (!(rs.next())) { // no community entry found... + if (allow_null) + return null; logger.error("Community '" + alias + "' not found in the database"); throw new DataException("The community '" + alias + "' was not found in the database."); @@ -1723,7 +1732,6 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend // initialize the object and check membership info CommunityUserContextImpl c = new CommunityUserContextImpl(env,rs.getInt(1),rs.getString(2),alias); - SQLUtil.shutdown(rs); c.checkMembership(conn); return c; @@ -1736,6 +1744,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend } // end catch finally { // make sure we release the connection before we go + SQLUtil.shutdown(rs); SQLUtil.shutdown(stmt); SQLUtil.shutdown(conn); @@ -1745,7 +1754,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend static final CommunityBackend getCommunityBackend(EnvUser env, Connection conn, int cid) throws DataException { - return getCommunityPrivate(env,conn,cid); + return getCommunityPrivate(env,conn,cid,false); } // end getCommunityBackend diff --git a/src/com/silverwrist/venice/core/impl/UserContextImpl.java b/src/com/silverwrist/venice/core/impl/UserContextImpl.java index 740c3d8..ca58648 100644 --- a/src/com/silverwrist/venice/core/impl/UserContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/UserContextImpl.java @@ -895,13 +895,13 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider public CommunityContext getCommunityContext(int cid) throws DataException { - return CommunityUserContextImpl.getCommunityContext(env,cid); + return CommunityUserContextImpl.getCommunityContext(env,cid,false); } // end getCommunityContext public CommunityContext getCommunityContext(String alias) throws DataException { - return CommunityUserContextImpl.getCommunityContext(env,alias); + return CommunityUserContextImpl.getCommunityContext(env,alias,false); } // end getCommunityContext diff --git a/src/com/silverwrist/venice/ui/helpers/ImportHelper.java b/src/com/silverwrist/venice/ui/helpers/ImportHelper.java index 1fd2910..f4f238b 100644 --- a/src/com/silverwrist/venice/ui/helpers/ImportHelper.java +++ b/src/com/silverwrist/venice/ui/helpers/ImportHelper.java @@ -77,6 +77,7 @@ public class ImportHelper SecurityInfo sinf = adm.getSecurityInfo(); Role default_role = sinf.getDefaultRole("Global.NewUser"); + HashMap community_cache = new HashMap(); ArrayList scroll = new ArrayList(); NodeList nl = root.getChildNodes(); for (int i=0; i element found"); vcard = new VCard(opts); + // Now process all the child nodes which may have multiple instances. + NodeList nl2 = n.getChildNodes(); + for (int j=0; j\n"); diff --git a/src/com/silverwrist/venice/util/XMLLoader.java b/src/com/silverwrist/venice/util/XMLLoader.java index 32175a1..92be19a 100644 --- a/src/com/silverwrist/venice/util/XMLLoader.java +++ b/src/com/silverwrist/venice/util/XMLLoader.java @@ -382,6 +382,22 @@ public class XMLLoader } // end configGetAttributeBoolean + public final boolean loadGetAttributeBoolean(Element elt, String attr_name, boolean default_val) + throws ValidationException + { + String tmp = elt.getAttribute(attr_name); + if (StringUtil.isStringEmpty(tmp)) + return default_val; + if (StringUtil.isBooleanTrue(tmp)) + return true; + if (StringUtil.isBooleanFalse(tmp)) + return false; + logger.error(attr_name + "= attribute in <" + elt.getTagName() + "/> element is not a valid boolean"); + throw new ValidationException(attr_name + "= attribute in <" + elt.getTagName() + + "/> element is not a valid boolean"); + + } // end loadGetAttributeBoolean + /*-------------------------------------------------------------------------------- * External static operations *--------------------------------------------------------------------------------