Esempio n. 1
0
        public static void ValidatePutBlockListArguments(IBlobObject blob, long contentLength, byte[] applicationMetadata, byte[][] blockIdList, BlockSource[] blockSourceList, byte[] md5, IBlobObjectCondition condition, BlobServiceVersion blobServiceVersion)
        {
            if (blob.Snapshot != StorageStampHelpers.RootBlobSnapshotVersion)
            {
                throw new XStoreArgumentException("This operation is only supported on the root blob.");
            }
            if (contentLength < (long)-1)
            {
                throw new ArgumentOutOfRangeException("contentLength", "contentLength must be >= -1");
            }
            if (contentLength > 5242880000000L)
            {
                throw new BlobContentTooLargeException(new long?(5242880000000L), null, null);
            }
            StorageStampHelpers.ValidateApplicationMetadata(applicationMetadata);
            if (blockSourceList != null && blobServiceVersion < BlobServiceVersion.July09)
            {
                throw new XStoreArgumentException("blockSourceList is only allowed for verisons STG18 and up.");
            }
            int num  = (blockIdList != null ? (int)blockIdList.Length : 0);
            int num1 = (blockSourceList != null ? (int)blockSourceList.Length : 0);

            if (blockIdList != null && blockSourceList != null && num != num1)
            {
                string str = string.Format("blockIdList (length {0}) and blockSourceList (length {1}) must be of the same length.", num, num1);
                throw new XStoreArgumentException(str);
            }
            if ((long)num > (long)50000)
            {
                throw new BlockListTooLongException();
            }
            StorageStampHelpers.ValidateMD5(md5);
        }
Esempio n. 2
0
        public IAsyncResult BeginSynchronousCopyBlob(string sourceAccount, IBlobObject sourceBlob, DateTime?expiryTime, byte[] applicationMetadata, OverwriteOption overwriteOption, IBlobObjectCondition sourceCondition, IBlobObjectCondition destinationCondition, UriString copySource, AsyncCallback callback, object state)
        {
            AsyncIteratorContext <CopyBlobOperationInfo> asyncIteratorContext = new AsyncIteratorContext <CopyBlobOperationInfo>("RealBlobObject.SynchronousCopyBlob", callback, state);

            asyncIteratorContext.Begin(this.SynchronousCopyBlobImpl(sourceAccount, sourceBlob, expiryTime, applicationMetadata, overwriteOption, sourceCondition, destinationCondition, copySource, asyncIteratorContext));
            return(asyncIteratorContext);
        }
Esempio n. 3
0
 public static void ValidatePutBlockArguments(IBlobObject blob, byte[] blockIdentifier, long contentLength, byte[] contentMD5, IBlobObjectCondition condition, bool isLargeBlockBlobRequest)
 {
     if (blob.Snapshot != StorageStampHelpers.RootBlobSnapshotVersion)
     {
         throw new XStoreArgumentException("This operation is only supported on the root blob.");
     }
     if ((int)blockIdentifier.Length <= 0 || (int)blockIdentifier.Length > 64)
     {
         throw new XStoreArgumentOutOfRangeException("blockIdentifier");
     }
     if (contentLength <= (long)0)
     {
         throw new ArgumentOutOfRangeException("contentLength", "contentLength must be > 0");
     }
     if (!isLargeBlockBlobRequest && contentLength > (long)4194304)
     {
         throw new BlobContentTooLargeException(new long?((long)4194304), null, null);
     }
     StorageStampHelpers.ValidateMD5(contentMD5);
     if (condition != null)
     {
         if (condition.IfModifiedSinceTime.HasValue)
         {
             throw new XStoreArgumentException("PutBlock does not support IfModifiedSince as a condition. Only LeaseId is supported as part of the condition for PutBlock.");
         }
         if (condition.IfNotModifiedSinceTime.HasValue)
         {
             throw new XStoreArgumentException("PutBlock does not support IfNotModifiedSince as a condition. Only LeaseId is supported as part of the condition for PutBlock.");
         }
     }
 }
