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


Java HyperExpress类代码示例

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


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

示例1: create

import com.strategicgains.hyperexpress.HyperExpress; //导入依赖的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.HyperExpress; //导入依赖的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.HyperExpress; //导入依赖的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.HyperExpress; //导入依赖的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.HyperExpress; //导入依赖的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: bindPaginationTokens

import com.strategicgains.hyperexpress.HyperExpress; //导入依赖的package包/类
public static void bindPaginationTokens(final QueryRange range, final long rows) {
    if (range.hasLimit()) {
        if (range.getOffset() + range.getLimit() <= rows) {
            HyperExpress.bind("nextOffset", Long.toString(range.getOffset() + range.getLimit()));
        }
        if (range.getOffset() - range.getLimit() >= 0) {
            HyperExpress.bind("prevOffset", Long.toString(range.getOffset() - range.getLimit()));
        }
    }
}
 
开发者ID:caratarse,项目名称:caratarse-auth,代码行数:11,代码来源:HyperExpressBindHelper.java

示例7: read

import com.strategicgains.hyperexpress.HyperExpress; //导入依赖的package包/类
public Comment read(Request request, Response response)
{
	String id = request.getHeader(Constants.Url.COMMENT_ID_PARAMETER, "No Comment ID supplied");
	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));
	entries.read(UUID.parse(blogEntryId));
	Comment entity = comments.read(UUID.parse(id));

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

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

示例8: readAll

import com.strategicgains.hyperexpress.HyperExpress; //导入依赖的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

示例9: define

import com.strategicgains.hyperexpress.HyperExpress; //导入依赖的package包/类
public static void define(RestExpress server)
	{
		Map<String, String> routes = server.getRouteUrlsByName();

		HyperExpress.relationships()
		.forCollectionOf(Database.class)
			.rel(SELF, routes.get(DATABASES))

		.forClass(Database.class)
			.rel(SELF, routes.get(DATABASE))
			.rel(UP, routes.get(DATABASES))
			.rel("collections", routes.get(TABLES))
				.title("The tables in this database")

		.forCollectionOf(Table.class)
			.rel(SELF, routes.get(TABLES))
			.rel(UP, routes.get(DATABASE))
				.title("The database containing this table")

		.forClass(Table.class)
			.rel(SELF, routes.get(TABLE))
			.rel(UP, routes.get(TABLES))
				.title("The entire list of tables in this database")

                .forCollectionOf(Index.class)
			.rel(SELF, routes.get(INDEXES))
			.rel(UP, routes.get(TABLE))
			.title("The collection that this index was created on.")
        
                .forClass(Index.class)
			.rel(SELF, routes.get(INDEX))
			.rel(UP, routes.get(INDEXES))
				.title("The list of indexes for this table.")
                
                   //N/A -- this is a global status of all current indexing operations
//                .forCollectionOf(IndexCreatedEvent.class)
//			.rel(SELF, routes.get(INDEX))
//			.rel(UP, routes.get(INDEXES))
                        
                .forClass(IndexCreatedEvent.class)
			.rel(SELF, routes.get(INDEX_STATUS))
			.rel(UP, routes.get(INDEX))
                        .rel("index", routes.get(INDEX))
				.title("The index for this status.")
                
			.rel("documents", routes.get(DOCUMENTS))
				.title("The documents in this collection")
                        
		.forCollectionOf(LinkableDocument.class)
//			.rel(SELF, routes.get(DOCUMENTS))
			.rel(UP, routes.get(TABLE))
				.title("The collection containing these documents")

		.forClass(LinkableDocument.class)
			.rel(SELF, routes.get(DOCUMENT))
			.rel(UP, routes.get(DOCUMENTS))
				.title("The entire list of documents in this collection");
	}
 
开发者ID:PearsonEducation,项目名称:Docussandra,代码行数:59,代码来源:Relationships.java

示例10: define

