本文整理汇总了Java中com.strategicgains.syntaxe.ValidationEngine.validateAndThrow方法的典型用法代码示例。如果您正苦于以下问题:Java ValidationEngine.validateAndThrow方法的具体用法?Java ValidationEngine.validateAndThrow怎么用?Java ValidationEngine.validateAndThrow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.strategicgains.syntaxe.ValidationEngine
的用法示例。
在下文中一共展示了ValidationEngine.validateAndThrow方法的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;
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例14: update
import com.strategicgains.syntaxe.ValidationEngine; //导入方法依赖的package包/类
public void update(Table entity)
{
ValidationEngine.validateAndThrow(entity);
tables.update(entity);
}
示例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);
}