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();
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();
}
}
use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.
the class ServiceImpl method getAllAuthorizedUsersOfProject.
@Override
public List<SUser> getAllAuthorizedUsersOfProject(Long poid) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
BimDatabaseAction<Set<User>> action = new GetAllAuthorizedUsersOfProjectDatabaseAction(session, getInternalAccessMethod(), poid);
return new ArrayList<SUser>(getBimServer().getSConverter().convertToSSetUser(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 getAllProjects.
@Override
public List<SProject> getAllProjects(Boolean onlyTopLevel, Boolean onlyActive) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
BimDatabaseAction<Set<Project>> action = new GetAllProjectsDatabaseAction(session, getInternalAccessMethod(), onlyTopLevel, onlyActive, getAuthorization());
List<SProject> convertToSListProject = getBimServer().getSConverter().convertToSListProject(session.executeAndCommitAction(action));
Collections.sort(convertToSListProject, new SProjectComparator());
return convertToSListProject;
} 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 deleteUser.
@Override
public Boolean deleteUser(Long uoid) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
BimDatabaseAction<Boolean> action = new DeleteUserDatabaseAction(session, getInternalAccessMethod(), getAuthorization(), uoid);
return 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 getSuggestedDeserializerForExtension.
@Override
public SDeserializerPluginConfiguration getSuggestedDeserializerForExtension(String extension, Long poid) throws ServerException, UserException {
// Token authenticated users should also be able to call this method
try {
requireAuthenticationAndRunningServer();
DatabaseSession session = getBimServer().getDatabase().createSession();
List<DeserializerPluginConfiguration> list = new ArrayList<>();
try {
Project project = session.get(poid, OldQuery.getDefault());
UserSettings userSettings = getUserSettings(session);
for (DeserializerPluginConfiguration deserializer : userSettings.getDeserializers()) {
Plugin plugin = getBimServer().getPluginManager().getPlugin(deserializer.getPluginDescriptor().getIdentifier(), true);
if (plugin instanceof DeserializerPlugin) {
DeserializerPlugin deserializerPlugin = (DeserializerPlugin) plugin;
if (deserializerPlugin.getSupportedSchemas().contains(Schema.valueOf(project.getSchema().toUpperCase()))) {
if (deserializerPlugin.canHandleExtension(extension)) {
list.add(deserializer);
}
}
} else if (plugin instanceof StreamingDeserializerPlugin) {
StreamingDeserializerPlugin streamingDeserializerPlugin = (StreamingDeserializerPlugin) plugin;
if (streamingDeserializerPlugin.getSupportedSchemas().contains(Schema.valueOf(project.getSchema().toUpperCase()))) {
if (streamingDeserializerPlugin.canHandleExtension(extension)) {
list.add(deserializer);
}
}
}
}
} finally {
session.close();
}
if (list.size() == 1) {
return getBimServer().getSConverter().convertToSObject(list.get(0));
} else if (list.size() > 1) {
for (DeserializerPluginConfiguration deserializerPluginConfiguration : list) {
Plugin plugin = getBimServer().getPluginManager().getPlugin(deserializerPluginConfiguration.getPluginDescriptor().getIdentifier(), true);
// Prefer the streaming version
if (plugin instanceof StreamingDeserializerPlugin) {
return getBimServer().getSConverter().convertToSObject(deserializerPluginConfiguration);
}
}
// Just return the first one
return getBimServer().getSConverter().convertToSObject(list.get(0));
}
} catch (Exception e) {
return handleException(e);
}
return null;
}
Aggregations