dao.ColMessageDaoDb.java Source code

Java tutorial

Introduction

Here is the source code for dao.ColMessageDaoDb.java

Source

/**
* Copyright (c) 2001-2012 "Redbasin Networks, INC," [http://redbasin.org]
*
* This file is part of Redbasin OpenDocShare community project.
*
* Redbasin OpenDocShare is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package dao;

import java.sql.Connection;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import javax.sql.DataSource;
import model.ColMessage;
import model.Hdlogin;
import model.Photo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
import util.DbConstants;
import util.RegexStrUtil;

/**
  * <B>ColMessageDaoDb</B>
  * <BR>
  * This object implements ColMessageDao interface.
  *
  * @author Smitha Gudur (smitha@redbasin.com)
  * @version $Revision: 1.1 $
  */
public class ColMessageDaoDb extends DirectoryAbstractDao implements ColMessageDao {

    protected final Log logger = LogFactory.getLog(getClass());

    private volatile ColMsgScreenQuery screenMessageQuery;
    private volatile ColMsgFreezeQuery freezeMessageQuery;

    private volatile ColMessageQuery listQuery;
    private volatile ColMessageAddQuery addQuery;
    private volatile ColMessageDeleteQuery deleteQuery;
    // private volatile CarryonByCategoryQuery pQuery;

    private volatile BasicQuery defaultPhotoQuery;

    // private volatile CollabrumAdminExistsQuery adminExistsQuery; 
    private volatile CollMemberExistsQuery memberExistsQuery;
    private volatile ColMsgAddAttributeQuery addAttrQuery;
    private volatile ColMsgOneQuery oneQuery;

    // private volatile DiaryAdmin diaryAdmin;

    // replyid is auto incremented in the database, this is not passed.
    // mid is the reply to the thread. so mid value is the rid of some entry to which it was replied to.
    //
    //   -------------------------
    //   tid    mid       rid
    //   -------------------------
    //   1      null       1     
    //   1       1         2     
    //   1       2         3     
    //   1       1         4     
    //   1       1         4     
    //  -------------------------
    //   2      null       5
    //   2       5         6
    //  -------------------------
    //   1       4         7
    //

    public void addColMessage(String tid, String mid, String message, String topic, String userId, String userLogin,
            String collabrumId, boolean personalBlog, String fontSize, String fontFace, String fontColor,
            String moodId, String bgColor) throws BaseDaoException {

        if (RegexStrUtil.isNull(tid) || RegexStrUtil.isNull(mid) || RegexStrUtil.isNull(userId)) {
            throw new BaseDaoException("params are null");
        }

        if (RegexStrUtil.isNull(message) && RegexStrUtil.isNull(topic)) {
            throw new BaseDaoException("message & topic are null");
        }

        /**
         *  check if this is personal blog. if not, check the permission - diaryAdmin or Organizer
         */
        if (!personalBlog) {
            if (!isOrganizer(collabrumId, userLogin, userId) && !isColMember(collabrumId, userId)) {
                throw new BaseDaoException("permission denied as this user is not a member of collabrum " + userId);
            }
        }

        /**
         *  Get scalability datasource for collmessages partitioned on tid
         */
        String sourceName = scalabilityManager.getWriteScalability(tid);
        ds = scalabilityManager.getSource(sourceName);
        if (ds == null) {
            throw new BaseDaoException("ds null, addColMessage() " + sourceName + " userId = " + userId);
        }
        Connection conn = null;
        try {
            conn = ds.getConnection();
            conn.setAutoCommit(false);
            addQuery.run(conn, tid, mid, message, topic, userId);
            addAttrQuery.run(conn, tid, "LAST_INSERT_ID()", fontSize, fontFace, fontColor, moodId, bgColor);
        } catch (Exception e) {
            try {
                conn.rollback();
            } catch (Exception e1) {
                try {
                    if (conn != null) {
                        conn.setAutoCommit(true);
                        conn.close();
                    }
                } catch (Exception e2) {
                    throw new BaseDaoException("connection close exception", e2);
                }
                throw new BaseDaoException("error occured while rollingback entries from ColmessageDaoDb", e1);
            }
        }
        try {
            conn.commit();
        } catch (Exception e3) {
            throw new BaseDaoException("commit exception", e3);
        }
        try {
            if (conn != null) {
                conn.setAutoCommit(true);
                conn.close();
            }
        } catch (Exception e4) {
            throw new BaseDaoException("connection close exception", e4);
        }

        /**
         *  delete collabrum messages
         */
        StringBuffer sb = new StringBuffer(collabrumId);
        sb.append("-");
        sb.append(tid);
        String key = sb.toString();
        Fqn fqn = cacheUtil.fqn(DbConstants.COLMSGS);
        if (treeCache.exists(fqn, key)) {
            treeCache.remove(fqn, key);
        }

        fqn = cacheUtil.fqn(DbConstants.COLTOPIC);
        if (treeCache.exists(fqn, key)) {
            treeCache.remove(fqn, key);
        }

        fqn = cacheUtil.fqn(DbConstants.COLTOPICS);
        if (treeCache.exists(fqn, collabrumId)) {
            treeCache.remove(fqn, collabrumId);
        }

        fqn = cacheUtil.fqn(DbConstants.COLLABRUM);
        if (treeCache.exists(fqn, collabrumId)) {
            treeCache.remove(fqn, collabrumId);
        }
    }

