Package org.apache.roller.weblogger

Examples of org.apache.roller.weblogger.WebloggerException


    }
   
    public void addUser(User newUser) throws WebloggerException {
       
        if(newUser == null)
            throw new WebloggerException("cannot add null user");
       
        // TODO BACKEND: we must do this in a better fashion, like getUserCnt()?
        boolean adminUser = false;
        List existingUsers = this.getUsers(null, Boolean.TRUE, null, null, 0, 1);
        if(existingUsers.size() == 0) {
            // Make first user an admin
            adminUser = true;
           
            //if user was disabled (because of activation user
            // account with e-mail property), enable it for admin user
            newUser.setEnabled(Boolean.TRUE);
            newUser.setActivationCode(null);
        }
       
        if(getUserByUserName(newUser.getUserName()) != null ||
                getUserByUserName(newUser.getUserName().toLowerCase()) != null) {
            throw new WebloggerException("error.add.user.userNameInUse");
        }
       
        newUser.grantRole("editor");
        if(adminUser) {
            newUser.grantRole("admin");
View Full Code Here


     * TODO BACKEND: do we really need this?  can't we just use storePermissions()?
     */
    public WeblogPermission inviteUser(Weblog website,
            User user, short mask) throws WebloggerException {
       
        if (website == null) throw new WebloggerException("Website cannot be null");
        if (user == null) throw new WebloggerException("User cannot be null");
       
        WeblogPermission perms = new WeblogPermission();
        perms.setWebsite(website);
        perms.setUser(user);
        perms.setPermissionMask(mask);
View Full Code Here

     *
     * TODO: replace this with a domain model method like weblog.retireUser(user)
     */
    public void retireUser(Weblog website, User user) throws WebloggerException {
       
        if (website == null) throw new WebloggerException("Website cannot be null");
        if (user == null) throw new WebloggerException("User cannot be null");
       
        Iterator perms = website.getPermissions().iterator();
        WeblogPermission target = null;
        while (perms.hasNext()) {
            WeblogPermission pd = (WeblogPermission)perms.next();
            if (pd.getUser().getId().equals(user.getId())) {
                target = pd;
                break;
            }
        }
        if (target == null) throw new WebloggerException("User not member of website");
       
        website.removePermission(target);
        this.strategy.remove(target);
    }
View Full Code Here

     */
    public Weblog getWebsiteByHandle(String handle, Boolean enabled)
    throws WebloggerException {
       
        if (handle==null )
            throw new WebloggerException("Handle cannot be null");
       
        // check cache first
        // NOTE: if we ever allow changing handles then this needs updating
        if(this.weblogHandleToIdMap.containsKey(handle)) {
           
View Full Code Here

   
    public User getUserByUserName(String userName, Boolean enabled)
    throws WebloggerException {
       
        if (userName==null )
            throw new WebloggerException("userName cannot be null");
       
        // check cache first
        // NOTE: if we ever allow changing usernames then this needs updating
        if(this.userNameToIdMap.containsKey(userName)) {
           
View Full Code Here

     */
    public WeblogTemplate getPageByLink(Weblog website, String pagelink)
    throws WebloggerException {
       
        if (website == null)
            throw new WebloggerException("userName is null");
       
        if (pagelink == null)
            throw new WebloggerException("Pagelink is null");
       
        Query query = strategy.getNamedQuery("WeblogTemplate.getByWebsite&Link");
        query.setParameter(1, website);
        query.setParameter(2, pagelink);
        try {
View Full Code Here

     */
    public WeblogTemplate getPageByAction(Weblog website, String action)
            throws WebloggerException {
       
        if (website == null)
            throw new WebloggerException("website is null");
       
        if (action == null)
            throw new WebloggerException("Action name is null");
       
       
        Query query = strategy.getNamedQuery("WeblogTemplate.getByAction");
        query.setParameter(1, website);
        query.setParameter(2, action);
View Full Code Here

     */
    public WeblogTemplate getPageByName(Weblog website, String pagename)
    throws WebloggerException {
       
        if (website == null)
            throw new WebloggerException("website is null");
       
        if (pagename == null)
            throw new WebloggerException("Page name is null");
       
        Query query = strategy.getNamedQuery("WeblogTemplate.getByWebsite&Name");
        query.setParameter(1, website);
        query.setParameter(2, pagename);
        try {
View Full Code Here

    /**
     * @see org.apache.roller.weblogger.model.UserManager#getPages(Weblog)
     */
    public List getPages(Weblog website) throws WebloggerException {
        if (website == null)
            throw new WebloggerException("website is null");
        Query q = strategy.getNamedQuery(
                "WeblogTemplate.getByWebsiteOrderByName");
        q.setParameter(1, website);
        return q.getResultList();
    }
View Full Code Here

        return ret;
    }
   
  public User getUserByActivationCode(String activationCode) throws WebloggerException {
    if (activationCode == null)
      throw new WebloggerException("activationcode is null");
        Query q = strategy.getNamedQuery("User.getUserByActivationCode");
        q.setParameter(1, activationCode);
        try {
            return (User)q.getSingleResult();
        } catch (NoResultException e) {
View Full Code Here

TOP

Related Classes of org.apache.roller.weblogger.WebloggerException

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.