Search in sources :

Example 11 with Plugin

use of org.bimserver.plugins.Plugin in project BIMserver by opensourceBIM.

the class AddInternalServiceDatabaseAction method execute.

@Override
public Long execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    User user = getDatabaseSession().get(StorePackage.eINSTANCE.getUser(), authorization.getUoid(), OldQuery.getDefault());
    InternalServicePluginConfiguration idEObject = getIdEObject();
    idEObject.setUserSettings(user.getUserSettings());
    Plugin plugin = bimServer.getPluginManager().getPlugin(idEObject.getPluginDescriptor().getIdentifier(), true);
    ObjectType settings = bimServer.convertSettings(getDatabaseSession(), plugin);
    user.getUserSettings().getServices().add(idEObject);
    idEObject.setSettings(settings);
    getDatabaseSession().store(user.getUserSettings());
    return super.execute();
}
Also used : ObjectType(org.bimserver.models.store.ObjectType) User(org.bimserver.models.store.User) InternalServicePluginConfiguration(org.bimserver.models.store.InternalServicePluginConfiguration) Plugin(org.bimserver.plugins.Plugin)

Example 12 with Plugin

use of org.bimserver.plugins.Plugin in project BIMserver by opensourceBIM.

the class ServiceImpl method download.

@Override
public Long download(Set<Long> roids, String jsonQuery, Long serializerOid, Boolean sync) throws ServerException, UserException {
    try {
        User user = null;
        DatabaseSession session = getBimServer().getDatabase().createSession();
        Plugin plugin = null;
        try {
            SerializerPluginConfiguration serializerPluginConfiguration = session.get(StorePackage.eINSTANCE.getSerializerPluginConfiguration(), serializerOid, OldQuery.getDefault());
            plugin = getBimServer().getPluginManager().getPlugin(serializerPluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
            user = (User) session.get(StorePackage.eINSTANCE.getUser(), getAuthorization().getUoid(), OldQuery.getDefault());
        } catch (BimserverDatabaseException e) {
            throw new UserException(e);
        } finally {
            session.close();
        }
        if (plugin instanceof StreamingSerializerPlugin || plugin instanceof MessagingStreamingSerializerPlugin) {
            LongStreamingDownloadAction longDownloadAction = new LongStreamingDownloadAction(getBimServer(), user == null ? "Unknown" : user.getName(), user == null ? "Unknown" : user.getUsername(), getAuthorization(), serializerOid, jsonQuery, roids);
            try {
                getBimServer().getLongActionManager().start(longDownloadAction);
            } catch (Exception e) {
                LOGGER.error("", e);
            }
            if (sync) {
                longDownloadAction.waitForCompletion();
            }
            return longDownloadAction.getProgressTopic().getKey().getId();
        } else if (plugin instanceof MessagingSerializerPlugin) {
            requireAuthenticationAndRunningServer();
            DownloadParameters downloadParameters = new DownloadParameters(getBimServer(), DownloadType.DOWNLOAD_BY_NEW_JSON_QUERY);
            downloadParameters.setRoids(roids);
            downloadParameters.setJsonQuery(jsonQuery);
            downloadParameters.setSerializerOid(serializerOid);
            return download(downloadParameters, sync);
        } else if (plugin instanceof SerializerPlugin) {
            requireAuthenticationAndRunningServer();
            DownloadParameters downloadParameters = new DownloadParameters(getBimServer(), DownloadType.DOWNLOAD_BY_NEW_JSON_QUERY);
            downloadParameters.setRoids(roids);
            downloadParameters.setJsonQuery(jsonQuery);
            downloadParameters.setSerializerOid(serializerOid);
            return download(downloadParameters, sync);
        } else {
            throw new UserException("Unimplemented");
        }
    } catch (Exception e) {
        return handleException(e);
    }
}
Also used : MessagingSerializerPlugin(org.bimserver.plugins.serializers.MessagingSerializerPlugin) SUser(org.bimserver.interfaces.objects.SUser) User(org.bimserver.models.store.User) DatabaseSession(org.bimserver.database.DatabaseSession) MessagingStreamingSerializerPlugin(org.bimserver.plugins.serializers.MessagingStreamingSerializerPlugin) LongStreamingDownloadAction(org.bimserver.longaction.LongStreamingDownloadAction) StreamingSerializerPlugin(org.bimserver.plugins.serializers.StreamingSerializerPlugin) MessagingSerializerPlugin(org.bimserver.plugins.serializers.MessagingSerializerPlugin) MessagingStreamingSerializerPlugin(org.bimserver.plugins.serializers.MessagingStreamingSerializerPlugin) SerializerPlugin(org.bimserver.plugins.serializers.SerializerPlugin) StreamingSerializerPlugin(org.bimserver.plugins.serializers.StreamingSerializerPlugin) MessagingStreamingSerializerPlugin(org.bimserver.plugins.serializers.MessagingStreamingSerializerPlugin) 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) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) UserException(org.bimserver.shared.exceptions.UserException) StreamingSerializerPlugin(org.bimserver.plugins.serializers.StreamingSerializerPlugin) QueryEnginePlugin(org.bimserver.plugins.queryengine.QueryEnginePlugin) MessagingSerializerPlugin(org.bimserver.plugins.serializers.MessagingSerializerPlugin) StreamingDeserializerPlugin(org.bimserver.plugins.deserializers.StreamingDeserializerPlugin) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) MessagingStreamingSerializerPlugin(org.bimserver.plugins.serializers.MessagingStreamingSerializerPlugin) SerializerPlugin(org.bimserver.plugins.serializers.SerializerPlugin) Plugin(org.bimserver.plugins.Plugin) DownloadParameters(org.bimserver.longaction.DownloadParameters)

Aggregations

Plugin (org.bimserver.plugins.Plugin)12 DatabaseSession (org.bimserver.database.DatabaseSession)6 ModelCheckerPlugin (org.bimserver.plugins.modelchecker.ModelCheckerPlugin)6 SerializerPlugin (org.bimserver.plugins.serializers.SerializerPlugin)6 StreamingSerializerPlugin (org.bimserver.plugins.serializers.StreamingSerializerPlugin)6 ServicePlugin (org.bimserver.plugins.services.ServicePlugin)6 WebModulePlugin (org.bimserver.plugins.web.WebModulePlugin)6 ServerException (org.bimserver.shared.exceptions.ServerException)6 UserException (org.bimserver.shared.exceptions.UserException)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)5 PluginDescriptor (org.bimserver.models.store.PluginDescriptor)5 DeserializerPlugin (org.bimserver.plugins.deserializers.DeserializerPlugin)5 StreamingDeserializerPlugin (org.bimserver.plugins.deserializers.StreamingDeserializerPlugin)5 QueryEnginePlugin (org.bimserver.plugins.queryengine.QueryEnginePlugin)5 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)4 SerializerPluginConfiguration (org.bimserver.models.store.SerializerPluginConfiguration)4 InternalServicePluginConfiguration (org.bimserver.models.store.InternalServicePluginConfiguration)3 Project (org.bimserver.models.store.Project)3