    public void deleteColMessage(String rid, String userId, String userLogin, String collabrumId, String tid)
            throws BaseDaoException {

        if (RegexStrUtil.isNull(rid) || RegexStrUtil.isNull(userId)) {
            throw new BaseDaoException("params are null");
        }

        /**
         *  check the permission - diaryAdmin or Organizer
         */
        boolean isAdmin = true;
        if (!isOrganizer(collabrumId, userLogin, userId)) {
            isAdmin = false;
        }

        /**
         *  Get scalability datasource for collmessages partitioned on tid
         */
        String sourceName = scalabilityManager.getWriteScalability(tid);
        ds = scalabilityManager.getSource(sourceName);
        if (ds == null) {
            throw new BaseDaoException("ds null, deleteColMessage() " + sourceName + " userId = " + userId);
        }

        Connection conn = null;
        try {
            conn = ds.getConnection();
            deleteQuery.run(conn, rid, userId, isAdmin);
        } catch (Exception e) {
            try {
                if (conn != null) {
                    conn.close();
                }
            } catch (Exception e2) {
                throw new BaseDaoException("connection close exception for collabrum " + " params (2) " + " rid = "
                        + rid + " userId = " + userId, e2);
            }
            throw new BaseDaoException("error occured while deleting collabrum message " + " params (2) "
                    + " rid = " + rid + " userId = " + userId, e);
        }
        try {
            if (conn != null) {
                conn.close();
            }
        } catch (Exception e2) {
            throw new BaseDaoException("connection close exception for deleteColMessage() ", e2);
        }

        /**
         *  delete collabrum messages
         */
        StringBuffer sb = new StringBuffer(collabrumId);
        sb.append("-");
        sb.append(tid);
        String key = sb.toString();
        Fqn fqn = cacheUtil.fqn(DbConstants.COLMSGS);
        if (treeCache.exists(fqn, key)) {
            treeCache.remove(fqn, key);
        }

        fqn = cacheUtil.fqn(DbConstants.COLTOPIC);
        if (treeCache.exists(fqn, key)) {
            treeCache.remove(fqn, key);
        }

        fqn = cacheUtil.fqn(DbConstants.COLLABRUM);
        if (treeCache.exists(fqn, collabrumId)) {
            treeCache.remove(fqn, collabrumId);
        }
        fqn = cacheUtil.fqn(DbConstants.COLTOPICS);
        if (treeCache.exists(fqn, collabrumId)) {
            treeCache.remove(fqn, collabrumId);
        }
    }

    /**
     *  This property is setby spring automatically at web.xml startup
     *  @param ds - this is JDBC datasource bean that is connection from the pool
     */
    public void setJdbcSource(DataSource ds) {
        this.ds = ds;
    }

