Exemplo n.º 1
0
        public CrcMismatchException(string message, long specifiedCrc, long calculatedCrc, bool isCriticalError, Exception innerException) : base(message, innerException)
        {
            this.SpecifiedCrc    = specifiedCrc;
            this.CalculatedCrc   = calculatedCrc;
            this.IsCriticalError = isCriticalError;
            if (isCriticalError)
            {
                TimeSpan?nullable = null;
                AlertsManager.AlertOrLogException(string.Format("Hit CrcMismatchException with message:{0} SpecifiedCrc:{1} CalculatedCrc:{2}", message, specifiedCrc, calculatedCrc), message, nullable);
                return;
            }
            IStringDataEventStream error = Logger <IRestProtocolHeadLogger> .Instance.Error;

            object[] objArray = new object[] { message, specifiedCrc, calculatedCrc };
            error.Log("Hit CrcMismatchException with message:{0} SpecifiedCrc:{1} CalculatedCrc:{2}", objArray);
        }
Exemplo n.º 2
0
        protected override void EncodeEntry(Uri requestUrl, ListBlobsOperationContext lboc, IListBlobResultsBlobProperties blobProps, XmlWriter xmlWriter)
        {
            string str;
            string httpString;
            string eTag;

            if (!blobProps.IsActualBlob)
            {
                xmlWriter.WriteStartElement("BlobPrefix");
                this.WriteElementString(xmlWriter, "Name", blobProps.BlobName);
            }
            else
            {
                xmlWriter.WriteStartElement("Blob");
                this.WriteElementString(xmlWriter, "Name", blobProps.BlobName);
                if (lboc.IsIncludingSnapshots && blobProps.Snapshot != DateTime.MaxValue)
                {
                    this.WriteElementString(xmlWriter, "Snapshot", HttpUtilities.ConvertSnapshotDateTimeToHttpString(blobProps.Snapshot));
                }
                if (lboc.ListingAcrossContainers)
                {
                    NephosAssertionException.Assert(!string.IsNullOrEmpty(blobProps.ContainerName), string.Concat("XStore didn't return us valid ContainerName for this blob ", blobProps.BlobName, " when we are listing blobs across the account"));
                    this.WriteElementString(xmlWriter, "ContainerName", blobProps.ContainerName);
                }
                if (lboc.IsIncludingUrlInResponse)
                {
                    string empty = string.Empty;
                    if (lboc.ListingAcrossContainers)
                    {
                        empty = string.Concat("/", blobProps.ContainerName);
                    }
                    string str1 = string.Concat(HttpRequestAccessorCommon.TrimEndSlash(requestUrl.GetLeftPart(UriPartial.Path)), empty);
                    string str2 = HttpRequestAccessorCommon.TrimRootContainerNameFromEnd(str1, true);
                    string str3 = string.Concat(str2, "/", blobProps.BlobName);
                    if (lboc.IsIncludingSnapshots && blobProps.Snapshot != DateTime.MaxValue)
                    {
                        str3 = string.Concat(str3, HttpUtilities.GetSnapshotQueryParameterStringForUrl(blobProps.Snapshot));
                    }
                    this.WriteElementString(xmlWriter, "Url", str3);
                }
                if (lboc.IsUsingPropertiesElement)
                {
                    xmlWriter.WriteStartElement("Properties");
                }
                string str4  = (lboc.IsUsingPropertiesElement ? "Last-Modified" : "LastModified");
                string str5  = (lboc.IsUsingPropertiesElement ? "Content-Length" : "Size");
                string str6  = (lboc.IsUsingPropertiesElement ? "Content-Type" : "ContentType");
                string str7  = (lboc.IsUsingPropertiesElement ? "Content-Encoding" : "ContentEncoding");
                string str8  = (lboc.IsUsingPropertiesElement ? "Content-Language" : "ContentLanguage");
                string str9  = (lboc.IsUsingPropertiesElement ? "Cache-Control" : "CacheControl");
                string str10 = (lboc.IsUsingPropertiesElement ? "Content-MD5" : "ContentMD5");
                bool   value = blobProps.LastModifiedTime.Value > DateTimeConstants.MinimumBlobLastModificationTime;
                if (value)
                {
                    XmlWriter xmlWriter1 = xmlWriter;
                    string    str11      = str4;
                    if (blobProps.LastModifiedTime.HasValue)
                    {
                        httpString = HttpUtilities.ConvertDateTimeToHttpString(blobProps.LastModifiedTime.Value);
                    }
                    else
                    {
                        httpString = null;
                    }
                    this.WriteElementString(xmlWriter1, str11, httpString);
                    XmlWriter xmlWriter2 = xmlWriter;
                    if (blobProps.LastModifiedTime.HasValue)
                    {
                        DateTime?lastModifiedTime = blobProps.LastModifiedTime;
                        eTag = BasicHttpProcessor.GetETag(lastModifiedTime.Value, this.shouldEncloseEtagsInQuotes);
                    }
                    else
                    {
                        eTag = null;
                    }
                    this.WriteElementString(xmlWriter2, "Etag", eTag);
                }
                XmlWriter xmlWriter3 = xmlWriter;
                string    str12      = str5;
                if (blobProps.ContentLength.HasValue)
                {
                    str = blobProps.ContentLength.Value.ToString(CultureInfo.InvariantCulture);
                }
                else
                {
                    str = null;
                }
                this.WriteElementString(xmlWriter3, str12, str);
                if (value)
                {
                    this.WriteElementString(xmlWriter, str6, blobProps.ContentType);
                    this.WriteElementString(xmlWriter, str7, blobProps.ContentEncoding);
                    this.WriteElementString(xmlWriter, str8, blobProps.ContentLanguage);
                    if (lboc.IsIncludingCrc64InResponse)
                    {
                        this.WriteElementString(xmlWriter, "Content-CRC64", blobProps.ContentCrc64);
                    }
                    if (lboc.IsUsingPropertiesElement)
                    {
                        this.WriteElementString(xmlWriter, str10, blobProps.ContentMD5);
                    }
                    if (lboc.IsIncludingCacheControlInResponse)
                    {
                        this.WriteElementString(xmlWriter, str9, blobProps.CacheControl);
                    }
                    if (lboc.IsIncludingContentDispositionInResponse)
                    {
                        this.WriteElementString(xmlWriter, "Content-Disposition", blobProps.ContentDisposition);
                    }
                }
                if (lboc.IsIncludingBlobTypeInResponse)
                {
                    if (blobProps.SequenceNumber.HasValue)
                    {
                        long num = blobProps.SequenceNumber.Value;
                        this.WriteElementString(xmlWriter, "x-ms-blob-sequence-number", num.ToString());
                    }
                    this.WriteElementString(xmlWriter, "BlobType", blobProps.BlobType);
                }
                if (lboc.IsIncludingLeaseStatusInResponse && blobProps.Snapshot == DateTime.MaxValue)
                {
                    this.WriteElementString(xmlWriter, "LeaseStatus", blobProps.LeaseStatus);
                    if (lboc.IsIncludingLeaseStateAndDurationInResponse)
                    {
                        if (!string.IsNullOrEmpty(blobProps.LeaseState))
                        {
                            this.WriteElementString(xmlWriter, "LeaseState", blobProps.LeaseState);
                        }
                        if (!string.IsNullOrEmpty(blobProps.LeaseDuration))
                        {
                            this.WriteElementString(xmlWriter, "LeaseDuration", blobProps.LeaseDuration);
                        }
                    }
                }
                if (lboc.IsIncludingCopyPropertiesInResponse)
                {
                    if (!string.IsNullOrEmpty(blobProps.CopyId))
                    {
                        this.WriteElementString(xmlWriter, "CopyId", blobProps.CopyId);
                    }
                    if (!string.IsNullOrEmpty(blobProps.CopySource))
                    {
                        this.WriteElementString(xmlWriter, "CopySource", (this.obfuscateSourceUri ? HttpUtilities.ObfuscateSourceUri(blobProps.CopySource) : blobProps.CopySource));
                    }
                    if (!string.IsNullOrEmpty(blobProps.CopyStatus))
                    {
                        this.WriteElementString(xmlWriter, "CopyStatus", blobProps.CopyStatus);
                    }
                    if (!string.IsNullOrEmpty(blobProps.CopyStatusDescription))
                    {
                        this.WriteElementString(xmlWriter, "CopyStatusDescription", blobProps.CopyStatusDescription);
                    }
                    if (!string.IsNullOrEmpty(blobProps.CopyProgress))
                    {
                        this.WriteElementString(xmlWriter, "CopyProgress", blobProps.CopyProgress);
                    }
                    if (blobProps.CopyCompletionTime.HasValue && !string.IsNullOrEmpty(blobProps.CopyStatus) && !blobProps.CopyStatus.Equals("pending", StringComparison.OrdinalIgnoreCase))
                    {
                        DateTime?copyCompletionTime = blobProps.CopyCompletionTime;
                        this.WriteElementString(xmlWriter, "CopyCompletionTime", HttpUtilities.ConvertDateTimeToHttpString(copyCompletionTime.Value));
                    }
                }
                if (lboc.IsIncludingIncrementalCopy && blobProps.IsIncrementalCopy)
                {
                    this.WriteElementString(xmlWriter, "IncrementalCopy", "true");
                    if (blobProps.LastCopySnapshot.HasValue && !string.IsNullOrEmpty(blobProps.CopyStatus) && blobProps.CopyStatus.Equals("success", StringComparison.OrdinalIgnoreCase))
                    {
                        if (blobProps.LastCopySnapshot.Value <= DateTimeConstants.MinimumIncrementalCopySnapshotTime)
                        {
                            AlertsManager.AlertOrLogException("LastCopySnapshot set to Minimum value, while a valid timestamp was expected.", null, null);
                        }
                        DateTime?lastCopySnapshot = blobProps.LastCopySnapshot;
                        this.WriteElementString(xmlWriter, "CopyDestinationSnapshot", HttpUtilities.ConvertSnapshotDateTimeToHttpString(lastCopySnapshot.Value));
                    }
                }
                if (lboc.IsIncludingEncryption)
                {
                    this.WriteElementString(xmlWriter, "ServerEncrypted", (!blobProps.IsBlobEncrypted.HasValue || !blobProps.IsBlobEncrypted.Value ? "false" : "true"));
                }
                if (lboc.IsUsingPropertiesElement)
                {
                    xmlWriter.WriteEndElement();
                }
                if (value && lboc.IsFetchingMetadata)
                {
                    MetadataEncoding.WriteMetadataToXml(xmlWriter, blobProps.Metadata, true, lboc.RequestVersion);
                }
            }
            xmlWriter.WriteEndElement();
        }
