Package org.apache.roller

Examples of org.apache.roller.RollerException


           
            mLogger.info("Upgrade to 200 complete.");
           
        } catch (SQLException e) {
            mLogger.error("Problem upgrading database to version 200", e);
            throw new RollerException("Problem upgrading database to version 200", e);
        }
       
        UpgradeDatabase.updateDatabaseVersion(con, 200);
    }
View Full Code Here


           
            mLogger.info("Upgrade to 210 complete.");
           
        } catch (SQLException e) {
            mLogger.error("Problem upgrading database to version 210", e);
            throw new RollerException("Problem upgrading database to version 210", e);
        }
       
        UpgradeDatabase.updateDatabaseVersion(con, 210);
    }
View Full Code Here

            stmt.executeUpdate("insert into roller_properties "+
                    "values('"+DBVERSION_PROP+"', '"+version+"')");
           
            mLogger.debug("Set database verstion to "+version);
        } catch(SQLException se) {
            throw new RollerException("Error setting database version.", se);
        }
    }
View Full Code Here

                    "set value = '"+version+"'"+
                    "where name = '"+DBVERSION_PROP+"'");
           
            mLogger.debug("Updated database verstion to "+version);
        } catch(SQLException se) {
            throw new RollerException("Error setting database version.", se);
        }
    }
View Full Code Here

   
   
    public void addUser(UserData newUser) throws RollerException {
       
        if(newUser == null)
            throw new RollerException("cannot add null user");
       
        // TODO BACKEND: we must do this in a better fashion, like getUserCnt()?
        boolean adminUser = false;
        List existingUsers = this.getUsers();
        if(existingUsers.size() == 0) {
            // Make first user an admin
            adminUser = true;
        }
       
        if(getUserByUsername(newUser.getUserName()) != null ||
                getUserByUsername(newUser.getUserName().toLowerCase()) != null) {
            throw new RollerException("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 PermissionsData inviteUser(WebsiteData website,
            UserData user, short mask) throws RollerException {
       
        if (website == null) throw new RollerException("Website cannot be null");
        if (user == null) throw new RollerException("User cannot be null");
       
        PermissionsData perms = new PermissionsData();
        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(WebsiteData website, UserData user) throws RollerException {
       
        if (website == null) throw new RollerException("Website cannot be null");
        if (user == null) throw new RollerException("User cannot be null");
       
        Iterator perms = website.getPermissions().iterator();
        PermissionsData target = null;
        while (perms.hasNext()) {
            PermissionsData pd = (PermissionsData)perms.next();
            if (pd.getUser().getId().equals(user.getId())) {
                target = pd;
                break;
            }
        }
        if (target == null) throw new RollerException("User not member of website");
       
        website.removePermission(target);
        this.strategy.remove(target);
    }
View Full Code Here

     */
    public WebsiteData getWebsiteByHandle(String handle, Boolean enabled)
            throws RollerException {
       
        if (handle==null )
            throw new RollerException("Handle cannot be null");
       
        // check cache first
        // NOTE: if we ever allow changing handles then this needs updating
        if(this.weblogHandleToIdMap.containsKey(handle)) {
           
            WebsiteData weblog = this.getWebsite((String) this.weblogHandleToIdMap.get(handle));
            if(weblog != null) {
                // only return weblog if enabled status matches
                if(enabled == null || enabled.equals(weblog.getEnabled())) {
                    log.debug("weblogHandleToId CACHE HIT - "+handle);
                    return weblog;
                }
            } else {
                // mapping hit with lookup miss?  mapping must be old, remove it
                this.weblogHandleToIdMap.remove(handle);
            }
        }
       
        // cache failed, do lookup
        try {
            Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
            Criteria criteria = session.createCriteria(WebsiteData.class);
           
            if (enabled != null) {
                criteria.add(
                        Expression.conjunction()
                        .add(new IgnoreCaseEqExpression("handle", handle))
                        .add(Expression.eq("enabled", enabled)));
            } else {
                criteria.add(
                        Expression.conjunction()
                        .add(Expression.eq("handle", handle)));
            }
           
            WebsiteData website = (WebsiteData) criteria.uniqueResult();
           
            // add mapping to cache
            if(website != null) {
                log.debug("weblogHandleToId CACHE MISS - "+handle);
                this.weblogHandleToIdMap.put(website.getHandle(), website.getId());
            }
           
            return website;
        } catch (HibernateException e) {
            throw new RollerException(e);
        }
    }
View Full Code Here

            if (active != null) {
                criteria.add(Expression.eq("active", active));
            }
            return criteria.list();
        } catch (HibernateException e) {
            throw new RollerException(e);
        }
    }
View Full Code Here

   
    public UserData getUserByUsername(String userName, Boolean enabled)
            throws RollerException {
       
        if (userName==null )
            throw new RollerException("userName cannot be null");
       
        // check cache first
        // NOTE: if we ever allow changing usernames then this needs updating
        if(this.userNameToIdMap.containsKey(userName)) {
           
            UserData user = this.getUser((String) this.userNameToIdMap.get(userName));
            if(user != null) {
                // only return the user if the enabled status matches
                if(enabled == null || enabled.equals(user.getEnabled())) {
                    log.debug("userNameToIdMap CACHE HIT - "+userName);
                    return user;
                }
            } else {
                // mapping hit with lookup miss?  mapping must be old, remove it
                this.userNameToIdMap.remove(userName);
            }
        }
       
        // cache failed, do lookup
        try {
            Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
            Criteria criteria = session.createCriteria(UserData.class);
           
            if (enabled != null) {
                criteria.add(
                        Expression.conjunction()
                        .add(Expression.eq("userName", userName))
                        .add(Expression.eq("enabled", enabled)));
            } else {
                criteria.add(
                        Expression.conjunction()
                        .add(Expression.eq("userName", userName)));
            }
           
            UserData user = (UserData) criteria.uniqueResult();
           
            // add mapping to cache
            if(user != null) {
                log.debug("userNameToIdMap CACHE MISS - "+userName);
                this.userNameToIdMap.put(user.getUserName(), user.getId());
            }
           
            return user;
        } catch (HibernateException e) {
            throw new RollerException(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.roller.RollerException

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.