Search in sources :

Example 6 with SerializerPluginConfiguration

use of org.bimserver.models.store.SerializerPluginConfiguration in project BIMserver by opensourceBIM.

the class PluginServiceImpl method addSerializer.

@Override
public Long addSerializer(SSerializerPluginConfiguration serializer) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        SerializerPluginConfiguration convert = getBimServer().getSConverter().convertFromSObject(serializer, session);
        return session.executeAndCommitAction(new AddSerializerDatabaseAction(session, getInternalAccessMethod(), getAuthorization(), convert));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : AddSerializerDatabaseAction(org.bimserver.database.actions.AddSerializerDatabaseAction) DatabaseSession(org.bimserver.database.DatabaseSession) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Example 7 with SerializerPluginConfiguration

use of org.bimserver.models.store.SerializerPluginConfiguration in project BIMserver by opensourceBIM.

the class LongDownloadOrCheckoutAction method executeAction.

protected void executeAction(BimDatabaseAction<? extends IfcModelInterface> action, DownloadParameters downloadParameters, DatabaseSession session, boolean commit) throws BimserverDatabaseException, UserException, NoSerializerFoundException, ServerException {
    try {
        if (action == null) {
            checkoutResult = new SCheckoutResult();
            checkoutResult.setFile(new CachingDataHandler(getBimServer().getDiskCacheManager(), downloadParameters));
            checkoutResult.setSerializerOid(downloadParameters.getSerializerOid());
        } else {
            Revision revision = session.get(StorePackage.eINSTANCE.getRevision(), downloadParameters.getRoid(), OldQuery.getDefault());
            if (revision == null) {
                throw new UserException("Revision with roid " + downloadParameters.getRoid() + " not found");
            }
            // Little hack to make
            revision.getProject().getGeoTag().load();
            // sure this is
            // lazily loaded,
            // because after the
            // executeAndCommitAction
            // the session won't
            // be usable
            IfcModelInterface ifcModel = session.executeAndCommitAction(action);
            // Session is closed after this
            DatabaseSession newSession = getBimServer().getDatabase().createSession();
            RenderEnginePlugin renderEnginePlugin = null;
            try {
                PluginConfiguration serializerPluginConfiguration = newSession.get(StorePackage.eINSTANCE.getPluginConfiguration(), downloadParameters.getSerializerOid(), OldQuery.getDefault());
                if (serializerPluginConfiguration != null) {
                    if (serializerPluginConfiguration instanceof MessagingSerializerPluginConfiguration) {
                        try {
                            messagingSerializer = getBimServer().getSerializerFactory().createMessagingSerializer(getUserName(), ifcModel, downloadParameters);
                        } catch (SerializerException e) {
                            e.printStackTrace();
                        }
                    } else if (serializerPluginConfiguration instanceof SerializerPluginConfiguration) {
                        RenderEnginePluginConfiguration renderEngine = ((SerializerPluginConfiguration) serializerPluginConfiguration).getRenderEngine();
                        if (renderEngine != null) {
                            renderEnginePlugin = getBimServer().getPluginManager().getRenderEnginePlugin(renderEngine.getPluginDescriptor().getPluginClassName(), true);
                        }
                        checkoutResult = convertModelToCheckoutResult(revision.getProject(), getUserName(), ifcModel, renderEnginePlugin, downloadParameters);
                    }
                }
            } catch (BimserverDatabaseException e) {
                LOGGER.error("", e);
            } finally {
                newSession.close();
            }
        }
    } finally {
        done();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) IfcModelInterface(org.bimserver.emf.IfcModelInterface) SCheckoutResult(org.bimserver.interfaces.objects.SCheckoutResult) RenderEnginePlugin(org.bimserver.plugins.renderengine.RenderEnginePlugin) SerializerException(org.bimserver.plugins.serializers.SerializerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) RenderEnginePluginConfiguration(org.bimserver.models.store.RenderEnginePluginConfiguration) Revision(org.bimserver.models.store.Revision) MessagingSerializerPluginConfiguration(org.bimserver.models.store.MessagingSerializerPluginConfiguration) RenderEnginePluginConfiguration(org.bimserver.models.store.RenderEnginePluginConfiguration) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) PluginConfiguration(org.bimserver.models.store.PluginConfiguration) MessagingSerializerPluginConfiguration(org.bimserver.models.store.MessagingSerializerPluginConfiguration) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) MessagingSerializerPluginConfiguration(org.bimserver.models.store.MessagingSerializerPluginConfiguration) UserException(org.bimserver.shared.exceptions.UserException)