    /**
     * This method returns a collabrum message. 
     * @param collabrumId - the collabrum Id
     * @param tid - the thread id based on which the messages are retrieved
     * @param rid - the reply id based on which the messages are retrieved
     * @return <code>ColMessage</code> bean
     * @throws BaseDaoException  - when error occurs
     */
    public ColMessage getOneColMessage(String collabrumId, String tid, String rid) throws BaseDaoException {

        if (RegexStrUtil.isNull(tid) || RegexStrUtil.isNull(collabrumId) || RegexStrUtil.isNull(rid)) {
            throw new BaseDaoException("params are null");
        }

        /**
         *  Get scalability datasource for collmessages, collmsgattr partitioned on tid
         */
        String sourceName = scalabilityManager.getReadScalability(tid);
        ds = scalabilityManager.getSource(sourceName);
        if (ds == null) {
            throw new BaseDaoException("ds null, getOneColMessage() " + sourceName + " tid = " + tid);
        }

        List result = null;
        try {
            Object[] params = { (Object) rid };
            result = oneQuery.execute(params);
        } catch (Exception e) {
            //throw new BaseDaoException("error occured while listing one collabrum message, " + oneQuery.getSql() + " params (1) rid = " + rid, e);
            throw new BaseDaoException("error occured while listing one collabrum message.");
        }
        if ((result != null) && (result.size() > 0)) {
            ColMessage colMsg = (ColMessage) result.get(0);
            setLoginAndPhoto(colMsg.getValue(DbConstants.OWNER_ID), colMsg, DbConstants.READ_FROM_SLAVE);
            return colMsg;
        }
        return null;
    }

    /**
     * This method returns collabrum messages. It reads the message from slave
     * @param tid - the thread id based on which the messages are retrieved
     *
     */
    public Vector getColMessages(String collabrumId, String tid) throws BaseDaoException {
        return getColMessages(collabrumId, tid, DbConstants.READ_FROM_SLAVE);
    }

