Search in sources :

Example 1 with MessagingStreamingSerializerPlugin

use of org.bimserver.plugins.serializers.MessagingStreamingSerializerPlugin 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

IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 MessagingException (javax.mail.MessagingException)1 AddressException (javax.mail.internet.AddressException)1 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)1 DatabaseSession (org.bimserver.database.DatabaseSession)1 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)1 SUser (org.bimserver.interfaces.objects.SUser)1 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)1 DownloadParameters (org.bimserver.longaction.DownloadParameters)1 LongStreamingDownloadAction (org.bimserver.longaction.LongStreamingDownloadAction)1 SerializerPluginConfiguration (org.bimserver.models.store.SerializerPluginConfiguration)1 User (org.bimserver.models.store.User)1 Plugin (org.bimserver.plugins.Plugin)1 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)1 DeserializerPlugin (org.bimserver.plugins.deserializers.DeserializerPlugin)1 StreamingDeserializerPlugin (org.bimserver.plugins.deserializers.StreamingDeserializerPlugin)1 QueryEnginePlugin (org.bimserver.plugins.queryengine.QueryEnginePlugin)1 MessagingSerializerPlugin (org.bimserver.plugins.serializers.MessagingSerializerPlugin)1