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;
}
Aggregations