private static CobaltStore GetCobaltStore(WacRequest wacRequest) { CachedAttachmentInfo attachmentInfo = WacRequestHandler.GetCachedAttachmentInfo(wacRequest); CobaltStore cobaltStore = attachmentInfo.CobaltStore; if (cobaltStore == null) { lock (attachmentInfo) { cobaltStore = attachmentInfo.CobaltStore; if (cobaltStore == null) { WacRequestHandler.ProcessAttachment(wacRequest, PropertyOpenMode.ReadOnly, delegate(IExchangePrincipal exchangePrincipal, Attachment attachment, Stream stream, bool contentProtected) { if (!WacRequestHandler.MessageIsDraft(wacRequest)) { throw new NotSupportedException("Cell storage requests are only supported for draft items."); } cobaltStore = WacRequestHandler.CreateCobaltStore(exchangePrincipal, attachment, wacRequest, attachmentInfo); }); attachmentInfo.CobaltStore = cobaltStore; } } } return(cobaltStore); }
private static void ProcessGetFileRequest(HttpContext context, WacRequest wacRequest, RequestDetailsLogger logger) { WacRequestHandler.UpdateAttachment(wacRequest, logger); WacRequestHandler.ProcessAttachment(wacRequest, PropertyOpenMode.ReadOnly, delegate(IExchangePrincipal exchangePrincipal, Attachment attachment, Stream stream, bool contentProtected) { WacUtilities.WriteStreamBody(context.Response, stream); }); }
private static void ProcessCheckFileRequest(HttpContext context, WacRequest wacRequest, RequestDetailsLogger logger) { WacRequestHandler.UpdateAttachment(wacRequest, logger); CachedAttachmentInfo cachedAttachmentInfo = WacRequestHandler.GetCachedAttachmentInfo(wacRequest); string attachmentStreamHash = null; long attachmentStreamLength = 0L; string attachmentFileName = null; string attachmentExtension = null; bool attachmentIsProtected = false; WacRequestHandler.ProcessAttachment(wacRequest, PropertyOpenMode.ReadOnly, delegate(IExchangePrincipal exchangePrincipal, Attachment attachment, Stream stream, bool isProtected) { attachmentStreamHash = WacUtilities.GenerateSHA256HashForStream(stream); attachmentStreamLength = stream.Length; attachmentFileName = attachment.FileName; attachmentExtension = attachment.FileExtension; attachmentIsProtected = isProtected; }); WacFileRep wacFileRep = wacRequest.WacFileRep; string downloadUrl = WacRequestHandler.GetDownloadUrl(context.Request, wacFileRep, wacRequest); WacCheckFileResponse wacCheckFileResponse = new WacCheckFileResponse(attachmentFileName, attachmentStreamLength, attachmentStreamHash, downloadUrl, cachedAttachmentInfo.MailboxSmtpAddress, cachedAttachmentInfo.LogonSmtpAddress, cachedAttachmentInfo.LogonDisplayName, cachedAttachmentInfo.LogonPuid, attachmentIsProtected, wacFileRep.DirectFileAccessEnabled, wacFileRep.WacExternalServicesEnabled, wacFileRep.OMEXEnabled); if (wacFileRep.IsEdit) { wacCheckFileResponse.UserCanWrite = true; wacCheckFileResponse.ReadOnly = false; wacCheckFileResponse.SupportsUpdate = true; wacCheckFileResponse.SupportsLocks = true; wacCheckFileResponse.SupportsCobalt = true; wacCheckFileResponse.SupportsFolders = true; } DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(typeof(WacCheckFileResponse)); using (MemoryStream memoryStream = new MemoryStream()) { dataContractJsonSerializer.WriteObject(memoryStream, wacCheckFileResponse); memoryStream.Position = 0L; context.Response.OutputStream.Write(memoryStream.GetBuffer(), 0, (int)memoryStream.Length); } }