    /**
     * This method returns collabrum messages.  
     * @param tid - the thread id based on which the messages are retrieved
     * @param accessFlag - it reads the message either from master(1) READ_FROM_MASTER or slave (0) READ_FROM_SLAVE
     *
     */
    public Vector getColMessages(String collabrumId, String tid, int accessFlag) throws BaseDaoException {

        if (RegexStrUtil.isNull(tid)) {
            throw new BaseDaoException("params are null");
        }

        StringBuffer sb = new StringBuffer(collabrumId);
        sb.append("-");
        sb.append(tid);
        String key = sb.toString();

        Fqn fqn = cacheUtil.fqn(DbConstants.COLMSGS);
        Object obj = treeCache.get(fqn, key);

        // set the photo and login if the user has deleted any photos
        if (obj != null) {
            Iterator iterator = ((Vector) obj).iterator();
            while (iterator.hasNext()) {
                ColMessage colMsg = (ColMessage) iterator.next();
                setLoginAndPhoto(colMsg.getValue(DbConstants.OWNER_ID), colMsg, accessFlag);
            }
            return (Vector) obj;
        }

        /**
         *  Get scalability datasource for collmessages, collmsgattr partitioned on tid
         */
        String sourceName = null;
        if (accessFlag == DbConstants.READ_FROM_MASTER) {
            sourceName = scalabilityManager.getWriteScalability(tid);
        } else {
            sourceName = scalabilityManager.getReadScalability(tid);
        }
        ds = scalabilityManager.getSource(sourceName);
        if (ds == null) {
            throw new BaseDaoException("ds null, getColMessages() " + sourceName + " tid = " + tid);
        }

        List result = null;
        try {
            Object[] params = { (Object) tid };
            result = listQuery.execute(params);
        } catch (Exception e) {
            throw new BaseDaoException("error occured while listing collabrum messages , " + listQuery.getSql()
                    + " params (1) tid = " + tid, e);
        }

        if ((result == null) || (result.size() <= 0)) {
            return null;
        }

        ColMessage colMsg = null;
        ColMessage root = new ColMessage();
        root.setValue(DbConstants.RID, "0");
        root.setValue(DbConstants.MID, "0");
        root.setValue(DbConstants.LEVEL, "0");
        root.setValue(DbConstants.TID, tid);
        root.setValue(DbConstants.NUM_POSTS, "1");

        //  get category information

        String rid, mid;
        rid = mid = null;

        if (result != null) {
            for (int i = 0; i < result.size(); i++) {
                colMsg = (ColMessage) result.get(i);
                //logger.info("Getting colMsg from result(" + i + ") = " + colMsg.toString());
                rid = colMsg.getValue(DbConstants.RID);
                mid = colMsg.getValue(DbConstants.MESSAGE_ID);
                colMsg.setValue(DbConstants.NUM_POSTS, "0");
                if (mid.equals("0")) {
                    setLoginAndPhoto(colMsg.getValue(DbConstants.OWNER_ID), colMsg, accessFlag);
                    colMsg.setValue(DbConstants.LEVEL, "1");
                    root.addReply(colMsg);
                    //logger.info("Adding child reply to root: mid = " + colMsg.getValue(DbConstants.MESSAGE_ID) + ", rid = " + colMsg.getValue(DbConstants.RID));
                } else {
                    ColMessage tempMsg = getNode(mid, root);
                    if (tempMsg != null) {
                        //logger.info("Finding node with mid = " + mid + ", node = " + tempMsg.toString());
                        String l1 = tempMsg.getValue(DbConstants.LEVEL);
                        //logger.info("l1 = " + l1);
                        int i1 = new Integer(l1).intValue() + 1;
                        //logger.info("i1 = " + i1);
                        String level = new Integer(i1).toString();
                        //logger.info("level = " + level);
                        //String level = new Integer(new Integer(tempMsg.getValue("level")).intValue() + 1).toString();
                        //logger.info("Setting level to node: level = " + level + ", mid = " + colMsg.getValue(DbConstants.MESSAGE_ID) + ", rid = " + colMsg.getValue(DbConstants.RID));
                        colMsg.setValue(DbConstants.LEVEL, level);
                        tempMsg.setValue(DbConstants.NUM_POSTS, "1");
                        setLoginAndPhoto(colMsg.getValue(DbConstants.OWNER_ID), colMsg, accessFlag);
                        tempMsg.addReply(colMsg);
                        //logger.info("Added child reply to node: parent mid = " + tempMsg.getValue(DbConstants.MESSAGE_ID) + ", parent rid = " + tempMsg.getValue(DbConstants.RID) + ", child mid = " + colMsg.getValue(DbConstants.MESSAGE_ID) + ", child rid = " + colMsg.getValue(DbConstants.RID));
                    }
                }
            }

        }

        //logger.info("root = " + root.toString());

        //return getList(root, new Vector());

        Vector msgs = getList(root, new Vector());
        if (msgs != null) {
            treeCache.put(fqn, key, msgs);
        }
        return msgs;
    }

    /**
     *  Sets the photo and login for each user
     */
    private void setLoginAndPhoto(String ownerId, ColMessage colMsg, int accessFlag) {

        if (RegexStrUtil.isNull(ownerId) || (colMsg == null)) {
            throw new BaseDaoException("params are null");
        }

        /**
         * get stream blob
         */
        boolean getPhotoFromDb = false;
        Fqn fqn = cacheUtil.fqn(DbConstants.DEFAULT_PHOTO);
        Object obj = treeCache.get(fqn, ownerId);
        if (obj != null) {
            colMsg.setPhoto((Photo) obj);
        } else {
            getPhotoFromDb = true;
        }

        /**
         *  Get the hdlogin information for each user
         */
        Hdlogin hdlogin = getLogin(ownerId);
        if (hdlogin != null) {
            colMsg.setValue(DbConstants.LOGIN, hdlogin.getValue(DbConstants.LOGIN));
            colMsg.setValue(DbConstants.OWNER_NAME, hdlogin.getValue(DbConstants.OWNER_NAME));
        }

        if (!getPhotoFromDb && (hdlogin != null)) {
            return;
        } else {
            /**
             *  Get scalability datasource for carryon partitioned on loginid
             */
            String queryName = null;
            if (accessFlag == DbConstants.READ_FROM_MASTER) {
                queryName = scalabilityManager.getWriteZeroScalability("userdefaultphotoQuery");
            } else {
                queryName = scalabilityManager.getReadZeroScalability("userdefaultphotoQuery");
            }
            defaultPhotoQuery = getQueryMapper().getQuery(queryName);

            /**
            *  get the photo query for each user, retrieves the entryid of Ist photo for each user
            */
            try {
                List uResult = null;
                Object[] params = { (Object) ownerId };
                uResult = defaultPhotoQuery.execute(params);
                if (uResult != null && uResult.size() > 0) {
                    colMsg.setPhoto((Photo) uResult.get(0));
                    treeCache.put(fqn, ownerId, (Photo) uResult.get(0));
                }
            } catch (Exception e) {
                throw new BaseDaoException("error executing Query " + defaultPhotoQuery.getSql(), e);
            }
        }
    }

