added "Find Users," including back-end functionality and some bugfixes

This commit is contained in:
Eric J. Bowersox
2003-05-31 02:27:09 +00:00
parent 4f62066e6b
commit 3fa600206e
25 changed files with 1053 additions and 11 deletions

View File

@@ -75,6 +75,12 @@ public class StdObject
} // end if
public Object getProperty(ObjectProvider obj, String namespace, String name)
{
return PropertyUtils.getPropertyNoErr(obj,namespace,name);
} // end getProperty
public String renderObject(Object obj) throws IOException, RenderingException
{
BufferTextRenderControl bufctrl = new BufferTextRenderControl(m_control);

View File

@@ -0,0 +1,75 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (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.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice;
import java.util.*;
import org.apache.commons.lang.enum.*;
public final class UserSearchField extends Enum
{
/*--------------------------------------------------------------------------------
* The actual enumeration values
*--------------------------------------------------------------------------------
*/
public static final UserSearchField USERNAME = new UserSearchField("USERNAME");
public static final UserSearchField DESCRIPTION = new UserSearchField("DESCRIPTION");
public static final UserSearchField FIRSTNAME = new UserSearchField("FIRSTNAME");
public static final UserSearchField LASTNAME = new UserSearchField("LASTNAME");
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
private UserSearchField(String name)
{
super(name);
} // end constructor
/*--------------------------------------------------------------------------------
* Standard static method implementations
*--------------------------------------------------------------------------------
*/
public static UserSearchField getEnum(String name)
{
return (UserSearchField)getEnum(UserSearchField.class,name);
} // end getEnum
public static Map getEnumMap()
{
return getEnumMap(UserSearchField.class);
} // end getEnumMap
public static List getEnumList()
{
return getEnumList(UserSearchField.class);
} // end getEnumList
public static Iterator iterator()
{
return iterator(UserSearchField.class);
} // end iterator
} // end class UserSearchField

View File

@@ -0,0 +1,278 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (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.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.app;
import java.util.*;
import org.apache.log4j.Logger;
import org.w3c.dom.*;
import com.silverwrist.util.xml.*;
import com.silverwrist.dynamo.db.NamespaceCache;
import com.silverwrist.dynamo.db.UserManagement;
import com.silverwrist.dynamo.db.UserProxyManagement;
import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*;
import com.silverwrist.dynamo.security.SecurityReferenceMonitor;
import com.silverwrist.dynamo.util.*;
import com.silverwrist.venice.SearchMode;
import com.silverwrist.venice.UserSearchField;
import com.silverwrist.venice.VeniceNamespaces;
public class AdvancedUserManager implements NamedObject, ComponentInitialize, ComponentShutdown, AdvancedUserService
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Logger logger = Logger.getLogger(AdvancedUserManager.class);
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String m_name; // this object's name
private AdvancedUserOps m_ops; // database operations
private NamespaceCache m_ns_cache; // namespace cache object
private SecurityReferenceMonitor m_srm; // security reference monitor
private UserManagement m_users; // user management object
private UserProxyManagement m_proxy; // user proxy management object
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public AdvancedUserManager()
{ // do nothing
} // end constructor
/*--------------------------------------------------------------------------------
* Internal operations
*--------------------------------------------------------------------------------
*/
private final List translateUIDArray(int[] uids)
{
if ((uids==null) || (uids.length==0))
return Collections.EMPTY_LIST;
ArrayList rc = new ArrayList(uids.length);
for (int i=0; i<uids.length; i++)
rc.add(m_proxy.getUserProxy(uids[i]));
return Collections.unmodifiableList(rc);
} // end translateUIDArray
/*--------------------------------------------------------------------------------
* Implementations from interface NamedObject
*--------------------------------------------------------------------------------
*/
public String getName()
{
return m_name;
} // end getName
/*--------------------------------------------------------------------------------
* Implementations from interface ComponentInitialize
*--------------------------------------------------------------------------------
*/
/**
* Initialize the component.
*
* @param config_root Pointer to the section of the Dynamo XML configuration file that configures this
* particular component. This is to be considered "read-only" by the component.
* @param services An implementation of {@link com.silverwrist.dynamo.iface.ServiceProvider ServiceProvider}
* which provides initialization services to the component. This will include an implementation
* of {@link com.silverwrist.dynamo.iface.ObjectProvider ObjectProvider} which may be used to
* get information about other objects previously initialized by the application.
* @exception com.silverwrist.dynamo.except.ConfigException If an error is encountered in the component
* configuration.
*/
public void initialize(Element config_root, ServiceProvider services) throws ConfigException
{
logger.info("AdvancedUserManager initializing");
XMLLoader loader = XMLLoader.get();
String name_pool = null, name_nscache = null, name_srm = null, name_users = null;
try
{ // verify the right node name
loader.verifyNodeName(config_root,"object");
// get the object's name
m_name = loader.getAttribute(config_root,"name");
// get the name of the database pool and namespace cache
DOMElementHelper config_root_h = new DOMElementHelper(config_root);
Element foo = loader.getSubElement(config_root_h,"database");
name_pool = loader.getAttribute(foo,"connection");
name_nscache = loader.getAttribute(foo,"namespaces");
// get the name of the security reference monitor
foo = loader.getSubElement(config_root_h,"security");
name_srm = loader.getAttribute(foo,"object");
// get the name of the user manager
foo = loader.getSubElement(config_root_h,"user-manager");
name_users = loader.getAttribute(foo,"object");
} // end try
catch (XMLLoadException e)
{ // error loading XML config data
logger.fatal("XML loader exception in CommunityManager",e);
throw new ConfigException(e);
} // end catch
// Get the database connection pool.
DBConnectionPool pool = GetObjectUtils.getDatabaseConnection(services,name_pool);
// Get the database operations object.
m_ops = AdvancedUserOps.get(pool);
// Get the namespace cache.
m_ns_cache = (NamespaceCache)(GetObjectUtils.getDynamoComponent(services,NamespaceCache.class,name_nscache));
// Get the security reference monitor.
m_srm = (SecurityReferenceMonitor)(GetObjectUtils.getDynamoComponent(services,SecurityReferenceMonitor.class,
name_srm));
// Get the user management object.
m_users = (UserManagement)(GetObjectUtils.getDynamoComponent(services,UserManagement.class,name_users));
m_proxy = (UserProxyManagement)(GetObjectUtils.getDynamoComponent(services,UserProxyManagement.class,name_users));
} // end initialize
/*--------------------------------------------------------------------------------
* Implementations from interface ComponentShutdown
*--------------------------------------------------------------------------------
*/
public void shutdown()
{
m_proxy = null;
m_users = null;
m_srm = null;
m_ns_cache = null;
m_ops.dispose();
m_ops = null;
} // end shutdown
/*--------------------------------------------------------------------------------
* Implementations from interface UserManagement
*--------------------------------------------------------------------------------
*/
public DynamoUser getAnonymousUser() throws DatabaseException
{
return m_users.getAnonymousUser();
} // end getAnonymousUser
public DynamoUser getUser(int id) throws DatabaseException
{
return m_users.getUser(id);
} // end getUser
public DynamoUser getUser(String username) throws DatabaseException
{
return m_users.getUser(username);
} // end getUser
public DynamoUser createUser(String username, String email) throws DatabaseException
{
return m_users.createUser(username,email);
} // end createUser
public DynamoGroup getGroup(int id) throws DatabaseException
{
return m_users.getGroup(id);
} // end getGroup
public DynamoGroup getGroup(String groupname) throws DatabaseException
{
return m_users.getGroup(groupname);
} // end getGroup
public DynamoGroup createGroup(String groupname) throws DatabaseException
{
return m_users.createGroup(groupname);
} // end createGroup
public void loadUserDefaults(DynamoUser user, Collection namespaces) throws DatabaseException
{
m_users.loadUserDefaults(user,namespaces);
} // end loadUserDefaults
/*--------------------------------------------------------------------------------
* Implementations from interface AdvancedUserService
*--------------------------------------------------------------------------------
*/
public List searchForUsers(DynamoUser caller, UserSearchField field, SearchMode mode, String term,
int offset, int count) throws DatabaseException
{
int[] rc = null;
String prop = null;
if (UserSearchField.USERNAME.equals(field))
rc = m_ops.searchName(mode,term,offset,count);
else if (UserSearchField.DESCRIPTION.equals(field))
prop = "description";
else if (UserSearchField.FIRSTNAME.equals(field))
prop = "name.given";
else if (UserSearchField.LASTNAME.equals(field))
prop = "name.family";
else
throw new IllegalArgumentException("invalid search field (shouldn't happen)");
if ((rc==null) && (prop!=null))
rc = m_ops.searchProperty(m_ns_cache.namespaceNameToId(VeniceNamespaces.USER_PROFILE_NAMESPACE),prop,mode,
term,offset,count);
return translateUIDArray(rc);
} // end searchForUsers
public int getSearchUserCount(DynamoUser caller, UserSearchField field, SearchMode mode, String term)
throws DatabaseException
{
String prop = null;
if (UserSearchField.USERNAME.equals(field))
return m_ops.searchNameCount(mode,term);
else if (UserSearchField.DESCRIPTION.equals(field))
prop = "description";
else if (UserSearchField.FIRSTNAME.equals(field))
prop = "name.given";
else if (UserSearchField.LASTNAME.equals(field))
prop = "name.family";
else
throw new IllegalArgumentException("invalid search field (shouldn't happen)");
return m_ops.searchPropertyCount(m_ns_cache.namespaceNameToId(VeniceNamespaces.USER_PROFILE_NAMESPACE),
prop,mode,term);
} // end getSearchUserCount
} // end class AdvancedUserManager

View File

@@ -0,0 +1,64 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (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.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.app;
import com.silverwrist.dynamo.db.OpsBase;
import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*;
import com.silverwrist.venice.SearchMode;
abstract class AdvancedUserOps extends OpsBase
{
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
protected AdvancedUserOps(DBConnectionPool pool)
{
super(pool);
} // end constructor
/*--------------------------------------------------------------------------------
* Abstract operations
*--------------------------------------------------------------------------------
*/
abstract int[] searchProperty(int nsid, String name, SearchMode mode, String term, int offset, int count)
throws DatabaseException;
abstract int searchPropertyCount(int nsid, String name, SearchMode mode, String term) throws DatabaseException;
abstract int[] searchName(SearchMode mode, String term, int offset, int count) throws DatabaseException;
abstract int searchNameCount(SearchMode mode, String term) throws DatabaseException;
/*--------------------------------------------------------------------------------
* External static operations
*--------------------------------------------------------------------------------
*/
static AdvancedUserOps get(DBConnectionPool pool) throws ConfigException
{
return (AdvancedUserOps)get(pool,AdvancedUserOps.class.getClassLoader(),
AdvancedUserOps.class.getName() + "_","AdvancedUserOps");
} // end get
} // end class AdvancedUserOps

View File

@@ -0,0 +1,261 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (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.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.app;
import java.sql.*;
import java.util.*;
import com.silverwrist.util.*;
import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*;
import com.silverwrist.venice.SearchMode;
public class AdvancedUserOps_mysql extends AdvancedUserOps
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private DBUtilities m_utils;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public AdvancedUserOps_mysql(DBConnectionPool pool)
{
super(pool);
m_utils = (DBUtilities)(pool.queryService(DBUtilities.class));
} // end constructor
/*--------------------------------------------------------------------------------
* Internal operations
*--------------------------------------------------------------------------------
*/
private final String preparePropertySearchTerm(SearchMode mode, String term)
{
StringBuffer buf = new StringBuffer();
if (SearchMode.PREFIX.equals(mode))
buf.append("LIKE '!").append(m_utils.encodeStringWildcards(term)).append("%'");
else if (SearchMode.SUBSTRING.equals(mode))
buf.append("LIKE '!%").append(m_utils.encodeStringWildcards(term)).append("%'");
else if (SearchMode.REGEXP.equals(mode))
{ // for regular expressions, if we're matching the start of the string, we have to include the ! prefix
buf.append("REGEXP '");
if (term.startsWith("^"))
buf.append("^!").append(m_utils.encodeString(term.substring(1)));
else
buf.append(m_utils.encodeString(term));
buf.append('\'');
} // end else if
return buf.toString();
} // end preparePropertySearchTerm
/*--------------------------------------------------------------------------------
* Overrides from class OpsBase
*--------------------------------------------------------------------------------
*/
public void dispose()
{
m_utils = null;
super.dispose();
} // end dispose
/*--------------------------------------------------------------------------------
* Abstract implementations from class AdvancedUserOps
*--------------------------------------------------------------------------------
*/
int[] searchProperty(int nsid, String name, SearchMode mode, String term, int offset, int count)
throws DatabaseException
{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
{ // get a connection
conn = getConnection();
// prepare and execute a query (note that we assemble it in SQL form)
StringBuffer sql = new StringBuffer("SELECT u.uid FROM users u, userprop p WHERE u.uid = p.uid "
+ "AND u.is_anon = 0 AND p.nsid = ");
sql.append(nsid).append(" AND p.prop_name = '").append(m_utils.encodeString(name)).append("' AND p.prop_value ");
sql.append(preparePropertySearchTerm(mode,term));
sql.append(" ORDER BY u.name LIMIT ").append(offset).append(", ").append(count+1).append(';');
stmt = conn.createStatement();
rs = stmt.executeQuery(sql.toString());
// We *know* the maximum number of indexes that can be returned, so allocate a temporary array big
// enough to hold them all.
int[] tmp = new int[count+1];
int ct = 0;
while (rs.next())
tmp[ct++] = rs.getInt(1);
// Create the actual return array and fill it.
int[] rc = new int[ct];
System.arraycopy(tmp,0,rc,0,ct);
return rc;
} // end try
catch (SQLException e)
{ // translate to a general DatabaseException
throw generalException(e);
} // end catch
finally
{ // shut everything down
SQLUtils.shutdown(rs);
SQLUtils.shutdown(stmt);
SQLUtils.shutdown(conn);
} // end finally
} // end searchProperty
int searchPropertyCount(int nsid, String name, SearchMode mode, String term) throws DatabaseException
{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
{ // get a connection
conn = getConnection();
// prepare and execute a query (note that we assemble it in SQL form)
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM users u, userprop p WHERE u.uid = p.uid "
+ "AND u.is_anon = 0 AND p.nsid = ");
sql.append(nsid).append(" AND p.prop_name = '").append(m_utils.encodeString(name)).append("' AND p.prop_value ");
sql.append(preparePropertySearchTerm(mode,term));
sql.append(';');
stmt = conn.createStatement();
rs = stmt.executeQuery(sql.toString());
return SQLUtils.getReturnCountInt(rs,1);
} // end try
catch (SQLException e)
{ // translate to a general DatabaseException
throw generalException(e);
} // end catch
finally
{ // shut everything down
SQLUtils.shutdown(rs);
SQLUtils.shutdown(stmt);
SQLUtils.shutdown(conn);
} // end finally
} // end searchPropertyCount
int[] searchName(SearchMode mode, String term, int offset, int count) throws DatabaseException
{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
{ // get a connection
conn = getConnection();
// prepare and execute a query (note that we assemble it in SQL form)
StringBuffer sql = new StringBuffer("SELECT uid FROM users WHERE is_anon = 0 AND username ");
if (SearchMode.PREFIX.equals(mode))
sql.append("LIKE '").append(m_utils.encodeStringWildcards(term)).append("%'");
else if (SearchMode.SUBSTRING.equals(mode))
sql.append("LIKE '%").append(m_utils.encodeStringWildcards(term)).append("%'");
else if (SearchMode.REGEXP.equals(mode))
sql.append("REGEXP '").append(m_utils.encodeString(term)).append('\'');
sql.append(" ORDER BY username LIMIT ").append(offset).append(", ").append(count+1).append(';');
stmt = conn.createStatement();
rs = stmt.executeQuery(sql.toString());
// We *know* the maximum number of indexes that can be returned, so allocate a temporary array big
// enough to hold them all.
int[] tmp = new int[count+1];
int ct = 0;
while (rs.next())
tmp[ct++] = rs.getInt(1);
// Create the actual return array and fill it.
int[] rc = new int[ct];
System.arraycopy(tmp,0,rc,0,ct);
return rc;
} // end try
catch (SQLException e)
{ // translate to a general DatabaseException
throw generalException(e);
} // end catch
finally
{ // shut everything down
SQLUtils.shutdown(rs);
SQLUtils.shutdown(stmt);
SQLUtils.shutdown(conn);
} // end finally
} // end searchName
int searchNameCount(SearchMode mode, String term) throws DatabaseException
{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
{ // get a connection
conn = getConnection();
// prepare and execute a query (note that we assemble it in SQL form)
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM users WHERE is_anon = 0 AND username ");
if (SearchMode.PREFIX.equals(mode))
sql.append("LIKE '").append(m_utils.encodeStringWildcards(term)).append("%'");
else if (SearchMode.SUBSTRING.equals(mode))
sql.append("LIKE '%").append(m_utils.encodeStringWildcards(term)).append("%'");
else if (SearchMode.REGEXP.equals(mode))
sql.append("REGEXP '").append(m_utils.encodeString(term)).append('\'');
sql.append(';');
stmt = conn.createStatement();
rs = stmt.executeQuery(sql.toString());
return SQLUtils.getReturnCountInt(rs,1);
} // end try
catch (SQLException e)
{ // translate to a general DatabaseException
throw generalException(e);
} // end catch
finally
{ // shut everything down
SQLUtils.shutdown(rs);
SQLUtils.shutdown(stmt);
SQLUtils.shutdown(conn);
} // end finally
} // end searchNameCount
} // end class AdvancedUserOps_mysql

View File

@@ -0,0 +1,35 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (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.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.app;
import java.util.List;
import com.silverwrist.dynamo.db.UserManagement;
import com.silverwrist.dynamo.except.DatabaseException;
import com.silverwrist.dynamo.iface.DynamoUser;
import com.silverwrist.venice.SearchMode;
import com.silverwrist.venice.UserSearchField;
public interface AdvancedUserService extends UserManagement
{
public List searchForUsers(DynamoUser caller, UserSearchField field, SearchMode mode, String term,
int offset, int count) throws DatabaseException;
public int getSearchUserCount(DynamoUser caller, UserSearchField field, SearchMode mode, String term)
throws DatabaseException;
} // end interface AdvancedUserService

View File

@@ -60,7 +60,7 @@ public class CommunityManagerOps_mysql extends CommunityManagerOps
else if (SearchMode.SUBSTRING.equals(mode))
buf.append("LIKE '!%").append(m_utils.encodeStringWildcards(term)).append("%'");
else if (SearchMode.REGEXP.equals(mode))
{ // for regular expressions, if we're matching the start of the string, we have to inlcude the ! prefix
{ // for regular expressions, if we're matching the start of the string, we have to include the ! prefix
buf.append("REGEXP '");
if (term.startsWith("^"))
buf.append("^!").append(m_utils.encodeString(term.substring(1)));

View File

@@ -21,6 +21,8 @@ public interface MenuRenderObject
{
public int getItemCount();
public int getItemContainingLinkText(String text);
public void setVariable(String name, String value);
public void setSelectedIndex(int index);

View File

@@ -227,6 +227,12 @@ class InlineMenuRendering implements MenuRenderObject, SelfRenderable
} // end getItemCount
public int getItemContainingLinkText(String text)
{
return m_menudef.getItemContainingLinkText(text);
} // end getItemContainingLinkText
public void setVariable(String name, String value)
{
if (m_menudef.isVariable(name))

View File

@@ -222,6 +222,12 @@ class LeftMenuRendering implements MenuRenderObject, SelfRenderable
} // end getItemCount
public int getItemContainingLinkText(String text)
{
return m_menudef.getItemContainingLinkText(text);
} // end getItemContainingLinkText
public void setVariable(String name, String value)
{
if (m_menudef.isVariable(name))

View File

@@ -122,4 +122,18 @@ public class MenuDefinition
} // end getItem
public int getItemContainingLinkText(String text)
{
for (int i=0; i<m_items.size(); i++)
{ // simple linear search through menu items
MenuItemDefinition md = (MenuItemDefinition)(m_items.get(i));
if (md.getLink().indexOf(text)>=0)
return i;
} // end for
return -1;
} // end getItemContainingLinkText
} // end class MenuDefinition

View File

@@ -215,6 +215,12 @@ class StandardMenuRendering implements MenuRenderObject, SelfRenderable, FramedC
} // end getItemCount
public int getItemContainingLinkText(String text)
{
return m_menudef.getItemContainingLinkText(text);
} // end getItemContainingLinkText
public void setVariable(String name, String value)
{
if (m_menudef.isVariable(name))

View File

@@ -20,7 +20,9 @@ package com.silverwrist.venice.script;
import com.silverwrist.dynamo.Namespaces;
import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*;
import com.silverwrist.venice.app.AdvancedUserService;
import com.silverwrist.venice.community.CategoryService;
import com.silverwrist.venice.community.CommunityService;
import com.silverwrist.venice.iface.*;
public class LibraryVeniceCast
@@ -81,6 +83,12 @@ public class LibraryVeniceCast
} // end getGlobalPropertiesStore
public final AdvancedUserService queryAdvancedUserService(Object obj)
{
return (AdvancedUserService)query(obj,AdvancedUserService.class);
} // end queryUserManagement
public final ButtonProvider queryButtonProvider(Object obj)
{
return (ButtonProvider)query(obj,ButtonProvider.class);
@@ -93,6 +101,12 @@ public class LibraryVeniceCast
} // end queryCategoryService
public final CommunityService queryCommunityService(Object obj)
{
return (CommunityService)query(obj,CommunityService.class);
} // end queryCategoryService
public final ContentBlockProvider queryContentBlockProvider(Object obj)
{
return (ContentBlockProvider)query(obj,ContentBlockProvider.class);