Package io.lumify.core.exception

Examples of io.lumify.core.exception.LumifyException


    @Override
    public void setPassword(User user, String password) {
        checkNotNull(password);
        Session session = sessionManager.getSession();
        if (user == null || user.getUserId() == null || findById(user.getUserId()) == null) {
            throw new LumifyException("User is not valid");
        }

        Transaction transaction = null;
        try {
            transaction = session.beginTransaction();
            byte[] salt = UserPasswordUtil.getSalt();
            byte[] passwordHash = UserPasswordUtil.hashPassword(password, salt);

            ((SqlUser) user).setPassword(salt, passwordHash);
            session.update(user);
            transaction.commit();
        } catch (HibernateException e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new LumifyException("HibernateException while setting password", e);
        }
    }
View Full Code Here


    @Override
    public boolean isPasswordValid(User user, String password) {
        checkNotNull(password);
        if (user == null || user.getUserId() == null || (user.getUserId() != null && findById(user.getUserId()) == null)) {
            throw new LumifyException("User is not valid");
        }

        byte[] passwordSalt = ((SqlUser) user).getPasswordSalt();
        byte[] passwordHash = ((SqlUser) user).getPasswordHash();
        if (passwordSalt == null || passwordHash == null) {
View Full Code Here

            transaction.commit();
        } catch (HibernateException e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new LumifyException("HibernateException while recording login", e);
        }
    }
View Full Code Here

    }

    @Override
    public User setCurrentWorkspace(String userId, String workspaceId) {
        if (userId == null) {
            throw new LumifyException("UserId cannot be null");
        }

        Session session = sessionManager.getSession();
        Transaction transaction = null;
        SqlUser sqlUser = null;
        try {
            transaction = session.beginTransaction();
            sqlUser = (SqlUser) findById(userId);
            if (sqlUser == null) {
                throw new LumifyException("User does not exist");
            }
            List<SqlWorkspace> workspaces = session.createQuery
                    ("select workspace from " + SqlWorkspace.class.getSimpleName() + " as workspace where workspace.workspaceId=:id")
                    .setParameter("id", workspaceId)
                    .list();
            if (workspaces.size() == 0) {
                throw new LumifyException("Could not find workspace with id: " + workspaceId);
            }
            sqlUser.setCurrentWorkspace(workspaces.get(0));
            session.merge(sqlUser);
            transaction.commit();
        } catch (HibernateException e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new LumifyException("HibernateException while setting current workspace", e);
        }
        return sqlUser;
    }
View Full Code Here

        Visibility visibility = new Visibility("");
        Authorizations authorizations = getAuthorizations();

        String hasMediaConceptTypeIri = getConfiguration().get("ontology.iri.hasMedia");
        if (hasMediaConceptTypeIri == null || hasMediaConceptTypeIri.length() == 0) {
            throw new LumifyException("'ontology.iri.hasMedia' is required.");
        }

        if (!owlPrefix.endsWith("#")) {
            owlPrefix = owlPrefix + "#";
        }
View Full Code Here

    }

    @Override
    public String getCurrentWorkspaceId(String userId) {
        if (userId == null) {
            throw new LumifyException("UserId cannot be null");
        }

        Session session = sessionManager.getSession();
        try {
            SqlUser sqlUser = (SqlUser) findById(userId);
            if (sqlUser == null) {
                throw new LumifyException("User does not exist");
            }
            return sqlUser.getCurrentWorkspace() == null ? null : sqlUser.getCurrentWorkspace().getWorkspaceId();
        } catch (HibernateException e) {
            throw new LumifyException("HibernateException while getting current workspace", e);
        }
    }
View Full Code Here

            transaction.commit();
        } catch (HibernateException e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new LumifyException("HibernateException while setting preferences", e);
        }
    }
View Full Code Here

    @Override
    public User setStatus(String userId, UserStatus status) {
        Session session = sessionManager.getSession();
        if (userId == null) {
            throw new LumifyException("UserId cannot be null");
        }

        Transaction transaction = null;
        SqlUser sqlUser;
        try {
            transaction = session.beginTransaction();
            sqlUser = (SqlUser) findById(userId);
            if (sqlUser == null) {
                throw new LumifyException("User does not exist");
            }
            sqlUser.setUserStatus(status);
            session.update(sqlUser);
            transaction.commit();
        } catch (HibernateException e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new LumifyException("HibernateException while setting status", e);
        }
        return sqlUser;
    }
View Full Code Here

            transaction.commit();
        } catch (HibernateException e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new LumifyException("HibernateException while setting display name", e);
        }
    }
View Full Code Here

            transaction.commit();
        } catch (HibernateException e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new LumifyException("HibernateException while setting e-mail address", e);
        }
    }
View Full Code Here

TOP

Related Classes of io.lumify.core.exception.LumifyException

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.