Example 8 with SerializerPluginConfiguration

use of org.bimserver.models.store.SerializerPluginConfiguration in project BIMserver by opensourceBIM.

the class GetSerializerByContentTypeDatabaseAction method execute.

@Override
public SerializerPluginConfiguration execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    for (SerializerPluginConfiguration serializerPluginConfiguration : getDatabaseSession().getAllOfType(StorePackage.eINSTANCE.getSerializerPluginConfiguration(), SerializerPluginConfiguration.class, OldQuery.getDefault())) {
        PluginConfiguration pluginConfiguration = new PluginConfiguration(serializerPluginConfiguration.getSettings());
        String string = pluginConfiguration.getString(SerializerPlugin.CONTENT_TYPE);
        if (string != null && string.equals(contentType)) {
            return serializerPluginConfiguration;
        }
    }
    return null;
}
Also used : SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) PluginConfiguration(org.bimserver.plugins.PluginConfiguration)

Example 9 with SerializerPluginConfiguration

use of org.bimserver.models.store.SerializerPluginConfiguration in project BIMserver by opensourceBIM.

the class GetSerializerByPluginClassNameDatabaseAction method execute.

@Override
public SerializerPluginConfiguration execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    PluginDescriptor pluginDescriptor = getDatabaseSession().querySingle(StorePackage.eINSTANCE.getPluginDescriptor_PluginClassName(), pluginClassName);
    if (pluginDescriptor == null) {
        throw new UserException("No plugin found with classname " + pluginClassName);
    }
    User user = getUserByUoid(authorization.getUoid());
    UserSettings userSettings = user.getUserSettings();
    for (SerializerPluginConfiguration serializerPluginConfiguration : userSettings.getSerializers()) {
        if (serializerPluginConfiguration.getPluginDescriptor() == pluginDescriptor) {
            return serializerPluginConfiguration;
        }
    }
    throw new UserException("No plugin found for this user with classname " + pluginClassName);
}
Also used : PluginDescriptor(org.bimserver.models.store.PluginDescriptor) User(org.bimserver.models.store.User) UserSettings(org.bimserver.models.store.UserSettings) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) UserException(org.bimserver.shared.exceptions.UserException)

Example 10 with SerializerPluginConfiguration

use of org.bimserver.models.store.SerializerPluginConfiguration in project BIMserver by opensourceBIM.

the class PluginServiceImpl method getAllSerializers.

@Override
public List<SSerializerPluginConfiguration> getAllSerializers(Boolean onlyEnabled) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        UserSettings userSettings = getUserSettings(session);
        List<SSerializerPluginConfiguration> sSerializers = new ArrayList<SSerializerPluginConfiguration>();
        for (SerializerPluginConfiguration serializerPluginConfiguration : userSettings.getSerializers()) {
            if (!onlyEnabled || (serializerPluginConfiguration.getEnabled() && serializerPluginConfiguration.getPluginDescriptor().getEnabled())) {
                sSerializers.add(getBimServer().getSConverter().convertToSObject(serializerPluginConfiguration));
            }
        }
        Collections.sort(sSerializers, new SPluginConfigurationComparator());
        return sSerializers;
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
    return null;
}
Also used : SPluginConfigurationComparator(org.bimserver.webservices.SPluginConfigurationComparator) DatabaseSession(org.bimserver.database.DatabaseSession) UserSettings(org.bimserver.models.store.UserSettings) ArrayList(java.util.ArrayList) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Aggregations

SerializerPluginConfiguration (org.bimserver.models.store.SerializerPluginConfiguration)19 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)14 DatabaseSession (org.bimserver.database.DatabaseSession)13 UserException (org.bimserver.shared.exceptions.UserException)10 IOException (java.io.IOException)7 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)7 UserSettings (org.bimserver.models.store.UserSettings)7 ServerException (org.bimserver.shared.exceptions.ServerException)7 User (org.bimserver.models.store.User)5 PluginConfiguration (org.bimserver.plugins.PluginConfiguration)5 SerializerException (org.bimserver.plugins.serializers.SerializerException)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 MalformedURLException (java.net.MalformedURLException)3 ArrayList (java.util.ArrayList)3 MessagingException (javax.mail.MessagingException)3 AddressException (javax.mail.internet.AddressException)3 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)3 Revision (org.bimserver.models.store.Revision)3 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)3 QueryEnginePlugin (org.bimserver.plugins.queryengine.QueryEnginePlugin)3