added the first real front page sidebox, the community membership list
This commit is contained in:
@@ -1047,4 +1047,22 @@ class CommunityImpl implements VeniceCommunity
|
||||
|
||||
} // end join
|
||||
|
||||
public boolean isAdministrator(DynamoUser user)
|
||||
{
|
||||
try
|
||||
{ // must be either the host UID or a member of the admin group
|
||||
if (user.getUID()==m_host_uid)
|
||||
return true;
|
||||
return m_users.getGroup(m_host_gid).isMember(user);
|
||||
|
||||
} // end try
|
||||
catch (DatabaseException e)
|
||||
{ // gotta catch it, even if we can't do anything with it
|
||||
logger.warn("CommunityImpl.isAdministrator caught DatabaseException",e);
|
||||
return false;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end isAdministrator
|
||||
|
||||
} // end class CommunityImpl
|
||||
|
||||
@@ -603,6 +603,12 @@ abstract class CommunityProxy implements VeniceCommunity, DynamicWrapper
|
||||
|
||||
} // end join
|
||||
|
||||
public boolean isAdministrator(DynamoUser user)
|
||||
{
|
||||
return getRealCommunity().isAdministrator(user);
|
||||
|
||||
} // end isAdministrator
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface DynamicWrapper
|
||||
*--------------------------------------------------------------------------------
|
||||
|
||||
@@ -311,4 +311,6 @@ public interface VeniceCommunity extends NamedObject, SecureObjectStore
|
||||
|
||||
public boolean join(DynamoUser joiner) throws DatabaseException, DynamoSecurityException;
|
||||
|
||||
public boolean isAdministrator(DynamoUser user);
|
||||
|
||||
} // end interface VeniceCommunity
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* 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.sidebox;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.dynamo.Namespaces;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.security.SecurityReferenceMonitor;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.dynamo.velocity.VelocityParamSupplier;
|
||||
import com.silverwrist.dynamo.velocity.VelocityRenderable;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
import com.silverwrist.venice.community.CommunityService;
|
||||
import com.silverwrist.venice.except.*;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
import com.silverwrist.venice.session.SessionInfoParams;
|
||||
|
||||
class CommunityListSidebox implements SideboxFactory
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal class that implements the actual sidebox
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private class MyBox implements Sidebox, VelocityRenderable
|
||||
{
|
||||
/*====================================================================
|
||||
* Attributes
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
private HashMap m_params = new HashMap();
|
||||
private String m_title_keyname;
|
||||
|
||||
/*====================================================================
|
||||
* Constructor
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
MyBox(DynamoUser user, List communities, boolean can_create)
|
||||
{
|
||||
m_params.put("user",user);
|
||||
m_params.put("communities",communities);
|
||||
if (can_create)
|
||||
m_params.put("can_create",Boolean.TRUE);
|
||||
if (user.isAnonymous())
|
||||
m_title_keyname = "anon.title";
|
||||
else
|
||||
m_title_keyname = "normal.title";
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*====================================================================
|
||||
* Implementations from interface Sidebox
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
public String getSideboxTitle()
|
||||
{
|
||||
return m_props.getObject(VeniceNamespaces.CONTENT_LAF_NAMESPACE,m_title_keyname).toString();
|
||||
|
||||
} // end getSideboxTitle
|
||||
|
||||
/*====================================================================
|
||||
* Implementations from interface VelocityParamSupplier
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the value of a parameter set on the object.
|
||||
*
|
||||
* @param key The name of the parameter to look up.
|
||||
* @return The parameter's value, or <CODE>null</CODE> if the parameter was not set.
|
||||
*/
|
||||
public Object getParameter(String key)
|
||||
{
|
||||
return m_params.get(key);
|
||||
|
||||
} // end getParameter
|
||||
|
||||
/**
|
||||
* Returns a <CODE>java.util.Collection</CODE> of all parameter names currently defined on this object.
|
||||
*
|
||||
* @return A collection of all parameter names currently defined.
|
||||
*/
|
||||
public Collection getParameterNames()
|
||||
{
|
||||
return Collections.unmodifiableSet(m_params.keySet());
|
||||
|
||||
} // end getParameterNames
|
||||
|
||||
/*====================================================================
|
||||
* Implementations from interface VelocityRenderable
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the MIME type of the output to be rendered. Usually, this will be "text/html".
|
||||
*
|
||||
* @return The MIME type of the output.
|
||||
*/
|
||||
public String getMimeType()
|
||||
{
|
||||
return "text/html";
|
||||
|
||||
} // end getMimeType
|
||||
|
||||
/**
|
||||
* Returns the resource name of the Velocity template to be used in rendering this object. This pathname
|
||||
* is interpreted relative to the "resource root path" specified in the Velocity renderer's configuration.
|
||||
* The template engine loads it via the standard
|
||||
* {@link com.silverwrist.dynamo.iface.ResourceProvider ResourceProvider}, and then applies the parameters
|
||||
* contained in this object to it.
|
||||
*
|
||||
* @return The resource pathname of the Velocity template to use.
|
||||
*/
|
||||
public String getTemplateName()
|
||||
{
|
||||
return m_props.getObject(VeniceNamespaces.CONTENT_LAF_NAMESPACE,"velocity.template").toString();
|
||||
|
||||
} // end getTemplateName
|
||||
|
||||
} // end class MyBox
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private ObjectProvider m_props; // properties provider
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
CommunityListSidebox(ObjectProvider properties)
|
||||
{
|
||||
m_props = properties;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface SideboxFactory
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public Sidebox createSidebox(Request req) throws DynamoException
|
||||
{
|
||||
// Get the user associated with this request.
|
||||
SessionInfoProvider prov = (SessionInfoProvider)(req.queryService(SessionInfoProvider.class));
|
||||
SessionInfo session = prov.getSessionInfo();
|
||||
DynamoUser user = (DynamoUser)(session.getObject(SessionInfoParams.NAMESPACE,SessionInfoParams.ATTR_USER));
|
||||
|
||||
// Get the list of the user's communities.
|
||||
String tmp_name = m_props.getObject(VeniceNamespaces.SESSION_CONTROL_NAMESPACE,"community.provider").toString();
|
||||
ObjectProvider op = (ObjectProvider)(req.queryService(ObjectProvider.class));
|
||||
CommunityService commsvc = (CommunityService)(op.getObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,tmp_name));
|
||||
List communities = commsvc.getMemberCommunities(user,user);
|
||||
|
||||
// Determine whether the user can actually create a community.
|
||||
tmp_name = m_props.getObject(VeniceNamespaces.SESSION_CONTROL_NAMESPACE,"security.provider").toString();
|
||||
SecurityReferenceMonitor srm = (SecurityReferenceMonitor)(op.getObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,
|
||||
tmp_name));
|
||||
boolean can_create = false;
|
||||
if (user.equals(srm.getAdminUser()))
|
||||
can_create = true;
|
||||
else
|
||||
can_create = srm.getGlobalAcl().testPermission(user,VeniceNamespaces.COMMUNITY_PERMS_NAMESPACE,"create.new");
|
||||
|
||||
// We now have all the info we need to create the sidebox.
|
||||
return new MyBox(user,communities,can_create);
|
||||
|
||||
} // end createSidebox
|
||||
|
||||
} // end class CommunityListSidebox
|
||||
@@ -155,6 +155,7 @@ public class SideboxManager implements NamedObject, ComponentInitialize, Compone
|
||||
m_pk_to_fact = new ReferenceMap(ReferenceMap.HARD,ReferenceMap.SOFT);
|
||||
m_id_to_type = new ReferenceMap(ReferenceMap.HARD,ReferenceMap.SOFT);
|
||||
m_id_to_name = new ReferenceMap(ReferenceMap.HARD,ReferenceMap.SOFT);
|
||||
m_ns_to_tf.put(StandardSideboxes.NAMESPACE,new StandardSideboxes());
|
||||
m_ns_to_tf.put(TestSideboxes.NAMESPACE,new TestSideboxes());
|
||||
|
||||
} // end constructor
|
||||
|
||||
@@ -22,3 +22,5 @@ no.sbtype=Unable to find sidebox type factory for type namespace {0}, name {1}.
|
||||
sbox.not.in.list=The sidebox with ID #{0} does not exist in the current list.
|
||||
sbox.already.in.list=The sidebox with ID #{0} already exists in the current list.
|
||||
sbox.impermissible=The sidebox with ID #{0} is not permitted in the current list.
|
||||
std.badNamespace=The standard sidebox factory was called with an invalid type namespace "{0}."
|
||||
std.badName=The standard sidebox factory was called with an invalid type name "{0}."
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.sidebox;
|
||||
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.venice.except.*;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
|
||||
class StandardSideboxes implements SideboxTypeFactory
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static final String NAMESPACE = "http://www.silverwrist.com/NS/venice/2003/06/03/standard.sideboxes";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
StandardSideboxes()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface SideboxTypeFactory
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public SideboxFactory createFactory(String type_namespace, String type_name, String box_namespace, String box_name,
|
||||
ObjectProvider properties) throws DynamoException
|
||||
{
|
||||
if (!(NAMESPACE.equals(type_namespace)))
|
||||
{ // wrong sidebox type namespace!
|
||||
SideboxException ee = new SideboxException(StandardSideboxes.class,"SideboxMessages","std.badNamespace");
|
||||
ee.setParameter(0,type_namespace);
|
||||
throw ee;
|
||||
|
||||
} // end if
|
||||
|
||||
// Determine which kind of sidebox factory to create.
|
||||
if (type_name.equals("community.list"))
|
||||
return new CommunityListSidebox(properties);
|
||||
|
||||
// Cannot find sidebox factory for type: throw an exception.
|
||||
SideboxException e = new SideboxException(StandardSideboxes.class,"SideboxMessages","std.badName");
|
||||
e.setParameter(0,type_name);
|
||||
throw e;
|
||||
|
||||
} // end createFactory
|
||||
|
||||
} // end class StandardSideboxes
|
||||
Reference in New Issue
Block a user