    private int getNodeLevel(String rid, Vector msgs, ColMessage colMsg) {

        if (RegexStrUtil.isNull(rid) || (msgs == null) || (colMsg == null)) {
            throw new BaseDaoException("params are null");
        }

        //logger.info("msgs.size() = " + msgs.size());

        int j = 0;
        Iterator iterator = msgs.iterator();
        if (rid != null) {
            while (iterator.hasNext()) {
                Vector replies = (Vector) iterator.next();
                if (replies == null) {
                    //logger.info("replies is null ");
                    continue;
                }
                for (int i = 0; i < replies.size(); i++) {
                    if (rid.equalsIgnoreCase(((ColMessage) replies.elementAt(i)).getValue(DbConstants.RID))) {
                        String levelStr = ((ColMessage) replies.elementAt(i)).getValue(DbConstants.LEVEL);

                        //logger.info("level = " + levelStr + "msgs rid " + ((ColMessage)replies.elementAt(i)).getValue(DbConstants.MESSAGE_ID) );
                        if (levelStr != null) {
                            Integer level = new Integer(levelStr);
                            //logger.info("level Integer = " + level);
                            level++;
                            //logger.info("level Integer = " + level.toString() + " j = " + j);
                            colMsg.setValue("level", level.toString());
                        }
                        return (j + 1);
                    }
                }
                j++;
            }
        }
        return -1;
    }

    private ColMessage getNode(String mid, ColMessage root) {

        if (RegexStrUtil.isNull(mid) || (root == null)) {
            throw new BaseDaoException("params are null");
        }

        if (mid.equals(root.getValue(DbConstants.RID))) {
            return root;
        } else {
            List colMsgs = (List) root.getReplies();
            for (int i = 0; i < colMsgs.size(); i++) {
                ColMessage colMsg = getNode(mid, (ColMessage) colMsgs.get(i));
                if (colMsg != null) {
                    return colMsg;
                }
            }
        }

        return null;
    }

    private Vector getList(ColMessage root, Vector v) {

        if ((root == null) || (v == null)) {
            throw new BaseDaoException("params are null");
        }

        List children = (List) root.getReplies();
        for (int i = 0; i < children.size(); i++) {
            ColMessage colMsg = (ColMessage) children.get(i);
            v.add(children.get(i));
            v = getList((ColMessage) children.get(i), v);
        }
        return v;
    }

