use of org.bimserver.models.store.InternalServicePluginConfiguration in project BIMserver by opensourceBIM.
the class PluginServiceImpl method getInternalServiceById.
@Override
public SInternalServicePluginConfiguration getInternalServiceById(Long oid) throws ServerException, UserException {
requireAuthenticationAndRunningServer();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
InternalServicePluginConfiguration internalPlugin = session.executeAndCommitAction(new GetByIdDatabaseAction<InternalServicePluginConfiguration>(session, getInternalAccessMethod(), oid, StorePackage.eINSTANCE.getInternalServicePluginConfiguration()));
if (internalPlugin == null) {
throw new UserException("No InternalServicePluginConfiguration found for id " + oid);
}
SInternalServicePluginConfiguration convertToSObject = getBimServer().getSConverter().convertToSObject(internalPlugin);
return convertToSObject;
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.models.store.InternalServicePluginConfiguration in project BIMserver by opensourceBIM.
the class PluginServiceImpl method getAllInternalServices.
@Override
public List<SInternalServicePluginConfiguration> getAllInternalServices(Boolean onlyEnabled) throws UserException, ServerException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
UserSettings userSettings = getUserSettings(session);
EList<InternalServicePluginConfiguration> services2 = userSettings.getServices();
List<SInternalServicePluginConfiguration> services = getBimServer().getSConverter().convertToSListInternalServicePluginConfiguration(services2);
Collections.sort(services, new SPluginConfigurationComparator());
return services;
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.models.store.InternalServicePluginConfiguration in project BIMserver by opensourceBIM.
the class PluginServiceImpl method updateInternalService.
@Override
public void updateInternalService(SInternalServicePluginConfiguration internalService) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
InternalServicePluginConfiguration convertFromSObject = session.get(internalService.getOid(), OldQuery.getDefault());
getBimServer().getSConverter().convertFromSObject(internalService, convertFromSObject, session);
session.executeAndCommitAction(new UpdateDatabaseAction<InternalServicePluginConfiguration>(session, getInternalAccessMethod(), convertFromSObject));
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.models.store.InternalServicePluginConfiguration 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.models.store.InternalServicePluginConfiguration 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;
}
Aggregations