// all the disk files should be marked with "snapshot + OVF_BUNDLE_PATH_IDENTIFIER" + hRef
// (packagePath relative)
for (String diskFileId : diskFileIds)
{
FileType file;
try
{
file = OVFReferenceUtils.getReferencedFile(envelope, diskFileId);
}
catch (IdNotFoundException e)
{
throw new AMException(AMError.TEMPLATE_BOUNDLE, String.format(
"The bundle [%s] can not be created because the "
+ "referenced file Id [%s] is not found on the Envelope", snapshot,
diskFileId), e);
}
// TODO check hRef is 'packagePath' relative
final String relativeBundleFileRef = snapshot + file.getHref();
final String absoluteBundleFileRef = packagePath + relativeBundleFileRef;
File bundleFile = new File(absoluteBundleFileRef);
Long bundleFileSize;
if (!bundleFile.exists() || bundleFile.isDirectory())
{
throw new AMException(AMError.TEMPLATE_BOUNDLE, String.format(
"The bundle [%s] can not be created because the "
+ "referenced file on [%s] is not found", snapshot, absoluteBundleFileRef));
}
else
{
// actually exist
bundleFileSize = bundleFile.length(); // Bytes
file.setSize(BigInteger.valueOf(bundleFileSize));
file.setHref(relativeBundleFileRef);
}
for (VirtualDiskDescType vDiskDesc : disks)
{
if (diskFileId.equalsIgnoreCase(vDiskDesc.getFileRef()))