    /**
      *   Freezes messages, so no replies can be posted on this message. 
      *   In the personal blogging, the owner is entered as the administrator of the personal blog.
      *   so the owner is organizer of the personalblog and is allowed to screen/delete/freeze personal blog messages.
      *   In the personalblog, the owner can screen/delete/freeze other people's posting to the personalblog.
     */
    public void freezeMessage(String collabrumId, String rid, String userId, String userLogin, String freezeVal,
            String tid) throws BaseDaoException {

        if (RegexStrUtil.isNull(collabrumId) || RegexStrUtil.isNull(rid) || RegexStrUtil.isNull(userLogin)
                || RegexStrUtil.isNull(userId) || RegexStrUtil.isNull(tid)) {
            throw new BaseDaoException("params are null");
        }

        /**
         * Check for permissions in the collabrum, is this user organizer or the admin? 
         */
        boolean isAdmin = true;
        if (!isOrganizer(collabrumId, userLogin, userId)) {
            isAdmin = false;
        }

        /**
         *  Get scalability datasource for carryon partitioned on loginid
         */
        String sourceName = scalabilityManager.getWriteScalability(tid);
        ds = scalabilityManager.getSource(sourceName);
        if (ds == null) {
            throw new BaseDaoException("ds null, freezeMessage() " + sourceName + " userId = " + userId);
        }

        Connection conn = null;
        try {
            conn = ds.getConnection();
            freezeMessageQuery.run(conn, rid, userId, isAdmin, freezeVal);
        } catch (Exception e) {
            try {
                if (conn != null) {
                    conn.close();
                }
            } catch (Exception e2) {
                throw new BaseDaoException("connection close exception for freezeMessage() collabrumId = "
                        + collabrumId + " rid =" + rid + " userLogin=" + userLogin, e2);
            }
            throw new BaseDaoException("error occured while freezeMessage(), collabrumId =" + collabrumId + " rid="
                    + rid + " userLogin = " + userLogin, e);
        }

        try {
            if (conn != null) {
                conn.close();
            }
        } catch (Exception e2) {
            throw new BaseDaoException("connection close exception for freezeMessage() collabrumId = " + collabrumId
                    + " rid =" + rid + " userLogin=" + userLogin, e2);
        }

        StringBuffer sb = new StringBuffer(collabrumId);
        sb.append("-");
        sb.append(tid);
        String key = sb.toString();
        Fqn fqn = cacheUtil.fqn(DbConstants.COLMSGS);
        if (treeCache.exists(fqn, key)) {
            treeCache.remove(fqn, key);
        }
    }

    /**
      * screen Message - screens the Message from others 
      * screen message from collmessages that matches this reply id
      * @param collabrumId - the collabrum id
      * @param rid - reply id
      * @param userId - the user id
      * @param tid - thread id
      * @param userLogin - the user login
      * @param screenVal - the screen value (to display or not to display)
      * @throws BaseDaoException If we have a problem interpreting the data or the data is missing or incorrect
      * In the personal blogging, the owner is entered as the administrator of the personal blog
      * so the owner is organizer of the personalblog and is allowed to screen/delete/freeze personal blog messages
      * In the personalblog, the owner can screen/delete/freeze other people's posting to the personalblog
     */
    public void screenMessage(String collabrumId, String rid, String userId, String tid, String userLogin,
            String screenVal) throws BaseDaoException {

        if (RegexStrUtil.isNull(collabrumId) || RegexStrUtil.isNull(rid) || RegexStrUtil.isNull(userLogin)
                || RegexStrUtil.isNull(userId) || RegexStrUtil.isNull(tid)) {
            throw new BaseDaoException("params are null");
        }

        /**
         *    check for collabrum, is this user organizer or the admin?
         */
        boolean isAdmin = true;
        if (!isOrganizer(collabrumId, userLogin, userId)) {
            isAdmin = false;
        }

        /**
         *  Get scalability datasource for carryon partitioned on loginid
         */
        String sourceName = scalabilityManager.getWriteScalability(tid);
        ds = scalabilityManager.getSource(sourceName);
        if (ds == null) {
            throw new BaseDaoException("ds null, screenMessage() " + sourceName + " userId = " + userId);
        }

        /**
         *  Screen this message, update it in the DB 
         */
        Connection conn = null;
        try {
            conn = ds.getConnection();
            screenMessageQuery.run(conn, rid, userId, isAdmin, screenVal);
        } catch (Exception e) {
            try {
                if (conn != null) {
                    conn.close();
                }
            } catch (Exception e2) {
                throw new BaseDaoException("connection close exception for screenMessage() collabrumId = "
                        + collabrumId + " rid =" + rid + " userLogin=" + userLogin, e2);
            }
            throw new BaseDaoException("error occured while screenMessage, collabrumId =" + collabrumId + " rid="
                    + rid + " userLogin = " + userLogin, e);
        }
        try {
            if (conn != null) {
                conn.close();
            }
        } catch (Exception e2) {
            throw new BaseDaoException("connection close exception for screenTopic() collabrumId = " + collabrumId
                    + " rid =" + rid + " userLogin=" + userLogin, e2);
        }

        StringBuffer sb = new StringBuffer(collabrumId);
        sb.append("-");
        sb.append(tid);
        String key = sb.toString();
        Fqn fqn = cacheUtil.fqn(DbConstants.COLMSGS);
        if (treeCache.exists(fqn, key)) {
            treeCache.remove(fqn, key);
        }
    }