Esempio n. 4
0
 private static void ValidateMaxBlobSizeForPutBlob(IBlobObject blob, long?maxBlobSize)
 {
     if (blob.Type == BlobType.ListBlob)
     {
         if (maxBlobSize.HasValue)
         {
             throw new XStoreArgumentException("The maximum blob size is not valid for a BlockBlob.");
         }
         return;
     }
     if (blob.Type == BlobType.IndexBlob)
     {
         if (!maxBlobSize.HasValue)
         {
             throw new XStoreArgumentException("The maximum blob size must be set for a PageBlob.");
         }
         if (maxBlobSize.Value < (long)0 || maxBlobSize.Value > 8796093022208L)
         {
             throw new XStoreArgumentOutOfRangeException("maxBlobSize", string.Format("The maximum PageBlob size must be between {0} and {1} bytes.", (long)0, 8796093022208L));
         }
         if (maxBlobSize.Value % (long)512 != (long)0)
         {
             string str = string.Format("The maximum blob size ({0}) does not fall on a page boundary.", maxBlobSize.Value);
             throw new XStoreArgumentException(str);
         }
     }
 }
Esempio n. 5
0
        IBlobObject Microsoft.Cis.Services.Nephos.Common.Storage.IBlobContainer.CreateBaseBlobObjectInstance(string blobName, DateTime snapshot, BlobServiceVersion version)
        {
            IBlobObject baseBlobObject;

            try
            {
                IBlobObject blobObject = this.InternalContainer.CreateBaseBlobObjectInstance(blobName, snapshot, version);
                baseBlobObject = new BaseBlobObject(blobObject);
            }
            catch (Exception exception)
            {
                StorageStamp.TranslateException(exception);
                throw;
            }
            return(baseBlobObject);
        }
Esempio n. 6
0
        public static void ValidatePutBlobArguments(IBlobObject blob, long contentLength, long?maxBlobSize, byte[] applicationMetadata, byte[] contentMD5, ISequenceNumberUpdate sequenceNumberUpdate, OverwriteOption overwriteOption, IBlobObjectCondition condition, bool isLargeBlockBlobRequest, bool is8TBPageBlobAllowed)
        {
            if (blob.Snapshot != StorageStampHelpers.RootBlobSnapshotVersion)
            {
                throw new XStoreArgumentException("This operation is only supported on the root blob.");
            }
            long num = 1099511627776L;

            if (contentLength < (long)0)
            {
                throw new ArgumentOutOfRangeException("contentLength", "contentLength must be >= 0");
            }
            if (blob.Type == BlobType.ListBlob && !isLargeBlockBlobRequest && contentLength > (long)67108864)
            {
                throw new BlobContentTooLargeException(new long?((long)67108864), null, null);
            }
            if (blob.Type == BlobType.IndexBlob && maxBlobSize.Value > num)
            {
                throw new BlobContentTooLargeException(new long?(num), null, null);
            }
            StorageStampHelpers.ValidateMaxBlobSizeForPutBlob(blob, maxBlobSize);
            StorageStampHelpers.ValidateApplicationMetadata(applicationMetadata);
            if (contentMD5 != null && (long)((int)contentMD5.Length) != (long)16)
            {
                throw new MD5InvalidException();
            }
            if (sequenceNumberUpdate != null)
            {
                if (blob.Type != BlobType.IndexBlob)
                {
                    throw new XStoreArgumentException("sequenceNumberUpdate only allowed for PageBlob");
                }
                if (sequenceNumberUpdate.UpdateType != SequenceNumberUpdateType.Update)
                {
                    throw new XStoreArgumentException("sequenceNumberUpdate can only have type Update for PutBlob.");
                }
                if (sequenceNumberUpdate.SequenceNumber < (long)0 || sequenceNumberUpdate.SequenceNumber > 9223372036854775807L)
                {
                    throw new XStoreArgumentException("sequenceNumberUpdate sequence number must be >= 0 and < Int64.MaxValue.");
                }
            }
        }
