use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.
the class ServiceImpl method addProjectAsSubProject.
@Override
public SProject addProjectAsSubProject(String projectName, Long parentPoid, String schema) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.POSSIBLY_WRITE);
try {
BimDatabaseAction<Project> action = new AddProjectDatabaseAction(getBimServer(), session, getInternalAccessMethod(), projectName, parentPoid, schema, getAuthorization());
return getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(action));
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.
the class ServiceImpl method checkinInitiatedInternal.
public SLongCheckinActionState checkinInitiatedInternal(Long topicId, final Long poid, final String comment, Long deserializerOid, Long fileSize, String fileName, DataHandler dataHandler, Boolean merge, Boolean sync, long newServiceId) throws ServerException, UserException {
requireAuthenticationAndRunningServer();
final DatabaseSession readOnlySession = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
String username = "Unknown";
String userUsername = "Unknown";
try {
User user = (User) readOnlySession.get(StorePackage.eINSTANCE.getUser(), getAuthorization().getUoid(), OldQuery.getDefault());
Project project = readOnlySession.get(poid, OldQuery.getDefault());
if (project == null) {
throw new UserException("No project found with poid " + poid);
}
username = user.getName();
userUsername = user.getUsername();
Path incomingFile = getIncomingFileName(fileName, null, userUsername);
// This is where we pass the responsibility for closing the inputStream on
return checkinInternal(topicId, poid, comment, deserializerOid, fileSize, fileName, dataHandler.getInputStream(), merge, sync, readOnlySession, username, userUsername, project, incomingFile, newServiceId);
} catch (UserException e) {
try {
clearCheckinInProgress(poid);
} catch (BimserverDatabaseException | ServiceException e1) {
LOGGER.error("", e1);
}
throw e;
} catch (Throwable e) {
try {
clearCheckinInProgress(poid);
} catch (BimserverDatabaseException | ServiceException e1) {
LOGGER.error("", e1);
}
LOGGER.error("", e);
throw new ServerException(e);
} finally {
readOnlySession.close();
}
}
use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.
the class ServiceImpl method getAllModelCheckers.
@Override
public List<SModelCheckerInstance> getAllModelCheckers() throws UserException, ServerException {
requireAuthenticationAndRunningServer();
DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
try {
return getBimServer().getSConverter().convertToSListModelCheckerInstance(session.executeAndCommitAction(new GetAllModelCheckersDatabaseAction(session, getInternalAccessMethod())));
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.
the class ServiceImpl method getQueryEngineByName.
@Override
public SQueryEnginePluginConfiguration getQueryEngineByName(String name) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
try {
return getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(new GetQueryEngineByNameDatabaseAction(session, getInternalAccessMethod(), name)));
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.
the class ServiceImpl method getFileMeta.
@Override
public SFile getFileMeta(Long fileId) throws ServerException, UserException {
DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
try {
org.bimserver.models.store.File file = (org.bimserver.models.store.File) session.get(StorePackage.eINSTANCE.getFile(), fileId, OldQuery.getDefault());
file.setData(null);
return getBimServer().getSConverter().convertToSObject(file);
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
Aggregations