当前位置: 首页>>代码示例>>Java>>正文


Java TokenResolver类代码示例

本文整理汇总了Java中com.strategicgains.hyperexpress.builder.TokenResolver的典型用法代码示例。如果您正苦于以下问题:Java TokenResolver类的具体用法?Java TokenResolver怎么用?Java TokenResolver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TokenResolver类属于com.strategicgains.hyperexpress.builder包,在下文中一共展示了TokenResolver类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import com.strategicgains.hyperexpress.builder.TokenResolver; //导入依赖的package包/类
public User create(Request request, Response response) {
    User user = request.getBodyAs(User.class, "User details not provided");
    ValidationEngine.validateAndThrow(user);
    userBo.store(user);

    // Construct the response for create...
    response.setResponseCreated();

    TokenResolver resolver = HyperExpress.bind(Constants.Url.USER_UUID, user.getUuid());

    // Include the Location header...
    String locationPattern = request.getNamedUrl(HttpMethod.GET,
            Constants.Routes.USER_READ_ROUTE);
    response.addLocationHeader(LOCATION_BUILDER.build(locationPattern, resolver));

    // Return the newly-created item...
    return user;
}
 
开发者ID:caratarse,项目名称:caratarse-auth,代码行数:19,代码来源:UserController.java

示例2: create

import com.strategicgains.hyperexpress.builder.TokenResolver; //导入依赖的package包/类
public Comment create(Request request, Response response)
{
	Comment comment = request.getBodyAs(Comment.class, "Comment details not provided");
	String blogId = request.getHeader(Constants.Url.BLOG_ID_PARAMETER, "Blog ID not provided");
	String blogEntryId = request.getHeader(Constants.Url.BLOG_ENTRY_ID_PARAMETER, "Blog Entry ID not provided");
	Blog blog = blogs.read(UUID.parse(blogId));
	BlogEntry entry = entries.read(UUID.parse(blogEntryId));
	comment.setBlogEntryId(entry.getUuid());
	ValidationEngine.validateAndThrow(comment);
	Comment saved = comments.create(comment);

	// Construct the response for create...
	response.setResponseCreated();

	// Bind the resource with link URL tokens, etc. here...
	TokenResolver resolver = HyperExpress.bind(Constants.Url.BLOG_ID_PARAMETER, UUID.format(blog.getUuid()));

	// Include the Location header...
	String locationPattern = request.getNamedUrl(HttpMethod.GET, Constants.Routes.COMMENT_READ_ROUTE);
	response.addLocationHeader(LOCATION_BUILDER.build(locationPattern, resolver));

	// Return the newly-created item...
	return saved;
}
 
开发者ID:RestExpress,项目名称:RestExpress-Examples,代码行数:25,代码来源:CommentController.java

示例3: addTokenBinder

import com.strategicgains.hyperexpress.builder.TokenResolver; //导入依赖的package包/类
private void addTokenBinder() {
    // Bind the resources in the collection with link URL tokens, etc. here...
    HyperExpress.tokenBinder(new TokenBinder<User>() {
        @Override
        public void bind(User entity, TokenResolver resolver) {
            resolver.bind(Constants.Url.USER_UUID, entity.getUuid())
                    .bind(Constants.Url.USER_ID, entity.getId().toString());
        }
    });
}
 
开发者ID:caratarse,项目名称:caratarse-auth,代码行数:11,代码来源:UserController.java

示例4: addAuthorizationToUser

import com.strategicgains.hyperexpress.builder.TokenResolver; //导入依赖的package包/类
public UserAuthorization addAuthorizationToUser(Request request, Response response) {
    String userUuid = request.getHeader(Constants.Url.USER_UUID, "No User UUID supplied");
    String authorizationName = request.getHeader(Constants.Url.AUTHORIZATION_NAME,
            "No Authorization Name supplied");
    UserAuthorization userAuthorizationPermissions = request.getBodyAs(UserAuthorization.class,
            "UserAuthorization with permissions details not provided");

    validateAndThrow(userUuid, authorizationName);

    UserAuthorization userAuthorization = userAuthorizationBo.addAuthorizationToUser(
            userUuid, authorizationName,
            userAuthorizationPermissions.getPermissions());

    // Construct the response for create...
    response.setResponseCreated();

    TokenResolver resolver = HyperExpress.bind(Constants.Url.USER_UUID, userUuid)
            .bind(Constants.Url.AUTHORIZATION_NAME, authorizationName);

    // Include the Location header...
    String locationPattern = request.getNamedUrl(HttpMethod.GET,
            Constants.Routes.USER_READ_ROUTE);
    response.addLocationHeader(LOCATION_BUILDER.build(locationPattern, resolver));

    // Return the newly-created item...
    return userAuthorization;
}
 
开发者ID:caratarse,项目名称:caratarse-auth,代码行数:28,代码来源:UserAuthorizationController.java

示例5: addTokenBinder

import com.strategicgains.hyperexpress.builder.TokenResolver; //导入依赖的package包/类
private void addTokenBinder() {
    // Bind the resources in the collection with link URL tokens, etc. here...
    HyperExpress.tokenBinder(new TokenBinder<UserAuthorization>() {
        @Override
        public void bind(UserAuthorization entity, TokenResolver resolver) {
            resolver.bind(Constants.Url.USER_AUTHORIZATION_ID, entity.getId().toString())
                    .bind(Constants.Url.AUTHORIZATION_NAME, entity.getAuthorization().getName())
                    .bind(Constants.Url.USER_UUID, entity.getUser().getUuid())
                    .bind(Constants.Url.USER_ID, entity.getUser().getId().toString());
        }
    });
}
 
开发者ID:caratarse,项目名称:caratarse-auth,代码行数:13,代码来源:UserAuthorizationController.java

示例6: readAll

import com.strategicgains.hyperexpress.builder.TokenResolver; //导入依赖的package包/类
public List<Comment> readAll(Request request, Response response)
{
	String blogId = request.getHeader(Constants.Url.BLOG_ID_PARAMETER, "No Blog ID supplied");
	String blogEntryId = request.getHeader(Constants.Url.BLOG_ENTRY_ID_PARAMETER, "No Blog Entry ID supplied");
	final Blog blog = blogs.read(UUID.parse(blogId));
	entries.read(UUID.parse(blogEntryId));

	QueryFilter filter = QueryFilters.parseFrom(request);
	QueryOrder order = QueryOrders.parseFrom(request);
	QueryRange range = QueryRanges.parseFrom(request, 20);
	
	filter.addCriteria("blogEntryId", FilterOperator.EQUALS, UuidConverter.parse(blogEntryId));
	List<Comment> entities = comments.readAll(filter, range, order);
	response.setCollectionResponse(range, entities.size(), comments.count(filter));

	// Bind the resources in the collection with link URL tokens, etc. here...
	HyperExpress.tokenBinder(new TokenBinder<Comment>()
	{
		@Override
		public void bind(Comment entity, TokenResolver resolver)
		{
			resolver.bind(Constants.Url.BLOG_ID_PARAMETER, UUID.format(blog.getUuid()));
		}
	});

	return entities;
}
 
开发者ID:RestExpress,项目名称:RestExpress-Examples,代码行数:28,代码来源:CommentController.java


注:本文中的com.strategicgains.hyperexpress.builder.TokenResolver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。