/* * 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 . * * 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 , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ package com.silverwrist.dynamo.db; import java.security.Principal; import java.security.acl.AclNotFoundException; import java.util.*; import com.silverwrist.dynamo.except.*; import com.silverwrist.dynamo.iface.*; abstract class GroupProxy implements DynamoGroup, DynamicWrapper { /*-------------------------------------------------------------------------------- * Attributes *-------------------------------------------------------------------------------- */ protected int m_gid; protected String m_groupname; /*-------------------------------------------------------------------------------- * Constructors *-------------------------------------------------------------------------------- */ protected GroupProxy(int gid) { m_gid = gid; m_groupname = null; } // end constructor protected GroupProxy(int gid, String groupname) { m_gid = gid; m_groupname = groupname; } // end constructor /*-------------------------------------------------------------------------------- * Abstract operations *-------------------------------------------------------------------------------- */ protected abstract DynamoGroup getRealGroup(); /*-------------------------------------------------------------------------------- * Implementations from interface Principal *-------------------------------------------------------------------------------- */ public boolean equals(Object another) { if (another==null) return false; if (another instanceof DynamoGroup) return (m_gid==((DynamoGroup)another).getGID()); return false; } // end equals public String toString() { if (m_groupname!=null) return "group " + m_groupname; return getRealGroup().toString(); } // end toString public int hashCode() { return m_gid; } // end hashCode public String getName() { if (m_groupname!=null) return m_groupname; return getRealGroup().getName(); } // end getName /*-------------------------------------------------------------------------------- * Implementations from interface Group *-------------------------------------------------------------------------------- */ public boolean addMember(Principal user) { return getRealGroup().addMember(user); } // end addMember public boolean removeMember(Principal user) { return getRealGroup().removeMember(user); } // end removeMember public boolean isMember(Principal member) { return getRealGroup().isMember(member); } // end isMember public Enumeration members() { return getRealGroup().members(); } // end members /*-------------------------------------------------------------------------------- * Implementations from interface ObjectProvider *-------------------------------------------------------------------------------- */ /** * Retrieves an object from this ObjectProvider. * * @param namespace The namespace to interpret the name relative to. * @param name The name of the object to be retrieved. * @return The object reference specified. */ public Object getObject(String namespace, String name) { return getRealGroup().getObject(namespace,name); } // end getObject /*-------------------------------------------------------------------------------- * Implementations from interface SecureObjectStore *-------------------------------------------------------------------------------- */ public Object setObject(DynamoUser caller, String namespace, String name, Object value) throws DatabaseException, DynamoSecurityException { return getRealGroup().setObject(caller,namespace,name,value); } // end setObject public Object removeObject(DynamoUser caller, String namespace, String name) throws DatabaseException, DynamoSecurityException { return getRealGroup().removeObject(caller,namespace,name); } // end removeObject public Collection getNamespaces() throws DatabaseException { return getRealGroup().getNamespaces(); } // end getNamespaces public Collection getNamesForNamespace(String namespace) throws DatabaseException { return getRealGroup().getNamesForNamespace(namespace); } // end getNamesForNamespace /*-------------------------------------------------------------------------------- * Implementations from interface DynamoGroup *-------------------------------------------------------------------------------- */ public int getGID() { return m_gid; } // end getGID public boolean addUID(DynamoUser caller, int uid) throws DatabaseException, DynamoSecurityException { return getRealGroup().addUID(caller,uid); } // end addUID public boolean removeUID(DynamoUser caller, int uid) throws DatabaseException, DynamoSecurityException { return getRealGroup().removeUID(caller,uid); } // end removeUID public boolean testUID(int uid) throws DatabaseException { return getRealGroup().testUID(uid); } // end testUID public int[] getUIDs() throws DatabaseException { return getRealGroup().getUIDs(); } // end getUIDs public boolean addMember(DynamoUser caller, Principal member) throws DatabaseException, DynamoSecurityException { return getRealGroup().addMember(caller,member); } // end addMember public boolean removeMember(DynamoUser caller, Principal member) throws DatabaseException, DynamoSecurityException { return getRealGroup().removeMember(caller,member); } // end removeMember public DynamoAcl getAcl() throws DatabaseException, AclNotFoundException { return getRealGroup().getAcl(); } // end getAcl public void setAcl(DynamoUser caller, DynamoAcl acl) throws DatabaseException, DynamoSecurityException { getRealGroup().setAcl(caller,acl); } // end setAcl public int getMemberCount() throws DatabaseException { return getRealGroup().getMemberCount(); } // end getMemberCount /*-------------------------------------------------------------------------------- * Implementations from interface DynamicWrapper *-------------------------------------------------------------------------------- */ public Object unwrap() { return getRealGroup(); } // end unwrap } // end class GroupProxy