use of org.bimserver.database.actions.SetPluginSettingsDatabaseAction 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();
}
}
Aggregations