Exemplo n.º 3
0
        public ListContainersResultContainerProperties(IBaseBlobContainer container)
        {
            long num;

            if (container == null)
            {
                throw new ArgumentNullException("container");
            }
            this.containerName = container.ContainerName;
            NephosAssertionException.Assert(container.LastModificationTime.HasValue);
            this.lastModifiedTime = container.LastModificationTime;
            if (container.ApplicationMetadata != null)
            {
                this.applicationMetadata = new NameValueCollection();
                try
                {
                    MetadataEncoding.Decode(container.ApplicationMetadata, this.applicationMetadata);
                }
                catch (MetadataFormatException metadataFormatException1)
                {
                    MetadataFormatException metadataFormatException = metadataFormatException1;
                    CultureInfo             invariantCulture        = CultureInfo.InvariantCulture;
                    object[] objArray = new object[] { this.containerName };
                    throw new NephosStorageDataCorruptionException(string.Format(invariantCulture, "Error decoding application metadata for container {0}", objArray), metadataFormatException);
                }
            }
            if (container.LeaseInfo != null)
            {
                if (container.LeaseInfo.Type == LeaseType.ReadWrite && container.LeaseInfo.Duration.HasValue)
                {
                    TimeSpan?duration = container.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 (container.LeaseInfo.State.HasValue)
                {
                    this.leaseState = LeaseStateStrings.LeaseStates[(int)container.LeaseInfo.State.Value];
                    if (container.LeaseInfo.State.Equals(Microsoft.Cis.Services.Nephos.Common.Storage.LeaseState.Leased))
                    {
                        TimeSpan?nullable = container.LeaseInfo.Duration;
                        TimeSpan timeSpan = TimeSpan.FromSeconds(4294967295);
                        if ((!nullable.HasValue ? true : nullable.GetValueOrDefault() != timeSpan))
                        {
                            this.leaseDuration = "fixed";
                        }
                        else
                        {
                            this.leaseDuration = "infinite";
                        }
                    }
                }
            }
            if (container.ServiceMetadata != null)
            {
                NameValueCollection nameValueCollection = new NameValueCollection();
                try
                {
                    MetadataEncoding.Decode(container.ServiceMetadata, nameValueCollection);
                }
                catch (MetadataFormatException metadataFormatException3)
                {
                    MetadataFormatException metadataFormatException2 = metadataFormatException3;
                    CultureInfo             cultureInfo = CultureInfo.InvariantCulture;
                    object[] objArray1 = new object[] { this.containerName };
                    throw new NephosStorageDataCorruptionException(string.Format(cultureInfo, "Error decoding service metadata for container {0}", objArray1), metadataFormatException2);
                }
                this.containerQuotaInGB = (long)RealServiceManager.MaxShareQuotaInGBPriorToLargeFileShareFeature;
                string str = nameValueCollection.Get(RealServiceManager.XSmbContainerQuotaMetadataName);
                if (str != null)
                {
                    if (!long.TryParse(str, out num) || num < (long)RealServiceManager.MinShareQuotaInGB || num > this.containerQuotaInGB)
                    {
                        TimeSpan?nullable1 = null;
                        AlertsManager.AlertOrLogException(string.Format("Invalid XsmbContainerQuota retrieved from servicemetadata for account {0}: {1}", this.accountNameForLogging, str), "InvalidXSMBContainerQuota", nullable1);
                    }
                    else
                    {
                        this.containerQuotaInGB = num;
                    }
                }
                string str1 = nameValueCollection.Get("PublicAccess");
                string str2 = nameValueCollection.Get("PublicAccess1");
                if (str1 != null)
                {
                    this.publicAccessLevel = str1;
                    return;
                }
                if (str2 != null)
                {
                    this.publicAccessLevel = str2;
                }
            }
        }