import com.strategicgains.hyperexpress.HyperExpress; //导入依赖的package包/类
public static void define(RestExpress server) {
        Map<String, String> routes = server.getRouteUrlsByName();

        HyperExpress.relationships()
                .forCollectionOf(User.class)
                    .rel(RelTypes.SELF, routes.get(Constants.Routes.USER_COLLECTION_READ_ROUTE))
                        .withQuery("filter={filter}")
                        .withQuery("limit={limit}")
                        .withQuery("offset={offset}")
                    .rel(RelTypes.NEXT, routes.get(Constants.Routes.USER_COLLECTION_READ_ROUTE) + "?offset={nextOffset}")
                        .withQuery("filter={filter}")
                        .withQuery("limit={limit}")
                        .optional()
                    .rel(RelTypes.PREV, routes.get(Constants.Routes.USER_COLLECTION_READ_ROUTE) + "?offset={prevOffset}")
                        .withQuery("filter={filter}")
                        .withQuery("limit={limit}")
                        .optional()
                .forClass(User.class)
                    .rel(RelTypes.SELF, routes.get(Constants.Routes.USER_READ_ROUTE))
                    .rel("userAuthorizations", routes.get(Constants.Routes.USER_AUTHORIZATIONS_ROUTE))
//                .forCollectionOf(UserService.class)
//                    .asRel("userServices")
//                    .rel(RelTypes.SELF, routes.get(Constants.Routes.USER_SERVICES_ROUTE))
//                    .rel(RelTypes.UP, routes.get(Constants.Routes.USER_READ_ROUTE))
//                .forClass(UserService.class)
//                    .rel(RelTypes.SELF, routes.get(Constants.Routes.USER_SERVICE_ROUTE))
//                    .rel("userAuthorizations", routes.get(Constants.Routes.USER_SERVICE_AUTHORIZATIONS_ROUTE))
                .forCollectionOf(UserAuthorization.class)
                    .asRel("userAuthorizations")
                    .rel(RelTypes.SELF, routes.get(Constants.Routes.USER_AUTHORIZATIONS_ROUTE))
                    .rel(RelTypes.UP, routes.get(Constants.Routes.USER_READ_ROUTE))
                .forClass(UserAuthorization.class)
                    .rel(RelTypes.SELF, routes.get(Constants.Routes.USER_AUTHORIZATION_ROUTE));

//		.forClass(User.class)
//			.rel(RelTypes.SELF, routes.get(Constants.Routes.SINGLE_USER))
//			.rel("entries", routes.get(Constants.Routes.BLOG_ENTRIES_READ_ROUTE))
//
//		.forCollectionOf(BlogEntry.class)
//			.asRel("entries")
//			.rel(RelTypes.SELF, routes.get(Constants.Routes.BLOG_ENTRIES_READ_ROUTE))
//				.withQuery("filter={filter}")
//				.withQuery("limit={limit}")
//				.withQuery("offset={offset}")
//			.rel(RelTypes.NEXT, routes.get(Constants.Routes.BLOG_ENTRIES_READ_ROUTE) + "?offset={nextOffset}")
//				.withQuery("filter={filter}")
//				.withQuery("limit={limit}")
//				.optional()
//			.rel(RelTypes.PREV, routes.get(Constants.Routes.BLOG_ENTRIES_READ_ROUTE) + "?offset={prevOffset}")
//				.withQuery("filter={filter}")
//				.withQuery("limit={limit}")
//				.optional()
//			.rel(RelTypes.UP, routes.get(Constants.Routes.BLOG_READ_ROUTE))
//
//		.forClass(BlogEntry.class)
//			.rel(RelTypes.SELF, routes.get(Constants.Routes.BLOG_ENTRY_READ_ROUTE))
//			.rel(RelTypes.UP, routes.get(Constants.Routes.BLOG_ENTRIES_READ_ROUTE))
//			.rel("comments", routes.get(Constants.Routes.COMMENTS_READ_ROUTE))
//
//		.forCollectionOf(Comment.class)
//			.rel(RelTypes.SELF, routes.get(Constants.Routes.COMMENTS_READ_ROUTE))
//				.withQuery("filter={filter}")
//				.withQuery("limit={limit}")
//				.withQuery("offset={offset}")
//			.rel(RelTypes.NEXT, routes.get(Constants.Routes.COMMENTS_READ_ROUTE) + "?offset={nextOffset}")
//				.withQuery("filter={filter}")
//				.withQuery("limit={limit}")
//				.optional()
//			.rel(RelTypes.PREV, routes.get(Constants.Routes.COMMENTS_READ_ROUTE) + "?offset={prevOffset}")
//				.withQuery("filter={filter}")
//				.withQuery("limit={limit}")
//				.optional()
//			.rel(RelTypes.UP, routes.get(Constants.Routes.COMMENT_READ_ROUTE))
//
//		.forClass(Comment.class)
//			.rel(RelTypes.SELF, routes.get(Constants.Routes.COMMENT_READ_ROUTE))
//			.rel(RelTypes.UP, routes.get(Constants.Routes.COMMENTS_READ_ROUTE));
    }
 
