Search in sources :

Example 96 with UserException

use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.

the class GetAllNonAuthorizedUsersOfProjectDatabaseAction method execute.

@Override
public Set<User> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    Project project = getProjectByPoid(poid);
    if (project == null) {
        throw new UserException("No Project with oid " + poid + " found");
    }
    Condition condition = new AndCondition(new AndCondition(new Not(new HasReferenceToCondition(StorePackage.eINSTANCE.getUser_HasRightsOn(), project)), new AttributeCondition(StorePackage.eINSTANCE.getUser_State(), new EnumLiteral(ObjectState.ACTIVE))), new Not(new AttributeCondition(StorePackage.eINSTANCE.getUser_UserType(), new EnumLiteral(UserType.SYSTEM))));
    return CollectionUtils.mapToSet(getDatabaseSession().query(condition, User.class, OldQuery.getDefault()));
}
Also used : AttributeCondition(org.bimserver.database.query.conditions.AttributeCondition) Condition(org.bimserver.database.query.conditions.Condition) AndCondition(org.bimserver.database.query.conditions.AndCondition) HasReferenceToCondition(org.bimserver.database.query.conditions.HasReferenceToCondition) Project(org.bimserver.models.store.Project) Not(org.bimserver.database.query.conditions.Not) User(org.bimserver.models.store.User) HasReferenceToCondition(org.bimserver.database.query.conditions.HasReferenceToCondition) AttributeCondition(org.bimserver.database.query.conditions.AttributeCondition) UserException(org.bimserver.shared.exceptions.UserException) EnumLiteral(org.bimserver.database.query.literals.EnumLiteral) AndCondition(org.bimserver.database.query.conditions.AndCondition)

Example 97 with UserException

use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.

the class LowLevelServiceImpl method startTransaction.

@Override
public Long startTransaction(Long poid) throws UserException, ServerException {
    requireAuthenticationAndRunningServer();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    int pid = -1;
    int rid = -1;
    long roid = -1;
    try {
        Project project = (Project) session.get(poid, OldQuery.getDefault());
        if (project == null) {
            throw new UserException("No project found with poid " + poid);
        }
        pid = project.getId();
        if (project.getLastRevision() != null) {
            Revision revision = project.getLastRevision();
            ConcreteRevision lastConcreteRevision = revision.getLastConcreteRevision();
            rid = lastConcreteRevision.getId();
            roid = revision.getOid();
        }
        LongTransaction longTransaction = getBimServer().getLongTransactionManager().newLongTransaction(getBimServer().getMetaDataManager().getPackageMetaData(project.getSchema()), poid, pid, rid, roid);
        return longTransaction.getTid();
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : Project(org.bimserver.models.store.Project) Revision(org.bimserver.models.store.Revision) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) DatabaseSession(org.bimserver.database.DatabaseSession) UserException(org.bimserver.shared.exceptions.UserException) LongTransaction(org.bimserver.webservices.LongTransaction) UserException(org.bimserver.shared.exceptions.UserException) NoTransactionException(org.bimserver.webservices.NoTransactionException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException)

Example 98 with UserException

use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.

the class LowLevelServiceImpl method getDataObjectsByType.

@Override
public List<SDataObject> getDataObjectsByType(Long roid, String packageName, String className, Boolean flat) throws ServerException, UserException {
    requireAuthenticationAndRunningServer();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    BimDatabaseAction<List<DataObject>> action = new GetDataObjectsByTypeDatabaseAction(getBimServer(), session, getInternalAccessMethod(), roid, packageName, className, getAuthorization(), flat);
    try {
        return getBimServer().getSConverter().convertToSListDataObject(session.executeAndCommitAction(action));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) GetDataObjectsByTypeDatabaseAction(org.bimserver.database.actions.GetDataObjectsByTypeDatabaseAction) ArrayList(java.util.ArrayList) List(java.util.List) UserException(org.bimserver.shared.exceptions.UserException) NoTransactionException(org.bimserver.webservices.NoTransactionException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException)

Example 99 with UserException

use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.

the class LowLevelServiceImpl method count.

public Integer count(Long roid, String className) throws UserException, ServerException {
    requireAuthenticationAndRunningServer();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        CountDatabaseAction action = new CountDatabaseAction(getBimServer(), session, getInternalAccessMethod(), roid, className, getAuthorization());
        return session.executeAndCommitAction(action);
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) CountDatabaseAction(org.bimserver.database.actions.CountDatabaseAction) UserException(org.bimserver.shared.exceptions.UserException) NoTransactionException(org.bimserver.webservices.NoTransactionException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException)

Example 100 with UserException

use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.

the class LowLevelServiceImpl method createObject.

@Override
public Long createObject(Long tid, String className, Boolean generateGuid) throws UserException, ServerException {
    requireAuthenticationAndRunningServer();
    try {
        LongTransaction longTransaction = getBimServer().getLongTransactionManager().get(tid);
        if (longTransaction == null) {
            throw new UserException("No transaction with tid " + tid + " was found");
        }
        try {
            EClass eClass = ((Database) getBimServer().getDatabase()).getEClass(longTransaction.getPackageMetaData().getEPackage().getName(), className);
            Long oid = getBimServer().getDatabase().newOid(eClass);
            CreateObjectChange createObject = new CreateObjectChange(className, oid, eClass, generateGuid);
            longTransaction.add(createObject);
            return oid;
        } catch (BimserverDatabaseException e) {
            throw new UserException("Unknown type: \"" + className + "\"");
        }
    } catch (Exception e) {
        return handleException(e);
    }
}
Also used : BimserverDatabaseException(org.bimserver.BimserverDatabaseException) EClass(org.eclipse.emf.ecore.EClass) CreateObjectChange(org.bimserver.changes.CreateObjectChange) Database(org.bimserver.database.Database) UserException(org.bimserver.shared.exceptions.UserException) LongTransaction(org.bimserver.webservices.LongTransaction) UserException(org.bimserver.shared.exceptions.UserException) NoTransactionException(org.bimserver.webservices.NoTransactionException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException)

Aggregations

UserException (org.bimserver.shared.exceptions.UserException)362 ServerException (org.bimserver.shared.exceptions.ServerException)253 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)241 DatabaseSession (org.bimserver.database.DatabaseSession)227 IOException (java.io.IOException)220 SerializerException (org.bimserver.plugins.serializers.SerializerException)113 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)112 MalformedURLException (java.net.MalformedURLException)109 MessagingException (javax.mail.MessagingException)109 BcfException (org.opensourcebim.bcf.BcfException)109 UnsupportedEncodingException (java.io.UnsupportedEncodingException)108 AddressException (javax.mail.internet.AddressException)108 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)108 User (org.bimserver.models.store.User)65 Project (org.bimserver.models.store.Project)48 Revision (org.bimserver.models.store.Revision)39 ArrayList (java.util.ArrayList)35 Date (java.util.Date)34 SProject (org.bimserver.interfaces.objects.SProject)31 PackageMetaData (org.bimserver.emf.PackageMetaData)30