Beispiel #1
0
 public Stream DownloadOVFFile()
 {
     try
     {
         Stream stream = (Stream)null;
         if (this.Resource.Link != null)
         {
             foreach (LinkType linkType in this.Resource.Link)
             {
                 if (linkType.rel.Equals("download:default"))
                 {
                     stream = RestUtil.DownloadFile(this.VcloudClient, linkType.href);
                     break;
                 }
             }
         }
         if (stream == null)
         {
             throw new VCloudException(SdkUtil.GetI18nString(SdkMessage.NO_DOWNLOAD_LINK_MSG));
         }
         return(stream);
     }
     catch (Exception ex)
     {
         throw new VCloudException(ex.Message);
     }
 }
Beispiel #2
0
 public Stream DownloadLosslessOVF()
 {
     foreach (LinkType linkType in this.Resource.Link)
     {
         if (linkType.rel.Equals("download:identity"))
         {
             return(RestUtil.DownloadFile(this.VcloudClient, linkType.href));
         }
     }
     throw new VCloudException(SdkUtil.GetI18nString(SdkMessage.NO_DOWNLOAD_LINK_MSG));
 }
Beispiel #3
0
 public Stream GetSchemaDefinition(string schemaFileName)
 {
     try
     {
         Logger.Log(TraceLevel.Information, SdkUtil.GetI18nString(SdkMessage.GET_SCHEMA_DEFINITION) + " - " + schemaFileName);
         return(RestUtil.DownloadFile(this, this.VCloudApiURL + "/v1.5/schema/" + schemaFileName));
     }
     catch (Exception ex)
     {
         throw new VCloudException(ex.Message);
     }
 }
Beispiel #4
0
 private Stream DownloadFile(string fileName, string href)
 {
     try
     {
         if (!this.GetDownloadFileNames().ContainsKey(fileName))
         {
             throw new VCloudException(SdkUtil.GetI18nString(SdkMessage.FILE_NOT_FOUND_MSG));
         }
         return(RestUtil.DownloadFile(this.VcloudClient, href.Replace("descriptor.ovf", fileName)));
     }
     catch (Exception ex)
     {
         throw new VCloudException(ex.Message);
     }
 }
Beispiel #5
0
 private Stream DownloadFile()
 {
     if (this.Resource.Files != null)
     {
         foreach (ResourceType resourceType in this.Resource.Files.File)
         {
             foreach (LinkType linkType in resourceType.Link)
             {
                 if (linkType.rel.Equals("download:default"))
                 {
                     return(RestUtil.DownloadFile(this.VcloudClient, linkType.href));
                 }
             }
         }
     }
     throw new VCloudException(SdkUtil.GetI18nString(SdkMessage.NO_DOWNLOAD_LINK_MSG));
 }
Beispiel #6
0
 private EnvelopeType DownloadOvfEnvelope()
 {
     try
     {
         if (this.Resource.Link != null)
         {
             foreach (LinkType linkType in this.Resource.Link)
             {
                 if (linkType.rel.Equals("download:default"))
                 {
                     return(SerializationUtil.DeserializeObject <EnvelopeType>(RestUtil.DownloadFile(this.VcloudClient, linkType.href), "com.vmware.vcloud.api.rest.schema"));
                 }
             }
         }
         throw new VCloudException(SdkUtil.GetI18nString(SdkMessage.NO_DOWNLOAD_LINK_MSG));
     }
     catch (Exception ex)
     {
         throw new VCloudException(ex.Message);
     }
 }