263 lines
8.4 KiB
Java
263 lines
8.4 KiB
Java
/*
|
|
* 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.conf.impl;
|
|
|
|
import java.security.acl.AclNotFoundException;
|
|
import java.util.*;
|
|
import org.apache.commons.collections.*;
|
|
import com.silverwrist.dynamo.db.NamespaceCache;
|
|
import com.silverwrist.dynamo.db.UserManagement;
|
|
import com.silverwrist.dynamo.except.*;
|
|
import com.silverwrist.dynamo.iface.*;
|
|
import com.silverwrist.dynamo.security.SecurityReferenceMonitor;
|
|
import com.silverwrist.venice.iface.*;
|
|
import com.silverwrist.venice.conf.ConfNamespaces;
|
|
import com.silverwrist.venice.conf.iface.*;
|
|
import com.silverwrist.venice.conf.obj.*;
|
|
|
|
public class ConferenceManager implements ConferenceAccessObject
|
|
{
|
|
/*--------------------------------------------------------------------------------
|
|
* Attributes
|
|
*--------------------------------------------------------------------------------
|
|
*/
|
|
|
|
private DynamicImplConferenceAccess m_dobj;
|
|
private UseCount m_uc;
|
|
private ConferenceManagerOps m_ops;
|
|
private NamespaceCache m_nscache;
|
|
private SecurityReferenceMonitor m_srm;
|
|
private UserManagement m_users; // user management object
|
|
private ReferenceMap m_confs;
|
|
|
|
/*--------------------------------------------------------------------------------
|
|
* Constructor
|
|
*--------------------------------------------------------------------------------
|
|
*/
|
|
|
|
public ConferenceManager(UseCount uc, DBConnectionPool pool, NamespaceCache nscache, SecurityReferenceMonitor srm,
|
|
UserManagement users) throws ModuleException
|
|
{
|
|
try
|
|
{ // initialize everything
|
|
m_dobj = new DynamicImplConferenceAccess(this);
|
|
m_uc = uc;
|
|
uc.incrementUseCount();
|
|
m_ops = ConferenceManagerOps.get(pool);
|
|
|
|
} // end try
|
|
catch (ConfigException e)
|
|
{ // convert it to a ModuleException
|
|
uc.decrementUseCount();
|
|
throw new ModuleException(e);
|
|
|
|
} // end catch
|
|
|
|
m_nscache = nscache;
|
|
m_srm = srm;
|
|
m_users = users;
|
|
m_confs = new ReferenceMap(ReferenceMap.HARD,ReferenceMap.SOFT);
|
|
|
|
} // end constructor
|
|
|
|
/*--------------------------------------------------------------------------------
|
|
* Internal operations
|
|
*--------------------------------------------------------------------------------
|
|
*/
|
|
|
|
private final ConferenceImpl loadConference(Map params)
|
|
{
|
|
Integer key = (Integer)(params.get(ConferenceManagerOps.KEY_CONFID));
|
|
ConferenceImpl rc = (ConferenceImpl)(m_confs.get(key));
|
|
if (rc==null)
|
|
{ // create a new conference implementation object and save it
|
|
rc = new ConferenceImpl(m_ops.getConferenceOps(),m_nscache,m_srm,m_users,params);
|
|
m_confs.put(key,rc);
|
|
|
|
} // end if
|
|
|
|
return rc;
|
|
|
|
} // end loadConference
|
|
|
|
/*--------------------------------------------------------------------------------
|
|
* Implementations from interface DynamicObject
|
|
*--------------------------------------------------------------------------------
|
|
*/
|
|
|
|
public Object get(String property_name) throws DynamicObjectException
|
|
{
|
|
return m_dobj.get(property_name);
|
|
|
|
} // end get
|
|
|
|
public void set(String property_name, Object value) throws DynamicObjectException
|
|
{
|
|
m_dobj.set(property_name,value);
|
|
|
|
} // end set
|
|
|
|
public Object call(String method_name, Object[] parameters) throws DynamicObjectException
|
|
{
|
|
return m_dobj.call(method_name,parameters);
|
|
|
|
} // end call
|
|
|
|
public Object call(String method_name, List parameters) throws DynamicObjectException
|
|
{
|
|
return m_dobj.call(method_name,parameters);
|
|
|
|
} // end call
|
|
|
|
public DynamicClass getDClass()
|
|
{
|
|
return m_dobj.getDClass();
|
|
|
|
} // end getDClass
|
|
|
|
/*--------------------------------------------------------------------------------
|
|
* Implementations from interface ConferenceAccessObject
|
|
*--------------------------------------------------------------------------------
|
|
*/
|
|
|
|
public List getConferences(DynamoUser user, VeniceCommunity comm) throws DatabaseException
|
|
{
|
|
boolean show_hidden = false;
|
|
try
|
|
{ // do we want to show hidden conferences?
|
|
show_hidden = comm.getAcl().testPermission(user,ConfNamespaces.PERMISSIONS_NAMESPACE,"see.hidden");
|
|
|
|
} // end try
|
|
catch (AclNotFoundException e)
|
|
{ // convert the AclNotFoundException
|
|
DatabaseException de = new DatabaseException(ConferenceManager.class,"ConferenceMessages","no.community.acl",e);
|
|
de.setParameter(0,comm.getName());
|
|
throw de;
|
|
|
|
} // end catch
|
|
|
|
List in_list = m_ops.getConferences(comm.getCID());
|
|
if (in_list.isEmpty())
|
|
return Collections.EMPTY_LIST;
|
|
|
|
ArrayList rc = new ArrayList();
|
|
Iterator it = in_list.iterator();
|
|
while (it.hasNext())
|
|
{ // get each data element and convert it
|
|
Map d = (Map)(it.next());
|
|
if (show_hidden || !(((Boolean)(d.get(ConferenceManagerOps.KEY_HIDE))).booleanValue()))
|
|
{ // skip hidden conferences if we don't have the "show hidden" permission
|
|
ConferenceImpl conf = loadConference(d);
|
|
rc.add(new LinkedConferenceImpl(m_ops.getLinkedConferenceOps(),conf,comm,m_srm,d));
|
|
|
|
} // end if
|
|
|
|
} // end while
|
|
|
|
if (rc.isEmpty())
|
|
return Collections.EMPTY_LIST;
|
|
rc.trimToSize();
|
|
return Collections.unmodifiableList(rc);
|
|
|
|
} // end getConferences
|
|
|
|
public VeniceConference getConference(int confid) throws DatabaseException
|
|
{
|
|
Map d = m_ops.getConferenceData(confid);
|
|
if (d==null)
|
|
{ // throw the not-found exception
|
|
DatabaseException de = new DatabaseException(ConferenceManager.class,"ConferenceMessages","confid.notfound");
|
|
de.setParameter(0,String.valueOf(confid));
|
|
throw de;
|
|
|
|
} // end if
|
|
|
|
return loadConference(d);
|
|
|
|
} // end getConference
|
|
|
|
public VeniceConference getConference(String alias) throws DatabaseException
|
|
{
|
|
Map d = m_ops.getConferenceData(alias);
|
|
if (d==null)
|
|
{ // throw the not-found exception
|
|
DatabaseException de = new DatabaseException(ConferenceManager.class,"ConferenceMessages","confalias.notfound");
|
|
de.setParameter(0,alias);
|
|
throw de;
|
|
|
|
} // end if
|
|
|
|
return loadConference(d);
|
|
|
|
} // end getConference
|
|
|
|
public VeniceLinkedConference getLinkedConference(VeniceCommunity comm, int confid) throws DatabaseException
|
|
{
|
|
Map d = m_ops.getConferenceData(comm.getCID(),confid);
|
|
if (d==null)
|
|
{ // throw the not-found exception
|
|
DatabaseException de = new DatabaseException(ConferenceManager.class,"ConferenceMessages",
|
|
"confid.comm.notfound");
|
|
de.setParameter(0,String.valueOf(confid));
|
|
de.setParameter(1,comm.getName());
|
|
throw de;
|
|
|
|
} // end if
|
|
|
|
ConferenceImpl conf = loadConference(d);
|
|
return new LinkedConferenceImpl(m_ops.getLinkedConferenceOps(),conf,comm,m_srm,d);
|
|
|
|
} // end getLinkedConference
|
|
|
|
public VeniceLinkedConference getLinkedConference(VeniceCommunity comm, String alias) throws DatabaseException
|
|
{
|
|
Map d = m_ops.getConferenceData(comm.getCID(),alias);
|
|
if (d==null)
|
|
{ // throw the not-found exception
|
|
DatabaseException de = new DatabaseException(ConferenceManager.class,"ConferenceMessages",
|
|
"confalias.comm.notfound");
|
|
de.setParameter(0,alias);
|
|
de.setParameter(1,comm.getName());
|
|
throw de;
|
|
|
|
} // end if
|
|
|
|
ConferenceImpl conf = loadConference(d);
|
|
return new LinkedConferenceImpl(m_ops.getLinkedConferenceOps(),conf,comm,m_srm,d);
|
|
|
|
} // end getLinkedConference
|
|
|
|
/*--------------------------------------------------------------------------------
|
|
* External operations
|
|
*--------------------------------------------------------------------------------
|
|
*/
|
|
|
|
public void dispose()
|
|
{
|
|
m_nscache = null;
|
|
m_srm = null;
|
|
m_users = null;
|
|
m_ops.dispose();
|
|
m_ops = null;
|
|
m_uc.decrementUseCount();
|
|
m_uc = null;
|
|
|
|
} // end dispose
|
|
|
|
} // end class ConferenceManager
|