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()));
}
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();
}
}
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();
}
}
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();
}
}
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);
}
}
Aggregations