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


Java ValidationEngine类代码示例

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


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

示例1: create

import com.strategicgains.syntaxe.ValidationEngine; //导入依赖的package包/类
/**
 * Creates a Document, ensuring that all business rules are met.
 *
 * @param database Database to insert the document into.
 * @param table Table to insert the document into.
 * @param json String of the JSON to insert.
 * @return The created document.
 * @throws IndexParseException If the document contains a field that should
 * be indexable, but isn't for some reason (probably the wrong datatype).
 */
public Document create(String database, String table, String json) throws IndexParseException
{
    verifyTable(database, table);

    Document doc = new Document();
    doc.setTable(database, table);
    doc.setObjectAsString(json);
    doc.setUuid(UUID.randomUUID());//TODO: is this right? -- https://github.com/PearsonEducation/Docussandra/issues/4
    ValidationEngine.validateAndThrow(doc);
    try
    {
        Document created = docRepo.create(doc);
        notifyAllPlugins(NotifierPlugin.MutateType.CREATE, created);
        return created;
    } catch (RuntimeException e)//the framework does not allow us to throw the IndexParseException directly from the repository layer
    {
        if (e.getCause() != null && e.getCause() instanceof IndexParseException)
        {
            throw (IndexParseException) e.getCause();
        } else
        {
            throw e;
        }
    }
}
 
开发者ID:PearsonEducation,项目名称:Docussandra,代码行数:36,代码来源:DocumentService.java

示例2: create

import com.strategicgains.syntaxe.ValidationEngine; //导入依赖的package包/类
/**
 * Creates an index. Index will be created synchronously, but it will be
 * populated asynchronously, and it will not be "active" (meaning it can't
 * be used for querying) until indexing is complete. Inactive indexes will
 * still be populated by NEW records that are being inserted.
 *
 * @param index Index to create.
 * @return An IndexCreatedEvent that contains the index and some metadata
 * about it's creation status.
 */
public IndexCreatedEvent create(Index index)
{
    verifyTable(index.getDatabaseName(), index.getTableName());
    ValidationEngine.validateAndThrow(index);

    index.setActive(false);//we default to not active when being created; we don't allow the user to change this; only the app can change this
    logger.debug("Creating index: " + index.toString());
    Index created = indexesRepo.create(index);
    long dataSize = tablesRepo.countTableSize(index.getDatabaseName(), index.getTableName());
    Date now = new Date();
    UUID uuid = UUID.randomUUID();//TODO: is this right?
    IndexCreatedEvent toReturn = new IndexCreatedEvent(uuid, now, now, created, dataSize, 0l);
    statusRepo.create(toReturn);
    toReturn.calculateValues();
    DomainEvents.publish(toReturn);
    return toReturn;
}
 
开发者ID:PearsonEducation,项目名称:Docussandra,代码行数:28,代码来源:IndexService.java

示例3: create

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

示例4: create

