use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.
the class ServiceImpl method getAllLocalProfiles.
@Override
public List<SProfileDescriptor> getAllLocalProfiles(String serviceIdentifier) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
List<SProfileDescriptor> descriptors = new ArrayList<SProfileDescriptor>();
try {
SUser currentUser = getCurrentUser();
Condition condition = new AttributeCondition(StorePackage.eINSTANCE.getUser_Token(), new StringLiteral(currentUser.getToken()));
User user = session.querySingle(condition, User.class, OldQuery.getDefault());
if (user != null) {
for (InternalServicePluginConfiguration internalServicePluginConfiguration : user.getUserSettings().getServices()) {
if (serviceIdentifier.equals("" + internalServicePluginConfiguration.getOid())) {
SProfileDescriptor sProfileDescriptor = new SProfileDescriptor();
descriptors.add(sProfileDescriptor);
sProfileDescriptor.setIdentifier("" + internalServicePluginConfiguration.getOid());
sProfileDescriptor.setName(internalServicePluginConfiguration.getName());
sProfileDescriptor.setDescription(internalServicePluginConfiguration.getDescription());
sProfileDescriptor.setPublicProfile(false);
}
}
}
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
return descriptors;
}
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();
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 checkinInitiatedInternal.
public Long 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 session = getBimServer().getDatabase().createSession();
String username = "Unknown";
String userUsername = "Unknown";
try {
if (getBimServer().getCheckinsInProgress().containsKey(poid)) {
Thread.sleep(1000);
throw new UserException("Checkin in progress on this project, please try again later");
}
User user = (User) session.get(StorePackage.eINSTANCE.getUser(), getAuthorization().getUoid(), OldQuery.getDefault());
Project project = session.get(poid, OldQuery.getDefault());
if (project == null) {
throw new UserException("No project found with poid " + poid);
}
username = user.getName();
userUsername = user.getUsername();
Path homeDirIncoming = getBimServer().getHomeDir().resolve("incoming");
Path userDirIncoming = homeDirIncoming.resolve(userUsername);
if (!Files.exists(userDirIncoming)) {
Files.createDirectories(userDirIncoming);
}
if (fileName.contains("/")) {
fileName = fileName.substring(fileName.lastIndexOf("/") + 1);
}
if (fileName.contains("\\")) {
fileName = fileName.substring(fileName.lastIndexOf("\\") + 1);
}
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
String cacheFileName = dateFormat.format(new Date()) + "-" + fileName;
Path file = userDirIncoming.resolve(cacheFileName);
return checkinInternal(topicId, poid, comment, deserializerOid, fileSize, fileName, dataHandler.getInputStream(), merge, sync, session, username, userUsername, project, file, newServiceId);
} catch (UserException e) {
throw e;
} catch (Throwable e) {
LOGGER.error("", e);
throw new ServerException(e);
} finally {
session.close();
}
}
use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.
the class ServiceImpl method getAllCheckoutsOfProjectAndSubProjects.
@Override
public List<SCheckout> getAllCheckoutsOfProjectAndSubProjects(Long poid) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
BimDatabaseAction<List<Checkout>> action = new GetAllCheckoutsOfProjectDatabaseAction(session, getInternalAccessMethod(), poid, true);
List<Checkout> list = session.executeAndCommitAction(action);
Collections.sort(list, new CheckoutComparator());
return getBimServer().getSConverter().convertToSListCheckout(list);
} 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 getQueryEngineById.
@Override
public SQueryEnginePluginConfiguration getQueryEngineById(Long oid) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
return getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(new GetQueryEngineByIdDatabaseAction(session, getInternalAccessMethod(), oid)));
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
Aggregations