Package net.sf.hibernate

Examples of net.sf.hibernate.Session


        }
       
        log.log(loggingPriority, "NT domain authenticated user "+userId);
       
        try {
            Session session = ThreadSession.get();
            try {
                log.log(loggingPriority, "looking for user: " + userId);
                Person person = getPerson(session, userId);
                if (person != null) {
                    HashSet principals = new HashSet();
View Full Code Here


        }
    }
   
    public Subject fallbackAuthenticate(String userId, String password) throws AuthenticationException {
        try {
            Session session = ThreadSession.get();
            try {
                log.log(loggingPriority, "attempting to authenticate: " + userId);
                Person person = getPerson(session, userId);
                if (person != null) {
                    if (isPasswordMatched(person, password)) {
View Full Code Here

        return context.getProjectId();
    }

    private Object[] getObjects(Class dataClass, String where, Object[] values, Type[] types, String orderBy) throws Exception {
        try {
            Session session = ThreadSession.get();
            Class objectClass = getInternalClass(dataClass);
            String query = "from object in class " + objectClass.getName();
            if (where != null) {
                query += " where " + where;
            }
            if (orderBy != null) {
                query += " order by " + orderBy;
            }
            List objects = values != null
                    ? session.find(query, values, types)
                    : session.find(query);
            return toArray(dataClass, objects);
        } catch (Exception ex) {
            log.error("error loading objects", ex);
            throw ex;
        }
View Full Code Here

        }
    }

    private Object[] getObjects(Class fromDataClass, int id, String propertyName, Class toDataClass) throws Exception {
        try {
            Session session = ThreadSession.get();
            Class objectClass = getInternalClass(fromDataClass);
            log.debug("getting object: " + id);
            Object object = session.load(objectClass, new Integer(id));
            log.debug("loaded object: " + object);
            Collection objects = (Collection)PropertyUtils.getProperty(object, propertyName);
            Object[] dataArray = toArray(toDataClass, objects);
            return dataArray;
        } catch (Exception ex) {
View Full Code Here

            throw ex;
        }
    }

    private Object getObject(Class dataClass, int id) throws Exception {
        Session session = null;
        try {
            session = ThreadSession.get();
            Class objectClass = getInternalClass(dataClass);
            log.debug("getting object: " + id);
            DomainObject object = (DomainObject)session.load(objectClass, new Integer(id));
            log.debug("loaded object: " + object);
            DomainData data = (DomainData)dataClass.newInstance();
            if (hasPermission(getProjectId(object), object, "read")) {
                populateDomainData(data, object);
                return data;
View Full Code Here

    }

    static Integer NULL = new Integer(-1);

    private void updateObject(DomainData data) throws Exception {
        Session session = null;
        try {
            Integer id = NULL;
            session = ThreadSession.get();
            Class objectClass = getInternalClass(data.getClass());
            id = getObjectId(data);
            DomainObject object = (DomainObject)session.load(objectClass, id);
            if (hasPermission(getProjectId(object), object, "edit")) {
                // JM: no need to write lock the object
                // There is a lot more chance to get the client out-of-sync during a get/update than just in that method
                // See to-do at the top of the file for better implementation
                if (object != null) {
View Full Code Here

    private Integer getObjectId(Object data) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
        return (Integer)PropertyUtils.getProperty(data, "id");
    }

    protected void removeObject(Class dataClass, int id) throws Exception {
        Session session = null;
        try {
            session = ThreadSession.get();
            log.debug("removing object: " + id);
            Class objectClass = getInternalClass(dataClass);
            Object object = session.load(objectClass, new Integer(id));
            if (hasPermission(getProjectId(object), (DomainObject)object, "delete")) {
                session.delete(object);
                saveHistory(session, object, HistoricalEvent.DELETED);
                commit(session);
            } else {
                throw new AuthenticationException("no permission to delete object");
            }
View Full Code Here

        }
    }


    protected Object addObject(int projectId, DomainData data) throws Exception {
        Session session = null;
        try {
            session = ThreadSession.get();
            Class objectClass = getInternalClass(data.getClass());
            DomainObject object = (DomainObject)objectClass.newInstance();
            if (hasPermission(projectId, object, "create")) {
                populateDomainObject(object, data);
                log.debug("adding object: " + object);
                Serializable id = session.save(object);
                saveHistory(session, object, HistoricalEvent.CREATED);
                commit(session);
                return getObject(data.getClass(), ((Integer)id).intValue());
            } else {
                throw new AuthenticationException("no permission to create object");
View Full Code Here

                return;
            }

            requestedUsername = requestedUsername.substring(0, requestedUsername.length() - 4);

            Session session = ThreadSession.get();

            // verify access of http user vs requested user
            if (!requestedUsername.equals(myUsername)) {
                if (!SystemAuthorizer.get().hasPermissionForSomeProject(myID, "system.person",
                        myID, "admin.edit")) {
View Full Code Here

import org.apache.commons.lang.StringUtils;

public class AttributeRepositoryImpl implements AttributeRepository {
    public void setAttribute(int targetId, String name, String value) throws RepositoryException {
        try {
            final Session session = ThreadSession.get();
            final Attribute attribute = new Attribute(targetId, name, value);
            List existingAttributes = session.find("from a in "+Attribute.class+
                    " where targetId = ? and name= ?",
                    new Object[]{ new Integer(targetId), name },
                    new Type[]{ Hibernate.INTEGER, Hibernate.STRING });
            if (existingAttributes.size() == 0) {
                session.save(attribute);
            } else {
                session.update(attribute);
            }
        } catch (RuntimeException e) {
            throw e;
        } catch (HibernateException e) {
            throw new RepositoryException(e);
View Full Code Here

TOP

Related Classes of net.sf.hibernate.Session

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.