Esempio n. 7
0
        public ListBlobResultsBlobProperties(IBlobObject blobObject, string separator)
        {
            if (blobObject == null)
            {
                throw new ArgumentNullException("blobObject");
            }
            this.blobName      = blobObject.Name;
            this.containerName = blobObject.ContainerName;
            if (separator == null || blobObject.Type != Microsoft.Cis.Services.Nephos.Common.Storage.BlobType.None)
            {
                this.isActualBlob = true;
                this.contentType  = blobObject.ContentType;
                NephosAssertionException.Assert(blobObject.LastModificationTime.HasValue);
                NephosAssertionException.Assert(blobObject.ContentLength.HasValue);
                this.lastModifiedTime = blobObject.LastModificationTime;
                this.size             = blobObject.ContentLength;
                NameValueCollection nameValueCollection = null;
                if (blobObject.ServiceMetadata != null)
                {
                    nameValueCollection = new NameValueCollection();
                    try
                    {
                        MetadataEncoding.Decode(blobObject.ServiceMetadata, nameValueCollection);
                    }
                    catch (MetadataFormatException metadataFormatException1)
                    {
                        MetadataFormatException metadataFormatException = metadataFormatException1;
                        CultureInfo             invariantCulture        = CultureInfo.InvariantCulture;
                        object[] objArray = new object[] { this.blobName };
                        throw new NephosStorageDataCorruptionException(string.Format(invariantCulture, "Error decoding service metadata for blob {0}", objArray), metadataFormatException);
                    }
                    this.contentEncoding    = nameValueCollection[RealServiceManager.ContentEncodingTag];
                    this.contentLanguage    = nameValueCollection[RealServiceManager.ContentLanguageTag];
                    this.cacheControl       = nameValueCollection[RealServiceManager.CacheControlTag];
                    this.contentCrc64       = nameValueCollection[RealServiceManager.ContentCrc64Tag];
                    this.contentMD5         = nameValueCollection[RealServiceManager.ContentMD5Tag];
                    this.contentDisposition = nameValueCollection[RealServiceManager.ContentDispositionTag];
                    if (this.contentMD5 != null && this.contentMD5.Equals(RealServiceManager.EmptyContentMD5Value, StringComparison.OrdinalIgnoreCase))
                    {
                        this.contentMD5 = null;
                    }
                    this.copyId                = nameValueCollection[RealServiceManager.CopyIdTag];
                    this.copySource            = nameValueCollection[RealServiceManager.CopySourceTag];
                    this.copyStatus            = nameValueCollection[RealServiceManager.CopyStatusTag];
                    this.copyStatusDescription = nameValueCollection[RealServiceManager.CopyStatusDescriptionTag];
                    if (!string.IsNullOrEmpty(nameValueCollection[RealServiceManager.CopyProgressOffsetTag]) && !string.IsNullOrEmpty(nameValueCollection[RealServiceManager.CopyProgressTotalTag]))
                    {
                        this.copyProgress = string.Format("{0}/{1}", nameValueCollection[RealServiceManager.CopyProgressOffsetTag], nameValueCollection[RealServiceManager.CopyProgressTotalTag]);
                    }
                    this.copyCompletionTime = RealServiceManager.ParseDateTimeFromString(nameValueCollection[RealServiceManager.CopyCompletionTimeTag]);
                }
                if (blobObject.ApplicationMetadata != null)
                {
                    this.metadata = new NameValueCollection();
                    try
                    {
                        MetadataEncoding.Decode(blobObject.ApplicationMetadata, this.metadata);
                    }
                    catch (MetadataFormatException metadataFormatException3)
                    {
                        MetadataFormatException metadataFormatException2 = metadataFormatException3;
                        CultureInfo             cultureInfo = CultureInfo.InvariantCulture;
                        object[] objArray1 = new object[] { this.blobName };
                        throw new NephosStorageDataCorruptionException(string.Format(cultureInfo, "Error decoding application metadata for blob {0}", objArray1), metadataFormatException2);
                    }
                }
                this.blobType = BlobTypeStrings.GetString(blobObject.Type);
                if (blobObject.LeaseInfo != null)
                {
                    if (blobObject.LeaseInfo.Type == LeaseType.ReadWrite && blobObject.LeaseInfo.Duration.HasValue)
                    {
                        TimeSpan?duration = blobObject.LeaseInfo.Duration;
                        TimeSpan zero     = TimeSpan.Zero;
                        if ((duration.HasValue ? duration.GetValueOrDefault() <= zero : true))
                        {
                            goto Label1;
                        }
                        this.leaseStatus = "locked";
                        goto Label0;
                    }
Label1:
                    this.leaseStatus = "unlocked";
Label0:
                    if (blobObject.LeaseInfo.State.HasValue)
                    {
                        this.leaseState = LeaseStateStrings.LeaseStates[(int)blobObject.LeaseInfo.State.Value];
                        if (blobObject.LeaseInfo.State.Equals(Microsoft.Cis.Services.Nephos.Common.Storage.LeaseState.Leased))
                        {
                            TimeSpan?nullable = blobObject.LeaseInfo.Duration;
                            TimeSpan timeSpan = TimeSpan.FromSeconds(4294967295);
                            if ((!nullable.HasValue ? true : nullable.GetValueOrDefault() != timeSpan))
                            {
                                this.leaseDuration = "fixed";
                            }
                            else
                            {
                                this.leaseDuration = "infinite";
                            }
                        }
                    }
                }
                this.snapshot = blobObject.Snapshot;
                if (blobObject.Type != Microsoft.Cis.Services.Nephos.Common.Storage.BlobType.IndexBlob)
                {
                    this.sequenceNumber = null;
                }
                else
                {
                    NephosAssertionException.Assert(blobObject.SequenceNumber.HasValue, "SequenceNumber must be present for PageBlob's.");
                    this.sequenceNumber = blobObject.SequenceNumber;
                }
                this.isBlobEncrypted   = blobObject.IsBlobEncrypted;
                this.isIncrementalCopy = blobObject.IsIncrementalCopy;
                if (this.isIncrementalCopy && nameValueCollection != null)
                {
                    this.lastCopySnapshot = RealServiceManager.ParseDateTimeFromString(nameValueCollection[RealServiceManager.LastCopySnapshotTag]);
                }
            }
        }
