String fileId = diskDescType.getFileRef();
if (!fileIdToFileType.containsKey(fileId))
{
String msg = "File Id [" + fileId + "] not found on the ReferencesSection";
throw new IdNotFoundException(msg);
}
FileType file = fileIdToFileType.get(fileId);
final String filePath = file.getHref();
final Long fileSize = file.getSize().longValue();
String format = diskDescType.getFormat(); // XXX using the same format on the OVF
// disk
if (!diskIdToVSs.containsKey(diskId))
{
throw new IdNotFoundException("Any virtualSystem is using diskId[" + diskId
+ "]"); // XXX warning ??
}
if (diskIdToVSs.size() != 1)
{
throw new AMException(AMError.TEMPLATE_INVALID, String.format(
"There are more than one virtual system on the OVF Envelope [%s]", ovfId));
}
for (String vssName : diskIdToVSs.get(diskId))
{
diskInfo = new TemplateDto();
diskInfo.setName(vssName);
diskInfo.setUrl(ovfId);
diskInfo.setLoginUser(getProductPropertyValue(product, "user"));
diskInfo.setLoginPassword(getProductPropertyValue(product, "password"));
diskInfo.setOsType(getOSType(ossection));
diskInfo.setOsVersion(getOSVersion(ossection));
DiskFormat diskFormat = DiskFormat.fromValue(format);
DiskFormatType ovfDiskFormat = DiskFormatType.valueOf(diskFormat.name());
diskInfo.setDiskFileFormat(ovfDiskFormat);
diskInfo.setDiskFileSize(fileSize);
// Note that getHRef() will now return the relative path
// of the file at the downloaded repository space
if (filePath.startsWith("http:"))
{
diskInfo.setDiskFilePath(FilenameUtils.getName(filePath));
}
else
{
diskInfo.setDiskFilePath(filePath);
}
diskInfo.setIconPath(iconPath);
diskInfo.setDescription(description);
diskInfo.setCategoryName(categoryName);
// XXX diskInfo.setSO(value);
if (!requiredByVSs.containsKey(vssName))
{
throw new IdNotFoundException("VirtualSystem id not found [" + vssName
+ "]");
}
TemplateDto requirement = requiredByVSs.get(vssName);