Search in sources :

Example 1 with DoneListener

use of org.bimserver.plugins.serializers.DoneListener in project BIMserver by opensourceBIM.

the class LongStreamingDownloadAction method getCheckoutResult.

public SCheckoutResult getCheckoutResult() throws SerializerException {
    if (checkoutResult.getFile() != null) {
        // already populated by cached file
        return checkoutResult;
    }
    if (serializer == null) {
        if (messagingStreamingSerializer == null) {
            throw new SerializerException("No serializer");
        } else {
            DataSource dataSource = new MessagingStreamingDataSource(messagingStreamingSerializer);
            checkoutResult.setFile(new DataHandler(dataSource));
        }
    } else {
        if (getBimServer().getNewDiskCacheManager().isEnabled()) {
            NewDiskCacheOutputStream diskCacheOutputStream = getBimServer().getNewDiskCacheManager().startCaching(downloadDescriptor);
            CacheStoringStreamingSerializerDataSource cacheStoringEmfSerializerDataSource = new CacheStoringStreamingSerializerDataSource(serializer, diskCacheOutputStream, new DoneListener() {

                @Override
                public void done() {
                    changeActionState(ActionState.FINISHED, "Done", 100);
                }
            });
            checkoutResult.setFile(new DataHandler(cacheStoringEmfSerializerDataSource));
        } else {
            StreamingSerializerDataSource streamingSerializerDataSource = new StreamingSerializerDataSource(filename, serializer, new DoneListener() {

                @Override
                public void done() {
                    changeActionState(ActionState.FINISHED, "Done", 100);
                }
            });
            checkoutResult.setFile(new DataHandler(streamingSerializerDataSource));
        }
    }
    return checkoutResult;
}
Also used : NewDiskCacheOutputStream(org.bimserver.cache.NewDiskCacheOutputStream) DoneListener(org.bimserver.plugins.serializers.DoneListener) StreamingSerializerDataSource(org.bimserver.plugins.serializers.StreamingSerializerDataSource) CacheStoringStreamingSerializerDataSource(org.bimserver.plugins.serializers.CacheStoringStreamingSerializerDataSource) DataHandler(javax.activation.DataHandler) SerializerException(org.bimserver.plugins.serializers.SerializerException) CacheStoringStreamingSerializerDataSource(org.bimserver.plugins.serializers.CacheStoringStreamingSerializerDataSource) StreamingSerializerDataSource(org.bimserver.plugins.serializers.StreamingSerializerDataSource) CacheStoringStreamingSerializerDataSource(org.bimserver.plugins.serializers.CacheStoringStreamingSerializerDataSource) DataSource(javax.activation.DataSource)

Aggregations

DataHandler (javax.activation.DataHandler)1 DataSource (javax.activation.DataSource)1 NewDiskCacheOutputStream (org.bimserver.cache.NewDiskCacheOutputStream)1 CacheStoringStreamingSerializerDataSource (org.bimserver.plugins.serializers.CacheStoringStreamingSerializerDataSource)1 DoneListener (org.bimserver.plugins.serializers.DoneListener)1 SerializerException (org.bimserver.plugins.serializers.SerializerException)1 StreamingSerializerDataSource (org.bimserver.plugins.serializers.StreamingSerializerDataSource)1