Esempio n. 8
0
 public IndexBlobObject(IBlobObject blob) : base(blob)
 {
 }
Esempio n. 9
0
 public BaseBlobObject(IBlobObject blob)
 {
     this.blob = blob;
 }
Esempio n. 10
0
        private IEnumerator <IAsyncResult> SynchronousCopyBlobImpl(string sourceAccount, IBlobObject sourceBlob, DateTime?expiryTime, byte[] applicationMetadata, OverwriteOption overwriteOption, IBlobObjectCondition sourceCondition, IBlobObjectCondition destinationCondition, UriString copySource, AsyncIteratorContext <CopyBlobOperationInfo> context)
        {
            IAsyncResult asyncResult;

            try
            {
                asyncResult = this.blob.BeginSynchronousCopyBlob(sourceAccount, ((BaseBlobObject)sourceBlob).blob, StorageStampHelpers.AdjustNullableDatetimeRange(expiryTime), applicationMetadata, overwriteOption, Helpers.Convert(sourceCondition), Helpers.Convert(destinationCondition), copySource, context.GetResumeCallback(), context.GetResumeState("IBlobObject.BeginSynchronousCopyBlob"));
            }
            catch (Exception exception)
            {
                StorageStamp.TranslateException(exception);
                throw;
            }
            yield return(asyncResult);

            CopyBlobOperationInfo copyBlobOperationInfo = null;

            try
            {
                copyBlobOperationInfo = this.blob.EndSynchronousCopyBlob(asyncResult);
            }
            catch (Exception exception1)
            {
                StorageStamp.TranslateException(exception1);
                throw;
            }
            context.ResultData = copyBlobOperationInfo;
        }
Esempio n. 11
0
 public static void ValidatePutBlockArguments(IBlobObject blob, byte[] blockIdentifier, long contentLength, byte[] contentMD5, IBlobObjectCondition condition)
 {
     StorageStampHelpers.ValidatePutBlockArguments(blob, blockIdentifier, contentLength, contentMD5, condition, false);
 }
Esempio n. 12
0
 public static void ValidatePutBlobArguments(IBlobObject blob, long contentLength, long?maxBlobSize, byte[] applicationMetadata, byte[] contentMD5, ISequenceNumberUpdate sequenceNumberUpdate, OverwriteOption overwriteOption, IBlobObjectCondition condition)
 {
     StorageStampHelpers.ValidatePutBlobArguments(blob, contentLength, maxBlobSize, applicationMetadata, contentMD5, sequenceNumberUpdate, overwriteOption, condition, false, false);
 }