org.apache.wicket.util.encoding.UrlEncoder Java Examples

The following examples show how to use org.apache.wicket.util.encoding.UrlEncoder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PathAwareUrl.java    From onedev with MIT License 6 votes vote down vote up
@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), StandardCharsets.UTF_8);
			path.append(url.getPath());
		} else {
			path.append(UrlEncoder.PATH_INSTANCE.encode(segment, charset));
		}
		slash = true;
	}
	return path.toString();
}
 
Example #2
Source File: NextServerApplication.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
@Override
public IRequestHandler onException(RequestCycle cycle, Exception e) {
	if (e instanceof PageExpiredException) {
		LOG.error("Page expired", e); // !?
		return null; // see
						// getApplicationSettings().setPageExpiredErrorPage
	}

	if (e instanceof MaintenanceException) {
		return new RenderPageRequestHandler(new PageProvider(MaintenancePage.class));
	}

	if (e instanceof StalePageException) {
		return null;
	}

	String errorCode = String.valueOf(System.currentTimeMillis());
	LOG.error("Error with code " + errorCode, e);

	PageParameters parameters = new PageParameters();
	parameters.add("errorCode", errorCode);
	parameters.add("errorMessage", UrlEncoder.QUERY_INSTANCE.encode(e.getMessage(), HTTP.ISO_8859_1));
	return new RenderPageRequestHandler(new PageProvider(ErrorPage.class, parameters));
}
 
Example #3
Source File: AbstractPivotTableWidget.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
public String getUrl() {
	String sql = getSql();
	return "/orientdb/query/db/sql/"+
				UrlEncoder.PATH_INSTANCE.encode(sql, "UTF-8")+
			"/99999?rnd="+
			noCacheRnd;
}
 
Example #4
Source File: DefaultSecurityService.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
/**
 * A reset token looks like:
 * USERNAME-sep-DIGEST(USER_PASSWORD_HASH)-sep-currentTimeMillis
 */
public String generateResetToken(User user) {
	String encryptedToken = tokenEncryptor.encrypt(user.getUsername() + SEPARATOR
            + simpleDigester.digest(user.getPassword()) + SEPARATOR
            + System.currentTimeMillis());
	
    return UrlEncoder.QUERY_INSTANCE.encode(encryptedToken, HTTP.ISO_8859_1);
}
 
Example #5
Source File: UrlUtils.java    From onedev with MIT License 4 votes vote down vote up
public static String encodePath(String url) {
	return UrlEncoder.PATH_INSTANCE.encode(url, StandardCharsets.UTF_8);
}
 
Example #6
Source File: UrlUtils.java    From onedev with MIT License 4 votes vote down vote up
public static String encodeQuery(String query) {
	return UrlEncoder.QUERY_INSTANCE.encode(query, StandardCharsets.UTF_8);
}