开发者ID:caratarse,项目名称:caratarse-auth,代码行数:79,代码来源:Relationships.java

示例11: define

import com.strategicgains.hyperexpress.HyperExpress; //导入依赖的package包/类
public static void define(RestExpress server)
{
	Map<String, String> routes = server.getRouteUrlsByName();

	HyperExpress.relationships()
	.forCollectionOf(Blog.class)
		.rel(RelTypes.SELF, routes.get(Constants.Routes.BLOGS_READ_ROUTE))

	.forClass(Blog.class)
		.rel(RelTypes.SELF, routes.get(Constants.Routes.BLOG_READ_ROUTE))
		.rel("entries", routes.get(Constants.Routes.BLOG_ENTRIES_READ_ROUTE))

	.forCollectionOf(BlogEntry.class)
		.asRel("entries")
		.rel(RelTypes.SELF, routes.get(Constants.Routes.BLOG_ENTRIES_READ_ROUTE))
			.withQuery("filter={filter}")
			.withQuery("limit={limit}")
			.withQuery("offset={offset}")
		.rel(RelTypes.NEXT, routes.get(Constants.Routes.BLOG_ENTRIES_READ_ROUTE) + "?offset={nextOffset}")
			.withQuery("filter={filter}")
			.withQuery("limit={limit}")
			.optional()
		.rel(RelTypes.PREV, routes.get(Constants.Routes.BLOG_ENTRIES_READ_ROUTE) + "?offset={prevOffset}")
			.withQuery("filter={filter}")
			.withQuery("limit={limit}")
			.optional()
		.rel(RelTypes.UP, routes.get(Constants.Routes.BLOG_READ_ROUTE))

	.forClass(BlogEntry.class)
		.rel(RelTypes.SELF, routes.get(Constants.Routes.BLOG_ENTRY_READ_ROUTE))
		.rel(RelTypes.UP, routes.get(Constants.Routes.BLOG_ENTRIES_READ_ROUTE))
		.rel("comments", routes.get(Constants.Routes.COMMENTS_READ_ROUTE))

	.forCollectionOf(Comment.class)
		.rel(RelTypes.SELF, routes.get(Constants.Routes.COMMENTS_READ_ROUTE))
			.withQuery("filter={filter}")
			.withQuery("limit={limit}")
			.withQuery("offset={offset}")
		.rel(RelTypes.NEXT, routes.get(Constants.Routes.COMMENTS_READ_ROUTE) + "?offset={nextOffset}")
			.withQuery("filter={filter}")
			.withQuery("limit={limit}")
			.optional()
		.rel(RelTypes.PREV, routes.get(Constants.Routes.COMMENTS_READ_ROUTE) + "?offset={prevOffset}")
			.withQuery("filter={filter}")
			.withQuery("limit={limit}")
			.optional()
		.rel(RelTypes.UP, routes.get(Constants.Routes.COMMENT_READ_ROUTE))

	.forClass(Comment.class)
		.rel(RelTypes.SELF, routes.get(Constants.Routes.COMMENT_READ_ROUTE))
		.rel(RelTypes.UP, routes.get(Constants.Routes.COMMENTS_READ_ROUTE));
}
 
开发者ID:RestExpress,项目名称:RestExpress-Examples,代码行数:53,代码来源:Relationships.java


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