Url u= ...; String[] pathparts= u.getPath().split("\\/"); String filename= pathparts[pathparts.length-1].split("\\.", 1)[0];
/** * return path for current url in original encoding * * @return path string */ public String getPath() { return getPath(getCharset()); }
/** * return path for current url in original encoding * * @return path string */ public String getPath() { return getPath(getCharset()); }
/** * Checks whether a CKEditor resource reference exists on the class path. * @param ref a CKEditor resource reference. */ static boolean existsOnClassPath(final UrlResourceReference ref) { final String path = ref.getUrl().getPath(); final InputStream resource = CKEditorConstants.class.getResourceAsStream("/" + path); IOUtils.closeQuietly(resource); return resource != null; }
private boolean isActiveItem(IModel<String> urlModel) { String currentUrl = RequestCycle.get().getRequest().getUrl().getPath(); String url = urlModel.getObject(); return url!=null && currentUrl.equals(url.replaceFirst("^/", "")); } }
@Override public String getPath(Charset charset) { StringBuilder path = new StringBuilder(); boolean slash = false; for (String segment : getSegments()) { if (slash) { path.append('/'); } if (segment.indexOf('/') != -1) { Url url = new Url(Splitter.on('/').splitToList(segment), Charsets.UTF_8); path.append(url.getPath()); } else { path.append(UrlEncoder.PATH_INSTANCE.encode(segment, charset)); } slash = true; } return path.toString(); }
@Override public void configure(IOLoggerConfiguration configuration) { super.configure(configuration); if(!Strings.isEmpty(collectorUrl)) { Url url = Url.parse(collectorUrl); if(Strings.isEmpty(url.getPath())) { collectorUrl = collectorUrl+(collectorUrl.endsWith("/")?"":"/")+"rest/ologger"; } } }
final String path = getPath(charset);
WicketTester tester = ...; // set up tester tester.setFollowRedirects(false); // important tester.startpage(...); // or tester.executeUrl(...); // then test to see if there was a redirect assert tester.getLastResponse().getRedirectLocation() != null; assert aTester.getLastResponse().getRedirectLocation().endsWith("...."); // then manually redirect to that page and test its the page you expected Url url = Url.parse(aTester.getLastResponse().getRedirectLocation()); aTester.executeUrl(url.getPath().substring(1)); // the substring chops off and leading / aTester.assertRenderedPage(YourRedirectPage.class);
final String path = getPath(charset);
String path = url.getPath(getCharset());
String path = url.getPath(getCharset());
/** * Monta a URL completa a partir da pagina informada e do "path" * <p> * A pagina deve estar anotada com @MountPath e com o parametro ${path} em seu valor, * por exemplo, caso a entrada possua uma pagina que esteja anotada com @MountPath("/page/${path}") * e um path com valor de "foo/bar", o valor retornado serĂ¡ "/page/foo/bar" * * @param pathURI o path que serĂ¡ substituido na URL * @return a url completa */ public static String getMergedPathIntoURL(String pathURI) { String[] paths = pathURI.split("/"); String moutedPathWithPathParameter = ""; if (paths.length > 0 && WebApplication.exists()) { final WebApplication webApplication = WebApplication.get(); final IRequestMapper rootRequestMapper = webApplication.getRootRequestMapper(); final Class<? extends Page> homePage = webApplication.getHomePage(); final PageParameters pageParameters = new PageParameters().add("path", PLACEHOLDER); final Url url = rootRequestMapper.mapHandler(new BookmarkablePageRequestHandler(new PageProvider(homePage, pageParameters))); moutedPathWithPathParameter = "/" + url.getPath().replace(PLACEHOLDER, pathURI); } return getServerContextPath() + moutedPathWithPathParameter; }
private BrixPageParameters createBrixPageParams(Url url, Path path) { BrixPageParameters parameters = new BrixPageParameters(); Path nodePath = path; Path requestPath = new Path("/" + url.getPath()); if (nodePath.isAncestorOf(requestPath)) { Path remaining = new Path(requestPath.toString(), false).toRelative(nodePath); int i = 0; for (String s : remaining) { parameters.set(i, urlDecode(s)); ++i; } } for (QueryParameter parameter : url.getQueryParameters()) { String parameterName = parameter.getName(); if (PageComponentInfo.parse(parameterName) == null) { parameters.add(parameterName, parameter.getValue()); } } return parameters; }