// Token: 0x06000C3C RID: 3132 RVA: 0x00040194 File Offset: 0x0003E394 protected override int InternalExecute(int count) { FolderSyncState folderSyncState = null; int result; try { string text = HttpUtility.UrlDecode(base.FileReference); int num = text.IndexOf(':'); ItemIdMapping itemIdMapping = null; if (num != -1 && num != text.LastIndexOf(':')) { string text2 = text.Substring(0, num); SyncCollection.CollectionTypes collectionType = AirSyncUtility.GetCollectionType(text2); if (collectionType != SyncCollection.CollectionTypes.Mailbox && collectionType != SyncCollection.CollectionTypes.Unknown) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NoAttachmentsOnVItem"); AirSyncPermanentException ex = new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.InvalidCombinationOfIDs, null, false); throw ex; } folderSyncState = base.SyncStateStorage.GetFolderSyncState(new MailboxSyncProviderFactory(base.Session), text2); if (folderSyncState == null) { throw new ObjectNotFoundException(ServerStrings.MapiCannotOpenAttachmentId(text)); } itemIdMapping = (ItemIdMapping)folderSyncState[CustomStateDatumType.IdMapping]; if (itemIdMapping == null) { throw new ObjectNotFoundException(ServerStrings.MapiCannotOpenAttachmentId(text)); } } int num2; base.ContentType = AttachmentHelper.GetAttachment(base.Session, text, base.OutStream, base.MinRange, count, base.MaxAttachmentSize, itemIdMapping, base.RightsManagementSupport, out num2); result = num2; } finally { if (folderSyncState != null) { folderSyncState.Dispose(); folderSyncState = null; } } return(result); }
// Token: 0x06001561 RID: 5473 RVA: 0x0007D91C File Offset: 0x0007BB1C protected StoreObjectId GetSmartItemId() { this.ParseXmlRequest(); string collectionId = this.CollectionId; string itemId = this.ItemId; string longId = this.LongId; StoreObjectId storeObjectId = null; FolderSyncState folderSyncState = null; StoreObjectId result; try { if (longId != null) { if (base.Version < 120) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "LongIdSupportedinV12Only"); throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidCombinationOfIDs, null, false); } try { storeObjectId = StoreObjectId.Deserialize(longId); goto IL_1F1; } catch (ArgumentException innerException) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidLongId"); throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.InvalidIDs, innerException, false); } catch (FormatException innerException2) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidLongId2"); throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.InvalidIDs, innerException2, false); } catch (CorruptDataException innerException3) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidLongId3"); throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.InvalidIDs, innerException3, false); } } if (collectionId == null) { StoreObjectId defaultFolderId = base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox); MailboxSyncProviderFactory syncProviderFactory = new MailboxSyncProviderFactory(base.MailboxSession, defaultFolderId); folderSyncState = base.SyncStateStorage.GetFolderSyncState(syncProviderFactory); } else { SyncCollection.CollectionTypes collectionType = AirSyncUtility.GetCollectionType(collectionId); if (collectionType != SyncCollection.CollectionTypes.Mailbox && collectionType != SyncCollection.CollectionTypes.Unknown) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "SendFromVirtualFolder"); throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidCombinationOfIDs, null, false); } folderSyncState = base.SyncStateStorage.GetFolderSyncState(collectionId); } if (folderSyncState == null) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "SyncStateNotFound"); throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.SyncStateNotFound, null, false); } ItemIdMapping itemIdMapping = (ItemIdMapping)folderSyncState[CustomStateDatumType.IdMapping]; if (itemIdMapping == null) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ItemIdMappingNotFound"); throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.ItemNotFound, null, false); } MailboxSyncItemId mailboxSyncItemId = itemIdMapping[itemId] as MailboxSyncItemId; storeObjectId = ((mailboxSyncItemId == null) ? null : ((StoreObjectId)mailboxSyncItemId.NativeId)); if (storeObjectId == null) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ItemIdMappingNotFound"); throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.ItemNotFound, null, false); } folderSyncState.Dispose(); folderSyncState = null; IL_1F1: result = storeObjectId; } finally { if (folderSyncState != null) { folderSyncState.Dispose(); } } return(result); }
internal override Command.ExecutionState ExecuteCommand() { string attachmentName = this.AttachmentName; string value = string.Empty; FolderSyncState folderSyncState = null; AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, this, "GetAttachmentCommand.Execute(). AttachmentName: '{0}'", attachmentName); try { int incBy = 0; if (base.Request.ContentType != null && !string.Equals(base.Request.ContentType, "message/rfc822", StringComparison.OrdinalIgnoreCase)) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidContentType"); throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.First140Error, null, false); } int num = attachmentName.IndexOf(':'); ItemIdMapping itemIdMapping = null; if (num != -1 && num != attachmentName.LastIndexOf(':')) { folderSyncState = base.SyncStateStorage.GetFolderSyncState(new MailboxSyncProviderFactory(base.MailboxSession), attachmentName.Substring(0, num)); if (folderSyncState == null) { throw new ObjectNotFoundException(ServerStrings.MapiCannotOpenAttachmentId(attachmentName)); } itemIdMapping = (ItemIdMapping)folderSyncState[CustomStateDatumType.IdMapping]; if (itemIdMapping == null) { throw new ObjectNotFoundException(ServerStrings.MapiCannotOpenAttachmentId(attachmentName)); } } PolicyData policyData = ADNotificationManager.GetPolicyData(base.User); if (policyData != null && !policyData.AttachmentsEnabled) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "AttachmentsNotEnabledGetAttCmd"); throw new AirSyncPermanentException(HttpStatusCode.Forbidden, StatusCode.AccessDenied, null, false); } Unlimited <ByteQuantifiedSize> maxAttachmentSize = (policyData != null) ? policyData.MaxAttachmentSize : Unlimited <ByteQuantifiedSize> .UnlimitedValue; value = AttachmentHelper.GetAttachment(base.MailboxSession, attachmentName, base.OutputStream, maxAttachmentSize, itemIdMapping, out incBy); base.ProtocolLogger.IncrementValue(ProtocolLoggerData.Attachments); base.ProtocolLogger.IncrementValueBy(ProtocolLoggerData.AttachmentBytes, incBy); } catch (FormatException innerException) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidAttachmentName"); AirSyncPermanentException ex = new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.InvalidIDs, innerException, false); throw ex; } catch (ObjectNotFoundException innerException2) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "AttachmentNotFound"); AirSyncPermanentException ex2 = new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.None, innerException2, false); throw ex2; } catch (IOException innerException3) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "IOException"); throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.None, innerException3, false); } catch (DataTooLargeException innerException4) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "AttachmentIsTooLarge"); PolicyData policyData2 = ADNotificationManager.GetPolicyData(base.User); if (policyData2 != null) { policyData2.MaxAttachmentSize.ToString(); } else { GlobalSettings.MaxDocumentDataSize.ToString(CultureInfo.InvariantCulture); } throw new AirSyncPermanentException(HttpStatusCode.RequestEntityTooLarge, StatusCode.AttachmentIsTooLarge, innerException4, false); } finally { if (folderSyncState != null) { folderSyncState.Dispose(); folderSyncState = null; } } base.Context.Response.AppendHeader("Content-Type", value); return(Command.ExecutionState.Complete); }