Search in sources :

Example 1 with SInternalServicePluginConfiguration

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();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) InternalServicePluginConfiguration(org.bimserver.models.store.InternalServicePluginConfiguration) SInternalServicePluginConfiguration(org.bimserver.interfaces.objects.SInternalServicePluginConfiguration) UserException(org.bimserver.shared.exceptions.UserException) 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)

Example 2 with SInternalServicePluginConfiguration

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();
    }
}
Also used : SPluginConfigurationComparator(org.bimserver.webservices.SPluginConfigurationComparator) DatabaseSession(org.bimserver.database.DatabaseSession) UserSettings(org.bimserver.models.store.UserSettings) InternalServicePluginConfiguration(org.bimserver.models.store.InternalServicePluginConfiguration) SInternalServicePluginConfiguration(org.bimserver.interfaces.objects.SInternalServicePluginConfiguration) 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)

Example 3 with SInternalServicePluginConfiguration

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();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) InternalServicePluginConfiguration(org.bimserver.models.store.InternalServicePluginConfiguration) 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)

Example 4 with SInternalServicePluginConfiguration

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();
    }
}
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)

Example 5 with SInternalServicePluginConfiguration

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);
        }
    }
}
Also used : ServicePlugin(org.bimserver.plugins.services.ServicePlugin) SInternalServicePluginConfiguration(org.bimserver.interfaces.objects.SInternalServicePluginConfiguration)

Aggregations

SInternalServicePluginConfiguration (org.bimserver.interfaces.objects.SInternalServicePluginConfiguration)5 IOException (java.io.IOException)4 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)4 DatabaseSession (org.bimserver.database.DatabaseSession)4 InternalServicePluginConfiguration (org.bimserver.models.store.InternalServicePluginConfiguration)4 ServerException (org.bimserver.shared.exceptions.ServerException)4 UserException (org.bimserver.shared.exceptions.UserException)4 ServicePlugin (org.bimserver.plugins.services.ServicePlugin)2 SetPluginSettingsDatabaseAction (org.bimserver.database.actions.SetPluginSettingsDatabaseAction)1 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)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 ModelComparePluginConfiguration (org.bimserver.models.store.ModelComparePluginConfiguration)1