use of org.bimserver.interfaces.objects.SInternalServicePluginConfiguration 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.interfaces.objects.SInternalServicePluginConfiguration 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.interfaces.objects.SInternalServicePluginConfiguration 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.interfaces.objects.SInternalServicePluginConfiguration 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.interfaces.objects.SInternalServicePluginConfiguration in project BIMserver by opensourceBIM.
the class BimServer method activateService.
public void activateService(long uoid, InternalServicePluginConfiguration internalServicePluginConfiguration) {
ServicePlugin servicePlugin = getPluginManager().getServicePlugin(internalServicePluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
if (servicePlugin == null) {
LOGGER.warn("Plugin " + internalServicePluginConfiguration.getPluginDescriptor().getPluginClassName() + " not found");
} else {
SInternalServicePluginConfiguration sInternalService = (SInternalServicePluginConfiguration) getSConverter().convertToSObject(internalServicePluginConfiguration);
try {
servicePlugin.unregister(sInternalService);
servicePlugin.register(uoid, sInternalService, new org.bimserver.plugins.PluginConfiguration(internalServicePluginConfiguration.getSettings()));
} catch (Throwable e) {
LOGGER.error("", e);
}
}
}
Aggregations