Search in sources :

Example 56 with BimserverDatabaseException

use of org.bimserver.BimserverDatabaseException in project BIMserver by opensourceBIM.

the class PluginServiceImpl method getDefaultObjectIDM.

public SObjectIDMPluginConfiguration getDefaultObjectIDM() throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        UserSettings settings = getUserSettings(session);
        return getBimServer().getSConverter().convertToSObject(settings.getDefaultObjectIDM());
    } catch (BimserverDatabaseException e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : BimserverDatabaseException(org.bimserver.BimserverDatabaseException) DatabaseSession(org.bimserver.database.DatabaseSession) UserSettings(org.bimserver.models.store.UserSettings)

Example 57 with BimserverDatabaseException

use of org.bimserver.BimserverDatabaseException 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 58 with BimserverDatabaseException

use of org.bimserver.BimserverDatabaseException 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;
}
Also used : AttributeCondition(org.bimserver.database.query.conditions.AttributeCondition) Condition(org.bimserver.database.query.conditions.Condition) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) User(org.bimserver.models.store.User) StringLiteral(org.bimserver.database.query.literals.StringLiteral) DatabaseSession(org.bimserver.database.DatabaseSession) InternalServicePluginConfiguration(org.bimserver.models.store.InternalServicePluginConfiguration) ArrayList(java.util.ArrayList) AttributeCondition(org.bimserver.database.query.conditions.AttributeCondition) SProfileDescriptor(org.bimserver.interfaces.objects.SProfileDescriptor)

Example 59 with BimserverDatabaseException

use of org.bimserver.BimserverDatabaseException in project BIMserver by opensourceBIM.

the class RemoteServiceImpl method getPublicProfiles.

@Override
public List<SProfileDescriptor> getPublicProfiles(String serviceIdentifier) throws UserException, ServerException {
    DatabaseSession session = getServiceMap().getBimServer().getDatabase().createSession();
    List<SProfileDescriptor> descriptors = new ArrayList<SProfileDescriptor>();
    try {
        IfcModelInterface modelInterface = session.getAllOfType(StorePackage.eINSTANCE.getInternalServicePluginConfiguration(), OldQuery.getDefault());
        for (InternalServicePluginConfiguration internalServicePluginConfiguration : modelInterface.getAll(InternalServicePluginConfiguration.class)) {
            if (internalServicePluginConfiguration.isPublicProfile()) {
                if (serviceIdentifier.equals("" + internalServicePluginConfiguration.getOid())) {
                    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;
}
Also used : BimserverDatabaseException(org.bimserver.BimserverDatabaseException) DatabaseSession(org.bimserver.database.DatabaseSession) IfcModelInterface(org.bimserver.emf.IfcModelInterface) InternalServicePluginConfiguration(org.bimserver.models.store.InternalServicePluginConfiguration) ArrayList(java.util.ArrayList) SProfileDescriptor(org.bimserver.interfaces.objects.SProfileDescriptor)

Example 60 with BimserverDatabaseException

use of org.bimserver.BimserverDatabaseException in project BIMserver by opensourceBIM.

the class ServiceImpl method download.

public Long download(DownloadParameters downloadParameters, Boolean sync) throws ServerException, UserException {
    requireAuthenticationAndRunningServer();
    User user = null;
    for (long roid : downloadParameters.getRoids()) {
        getAuthorization().canDownload(roid);
    }
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        user = (User) session.get(StorePackage.eINSTANCE.getUser(), getAuthorization().getUoid(), OldQuery.getDefault());
    } catch (BimserverDatabaseException e) {
        throw new UserException(e);
    } finally {
        session.close();
    }
    LongDownloadOrCheckoutAction longDownloadAction = new LongDownloadAction(getBimServer(), user == null ? "Unknown" : user.getName(), user == null ? "Unknown" : user.getUsername(), downloadParameters, getAuthorization(), getInternalAccessMethod());
    try {
        getBimServer().getLongActionManager().start(longDownloadAction);
    } catch (Exception e) {
        LOGGER.error("", e);
    }
    if (sync) {
        longDownloadAction.waitForCompletion();
    }
    return longDownloadAction.getProgressTopic().getKey().getId();
}
Also used : LongDownloadAction(org.bimserver.longaction.LongDownloadAction) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) LongDownloadOrCheckoutAction(org.bimserver.longaction.LongDownloadOrCheckoutAction) SUser(org.bimserver.interfaces.objects.SUser) User(org.bimserver.models.store.User) DatabaseSession(org.bimserver.database.DatabaseSession) UserException(org.bimserver.shared.exceptions.UserException) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException)

Aggregations

BimserverDatabaseException (org.bimserver.BimserverDatabaseException)123 DatabaseSession (org.bimserver.database.DatabaseSession)56 UserException (org.bimserver.shared.exceptions.UserException)30 EClass (org.eclipse.emf.ecore.EClass)24 User (org.bimserver.models.store.User)20 ByteBuffer (java.nio.ByteBuffer)19 BimserverLockConflictException (org.bimserver.database.BimserverLockConflictException)18 ServerSettings (org.bimserver.models.store.ServerSettings)18 IOException (java.io.IOException)16 ServerSettingsSetter (org.bimserver.database.actions.ServerSettingsSetter)16 SetServerSettingDatabaseAction (org.bimserver.database.actions.SetServerSettingDatabaseAction)16 SServerSettings (org.bimserver.interfaces.objects.SServerSettings)16 ServerException (org.bimserver.shared.exceptions.ServerException)15 UserSettings (org.bimserver.models.store.UserSettings)12 ServiceException (org.bimserver.shared.exceptions.ServiceException)11 HashMapVirtualObject (org.bimserver.shared.HashMapVirtualObject)10 ArrayList (java.util.ArrayList)9 IdEObject (org.bimserver.emf.IdEObject)9 Project (org.bimserver.models.store.Project)9 SerializerPluginConfiguration (org.bimserver.models.store.SerializerPluginConfiguration)9