Package org.apache.roller.weblogger.pojos

Examples of org.apache.roller.weblogger.pojos.User


                UserEntry entry = (UserEntry)c.getEntries()[i];
                if (entry.getDateCreated() == null) {
                    // if no creation date supplied, add it
                    entry.setDateCreated(new Date());
                }
                User ud = toUserData(entry);
                mgr.addUser(ud);
                getRoller().flush();
                CacheManager.invalidate(ud);
                userDatas.add(ud);
            }
View Full Code Here


       
    private UserEntrySet updateUsers(UserEntrySet c) throws HandlerException {
        List userDatas = new ArrayList();
        for (int i = 0; i < c.getEntries().length; i++) {
            UserEntry entry = (UserEntry)c.getEntries()[i];
            User ud = getUserData(entry.getName());
            updateUserData(ud, entry);
            userDatas.add(ud);
        }
        return toUserEntrySet((User[])userDatas.toArray(new User[0]));
    }
View Full Code Here

            throw new InternalException("ERROR: could not update user data", re);
        }
    }
   
    private EntrySet deleteEntry() throws HandlerException {
        User ud = getUserData(getUri().getEntryId());
       
        // don't allow deletion of the currently authenticated user
        if (ud.getUserName().equals(getUserName())) {
            throw new NotAllowedException("ERROR: Can't delete authenticated user: " + getUserName());
       
       
        try {
            CacheManager.invalidate(ud);
View Full Code Here

        }
        UserEntrySet ues = new UserEntrySet(getUrlPrefix());
       
        List entries = new ArrayList();
        for (int i = 0; i < uds.length; i++) {
            User ud = uds[i];
            Entry entry = toUserEntry(ud);
            entries.add(entry);
        }
        ues.setEntries((Entry[])entries.toArray(new Entry[0]));
       
View Full Code Here

       
        //
        // if any of the entry fields are null, the set below amounts
        // to a no-op.
        //
        User ud = new User();
        ud.setUserName(ue.getName());

        if (ue.getScreenName() != null) {
            ud.setScreenName(ue.getScreenName());
        }
        if (ue.getFullName() != null) {
            ud.setFullName(ue.getFullName());
        }
        if (ue.getPassword() != null) {
            ud.setPassword(ue.getPassword());
        }
        if (ue.getEmailAddress() != null) {
            ud.setEmailAddress(ue.getEmailAddress());
        }
        if (ue.getLocale() != null) {
            ud.setLocale(ue.getLocale().toString());
        }
        if (ue.getTimezone() != null) {
            ud.setTimeZone(ue.getTimezone().getID());
        }
        if (ue.getDateCreated() != null) {
            ud.setDateCreated(ue.getDateCreated());
        }
        if (ue.getEnabled() != null) {
            ud.setEnabled(ue.getEnabled());
        }
        return ud;
    }
View Full Code Here

        log.debug("Attempting to process weblog invitation");
       
        UserManager umgr = WebloggerFactory.getWeblogger().getUserManager();
       
        // user being invited
        User user = null;
        try {
            user = umgr.getUserByUserName(getUserName());
            if (user == null) {
                addError("inviteMember.error.userNotFound");
            }
View Full Code Here

            List websiteUsers = wmgr.getWeblogUsers(entry.getWebsite(), true);
           
            // build list of reviewers (website users with author permission)
            Iterator websiteUserIter = websiteUsers.iterator();
            while (websiteUserIter.hasNext()) {
                User websiteUser = (User)websiteUserIter.next();
                if (entry.getWebsite().hasUserPermission(                       
                        websiteUser, WeblogPermission.POST)
                        && websiteUser.getEmailAddress() != null) {
                    reviewers.add(websiteUser.getEmailAddress());
                }
            }
            to = (String[])reviewers.toArray(new String[reviewers.size()]);
           
            // Figure URL to entry edit page
View Full Code Here

                                             boolean notifySubscribers)
            throws MailingException {
       
        WeblogEntry entry = commentObject.getWeblogEntry();
        Weblog weblog = entry.getWebsite();
        User user = entry.getCreator();
       
        // Only send email if email notificaiton is enabled
        boolean notify = WebloggerRuntimeConfig.getBooleanProperty("users.comments.emailnotify");
        if (!notify || !weblog.getEmailComments().booleanValue()) {
            // notifications disabled, just bail
            return;
        }
       
        log.debug("Comment notification enabled ... preparing email");
       
        // Determine message and addressing options from init parameters
        boolean hideCommenterAddrs = WebloggerConfig.getBooleanProperty(
                "comment.notification.hideCommenterAddresses");
       
        // use either the weblog configured from address or the site configured from address
        String from = weblog.getEmailFromAddress();
        if(StringUtils.isEmpty(from)) {
            // TODO: this should not be the users email address
            from = user.getEmailAddress();
        }
       
        // build list of email addresses to send notification to
        Set subscribers = new TreeSet();
       
    // If we are to notify subscribers, then...
    if (notifySubscribers) {
      log.debug("Sending notification email to all subscribers");

      // Get all the subscribers to this comment thread
      List comments = entry.getComments(true, true);
      for (Iterator it = comments.iterator(); it.hasNext();) {
        WeblogEntryComment comment = (WeblogEntryComment) it.next();
        if (!StringUtils.isEmpty(comment.getEmail())) {
          // If user has commented twice,
          // count the most recent notify setting
          if (commentObject.getApproved()) {
            if (comment.getNotify().booleanValue()) {
              // only add those with valid email
              if (comment.getEmail().matches(EMAIL_ADDR_REGEXP)) {
                log.info("Add to subscribers list : " + comment.getEmail());
                subscribers.add(comment.getEmail());
              }
            } else {
              // remove user who doesn't want to be notified
              log.info("Remove from subscribers list : " + comment.getEmail());
              subscribers.remove(comment.getEmail());
            }
          }
        }
      }
    } else {
      log.debug("Sending notification email only to weblog owner");
    }
       
        // Form array of commenter addrs
        String[] commenterAddrs = (String[])subscribers.toArray(new String[0]);
       
        //------------------------------------------
        // --- Form the messages to be sent -
        // Build separate owner and commenter (aka subscriber) messages
       
        // Determine with mime type to use for e-mail
        StringBuffer msg = new StringBuffer();
        StringBuffer ownermsg = new StringBuffer();
        boolean escapeHtml = !WebloggerRuntimeConfig.getBooleanProperty("users.comments.htmlenabled");
       
        // first the commenter message       
        if (!escapeHtml) {
            msg.append("<html><body style=\"background: white; ");
            msg.append(" color: black; font-size: 12px\">");
        }
       
        if (!StringUtils.isEmpty(commentObject.getName())) {
            String emailAddress = StringUtils.isBlank(commentObject.getEmail()) ? " " :
                    " (" + commentObject.getEmail() + ") ";
            msg.append(commentObject.getName() + emailAddress
                    + resources.getString("email.comment.wrote")+": ");
        } else {
            msg.append(resources.getString("email.comment.anonymous")+": ");
        }
       
        msg.append((escapeHtml) ? "\n\n" : "<br /><br />");
       
        msg.append((escapeHtml) ? Utilities.escapeHTML(commentObject.getContent())
        : Utilities.transformToHTMLSubset(Utilities.escapeHTML(commentObject.getContent())));
       
        msg.append((escapeHtml) ? "\n\n----\n"
                : "<br /><br /><hr /><span style=\"font-size: 11px\">");
        msg.append(resources.getString("email.comment.respond") + ": ");
        msg.append((escapeHtml) ? "\n" : "<br />");
       
        // Build link back to comment
        String commentURL = WebloggerFactory.getWeblogger().getUrlStrategy().getWeblogCommentsURL(weblog, null, entry.getAnchor(), true);
       
        if (escapeHtml) {
            msg.append(commentURL);
        } else {
            msg.append("<a href=\""+commentURL+"\">"+commentURL+"</a></span>");
        }
       
        // next the owner message
       
        // First, list any messages from the system that were passed in:
        if (messages.getMessageCount() > 0) {
            ownermsg.append((escapeHtml) ? "" : "<p>");
            ownermsg.append(resources.getString("commentServlet.email.thereAreSystemMessages"));
            ownermsg.append((escapeHtml) ? "\n\n" : "</p>");
            ownermsg.append((escapeHtml) ? "" : "<ul>");
        }
        for (Iterator it = messages.getMessages(); it.hasNext();) {
            RollerMessage rollerMessage = (RollerMessage)it.next();
            ownermsg.append((escapeHtml) ? "" : "<li>");
            ownermsg.append(MessageFormat.format(resources.getString(rollerMessage.getKey()), (Object[])rollerMessage.getArgs()) );
            ownermsg.append((escapeHtml) ? "\n\n" : "</li>");
        }
        if (messages.getMessageCount() > 0) {
            ownermsg.append((escapeHtml) ? "\n\n" : "</ul>");
        }
       
        // Next, list any validation error messages that were passed in:
        if (messages.getErrorCount() > 0) {
            ownermsg.append((escapeHtml) ? "" : "<p>");
            ownermsg.append(resources.getString("commentServlet.email.thereAreErrorMessages"));
            ownermsg.append((escapeHtml) ? "\n\n" : "</p>");
            ownermsg.append((escapeHtml) ? "" : "<ul>");
        }
        for (Iterator it = messages.getErrors(); it.hasNext();) {
            RollerMessage rollerMessage = (RollerMessage)it.next();
            ownermsg.append((escapeHtml) ? "" : "<li>");
            ownermsg.append(MessageFormat.format(resources.getString(rollerMessage.getKey()), (Object[])rollerMessage.getArgs()) );
            ownermsg.append((escapeHtml) ? "\n\n" : "</li>");
        }
        if (messages.getErrorCount() > 0) {
            ownermsg.append((escapeHtml) ? "\n\n" : "</ul>");
        }
       
        ownermsg.append(msg);
       
        // add link to weblog edit page so user can login to manage comments
        ownermsg.append((escapeHtml) ? "\n\n----\n" :
            "<br /><br /><hr /><span style=\"font-size: 11px\">");
        ownermsg.append("Link to comment management page:");
        ownermsg.append((escapeHtml) ? "\n" : "<br />");
       
        Map<String, String> parameters = new HashMap();
        parameters.put("bean.entryId", entry.getId());
        String deleteURL = WebloggerFactory.getWeblogger().getUrlStrategy().getActionURL(
                "comments", "/roller-ui/authoring", weblog.getHandle(), parameters, true);
       
        if (escapeHtml) {
            ownermsg.append(deleteURL);
        } else {
            ownermsg.append(
                    "<a href=\"" + deleteURL + "\">" + deleteURL + "</a></span>");
            msg.append("</Body></html>");
            ownermsg.append("</Body></html>");
        }
       
        String subject = null;
        if ((subscribers.size() > 1) ||
                (StringUtils.equals(commentObject.getEmail(), user.getEmailAddress()))) {
            subject= "RE: "+resources.getString("email.comment.title")+": ";
        } else {
            subject = resources.getString("email.comment.title") + ": ";
        }
        subject += entry.getTitle();
       
        // send message to email recipients
        try {
            boolean isHtml = !escapeHtml;
           
            // Send separate messages to owner and commenters
            if(isHtml) {
                sendHTMLMessage(
                        from,
                        new String[]{user.getEmailAddress()},
                        null,
                        null,
                        subject,
                        ownermsg.toString());
            } else {
                sendTextMessage(
                        from,
                        new String[]{user.getEmailAddress()},
                        null,
                        null,
                        subject,
                        ownermsg.toString());
            }
View Full Code Here

                                                     I18nMessages resources)
            throws MailingException {
       
        WeblogEntry entry = cd.getWeblogEntry();
        Weblog weblog = entry.getWebsite();
        User user = entry.getCreator();
       
        // Only send email if email notificaiton is enabled
        boolean notify = WebloggerRuntimeConfig.getBooleanProperty("users.comments.emailnotify");
        if (!notify || !weblog.getEmailComments().booleanValue()) {
            // notifications disabled, just bail
            return;
        }
       
        log.debug("Comment notification enabled ... preparing email");
       
        // use either the weblog configured from address or the site configured from address
        String from = weblog.getEmailFromAddress();
        if(StringUtils.isEmpty(from)) {
            // TODO: this should not be the users email address
            from = user.getEmailAddress();
        }
       
        // form the message to be sent
        String subject = resources.getString("email.comment.commentApproved");
       
View Full Code Here

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {

    try {
      HttpServletRequest httpReq = (HttpServletRequest) request;
      final User authenticUser;
      UserManager umgr = WebloggerFactory.getWeblogger().getUserManager();
      if (httpReq.getUserPrincipal() != null) {
        try {
          authenticUser = umgr.getUserByUserName(httpReq.getUserPrincipal().getName(), Boolean.TRUE);
        } catch (WebloggerException ex) {
          log.error("ERROR checking user role", ex);
          throw new ServletException("Security Violation");
        }
      } else {
        authenticUser = null;
      }

      if (httpReq.getMethod().equals("POST") && authenticUser != null) {
        String salt = (String) httpReq.getParameter("salt");
        SaltCache saltCache = SaltCache.getInstance();
        if (salt == null || saltCache.get(salt) == null || !saltCache.get(salt).equals(authenticUser.getId())) {
          throw new ServletException("Security Violation");
        }
      }
   
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.apache.roller.weblogger.pojos.User

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.