import com.strategicgains.syntaxe.ValidationEngine; //导入依赖的package包/类
public Blog create(Request request, Response response)
{
	Blog blog = request.getBodyAs(Blog.class, "Blog details not provided");
	ValidationEngine.validateAndThrow(blog);
	Blog saved = blogs.create(blog);

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

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

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

示例5: create

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

示例6: create

import com.strategicgains.syntaxe.ValidationEngine; //导入依赖的package包/类
public BlogEntry create(Request request, Response response)
{
	String blogId = request.getHeader(Constants.Url.BLOG_ID_PARAMETER, "No Blog ID provided");
	BlogEntry blogEntry = request.getBodyAs(BlogEntry.class, "BlogEntry details not provided");
	Blog blog = blogs.read(UUID.parse(blogId));
	blogEntry.setBlogId(blog.getUuid());
	ValidationEngine.validateAndThrow(blogEntry);
	BlogEntry saved = blogEntries.create(blogEntry);

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

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

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

示例7: update

import com.strategicgains.syntaxe.ValidationEngine; //导入依赖的package包/类
/**
 * Updates a document.
 *
 * @param entity The document you are trying to update with the changes you
 * are trying to apply.
 */
public void update(Document entity)
{
    ValidationEngine.validateAndThrow(entity);
    docRepo.update(entity);
    notifyAllPlugins(NotifierPlugin.MutateType.UPDATE, entity);
}
 
开发者ID:PearsonEducation,项目名称:Docussandra,代码行数:13,代码来源:DocumentService.java

示例8: create

import com.strategicgains.syntaxe.ValidationEngine; //导入依赖的package包/类
public Table create(Table entity)
{
    if (!databases.exists(entity.getDatabase().getId()))
    {
        throw new ItemNotFoundException("Database not found: " + entity.getDatabase());
    }
    //check if the table exits
    if (tables.exists(entity.getId()))
    {
        throw new DuplicateItemException("Table name already exists");
    }

    ValidationEngine.validateAndThrow(entity);
    return tables.create(entity);
}
 
开发者ID:PearsonEducation,项目名称:Docussandra,代码行数:16,代码来源:TableService.java

示例9: create

import com.strategicgains.syntaxe.ValidationEngine; //导入依赖的package包/类
public Database create(Database entity)
{
    logger.info("Attempting to create database: " + entity);
    //check if database name exists
    if(databases.exists(entity.getId())) {
        throw new DuplicateItemException("Database name already exists");
    }
    else{
        ValidationEngine.validateAndThrow(entity);
        return databases.create(entity);
    }
}
 
开发者ID:PearsonEducation,项目名称:Docussandra,代码行数:13,代码来源:DatabaseService.java

示例10: update

import com.strategicgains.syntaxe.ValidationEngine; //导入依赖的package包/类
public void update(Request request, Response response) {
    String uuid = request.getHeader(Constants.Url.USER_UUID, "No User UUID supplied");
    User dbUser = userBo.getUser(uuid);
    if (dbUser == null) {
        response.setResponseStatus(HttpResponseStatus.NOT_FOUND);
        return;
    }
    User user = request.getBodyAs(User.class, "User details not provided");
    dbUser.copy(user);
    ValidationEngine.validateAndThrow(dbUser);
    userBo.store(dbUser);
    response.setResponseNoContent();
}
 
开发者ID:caratarse,项目名称:caratarse-auth,代码行数:14,代码来源:UserController.java

示例11: update

import com.strategicgains.syntaxe.ValidationEngine; //导入依赖的package包/类
public void update(Request request, Response response)
{
	String id = request.getHeader(Constants.Url.BLOG_ID_PARAMETER);
	Blog blog = request.getBodyAs(Blog.class, "Blog details not provided");

	// Can't change the blod ID via update.
	blog.setId(UUID.parse(id));

	ValidationEngine.validateAndThrow(blog);
	blogs.update(blog);
	response.setResponseNoContent();
}
 
开发者ID:RestExpress,项目名称:RestExpress-Examples,代码行数:13,代码来源:BlogController.java

示例12: update

import com.strategicgains.syntaxe.ValidationEngine; //导入依赖的package包/类
public void update(Request request, Response response)
{
	String id = request.getHeader(Constants.Url.COMMENT_ID_PARAMETER, "No Comment ID supplied");
	String blogEntryId = request.getHeader(Constants.Url.BLOG_ENTRY_ID_PARAMETER, "Blog Entry ID not provided");
	Comment comment = request.getBodyAs(Comment.class, "Comment details not provided");
	BlogEntry entry = entries.read(UUID.parse(blogEntryId));

	// Cannot change entry, comment IDs on update.
	comment.setId(UUID.parse(id));
	comment.setBlogEntryId(entry.getUuid());
	ValidationEngine.validateAndThrow(comment);
	comments.update(comment);
	response.setResponseNoContent();
}
 
开发者ID:RestExpress,项目名称:RestExpress-Examples,代码行数:15,代码来源:CommentController.java

示例13: update

import com.strategicgains.syntaxe.ValidationEngine; //导入依赖的package包/类
public void update(Request request, Response response)
{
	String blogId = request.getHeader(Constants.Url.BLOG_ID_PARAMETER, "Blog ID not provided");
	String id = request.getHeader(Constants.Url.BLOG_ENTRY_ID_PARAMETER);
	BlogEntry blogEntry = request.getBodyAs(BlogEntry.class, "BlogEntry details not provided");

	// Cannot change the blog, blog entry IDs via update.
	Blog blog = blogs.read(UUID.parse(blogId));
	blogEntry.setBlogId(blog.getUuid());
	blogEntry.setId(UUID.parse(id));

	ValidationEngine.validateAndThrow(blogEntry);
	blogEntries.update(blogEntry);
	response.setResponseNoContent();
}
 
开发者ID:RestExpress,项目名称:RestExpress-Examples,代码行数:16,代码来源:BlogEntryController.java

示例14: update

import com.strategicgains.syntaxe.ValidationEngine; //导入依赖的package包/类
public void update(Table entity)
{
    ValidationEngine.validateAndThrow(entity);
    tables.update(entity);
}
 
开发者ID:PearsonEducation,项目名称:Docussandra,代码行数:6,代码来源:TableService.java

示例15: update

import com.strategicgains.syntaxe.ValidationEngine; //导入依赖的package包/类
public void update(Database entity)
{
    logger.info("Attempting to update database: " + entity.getName());
    ValidationEngine.validateAndThrow(entity);
    databases.update(entity);
}
 
开发者ID:PearsonEducation,项目名称:Docussandra,代码行数:7,代码来源:DatabaseService.java


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