Search in sources :

Example 1 with SetPluginSettingsDatabaseAction

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();
    }
}
Also used : SObjectType(org.bimserver.interfaces.objects.SObjectType) ObjectType(org.bimserver.models.store.ObjectType) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) ServicePlugin(org.bimserver.plugins.services.ServicePlugin) SetPluginSettingsDatabaseAction(org.bimserver.database.actions.SetPluginSettingsDatabaseAction) DatabaseSession(org.bimserver.database.DatabaseSession) InternalServicePluginConfiguration(org.bimserver.models.store.InternalServicePluginConfiguration) SInternalServicePluginConfiguration(org.bimserver.interfaces.objects.SInternalServicePluginConfiguration) SRenderEnginePluginConfiguration(org.bimserver.interfaces.objects.SRenderEnginePluginConfiguration) SObjectIDMPluginConfiguration(org.bimserver.interfaces.objects.SObjectIDMPluginConfiguration) PluginConfiguration(org.bimserver.models.store.PluginConfiguration) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) SQueryEnginePluginConfiguration(org.bimserver.interfaces.objects.SQueryEnginePluginConfiguration) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) ModelComparePluginConfiguration(org.bimserver.models.store.ModelComparePluginConfiguration) QueryEnginePluginConfiguration(org.bimserver.models.store.QueryEnginePluginConfiguration) WebModulePluginConfiguration(org.bimserver.models.store.WebModulePluginConfiguration) InternalServicePluginConfiguration(org.bimserver.models.store.InternalServicePluginConfiguration) SInternalServicePluginConfiguration(org.bimserver.interfaces.objects.SInternalServicePluginConfiguration) DeserializerPluginConfiguration(org.bimserver.models.store.DeserializerPluginConfiguration) ModelMergerPluginConfiguration(org.bimserver.models.store.ModelMergerPluginConfiguration) SModelComparePluginConfiguration(org.bimserver.interfaces.objects.SModelComparePluginConfiguration) SWebModulePluginConfiguration(org.bimserver.interfaces.objects.SWebModulePluginConfiguration) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) RenderEnginePluginConfiguration(org.bimserver.models.store.RenderEnginePluginConfiguration) SModelMergerPluginConfiguration(org.bimserver.interfaces.objects.SModelMergerPluginConfiguration) SInternalServicePluginConfiguration(org.bimserver.interfaces.objects.SInternalServicePluginConfiguration) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Aggregations

IOException (java.io.IOException)1 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)1 DatabaseSession (org.bimserver.database.DatabaseSession)1 SetPluginSettingsDatabaseAction (org.bimserver.database.actions.SetPluginSettingsDatabaseAction)1 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)1 SInternalServicePluginConfiguration (org.bimserver.interfaces.objects.SInternalServicePluginConfiguration)1 SModelComparePluginConfiguration (org.bimserver.interfaces.objects.SModelComparePluginConfiguration)1 SModelMergerPluginConfiguration (org.bimserver.interfaces.objects.SModelMergerPluginConfiguration)1 SObjectIDMPluginConfiguration (org.bimserver.interfaces.objects.SObjectIDMPluginConfiguration)1 SObjectType (org.bimserver.interfaces.objects.SObjectType)1 SQueryEnginePluginConfiguration (org.bimserver.interfaces.objects.SQueryEnginePluginConfiguration)1 SRenderEnginePluginConfiguration (org.bimserver.interfaces.objects.SRenderEnginePluginConfiguration)1 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)1 SWebModulePluginConfiguration (org.bimserver.interfaces.objects.SWebModulePluginConfiguration)1 DeserializerPluginConfiguration (org.bimserver.models.store.DeserializerPluginConfiguration)1 InternalServicePluginConfiguration (org.bimserver.models.store.InternalServicePluginConfiguration)1 ModelComparePluginConfiguration (org.bimserver.models.store.ModelComparePluginConfiguration)1 ModelMergerPluginConfiguration (org.bimserver.models.store.ModelMergerPluginConfiguration)1 ObjectType (org.bimserver.models.store.ObjectType)1 PluginConfiguration (org.bimserver.models.store.PluginConfiguration)1