// Token: 0x06001149 RID: 4425 RVA: 0x000478C4 File Offset: 0x00045AC4 public PhotoResponse Retrieve(PhotoRequest request, PhotoResponse response) { PhotoResponse result; using (new StopwatchPerformanceTracker("ADHandlerTotal", request.PerformanceLogger)) { using (new ADPerformanceTracker("ADHandlerTotal", request.PerformanceLogger)) { if (request.ShouldSkipHandlers(PhotoHandlers.ActiveDirectory)) { this.tracer.TraceDebug((long)this.GetHashCode(), "AD HANDLER: skipped by request."); result = response; } else if (response.Served) { this.tracer.TraceDebug((long)this.GetHashCode(), "AD HANDLER: skipped because photo has already been served by an upstream handler."); result = response; } else { response.ADHandlerProcessed = true; request.PerformanceLogger.Log("ADHandlerProcessed", string.Empty, 1U); try { result = this.FindTargetAndReadPhoto(request, response); } catch (ADNoSuchObjectException arg) { this.tracer.TraceDebug <ADNoSuchObjectException>((long)this.GetHashCode(), "AD HANDLER: no photo. Exception: {0}", arg); request.PerformanceLogger.Log("ADHandlerPhotoAvailable", string.Empty, 0U); result = response; } catch (TransientException arg2) { this.tracer.TraceError <TransientException>((long)this.GetHashCode(), "AD HANDLER: transient exception at reading photo. Exception: {0}", arg2); request.PerformanceLogger.Log("ADHandlerError", string.Empty, 1U); throw; } catch (ADOperationException arg3) { this.tracer.TraceError <ADOperationException>((long)this.GetHashCode(), "AD HANDLER: AD exception at reading photo. Exception: {0}", arg3); request.PerformanceLogger.Log("ADHandlerError", string.Empty, 1U); throw; } catch (IOException arg4) { this.tracer.TraceError <IOException>((long)this.GetHashCode(), "AD HANDLER: I/O exception at reading photo. Exception: {0}", arg4); request.PerformanceLogger.Log("ADHandlerError", string.Empty, 1U); throw; } } } } return(result); }
public PhotoResponse Retrieve(PhotoRequest request, PhotoResponse response) { ArgumentValidator.ThrowIfNull("request", request); ArgumentValidator.ThrowIfNull("response", response); PhotoResponse result; using (new StopwatchPerformanceTracker("PrivateHandlerTotal", request.PerformanceLogger)) { using (new StorePerformanceTracker("PrivateHandlerTotal", request.PerformanceLogger)) { if (request.ShouldSkipHandlers(PhotoHandlers.Private)) { this.tracer.TraceDebug((long)this.GetHashCode(), "PRIVATE HANDLER: skipped by request."); result = response; } else if (response.Served) { this.tracer.TraceDebug((long)this.GetHashCode(), "PRIVATE HANDLER: skipped because photo has already been served by an upstream handler."); result = response; } else if (request.RequestorMailboxSession == null) { this.tracer.TraceDebug((long)this.GetHashCode(), "PRIVATE HANDLER: skipped because a session to the requestor's mailbox has NOT been initialized."); result = response; } else { response.PrivateHandlerProcessed = true; request.PerformanceLogger.Log("PrivateHandlerProcessed", string.Empty, 1U); try { result = this.FindContactOrPersonAndServePhoto(request, response); } catch (ObjectNotFoundException arg) { this.tracer.TraceDebug <ObjectNotFoundException>((long)this.GetHashCode(), "PRIVATE HANDLER: photo not found. Exception: {0}", arg); result = response; } catch (StorageTransientException arg2) { this.tracer.TraceError <StorageTransientException>((long)this.GetHashCode(), "PRIVATE HANDLER: transient exception at reading photo. Exception: {0}", arg2); throw; } catch (StoragePermanentException arg3) { this.tracer.TraceError <StoragePermanentException>((long)this.GetHashCode(), "PRIVATE HANDLER: permanent exception at reading photo. Exception: {0}", arg3); throw; } } } } return(result); }
public PhotoResponse Retrieve(PhotoRequest request, PhotoResponse response) { PhotoResponse result; using (new StopwatchPerformanceTracker("FileSystemHandlerTotal", request.PerformanceLogger)) { using (new CpuPerformanceTracker("FileSystemHandlerTotal", request.PerformanceLogger)) { if (request.ShouldSkipHandlers(PhotoHandlers.FileSystem)) { this.tracer.TraceDebug((long)this.GetHashCode(), "FILE SYSTEM HANDLER: skipped by request."); result = response; } else if (response.Served) { this.tracer.TraceDebug((long)this.GetHashCode(), "FILE SYSTEM HANDLER: skipped because photo has already been served by an upstream handler."); result = response; } else if (string.IsNullOrEmpty(request.TargetSmtpAddress)) { this.tracer.TraceError((long)this.GetHashCode(), "FILE SYSTEM HANDLER: skipped because target SMTP address has not been initialized."); result = response; } else if (!this.IsSizeCacheable(request.Size)) { this.tracer.TraceDebug((long)this.GetHashCode(), "FILE SYSTEM HANDLER: skipped because requested size is not cacheable on file system."); result = response; } else { response.FileSystemHandlerProcessed = true; request.PerformanceLogger.Log("FileSystemHandlerProcessed", string.Empty, 1U); try { string photoFullPath = this.ComputeAndStampPhotoFullPathOntoResponse(request, response); if (this.PhotoFileHasExpired(photoFullPath)) { this.tracer.TraceDebug((long)this.GetHashCode(), "FILE SYSTEM HANDLER: photo file doesn't exist or has expired."); response.IsPhotoFileOnFileSystem = false; request.PerformanceLogger.Log("FileSystemHandlerPhotoAvailable", string.Empty, 0U); request.PerformanceLogger.Log("FileSystemHandlerPhotoServed", string.Empty, 0U); result = response; } else { int num = this.ReadThumbprintAndStampOntoResponse(request, response, photoFullPath); this.tracer.TraceDebug <int>((long)this.GetHashCode(), "FILE SYSTEM HANDLER: thumbprint = {0:X8}.", num); if (PhotoThumbprinter.Default.ThumbprintMatchesETag(num, request.ETag)) { result = this.ServePhotoNotModified(request, response); } else { result = this.ReadPhotoFromFileOntoResponse(request, response, photoFullPath); } } } catch (CannotMapInvalidSmtpAddressToPhotoFileException arg) { this.tracer.TraceError <CannotMapInvalidSmtpAddressToPhotoFileException>((long)this.GetHashCode(), "FILE SYSTEM HANDLER: invalid SMTP address cannot be mapped to file system. Exception: {0}", arg); request.PerformanceLogger.Log("FileSystemHandlerError", string.Empty, 1U); result = response; } catch (FileNotFoundException arg2) { this.tracer.TraceDebug <FileNotFoundException>((long)this.GetHashCode(), "FILE SYSTEM HANDLER: no photo. Exception: {0}", arg2); response.IsPhotoFileOnFileSystem = false; request.PerformanceLogger.Log("FileSystemHandlerPhotoAvailable", string.Empty, 0U); result = response; } catch (DirectoryNotFoundException arg3) { this.tracer.TraceDebug <DirectoryNotFoundException>((long)this.GetHashCode(), "FILE SYSTEM HANDLER: no photo. Exception: {0}", arg3); response.IsPhotoFileOnFileSystem = false; request.PerformanceLogger.Log("FileSystemHandlerPhotoAvailable", string.Empty, 0U); result = response; } catch (EndOfStreamException arg4) { this.tracer.TraceDebug <EndOfStreamException>((long)this.GetHashCode(), "FILE SYSTEM HANDLER: no photo. Exception: {0}", arg4); request.PerformanceLogger.Log("FileSystemHandlerPhotoAvailable", string.Empty, 0U); result = response; } catch (IOException arg5) { this.tracer.TraceDebug <IOException>((long)this.GetHashCode(), "FILE SYSTEM HANDLER: I/O exception reading photo, possibly because it's opened with exclusive access by some other process. Exception: {0}", arg5); response.IsPhotoFileOnFileSystem = true; request.PerformanceLogger.Log("FileSystemHandlerPhotoAvailable", string.Empty, 1U); request.PerformanceLogger.Log("FileSystemHandlerError", string.Empty, 1U); result = response; } catch (Win32Exception ex) { switch (ex.NativeErrorCode) { case 2: case 3: this.tracer.TraceDebug <Win32Exception>((long)this.GetHashCode(), "FILE SYSTEM HANDLER: no photo. Exception: {0}", ex); response.IsPhotoFileOnFileSystem = false; request.PerformanceLogger.Log("FileSystemHandlerPhotoAvailable", string.Empty, 0U); return(response); case 5: this.tracer.TraceDebug <Win32Exception>((long)this.GetHashCode(), "FILE SYSTEM HANDLER: cannot read photo because it's opened with exclusive access by some other process. Exception: {0}", ex); response.IsPhotoFileOnFileSystem = true; request.PerformanceLogger.Log("FileSystemHandlerPhotoAvailable", string.Empty, 1U); request.PerformanceLogger.Log("FileSystemHandlerError", string.Empty, 1U); return(response); } this.tracer.TraceDebug <Win32Exception>((long)this.GetHashCode(), "FILE SYSTEM HANDLER: Win32 exception reading photo. Exception: {0}", ex); request.PerformanceLogger.Log("FileSystemHandlerError", string.Empty, 1U); throw; } } } } return(result); }
// Token: 0x060011A6 RID: 4518 RVA: 0x0004A028 File Offset: 0x00048228 public PhotoResponse Retrieve(PhotoRequest request, PhotoResponse response) { ArgumentValidator.ThrowIfNull("request", request); ArgumentValidator.ThrowIfNull("response", response); PhotoResponse result; using (new StopwatchPerformanceTracker("HttpHandlerTotal", request.PerformanceLogger)) { using (new ADPerformanceTracker("HttpHandlerTotal", request.PerformanceLogger)) { if (request.ShouldSkipHandlers(PhotoHandlers.Http)) { this.tracer.TraceDebug((long)this.GetHashCode(), "HTTP HANDLER: skipped by request."); result = response; } else if (response.Served) { this.tracer.TraceDebug((long)this.GetHashCode(), "HTTP HANDLER: skipped because photo has already been served by an upstream handler."); result = response; } else if (request.TargetRecipient == null || !(request.TargetRecipient is ADUser)) { this.tracer.TraceDebug((long)this.GetHashCode(), "HTTP HANDLER: skipped because target recipient has not been initialized OR is of unexpected type."); result = response; } else { response.HttpHandlerProcessed = true; request.PerformanceLogger.Log("HttpHandlerProcessed", string.Empty, 1U); try { HttpWebRequest httpRequestToConfigure = new HttpPhotoRequestBuilder(this.configuration, this.tracer).Build(this.LocatePhotoService(request), request, this.outgoingRequestProxyProvider, request.Trace); using (HttpWebResponse httpWebResponse = this.ConfigureAndSendRequest(request, httpRequestToConfigure)) { result = this.ProcessResponseFromRemoteServer(request, response, httpWebResponse); } } catch (WebException ex) { this.WriteTracesCollectedByRemoteServerOntoLocalTracer(ex.Response); HttpStatusCode httpStatusCodeFromWebException = HttpPhotoHandler.GetHttpStatusCodeFromWebException(ex); this.tracer.TraceDebug <HttpStatusCode, WebExceptionStatus>((long)this.GetHashCode(), "HTTP HANDLER: caught WebException and translated it to HTTP {0}. Web exception status: {1}", httpStatusCodeFromWebException, ex.Status); HttpStatusCode httpStatusCode = httpStatusCodeFromWebException; if (httpStatusCode <= HttpStatusCode.Unauthorized) { if (httpStatusCode == HttpStatusCode.NotModified) { response.Served = true; response.Status = HttpStatusCode.NotModified; response.HttpExpiresHeader = HttpPhotoHandler.GetHeaderValueFromWebException(ex, HttpResponseHeader.Expires); response.ETag = HttpPhotoHandler.GetHeaderValueFromWebException(ex, HttpResponseHeader.ETag); return(response); } if (httpStatusCode == HttpStatusCode.Unauthorized) { response.Status = HttpStatusCode.Unauthorized; request.PerformanceLogger.Log("HttpHandlerError", string.Empty, 1U); return(response); } } else { if (httpStatusCode == HttpStatusCode.NotFound) { response.Served = true; response.Status = HttpStatusCode.NotFound; response.HttpExpiresHeader = HttpPhotoHandler.GetHeaderValueFromWebException(ex, HttpResponseHeader.Expires); return(response); } if (httpStatusCode != HttpStatusCode.InternalServerError) { } } response.Status = HttpStatusCode.InternalServerError; request.PerformanceLogger.Log("HttpHandlerError", string.Empty, 1U); result = response; } catch (BackEndLocatorException arg) { this.tracer.TraceError <BackEndLocatorException>((long)this.GetHashCode(), "HTTP HANDLER: failed to locate service. Exception: {0}", arg); request.PerformanceLogger.Log("HttpHandlerError", string.Empty, 1U); result = response; } catch (IOException arg2) { this.tracer.TraceError <IOException>((long)this.GetHashCode(), "HTTP HANDLER: request to remote server failed with I/O exception: {0}", arg2); request.PerformanceLogger.Log("HttpHandlerError", string.Empty, 1U); result = response; } catch (ProtocolViolationException arg3) { this.tracer.TraceError <ProtocolViolationException>((long)this.GetHashCode(), "HTTP HANDLER: request to remote server failed with a protocol violation. Exception: {0}", arg3); request.PerformanceLogger.Log("HttpHandlerError", string.Empty, 1U); result = response; } catch (InvalidOperationException arg4) { this.tracer.TraceError <InvalidOperationException>((long)this.GetHashCode(), "HTTP HANDLER: request to remote server failed with invalid operation. Exception: {0}", arg4); request.PerformanceLogger.Log("HttpHandlerError", string.Empty, 1U); result = response; } catch (NotSupportedException arg5) { this.tracer.TraceError <NotSupportedException>((long)this.GetHashCode(), "HTTP HANDLER: request to remote server with an unsupported operation. Exception: {0}", arg5); request.PerformanceLogger.Log("HttpHandlerError", string.Empty, 1U); result = response; } catch (TimeoutException arg6) { this.tracer.TraceError <TimeoutException>((long)this.GetHashCode(), "HTTP HANDLER: timed out. Exception: {0}", arg6); request.PerformanceLogger.Log("HttpHandlerError", string.Empty, 1U); result = response; } catch (TransientException arg7) { this.tracer.TraceError <TransientException>((long)this.GetHashCode(), "HTTP HANDLER: failed with a transient error. Exception: {0}", arg7); request.PerformanceLogger.Log("HttpHandlerError", string.Empty, 1U); result = response; } } } } return(result); }
public PhotoResponse Retrieve(PhotoRequest request, PhotoResponse response) { PhotoResponse result; using (new StopwatchPerformanceTracker("CachingHandlerTotal", request.PerformanceLogger)) { using (new CpuPerformanceTracker("CachingHandlerTotal", request.PerformanceLogger)) { if (request.ShouldSkipHandlers(PhotoHandlers.Caching)) { this.tracer.TraceDebug((long)this.GetHashCode(), "CACHING HANDLER: skipped by request."); result = response; } else if (response.ServerCacheHit) { this.tracer.TraceDebug((long)this.GetHashCode(), "CACHING HANDLER: skipped because photo is already cached on the server."); result = response; } else if (response.IsPhotoFileOnFileSystem) { this.tracer.TraceDebug((long)this.GetHashCode(), "CACHING HANDLER: skipped because photo file is already on the file system."); result = response; } else if (response.Status == HttpStatusCode.NotModified) { this.tracer.TraceDebug((long)this.GetHashCode(), "CACHING HANDLER: NOT MODIFIED. Skipped because requestor (client) already has the photo cached."); result = response; } else if (!this.IsSizeCacheable(request.Size)) { this.tracer.TraceDebug((long)this.GetHashCode(), "CACHING HANDLER: skipped because size is not cacheable."); result = response; } else if (CachingPhotoHandler.UserNotFound(request)) { this.tracer.TraceDebug((long)this.GetHashCode(), "CACHING HANDLER: skipped because target user has not been found."); result = response; } else { try { this.ComputeAndStampPhotoFullPathOntoResponse(request, response); if (string.IsNullOrEmpty(response.PhotoFullPathOnFileSystem)) { this.tracer.TraceDebug((long)this.GetHashCode(), "CACHING HANDLER: cannot cache because path on filesystem has NOT been initialized and could NOT be computed."); result = response; } else if (this.NoPhoto(response)) { result = this.NegativeCacheToFileSystem(request, response); } else { result = this.CacheToFileSystem(request, response); } } catch (CannotMapInvalidSmtpAddressToPhotoFileException arg) { this.tracer.TraceError <CannotMapInvalidSmtpAddressToPhotoFileException>((long)this.GetHashCode(), "CACHING HANDLER: invalid SMTP address cannot be mapped to file system. Exception: {0}", arg); result = response; } catch (IOException arg2) { this.tracer.TraceError <string, IOException>((long)this.GetHashCode(), "CACHING HANDLER: I/O failure writing photo at {0}. Exception: {1}", response.PhotoFullPathOnFileSystem, arg2); result = response; } catch (UnauthorizedAccessException arg3) { this.tracer.TraceError <string, UnauthorizedAccessException>((long)this.GetHashCode(), "CACHING HANDLER: authorization failure writing photo at {0}. Exception: {1}", response.PhotoFullPathOnFileSystem, arg3); throw; } catch (Win32Exception arg4) { this.tracer.TraceDebug <Win32Exception>((long)this.GetHashCode(), "CACHING HANDLER: Win32 exception writing photo. Exception: {0}", arg4); result = response; } } } } return(result); }
public PhotoResponse Retrieve(PhotoRequest request, PhotoResponse response) { PhotoResponse result; using (new StopwatchPerformanceTracker("MailboxHandlerTotal", request.PerformanceLogger)) { using (new StorePerformanceTracker("MailboxHandlerTotal", request.PerformanceLogger)) { if (request.ShouldSkipHandlers(PhotoHandlers.Mailbox)) { this.tracer.TraceDebug((long)this.GetHashCode(), "MAILBOX HANDLER: skipped by request."); result = response; } else if (response.Served) { this.tracer.TraceDebug((long)this.GetHashCode(), "MAILBOX HANDLER: skipped because photo has already been served by an upstream handler."); result = response; } else { response.MailboxHandlerProcessed = true; request.PerformanceLogger.Log("MailboxHandlerProcessed", string.Empty, 1U); try { this.ComputeTargetPrincipalAndStampOntoRequest(request); if (request.TargetPrincipal == null) { this.tracer.TraceDebug((long)this.GetHashCode(), "MAILBOX HANDLER: skipped because target principal has not been initialized and could not be computed."); result = response; } else { this.tracer.TraceDebug <ExchangePrincipal, SmtpAddress>((long)this.GetHashCode(), "MAILBOX HANDLER: target principal: {0}; PRIMARY SMTP address: {1}", request.TargetPrincipal, request.TargetPrincipal.MailboxInfo.PrimarySmtpAddress); using (DisposeGuard disposeGuard = default(DisposeGuard)) { bool forceReloadThumbprint = true; IMailboxSession mailboxSession = request.HostOwnedTargetMailboxSessionGetter(request.TargetPrincipal); if (mailboxSession == null) { this.tracer.TraceDebug <ExchangePrincipal>((long)this.GetHashCode(), "MAILBOX HANDLER: opening session to mailbox of user {0}", request.TargetPrincipal); mailboxSession = this.CreateMailboxSession(request); disposeGuard.Add <IMailboxSession>(mailboxSession); forceReloadThumbprint = false; } int num = this.ReadThumbprintAndStampOntoResponse(request, response, mailboxSession, forceReloadThumbprint); this.tracer.TraceDebug <int>((long)this.GetHashCode(), "MAILBOX HANDLER: read photo thumbprint = {0:X8}", num); if (PhotoThumbprinter.Default.ThumbprintMatchesETag(num, request.ETag)) { result = this.ServePhotoNotModified(request, response); } else { result = this.ReadPhotoFromMailboxOntoResponse(request, response, mailboxSession); } } } } catch (ObjectNotFoundException ex) { request.PerformanceLogger.Log("MailboxHandlerPhotoAvailable", string.Empty, 0U); if (this.reader.HasPhotoBeenDeleted(ex)) { result = this.ServePhotoHasBeenDeleted(request, response); } else { this.tracer.TraceDebug <ObjectNotFoundException>((long)this.GetHashCode(), "MAILBOX HANDLER: photo not found. Exception: {0}", ex); result = response; } } catch (StorageTransientException arg) { this.tracer.TraceError <StorageTransientException>((long)this.GetHashCode(), "MAILBOX HANDLER: transient exception at reading photo. Exception: {0}", arg); request.PerformanceLogger.Log("MailboxHandlerError", string.Empty, 1U); throw; } catch (StoragePermanentException arg2) { this.tracer.TraceError <StoragePermanentException>((long)this.GetHashCode(), "MAILBOX HANDLER: permanent exception at reading photo. Exception: {0}", arg2); request.PerformanceLogger.Log("MailboxHandlerError", string.Empty, 1U); throw; } } } } return(result); }