/// <summary> /// Creates a new ArcGIS Server REST Administration endpoint representation /// </summary> /// <param name="relativePath">Path of the endpoint relative to the root url of the ArcGIS Server</param> public ArcGISServerAdminEndpoint(string relativePath) { if (string.IsNullOrWhiteSpace(relativePath)) { throw new ArgumentNullException(nameof(relativePath), "relativePath is null."); } if (!Uri.TryCreate(relativePath, UriKind.RelativeOrAbsolute, out Uri uri)) { throw new InvalidOperationException("Not a valid relative url " + relativePath); } if (uri.IsAbsoluteUri) { RelativeUrl = uri.AbsolutePath.Trim('/') + "/"; } else { RelativeUrl = uri.OriginalString.Trim('/') + "/"; } if (RelativeUrl.IndexOf("admin/", StringComparison.OrdinalIgnoreCase) > -1) { RelativeUrl = RelativeUrl.Substring(RelativeUrl.LastIndexOf("admin/", StringComparison.OrdinalIgnoreCase)); } RelativeUrl = RelativeUrl.Replace("admin/", ""); RelativeUrl = "admin/" + RelativeUrl.Trim('/'); }
public override Task ProcessRequestAsync(IRequest request, IResponse response, string operationName) { if (string.IsNullOrEmpty(RelativeUrl) && string.IsNullOrEmpty(AbsoluteUrl)) { throw new ArgumentException("RelativeUrl and AbsoluteUrl is Required"); } if (!string.IsNullOrEmpty(AbsoluteUrl)) { response.StatusCode = (int)StatusCode; response.AddHeader(HttpHeaders.Location, this.AbsoluteUrl); } else { if (RelativeUrl.StartsWith("http://") || RelativeUrl.StartsWith("https://")) { throw new ArgumentException($"'{RelativeUrl}' is not a RelativeUrl, use AbsoluteUrl instead"); } var absoluteUrl = this.RelativeUrl.StartsWith("/") ? request.GetApplicationUrl().CombineWith(this.RelativeUrl) //preserve compat : request.ResolveAbsoluteUrl(MakeRelative(this.RelativeUrl)); response.StatusCode = (int)StatusCode; response.AddHeader(HttpHeaders.Location, absoluteUrl); } response.EndHttpHandlerRequest(skipClose: true); return(TypeConstants.EmptyTask); }
/// <summary> /// ASP.NET requests /// </summary> /// <param name="context"></param> public override void ProcessRequest(HttpContextBase context) { var request = context.Request; var response = context.Response; if (string.IsNullOrEmpty(RelativeUrl) && string.IsNullOrEmpty(AbsoluteUrl)) { throw new ArgumentException("RelativeUrl and AbsoluteUrl is Required"); } if (!string.IsNullOrEmpty(AbsoluteUrl)) { response.StatusCode = (int)StatusCode; response.AddHeader(HttpHeaders.Location, this.AbsoluteUrl); } else { if (RelativeUrl.StartsWith("http://") || RelativeUrl.StartsWith("https://")) { throw new ArgumentException($"'{RelativeUrl}' is not a RelativeUrl, use AbsoluteUrl instead"); } var absoluteUrl = this.RelativeUrl.StartsWith("/") ? request.GetApplicationUrl().CombineWith(this.RelativeUrl) //preserve compat : request.ToRequest(RequestName).ResolveAbsoluteUrl(MakeRelative(this.RelativeUrl)); response.StatusCode = (int)StatusCode; response.AddHeader(HttpHeaders.Location, absoluteUrl); } context.EndHttpHandlerRequest(closeOutputStream: true); }
private void FileBrowser_Loaded(object sender, RoutedEventArgs e) { CurrentFolderDepth = 0; RelativeUrl = StartupRelativeUrl; if (RelativeUrl != null) { CurrentFolderDepth = RelativeUrl.Count <char>(c => c == '/') + 1; } getFiles(RelativeUrl); }
/// <summary> /// Creates a new ArcGIS Online or Portal REST endpoint representation /// </summary> /// <param name="relativePath">Path of the endpoint relative to the root url of ArcGIS Online / Portal</param> public ArcGISOnlineEndpoint(String relativePath) { if (String.IsNullOrWhiteSpace(relativePath)) { throw new ArgumentNullException("relativePath"); } RelativeUrl = relativePath.Trim('/'); if (RelativeUrl.IndexOf("sharing/rest") > 0) { RelativeUrl = RelativeUrl.Substring(RelativeUrl.IndexOf("sharing/rest")); } RelativeUrl = RelativeUrl.Replace("sharing/rest/", ""); System.Diagnostics.Debug.WriteLine("Created ArcGISOnlineEndpoint for " + RelativeUrl); }
public override string OnQualifyUrl(string url) { if (!Uri.IsWellFormedUriString(url, UriKind.Absolute)) { RelativeUrl?.Invoke(url); if (!checkUrl) { url = url.Replace("/", "_"); } } if (baseUrl != null && !url.StartsWith("/") && !url.Contains(":")) { url = baseUrl + url; } return(base.OnQualifyUrl(url)); }
/// <summary> /// Resolves the given url. /// </summary> /// <param name="url"></param> /// <returns></returns> public Uri ResolveUrl(string url) { var uri = new Uri(url, UriKind.RelativeOrAbsolute); // convert relative to absolute if (!uri.IsAbsoluteUri) { uri = new Uri(RelativeUrl, url); } // url is now relative, localize if (uri.IsAbsoluteUri) { uri = LocalizeUri(uri); } // url is absolute, attempt to make relative if (uri.IsAbsoluteUri) { uri = RelativeUrl.MakeRelativeUri(uri); } return(uri); }
/// <summary> /// Gets the <see cref="Uri"/> to retrieve the given resource name. /// </summary> /// <param name="resourceSource"></param> /// <param name="resourceName"></param> /// <returns></returns> public Uri ResolveResourceUrl(Type resourceSource, string resourceName, CultureInfo culture) { return(RelativeUrl.MakeRelativeUri(AppendQueryArgToUri(RequestUrl, ResourceQueryKey, "T:" + resourceSource.Assembly.GetName().Name + "/" + resourceSource.FullName + "/" + resourceName + "/" + (culture ?? CultureInfo.InvariantCulture).Name))); }
/// <summary> /// Gets the <see cref="Uri"/> to post back and resume the workflow with the given bookmark. /// </summary> /// <param name="bookmark"></param> /// <returns></returns> public Uri ResolveBookmarkUrl(Bookmark bookmark) { return(RelativeUrl.MakeRelativeUri(AppendQueryArgToUri(SelfUrl, BookmarkQueryKey, bookmark.Name))); }