コード例 #1
0
  @Override
  protected void readDiskImageItem(XmlNode node) {
    final Guid guid = new Guid(node.SelectSingleNode("rasd:InstanceId", _xmlNS).innerText);

    DiskImage image =
        LinqUtils.firstOrNull(
            _images,
            new Predicate<DiskImage>() {
              @Override
              public boolean eval(DiskImage diskImage) {
                return diskImage.getImageId().equals(guid);
              }
            });
    image.setId(
        OvfParser.GetImageGrupIdFromImageFile(
            node.SelectSingleNode("rasd:HostResource", _xmlNS).innerText));
    if (StringUtils.isNotEmpty(node.SelectSingleNode("rasd:Parent", _xmlNS).innerText)) {
      image.setParentId(new Guid(node.SelectSingleNode("rasd:Parent", _xmlNS).innerText));
    }
    if (StringUtils.isNotEmpty(node.SelectSingleNode("rasd:Template", _xmlNS).innerText)) {
      image.setImageTemplateId(new Guid(node.SelectSingleNode("rasd:Template", _xmlNS).innerText));
    }
    image.setAppList(node.SelectSingleNode("rasd:ApplicationList", _xmlNS).innerText);
    if (StringUtils.isNotEmpty(node.SelectSingleNode("rasd:StorageId", _xmlNS).innerText)) {
      image.setStorageIds(
          new ArrayList<Guid>(
              Arrays.asList(new Guid(node.SelectSingleNode("rasd:StorageId", _xmlNS).innerText))));
    }
    if (StringUtils.isNotEmpty(node.SelectSingleNode("rasd:StoragePoolId", _xmlNS).innerText)) {
      image.setStoragePoolId(
          new Guid(node.SelectSingleNode("rasd:StoragePoolId", _xmlNS).innerText));
    }
    final Date creationDate =
        OvfParser.UtcDateStringToLocaDate(
            node.SelectSingleNode("rasd:CreationDate", _xmlNS).innerText);
    if (creationDate != null) {
      image.setCreationDate(creationDate);
    }
    final Date lastModified =
        OvfParser.UtcDateStringToLocaDate(
            node.SelectSingleNode("rasd:LastModified", _xmlNS).innerText);
    if (lastModified != null) {
      image.setLastModified(lastModified);
    }
    readManagedVmDevice(node, image.getId());
  }