internal static bool TryParse(string url, out PublicUrl publicUrl) { publicUrl = null; Uri uri = null; if (!PublishingUrl.IsAbsoluteUriString(url, out uri)) { ExTraceGlobals.SharingTracer.TraceError <string>(0L, "PublicUrl.TryParse(): The string '{0}' is not an valid Uri.", url); return(false); } string localPath = uri.LocalPath; ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "PublicUrl.TryParse(): Get path of url: {0}", localPath); Match match = PublicUrl.PublicUrlRegex.Match(localPath); if (!match.Success) { ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "PublicUrl.TryParse(): The string '{0}' is not PublicUrl.", url); return(false); } SharingDataType dataType = SharingDataType.FromExternalName(match.Result("${datatype}")); string text = match.Result("${address}"); if (!SmtpAddress.IsValidSmtpAddress(text)) { ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "PublicUrl.TryParse(): {0} is not valid SMTP address.", text); return(false); } publicUrl = new PublicUrl(uri, dataType, new SmtpAddress(text), match.Result("${name}")); ExTraceGlobals.SharingTracer.TraceDebug <string, string>(0L, "PublicUrl.TryParse(): The url {0} is parsed as PublicUrl {1}.", url, publicUrl.TraceInfo); return(true); }
internal override void ParseSharingMessageProvider(SharingContext context, SharingMessageProvider sharingMessageProvider) { Uri uri = null; if (!PublishingUrl.IsAbsoluteUriString(sharingMessageProvider.BrowseUrl, out uri)) { ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: BrowseUrl is invalid: {1}", context.UserLegacyDN, sharingMessageProvider.BrowseUrl); throw new InvalidSharingDataException("BrowseUrl", sharingMessageProvider.BrowseUrl); } context.BrowseUrl = sharingMessageProvider.BrowseUrl; if (context.DataType == SharingDataType.Calendar) { if (string.IsNullOrEmpty(sharingMessageProvider.ICalUrl)) { ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: ICalUrl is missing: {1}", context.UserLegacyDN, sharingMessageProvider.ICalUrl); throw new InvalidSharingDataException("ICalUrl", string.Empty); } if (!PublishingUrl.IsAbsoluteUriString(sharingMessageProvider.ICalUrl, out uri)) { ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: ICalUrl is invalid: {1}", context.UserLegacyDN, sharingMessageProvider.ICalUrl); throw new InvalidSharingDataException("ICalUrl", sharingMessageProvider.ICalUrl); } context.ICalUrl = sharingMessageProvider.ICalUrl; } }
public static SubscribeResultsWebCal Subscribe(MailboxSession mailboxSession, string iCalUrlString, string folderName = null) { Util.ThrowOnNullArgument(mailboxSession, "mailboxSession"); Util.ThrowOnNullOrEmptyArgument(iCalUrlString, "iCalUrlString"); Uri iCalUrl = null; if (!PublishingUrl.IsAbsoluteUriString(iCalUrlString, out iCalUrl) || !Array.Exists <string>(WebCalendar.validWebCalendarSchemes, (string scheme) => StringComparer.OrdinalIgnoreCase.Equals(scheme, iCalUrl.Scheme))) { throw new InvalidSharingDataException("iCalUrlString", iCalUrlString); } string text; if ((text = folderName) == null && (text = WebCalendar.GetFolderNameFromInternetCalendar(iCalUrl)) == null) { text = (WebCalendar.GetFolderNameFromUrl(iCalUrl) ?? ClientStrings.Calendar.ToString(mailboxSession.InternalPreferedCulture)); } folderName = text; PublishingSubscriptionData newSubscription = WebCalendar.CreateSubscriptionData(iCalUrl, folderName); return(WebCalendar.InternalSubscribe(mailboxSession, newSubscription, null, null)); }
private void ReadFromMessageXProperties(MessageItem messageItem) { string valueOrDefault = messageItem.GetValueOrDefault <string>(InternalSchema.XSharingFlavor, null); if (valueOrDefault == null) { ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: XSharingFlavor is missing", messageItem.Session.UserLegacyDN); throw new InvalidSharingMessageException("XSharingFlavor"); } try { this.context.SharingFlavor = (SharingFlavor)int.Parse(valueOrDefault, NumberStyles.HexNumber); } catch (FormatException) { ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: XSharingFlavor is invalid: {1}", messageItem.Session.UserLegacyDN, valueOrDefault); throw new InvalidSharingMessageException("XSharingFlavor"); } string valueOrDefault2 = messageItem.GetValueOrDefault <string>(InternalSchema.XSharingRemoteType, null); if (valueOrDefault2 == null) { ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: XSharingRemoteType is missing.", messageItem.Session.UserLegacyDN); throw new InvalidSharingMessageException("XSharingRemoteType"); } if (SharingDataType.FromPublishName(valueOrDefault2) == null) { ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: XSharingRemoteType is invalid: {1}.", messageItem.Session.UserLegacyDN, valueOrDefault2); throw new InvalidSharingMessageException("XSharingRemoteType"); } string valueOrDefault3 = messageItem.GetValueOrDefault <string>(InternalSchema.XSharingLocalType, null); if (valueOrDefault3 == null) { ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: XSharingLocalType is missing.", messageItem.Session.UserLegacyDN); throw new InvalidSharingMessageException("XSharingLocalType"); } if (SharingDataType.FromContainerClass(valueOrDefault3) == null) { ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: XSharingLocalType is invalid: {1}.", messageItem.Session.UserLegacyDN, valueOrDefault3); throw new InvalidSharingMessageException("XSharingLocalType"); } this.context.FolderClass = valueOrDefault3; string valueOrDefault4 = messageItem.GetValueOrDefault <string>(InternalSchema.XSharingRemoteName, null); if (valueOrDefault4 == null) { ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: XSharingRemoteName is missing.", messageItem.Session.UserLegacyDN); throw new InvalidSharingMessageException("XSharingRemoteName"); } this.context.FolderName = valueOrDefault4; Uri uri = null; string valueOrDefault5 = messageItem.GetValueOrDefault <string>(InternalSchema.XSharingBrowseUrl, null); if (string.IsNullOrEmpty(valueOrDefault5)) { ExTraceGlobals.SharingTracer.TraceDebug <string>((long)this.GetHashCode(), "{0}: XSharingBrowseUrl is missing or empty.", messageItem.Session.UserLegacyDN); } else { if (!PublishingUrl.IsAbsoluteUriString(valueOrDefault5, out uri)) { ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: XSharingBrowseUrl is not well formed : {1}", messageItem.Session.UserLegacyDN, valueOrDefault5); throw new InvalidSharingMessageException("XSharingBrowseUrl"); } this.context.BrowseUrl = valueOrDefault5; } string valueOrDefault6 = messageItem.GetValueOrDefault <string>(InternalSchema.XSharingRemotePath, null); if (valueOrDefault6 == null) { ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: XSharingRemotePath is missing.", messageItem.Session.UserLegacyDN); throw new InvalidSharingMessageException("XSharingRemotePath"); } if (!PublishingUrl.IsAbsoluteUriString(valueOrDefault6, out uri)) { ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: XSharingRemotePath is not well formed : {1}", messageItem.Session.UserLegacyDN, valueOrDefault6); throw new InvalidSharingMessageException("XSharingRemotePath"); } this.context.ICalUrl = valueOrDefault6; }