@Override
public long downloadPackageBits(ContentContext context, PackageDetailsKey packageDetailsKey,
OutputStream outputStream, boolean resourceExists) {
ContentContextImpl contextImpl = (ContentContextImpl) context; // this has to be of this type, we gave it to the plugin
ContentServerService serverService = getContentServerService();
// we need to load the content to server before we will start download the content
// it is because of timeout on remoteStreams
serverService.preLoadRemoteContent(contextImpl.getResourceId(), packageDetailsKey);
outputStream = remoteOutputStream(outputStream);
long count = 0;
if (resourceExists) {
count = serverService.downloadPackageBitsGivenResource(contextImpl.getResourceId(), packageDetailsKey,
outputStream);
} else {
// TODO: Figure out how to support this; the APIs require the resource to get the bits
}
return count;