use of org.bimserver.BimserverDatabaseException in project BIMserver by opensourceBIM.
the class PluginServiceImpl method getDefaultObjectIDM.
public SObjectIDMPluginConfiguration getDefaultObjectIDM() throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
UserSettings settings = getUserSettings(session);
return getBimServer().getSConverter().convertToSObject(settings.getDefaultObjectIDM());
} catch (BimserverDatabaseException e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.BimserverDatabaseException in project BIMserver by opensourceBIM.
the class PluginServiceImpl method setPluginSettings.
@Override
public void setPluginSettings(Long poid, SObjectType settings) throws ServerException, UserException {
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
ObjectType convertedSettings = getBimServer().getSConverter().convertFromSObject(settings, session);
SetPluginSettingsDatabaseAction action = new SetPluginSettingsDatabaseAction(session, getInternalAccessMethod(), poid, convertedSettings);
session.executeAndCommitAction(action);
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
session = getBimServer().getDatabase().createSession();
try {
PluginConfiguration pluginConfiguration = session.get(StorePackage.eINSTANCE.getPluginConfiguration(), poid, OldQuery.getDefault());
if (pluginConfiguration instanceof InternalServicePluginConfiguration) {
ServicePlugin servicePlugin = getBimServer().getPluginManager().getServicePlugin(pluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
SInternalServicePluginConfiguration sInternalService = (SInternalServicePluginConfiguration) getBimServer().getSConverter().convertToSObject(pluginConfiguration);
servicePlugin.unregister(sInternalService);
servicePlugin.register(getAuthorization().getUoid(), sInternalService, new org.bimserver.plugins.PluginConfiguration(settings));
}
} catch (BimserverDatabaseException e) {
handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.BimserverDatabaseException in project BIMserver by opensourceBIM.
the class RemoteServiceImpl method getPrivateProfiles.
@Override
public List<SProfileDescriptor> getPrivateProfiles(String serviceIdentifier, String token) throws UserException, ServerException {
DatabaseSession session = getServiceMap().getBimServer().getDatabase().createSession();
List<SProfileDescriptor> descriptors = new ArrayList<SProfileDescriptor>();
try {
Condition condition = new AttributeCondition(StorePackage.eINSTANCE.getUser_Token(), new StringLiteral(token));
User user = session.querySingle(condition, User.class, OldQuery.getDefault());
if (user != null) {
for (InternalServicePluginConfiguration internalServicePluginConfiguration : user.getUserSettings().getServices()) {
if (internalServicePluginConfiguration.getPluginDescriptor().getPluginClassName().equals(serviceIdentifier)) {
SProfileDescriptor sProfileDescriptor = new SProfileDescriptor();
descriptors.add(sProfileDescriptor);
sProfileDescriptor.setIdentifier("" + internalServicePluginConfiguration.getOid());
sProfileDescriptor.setName(internalServicePluginConfiguration.getName());
sProfileDescriptor.setDescription(internalServicePluginConfiguration.getDescription());
sProfileDescriptor.setPublicProfile(false);
}
}
}
} catch (BimserverDatabaseException e) {
handleException(e);
} finally {
session.close();
}
return descriptors;
}
use of org.bimserver.BimserverDatabaseException in project BIMserver by opensourceBIM.
the class RemoteServiceImpl method getPublicProfiles.
@Override
public List<SProfileDescriptor> getPublicProfiles(String serviceIdentifier) throws UserException, ServerException {
DatabaseSession session = getServiceMap().getBimServer().getDatabase().createSession();
List<SProfileDescriptor> descriptors = new ArrayList<SProfileDescriptor>();
try {
IfcModelInterface modelInterface = session.getAllOfType(StorePackage.eINSTANCE.getInternalServicePluginConfiguration(), OldQuery.getDefault());
for (InternalServicePluginConfiguration internalServicePluginConfiguration : modelInterface.getAll(InternalServicePluginConfiguration.class)) {
if (internalServicePluginConfiguration.isPublicProfile()) {
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 (BimserverDatabaseException e) {
handleException(e);
} finally {
session.close();
}
return descriptors;
}
use of org.bimserver.BimserverDatabaseException in project BIMserver by opensourceBIM.
the class ServiceImpl method download.
public Long download(DownloadParameters downloadParameters, Boolean sync) throws ServerException, UserException {
requireAuthenticationAndRunningServer();
User user = null;
for (long roid : downloadParameters.getRoids()) {
getAuthorization().canDownload(roid);
}
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
user = (User) session.get(StorePackage.eINSTANCE.getUser(), getAuthorization().getUoid(), OldQuery.getDefault());
} catch (BimserverDatabaseException e) {
throw new UserException(e);
} finally {
session.close();
}
LongDownloadOrCheckoutAction longDownloadAction = new LongDownloadAction(getBimServer(), user == null ? "Unknown" : user.getName(), user == null ? "Unknown" : user.getUsername(), downloadParameters, getAuthorization(), getInternalAccessMethod());
try {
getBimServer().getLongActionManager().start(longDownloadAction);
} catch (Exception e) {
LOGGER.error("", e);
}
if (sync) {
longDownloadAction.waitForCompletion();
}
return longDownloadAction.getProgressTopic().getKey().getId();
}
Aggregations