    /**
      * @param collabrumId the id of the collabrum
      * @param userId the userId who does the query to get the userIds, need to be organizer.
      * @return boolean
      * @throws BaseDaoException If we have a problem interpreting the data or the data is missing or incorrect
      */
    /*
       private boolean isOrganizer(String collabrumId, String userId) throws BaseDaoException {
        
       if (RegexStrUtil.isNull(collabrumId) || RegexStrUtil.isNull(userId)) {
          throw new BaseDaoException("params are null");
       }
        
    String sourceName = scalabilityManager.getReadZeroScalability();
    ds = scalabilityManager.getSource(sourceName);
    if (ds == null) {
        throw new BaseDaoException("ds null, isOrganizer() " + sourceName + " userId = " + userId);
    }
        
    List result = null;
    try {
       Object[] params = {(Object)collabrumId, (Object)userId};
       result = adminExistsQuery.execute(params);
    } catch (Exception e) {
       throw new BaseDaoException("exception error in adminExistsQuery , " + adminExistsQuery.getSql() + " collabrumId = " + collabrumId + " userId = " + userId, e);
    }
    if (result == null) {
       return false;
    }
    if (result.size() > 0) {
       return true;
    } else {
       return false;
    }
       }
        
    */

    private boolean isColMember(String collabrumId, String userId) {

        if (RegexStrUtil.isNull(collabrumId) || RegexStrUtil.isNull(userId)) {
            throw new BaseDaoException("params are null in isColMember");
        }

        /**
         *  Get scalability datasource for collmembers not partitioned
         */
        String sourceName = scalabilityManager.getReadZeroScalability();
        ds = scalabilityManager.getSource(sourceName);
        if (ds == null) {
            throw new BaseDaoException("ds null, isColMember() " + sourceName + " userId = " + userId);
        }

        List result = null;
        try {
            Object[] params = { (Object) userId, (Object) collabrumId };
            result = memberExistsQuery.execute(params);
        } catch (Exception e) {
            throw new BaseDaoException("exception error in isColMember , " + memberExistsQuery.getSql()
                    + " collabrumId = " + collabrumId + " userId = " + userId, e);
        }
        if (result == null) {
            return false;
        }
        if (result.size() > 0) {
            return true;
        } else {
            return false;
        }
    }

    public void setcolmsgscreenQuery(ColMsgScreenQuery daq) {
        this.screenMessageQuery = daq;
    }

    public void setcolmsgfreezeQuery(ColMsgFreezeQuery daq) {
        this.freezeMessageQuery = daq;
    }

    public void setcolmsgQuery(ColMessageQuery daq) {
        this.listQuery = daq;
    }

    public void setcolmsgaddQuery(ColMessageAddQuery daq) {
        this.addQuery = daq;
    }

    public void setcolmsgdeleteQuery(ColMessageDeleteQuery daq) {
        this.deleteQuery = daq;
    }

    /*
       public void setdiaryadmin(DiaryAdmin diaryAdmin ) {
    this.diaryAdmin = diaryAdmin;
       }
       public void setcollabrumadminexistsQuery(CollabrumAdminExistsQuery daq) {
          this.adminExistsQuery = daq;
       }
    */
    public void setismemberQuery(CollMemberExistsQuery daq) {
        this.memberExistsQuery = daq;
    }

    public void setaddattrQuery(ColMsgAddAttributeQuery daq) {
        this.addAttrQuery = daq;
    }

    public void setgetonecolmsgQuery(ColMsgOneQuery daq) {
        this.oneQuery = daq;
    }

    /*
       public void setcarryonbycategoryQuery(CarryonByCategoryQuery daq) {
    this.pQuery = daq;
       }
    */

}