本文整理汇总了Java中org.craftercms.commons.http.HttpUtils类的典型用法代码示例。如果您正苦于以下问题:Java HttpUtils类的具体用法?Java HttpUtils怎么用?Java HttpUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HttpUtils类属于org.craftercms.commons.http包,在下文中一共展示了HttpUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createProfile
import org.craftercms.commons.http.HttpUtils; //导入依赖的package包/类
@Override
public Profile createProfile(String tenantName, String username, String password, String email, boolean enabled,
Set<String> roles, Map<String, Object> attributes, String verificationUrl)
throws ProfileException {
MultiValueMap<String, String> params = createBaseParams();
HttpUtils.addValue(PARAM_TENANT_NAME, tenantName, params);
HttpUtils.addValue(PARAM_USERNAME, username, params);
HttpUtils.addValue(PARAM_PASSWORD, password, params);
HttpUtils.addValue(PARAM_EMAIL, email, params);
HttpUtils.addValue(PARAM_ENABLED, enabled, params);
HttpUtils.addValues(PARAM_ROLE, roles, params);
if (MapUtils.isNotEmpty(attributes)) {
HttpUtils.addValue(PARAM_ATTRIBUTES, serializeAttributes(attributes), params);
}
HttpUtils.addValue(PARAM_VERIFICATION_URL, verificationUrl, params);
String url = getAbsoluteUrl(BASE_URL_PROFILE + URL_PROFILE_CREATE);
return doPostForObject(url, params, Profile.class);
}
示例2: getProfile
import org.craftercms.commons.http.HttpUtils; //导入依赖的package包/类
@Override
public Profile getProfile(String profileId, String... attributesToReturn) throws ProfileException {
MultiValueMap<String, String> params = createBaseParams();
HttpUtils.addValues(PARAM_ATTRIBUTE_TO_RETURN, attributesToReturn, params);
String url = getAbsoluteUrl(BASE_URL_PROFILE + URL_PROFILE_GET);
url = addQueryParams(url, params, false);
try {
return doGetForObject(url, Profile.class, profileId);
} catch (ProfileRestServiceException e) {
if (e.getStatus() == HttpStatus.NOT_FOUND) {
return null;
} else {
throw e;
}
}
}
示例3: getProfileByUsername
import org.craftercms.commons.http.HttpUtils; //导入依赖的package包/类
@Override
public Profile getProfileByUsername(String tenantName, String username, String... attributesToReturn) throws ProfileException {
MultiValueMap<String, String> params = createBaseParams();
HttpUtils.addValue(PARAM_TENANT_NAME, tenantName, params);
HttpUtils.addValue(PARAM_USERNAME, username, params);
HttpUtils.addValues(PARAM_ATTRIBUTE_TO_RETURN, attributesToReturn, params);
String url = getAbsoluteUrl(BASE_URL_PROFILE + URL_PROFILE_GET_BY_USERNAME);
url = addQueryParams(url, params, false);
try {
return doGetForObject(url, Profile.class);
} catch (ProfileRestServiceException e) {
if (e.getStatus() == HttpStatus.NOT_FOUND) {
return null;
} else {
throw e;
}
}
}
示例4: getProfileByTicket
import org.craftercms.commons.http.HttpUtils; //导入依赖的package包/类
@Override
public Profile getProfileByTicket(String ticketId, String... attributesToReturn) throws ProfileException {
MultiValueMap<String, String> params = createBaseParams();
HttpUtils.addValue(PARAM_TICKET_ID, ticketId, params);
HttpUtils.addValues(PARAM_ATTRIBUTE_TO_RETURN, attributesToReturn, params);
String url = getAbsoluteUrl(BASE_URL_PROFILE + URL_PROFILE_GET_BY_TICKET);
url = addQueryParams(url, params, false);
try {
return doGetForObject(url, Profile.class);
} catch (ProfileRestServiceException e) {
if (e.getStatus() == HttpStatus.NOT_FOUND) {
return null;
} else {
throw e;
}
}
}
示例5: getProfilesByQuery
import org.craftercms.commons.http.HttpUtils; //导入依赖的package包/类
@Override
public List<Profile> getProfilesByQuery(String tenantName, String query, String sortBy, SortOrder sortOrder,
Integer start, Integer count, String... attributesToReturn) throws ProfileException {
MultiValueMap<String, String> params = createBaseParams();
HttpUtils.addValue(PARAM_TENANT_NAME, tenantName, params);
HttpUtils.addValue(PARAM_QUERY, query, params);
HttpUtils.addValue(PARAM_SORT_BY, sortBy, params);
HttpUtils.addValue(PARAM_SORT_ORDER, sortOrder, params);
HttpUtils.addValue(PARAM_START, start, params);
HttpUtils.addValue(PARAM_COUNT, count, params);
HttpUtils.addValues(PARAM_ATTRIBUTE_TO_RETURN, attributesToReturn, params);
String url = getAbsoluteUrl(BASE_URL_PROFILE + URL_PROFILE_GET_BY_QUERY);
url = addQueryParams(url, params, true);
try {
return doGetForObject(new URI(url), profileListTypeRef);
} catch (URISyntaxException e) {
throw new I10nProfileException(ERROR_KEY_INVALID_URI_ERROR, url);
}
}
示例6: getProfileRange
import org.craftercms.commons.http.HttpUtils; //导入依赖的package包/类
@Override
public List<Profile> getProfileRange(String tenantName, String sortBy, SortOrder sortOrder, Integer start,
Integer count, String... attributesToReturn) throws ProfileException {
MultiValueMap<String, String> params = createBaseParams();
HttpUtils.addValue(PARAM_TENANT_NAME, tenantName, params);
HttpUtils.addValue(PARAM_SORT_BY, sortBy, params);
HttpUtils.addValue(PARAM_SORT_ORDER, sortOrder, params);
HttpUtils.addValue(PARAM_START, start, params);
HttpUtils.addValue(PARAM_COUNT, count, params);
HttpUtils.addValues(PARAM_ATTRIBUTE_TO_RETURN, attributesToReturn, params);
String url = getAbsoluteUrl(BASE_URL_PROFILE + URL_PROFILE_GET_RANGE);
url = addQueryParams(url, params, false);
return doGetForObject(url, profileListTypeRef);
}
示例7: getProfilesByExistingAttribute
import org.craftercms.commons.http.HttpUtils; //导入依赖的package包/类
@Override
public List<Profile> getProfilesByExistingAttribute(String tenantName, String attributeName, String sortBy,
SortOrder sortOrder, String... attributesToReturn)
throws ProfileException {
MultiValueMap<String, String> params = createBaseParams();
HttpUtils.addValue(PARAM_TENANT_NAME, tenantName, params);
HttpUtils.addValue(PARAM_ATTRIBUTE_NAME, attributeName, params);
HttpUtils.addValue(PARAM_SORT_BY, sortBy, params);
HttpUtils.addValue(PARAM_SORT_ORDER, sortOrder, params);
HttpUtils.addValues(PARAM_ATTRIBUTE_TO_RETURN, attributesToReturn, params);
String url = getAbsoluteUrl(BASE_URL_PROFILE + URL_PROFILE_GET_BY_EXISTING_ATTRIB);
url = addQueryParams(url, params, false);
return doGetForObject(url, profileListTypeRef);
}
示例8: getProfilesByAttributeValue
import org.craftercms.commons.http.HttpUtils; //导入依赖的package包/类
@Override
public List<Profile> getProfilesByAttributeValue(String tenantName, String attributeName,
String attributeValue, String sortBy, SortOrder sortOrder,
String... attributesToReturn) throws ProfileException {
MultiValueMap<String, String> params = createBaseParams();
HttpUtils.addValue(PARAM_TENANT_NAME, tenantName, params);
HttpUtils.addValue(PARAM_ATTRIBUTE_NAME, attributeName, params);
HttpUtils.addValue(PARAM_ATTRIBUTE_VALUE, attributeValue, params);
HttpUtils.addValue(PARAM_SORT_BY, sortBy, params);
HttpUtils.addValue(PARAM_SORT_ORDER, sortOrder, params);
HttpUtils.addValues(PARAM_ATTRIBUTE_TO_RETURN, attributesToReturn, params);
String url = getAbsoluteUrl(BASE_URL_PROFILE + URL_PROFILE_GET_BY_ATTRIB_VALUE);
url = addQueryParams(url, params, false);
return doGetForObject(url, profileListTypeRef);
}
示例9: excludeRequest
import org.craftercms.commons.http.HttpUtils; //导入依赖的package包/类
/**
* Returns trues if the request should be excluded from processing.
*/
protected boolean excludeRequest(HttpServletRequest request) {
if (ArrayUtils.isNotEmpty(urlsToExclude)) {
for (String pathPattern : urlsToExclude) {
if (pathMatcher.match(pathPattern, HttpUtils.getRequestUriWithoutContextPath(request))) {
return true;
}
}
}
return false;
}
示例10: includeRequest
import org.craftercms.commons.http.HttpUtils; //导入依赖的package包/类
/**
* Returns trues if the request should be included for processing.
*/
protected boolean includeRequest(HttpServletRequest request) {
if (ArrayUtils.isNotEmpty(urlsToInclude)) {
for (String pathPattern : urlsToInclude) {
if (pathMatcher.match(pathPattern, HttpUtils.getRequestUriWithoutContextPath(request))) {
return true;
}
}
}
return false;
}
示例11: getProfileLastModifiedCookie
import org.craftercms.commons.http.HttpUtils; //导入依赖的package包/类
/**
* Returns the last modified timestamp cookie from the request.
*
* @param request the request where to retrieve the last modified timestamp from
*
* @return the last modified timestamp of the authenticated profile
*/
public static Long getProfileLastModifiedCookie(HttpServletRequest request) {
String profileLastModified = HttpUtils.getCookieValue(PROFILE_LAST_MODIFIED_COOKIE_NAME, request);
if (StringUtils.isNotEmpty(profileLastModified)) {
try {
return new Long(profileLastModified);
} catch (NumberFormatException e) {
logger.error("Invalid profile last modified cookie format: {}", profileLastModified);
}
}
return null;
}
示例12: updateProfile
import org.craftercms.commons.http.HttpUtils; //导入依赖的package包/类
@Override
public Profile updateProfile(String profileId, String username, String password, String email, Boolean enabled,
Set<String> roles, Map<String, Object> attributes, String... attributesToReturn)
throws ProfileException {
MultiValueMap<String, String> params = createBaseParams();
HttpUtils.addValue(PARAM_USERNAME, username, params);
HttpUtils.addValue(PARAM_PASSWORD, password, params);
HttpUtils.addValue(PARAM_EMAIL, email, params);
HttpUtils.addValue(PARAM_ENABLED, enabled, params);
// Send empty role to indicate that all roles should be deleted
if (roles != null && roles.isEmpty()) {
HttpUtils.addValue(PARAM_ROLE, "", params);
} else {
HttpUtils.addValues(PARAM_ROLE, roles, params);
}
if (MapUtils.isNotEmpty(attributes)) {
HttpUtils.addValue(PARAM_ATTRIBUTES, serializeAttributes(attributes), params);
}
HttpUtils.addValues(PARAM_ATTRIBUTE_TO_RETURN, attributesToReturn, params);
String url = getAbsoluteUrl(BASE_URL_PROFILE + URL_PROFILE_UPDATE);
return doPostForObject(url, params, Profile.class, profileId);
}
示例13: verifyProfile
import org.craftercms.commons.http.HttpUtils; //导入依赖的package包/类
@Override
public Profile verifyProfile(String verificationTokenId, String... attributesToReturn) throws ProfileException {
MultiValueMap<String, String> params = createBaseParams();
HttpUtils.addValue(PARAM_VERIFICATION_TOKEN_ID, verificationTokenId, params);
HttpUtils.addValues(PARAM_ATTRIBUTE_TO_RETURN, attributesToReturn, params);
String url = getAbsoluteUrl(BASE_URL_PROFILE + URL_PROFILE_VERIFY);
return doPostForObject(url, params, Profile.class);
}
示例14: enableProfile
import org.craftercms.commons.http.HttpUtils; //导入依赖的package包/类
@Override
public Profile enableProfile(String profileId, String... attributesToReturn) throws ProfileException {
MultiValueMap<String, String> params = createBaseParams();
HttpUtils.addValues(PARAM_ATTRIBUTE_TO_RETURN, attributesToReturn, params);
String url = getAbsoluteUrl(BASE_URL_PROFILE + URL_PROFILE_ENABLE);
return doPostForObject(url, params, Profile.class, profileId);
}
示例15: disableProfile
import org.craftercms.commons.http.HttpUtils; //导入依赖的package包/类
@Override
public Profile disableProfile(String profileId, String... attributesToReturn) throws ProfileException {
MultiValueMap<String, String> params = createBaseParams();
HttpUtils.addValues(PARAM_ATTRIBUTE_TO_RETURN, attributesToReturn, params);
String url = getAbsoluteUrl(BASE_URL_PROFILE + URL_PROFILE_DISABLE);
return doPostForObject(url, params, Profile.class, profileId);
}