Package org.jresearch.gossip.configuration

Examples of org.jresearch.gossip.configuration.Configurator


        HttpServletRequest request, HttpServletResponse response)
        throws SystemException {
        MessageResources messages = getResources(request);
        ForumDAO dao = ForumDAO.getInstance();
        UserDAO userdao = UserDAO.getInstance();
    Configurator config=Configurator.getInstance();
    ProcessModForm pmForm = (ProcessModForm) form;

        try {

            dao.dropMod(pmForm.getFid(),pmForm.getName());
View Full Code Here


                    /*
                     * MailMessage(String messagetext, String subject, String
                     * addrfrom, String namefrom, String addrto, String nameto)
                     */
                    MessageResources messages = getResources(request);
                    Configurator config = Configurator.getInstance();

                    /*
                     * {0} - login {1} - new password {2} - site url {3} - site
                     * name
                     */
                    StringBuffer siteUrl = new StringBuffer();
                    siteUrl.append(request.getServerName());
                    siteUrl.append(":");
                    siteUrl.append(request.getServerPort());
                    siteUrl.append(request.getContextPath());
                    siteUrl.append(config.get(IConst.CONFIG.MODULE_PREFIX));
                    siteUrl.append("/");

                    Object[] messArgs = new Object[] { newuser.getName(),
                            profile.getPassword(), siteUrl.toString(),
                            config.get(IConst.CONFIG.SITE_NAME) };

                    MailQueue queue = (MailQueue) session.getServletContext()
                            .getAttribute(IConst.CONTEXT.MAIL_QUEUE);
                    queue.push(new MailMessage(messages.getMessage(
                            "mails.NEW_ACCOUNT", messArgs), messages
                            .getMessage("mails.NEW_USER_SUBJ", config
                                    .get(IConst.CONFIG.SITE_NAME)), config
                            .get(IConst.CONFIG.ADMINMAIL), messages
                            .getMessage("mails.FORUM_ADMIN"), newuser.getInfo()
                            .getEmail(), newuser.getName()));
                }
            } else {
View Full Code Here

        User user = (User) session.getAttribute(IConst.SESSION.USER_KEY);
        ForumDAO dao = ForumDAO.getInstance();
        UserDAO userdao = UserDAO.getInstance();
        ActionErrors errors = new ActionErrors();
        StringBuffer forward = new StringBuffer();
        Configurator config = Configurator.getInstance();

        if ((user.getStatus() > 0)) {
            messageForm.setEmail(user.getInfo().getEmail());
            messageForm.setName(user.getName());
        } else { //validation if user is not registered yet

            if (messageForm.getName().trim().equals("")) {
                errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
                        "errors.ERR20"));
            }

            if (messageForm.getEmail().trim().equals("")) {
                errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
                        "errors.ERR19"));
            }
        }

        //    Report any errors we have discovered back to the original form
        if (!errors.isEmpty()) {
            saveErrors(request, errors);

            return (mapping.getInputForward());
        }

        try {

            boolean announce = false;
            boolean isUserMod = dao.checkMod(Integer.parseInt(messageForm
                    .getFid()), user);
            Forum currForum = dao.getForumInfo(Integer.parseInt(messageForm
                    .getFid()));

            //      check access rights if forum invisible
            if ((currForum.getLocked() == IConst.Forum.STATUS_INVISIBLE)
                    && (user.getStatus() < Integer.parseInt(Configurator
                            .getInstance().get(IConst.CONFIG.INVADER1)))) { return (mapping
                    .findForward(IConst.TOKEN.DENIED)); }

            //      check access rights if forum topics are locked
            if (((currForum.getLocked() == IConst.Forum.STATUS_TOPICS_LOCKED) && messageForm
                    .getTid().equals(""))
                    && (!isUserMod)) { return (mapping
                    .findForward(IConst.TOKEN.DENIED)); }

            // insert new thread if it is necessary
            if (messageForm.getTid().equals("")) {
                messageForm.setTid(dao.insertNewThread(messageForm.getFid()));

                announce = ((dao.isUserMod(user.getName()) || (user.getStatus() > 7)) && IConst.VALUES.TRUE
                        .equals(messageForm.getAnnounce()));
            }

            // check user access rights if current topic or completely forum is
            // locked
            if ((dao.getThreadInfo(Integer.parseInt(messageForm.getTid()))
                    .getLocked() == IConst.Topic.STATUS_LOCKED || currForum
                    .getLocked() == IConst.Forum.STATUS_COMPLETELY_LOCKED)
                    && (!isUserMod)) { return (mapping
                    .findForward(IConst.TOKEN.DENIED)); }

            // mark username for not registered users
            if (user.getStatus() == 0) {
                messageForm.setName("<" + messageForm.getName() + ">");
            }

            int mid = dao.addMessage(messageForm, request.getRemoteAddr(),
                    announce);
            //save attachment
            if (Configurator.getInstance().getBoolean(
                    IConst.CONFIG.ENABLE_FILE_UPLOAD)) {
                saveAttach(request, mid, ((FileUploadForm) messageForm)
                        .getFileData());
            }
            forward.append("/ShowMessage.do?fid=");
            forward.append(messageForm.getFid());
            forward.append("&tid=");
            forward.append(messageForm.getTid());
            forward.append("&mid=");
            forward.append(mid);

            log(request, "logs.LOG5", messageForm.getTid() + " fid="
                    + messageForm.getFid());

            //      e-mail all the subscribors of this thread...
            ArrayList subscrbe = dao.getSubscribersList(messageForm.getTid(),
                    messageForm.getName());

            if (subscrbe.size() > 0) {
                StringBuffer siteUrl = new StringBuffer();
                siteUrl.append(request.getServerName());
                siteUrl.append(":");
                siteUrl.append(request.getServerPort());
                siteUrl.append("/");
                siteUrl.append(request.getContextPath());
                siteUrl.append(config.get(IConst.CONFIG.MODULE_PREFIX));
                siteUrl.append("/");

                String tSubj = dao.getThreadSubject(messageForm.getTid());
                MessageProcessor mp = MessageProcessor.getInstance();
                String mess = mp.prepareMessage(HtmlCodec.encode(messageForm
                        .getText()), 0, messages);
                mess = mp.cleanup(mess);

                /*
                 * {0} - subsriber's login {1} - site url {2} - show message url
                 * {3} - topic title {4} - new message text {5} - new message
                 * sender {6} - site name
                 */
                Object[] messArgs = new Object[] { "", siteUrl.toString(),
                        forward.toString(), tSubj, mess,
                        HtmlCodec.encode(messageForm.getName()),
                        config.get(IConst.CONFIG.SITE_NAME) };
                MailQueue queue = (MailQueue) session.getServletContext()
                        .getAttribute(IConst.CONTEXT.MAIL_QUEUE);

                Iterator it = subscrbe.iterator();
                BanGuard guard = BanGuard.getInstance();
                while (it.hasNext()) {
                    Subscriber s = (Subscriber) it.next();
                    if (!guard.checkBan(s.getEmail(), BanType.EMAIL)) {
                        messArgs[0] = HtmlCodec.encode(s.getName());

                        queue.push(new MailMessage(messages.getMessage(
                                "mails.NEW_MESSAGE", messArgs), messages
                                .getMessage("mails.NEW_MESSAGE_SUBJ"), config
                                .get(IConst.CONFIG.ADMINMAIL), messages
                                .getMessage("mails.FORUM_ADMIN"), s.getEmail(),
                                s.getName()));
                    }
                }
View Full Code Here

    /**
     * 
     */
    public FileUploadForm() {
        Configurator config = Configurator.getInstance();
        try {
            this.maxFileCount = config
                    .getInt(IConst.CONFIG.MAX_ATTACHMENT_COUNT);
        } catch (ConfiguratorException e) {
            e.printStackTrace();
            maxFileCount = 1;
        }
View Full Code Here

    protected Session getMailSession() throws Exception {
        // Create mail session if it doesn't exist
        if (_mailSession == null) {
            _authenticator = new SmtpAuthenticator();

            Configurator config = Configurator.getInstance();
            Properties props = new Properties();
            props.put("mail.smtp.user", config.get(IConst.CONFIG.MAILUSER));
            props.put("mail.smtp.host", config.get(IConst.CONFIG.MAILHOST));
      props.put("mail.smtp.port", config.get(IConst.CONFIG.SMTP_SERVER_PORT));
      props.put("mail.mime.charset", config.get(IConst.CONFIG.CHARSET));
      String smtpUser=config.get(IConst.CONFIG.MAILUSER);
      if(!smtpUser.equals("anonymous"))
        props.put("mail.smtp.auth","true");
            _mailSession = Session.getInstance(props, _authenticator);
        }
View Full Code Here

                /*
                 * MailMessage(String messagetext, String subject, String
                 * addrfrom, String namefrom, String addrto, String nameto)
                 */
                MessageResources messages = getResources(request);
                Configurator config = Configurator.getInstance();

                /*
                 * {0} - login {1} - activation url {2} - site url {3} - site
                 * name {4} - remove url
                 */
                StringBuffer siteUrl = new StringBuffer();
                siteUrl.append(request.getServerName());
                siteUrl.append(":");
                siteUrl.append(request.getServerPort());
                siteUrl.append(request.getContextPath());
                siteUrl.append(config.get(IConst.CONFIG.MODULE_PREFIX));
                siteUrl.append("/");
                //parameters for Confirm/Delete actions
                StringBuffer params = new StringBuffer("?login=");
                params.append(prForm.getLogin());
                params.append("&email=");
                params.append(prForm.getEmail());
                params.append("&code=");
                params.append(confirmcode);
                //Confirm url
                StringBuffer actUrl = new StringBuffer();
                actUrl.append(siteUrl);
                actUrl.append("ConfirmRegistration.do");
                actUrl.append(params);
                //Delete url
                StringBuffer delUrl = new StringBuffer();
                delUrl.append(siteUrl);
                delUrl.append("DeleteRegistration.do");
                delUrl.append(params);
                Object[] messArgs = new Object[] { prForm.getLogin(),
                        actUrl.toString(), siteUrl.toString(),
                        config.get(IConst.CONFIG.SITE_NAME), delUrl.toString() };

                MailQueue queue = (MailQueue) session.getServletContext()
                        .getAttribute(IConst.CONTEXT.MAIL_QUEUE);
                queue.push(new MailMessage(messages.getMessage(
                        "mails.CONFIRM_ACCOUNT", messArgs), messages
                        .getMessage("mails.CONFIRM_ACCOUNT_SUBJ", config
                                .get(IConst.CONFIG.SITE_NAME)), config
                        .get(IConst.CONFIG.ADMINMAIL), messages
                        .getMessage("mails.FORUM_ADMIN"), prForm.getEmail(),
                        prForm.getLogin()));

            } else {
View Full Code Here

    }

    private PictureGenerator() throws SystemException {

        try {
            Configurator config = Configurator.getInstance();
            int newHeight = config
                    .getInt(IConst.MISC.REGISTRATION_PICTURE_HEIGHT);
            int newWidth = config
                    .getInt(IConst.MISC.REGISTRATION_PICTURE_WIDTH);
            int newGrid = config.getInt(IConst.MISC.REGISTRATION_PICTURE_GRID);

            int newMaxH = config.getInt(IConst.MISC.AVATAR_HEIGHT);
            int newMaxW = config.getInt(IConst.MISC.AVATAR_WIDTH);

            int newThunbH = config.getInt(IConst.MISC.THUMBNAIL_HEIGHT);
            int newThunbW = config.getInt(IConst.MISC.THUMBNAIL_WIDTH);

            maxH = newMaxH;
            maxW = newMaxW;

            thumbH = newThunbH;
View Full Code Here

                /*
                 * MailMessage(String messagetext, String subject, String
                 * addrfrom, String namefrom, String addrto, String nameto)
                 */
                MessageResources messages = getResources(request);
                Configurator config = Configurator.getInstance();

                /*
                 * {0} - login {1} - new password {2} - site url {3} - site name
                 */
                StringBuffer siteUrl = new StringBuffer();
                siteUrl.append(request.getServerName());
                siteUrl.append(":");
                siteUrl.append(request.getServerPort());
                siteUrl.append(request.getContextPath());
                siteUrl.append(config.get(IConst.CONFIG.MODULE_PREFIX));
                siteUrl.append("/");

                Object[] messArgs = new Object[] { newuser.getName(), tempPass,
                        siteUrl.toString(), config.get(IConst.CONFIG.SITE_NAME) };

                MailQueue queue = (MailQueue) session.getServletContext()
                        .getAttribute(IConst.CONTEXT.MAIL_QUEUE);
                queue.push(new MailMessage(messages.getMessage(
                        "mails.NEW_ACCOUNT", messArgs), messages.getMessage(
                        "mails.NEW_USER_SUBJ", config
                                .get(IConst.CONFIG.SITE_NAME)), config
                        .get(IConst.CONFIG.ADMINMAIL), messages
                        .getMessage("mails.FORUM_ADMIN"), newuser.getInfo()
                        .getEmail(), newuser.getName()));
            } else {
                ActionErrors errors = new ActionErrors();
View Full Code Here

    }

    private String process(String result, boolean skipSmiles)
        throws ConfiguratorException {
        MessageProcessor mp = MessageProcessor.getInstance();
        Configurator conf = Configurator.getInstance();
        result = mp.prepareMessage(result, this.cutToLength,
                (MessageResources) pageContext.getServletContext().getAttribute(Globals.MESSAGES_KEY +
                    conf.get(IConst.CONFIG.MODULE_PREFIX)));

        if ((cutToLength == 0) && !skipSmiles) {
            result = mp.processEmoticons(result,
                    (MessageResources) pageContext.getServletContext()
                                                  .getAttribute(Globals.MESSAGES_KEY +
                        conf.get(IConst.CONFIG.MODULE_PREFIX)));
        }else if(skipSmiles){
            result=mp.cleanup(result);
        }

        return result;
View Full Code Here

        }
        //Setting up MessageProcessor
        MessageProcessor.setEmoticonsMap(ResourceBundle
                .getBundle("org/jresearch/gossip/resources/emoticon"));
        //Load configuration parameters
        Configurator conf = Configurator.getInstance();
        conf.setDataSource(ds);
        try {
            conf.load(app);
        } catch (SQLException e) {
            if (log.isErrorEnabled()) {
                log.error("jGossip Configurator is not loaded");
            }
            throw new ServletException(e);
View Full Code Here

TOP

Related Classes of org.jresearch.gossip.configuration.Configurator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.