本文整理汇总了Java中com.redhat.lightblue.util.Error类的典型用法代码示例。如果您正苦于以下问题:Java Error类的具体用法?Java Error怎么用?Java Error使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Error类属于com.redhat.lightblue.util包,在下文中一共展示了Error类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: find
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
/**
* This endpoint streams the results with chunked encoding if
* stream query parameter is true
*/
@POST
@LZF
@Path("/find/{entity}/{version}")
public Response find(@PathParam(PARAM_ENTITY) String entity,
@PathParam(PARAM_VERSION) String version,
@QueryParam("stream") Boolean stream,
String request) {
Error.reset();
boolean bstream=stream!=null&&stream;
FindCommand f=new FindCommand(entity, version, request, bstream, METRICS);
CallStatus st=f.run();
if(!st.hasErrors()&&bstream) {
// This is how you stream. You put a response stream into
// the response, and data is streamed to the client
return Response.ok().entity(f.getResponseStream()).build();
} else {
return Response.status(st.getHttpStatus()).entity(st.toString()).build();
}
}
开发者ID:lightblue-platform,项目名称:lightblue-rest,代码行数:24,代码来源:AbstractCrudResource.java
示例2: translate
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
@Override
protected void translate(SimpleField field, JsonNode node, Object target) {
String attributeName = fieldNameTranslator.translateFieldName(field.getFullPath());
if(LdapConstant.ATTRIBUTE_DN.equalsIgnoreCase(attributeName)){
//DN is derived using metadata.uniqueattr, providing it is confusing.
throw Error.get(MetadataConstants.ERR_INVALID_FIELD_REFERENCE, LdapConstant.ATTRIBUTE_DN);
}
Type type = field.getType();
Object o = fromJson(type, node);
if(type instanceof BinaryType) {
((Entry) target).addAttribute(attributeName, (byte[])o);
}
else{
((Entry) target).addAttribute(attributeName, o.toString());
}
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:19,代码来源:EntryTranslatorFromJson.java
示例3: simpleFind
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
@GET
@LZF
@Path("/find/{entity}/{version}")
//?Q&P&S&from&to
public Response simpleFind(@PathParam(PARAM_ENTITY) String entity,
@PathParam(PARAM_VERSION) String version,
@QueryParam("Q") String q,
@QueryParam("P") String p,
@QueryParam("S") String s,
@QueryParam("from") Long from,
@QueryParam("to") Long to,
@QueryParam("maxResults") Long maxResults) throws IOException {
Error.reset();
String request=buildSimpleRequest(entity,version,q,p,s,from,to,maxResults).toString();
CallStatus st = new FindCommand(null, entity, version, request, METRICS).run();
return Response.status(st.getHttpStatus()).entity(st.toString()).build();
}
开发者ID:lightblue-platform,项目名称:lightblue-rest,代码行数:18,代码来源:AbstractCrudResource.java
示例4: simpleExplain
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
@GET
@LZF
@Path("/explain/{entity}/{version}")
//?Q&P&S&from&to
public Response simpleExplain(@PathParam(PARAM_ENTITY) String entity,
@PathParam(PARAM_VERSION) String version,
@QueryParam("Q") String q,
@QueryParam("P") String p,
@QueryParam("S") String s,
@QueryParam("from") Long from,
@QueryParam("to") Long to,
@QueryParam("maxResults") Long maxResults) throws IOException {
Error.reset();
String request=buildSimpleRequest(entity,version,q,p,s,from,to,maxResults).toString();
CallStatus st = new ExplainCommand(null, entity, version, request, METRICS).run();
return Response.status(st.getHttpStatus()).entity(st.toString()).build();
}
开发者ID:lightblue-platform,项目名称:lightblue-rest,代码行数:18,代码来源:AbstractCrudResource.java
示例5: getMediator
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
/**
* Returns the mediator. If no mediator is set on the command uses
* CrudManager#getMediator() method.
*
* @return
* @throws Exception
*/
protected Mediator getMediator() {
Mediator m = null;
try {
if (null != mediator) {
m = mediator;
} else {
m = RestConfiguration.getFactory().getMediator();
}
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
throw Error.get(RestCrudConstants.ERR_CANT_GET_MEDIATOR);
}
return m;
}
开发者ID:lightblue-platform,项目名称:lightblue-rest,代码行数:23,代码来源:AbstractRestCommand.java
示例6: validateReq
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
protected void validateReq(Request req, String entity, String version) {
// If entity and/or version is not set in the request, this
// code below sets it from the uri
if (req.getEntityVersion() == null) {
req.setEntityVersion(new EntityVersion());
}
if (req.getEntityVersion().getEntity() == null) {
req.getEntityVersion().setEntity(entity);
}
if (req.getEntityVersion().getVersion() == null) {
req.getEntityVersion().setVersion(version);
}
if (!req.getEntityVersion().getEntity().equals(entity)) {
throw Error.get(RestCrudConstants.ERR_NO_ENTITY_MATCH, entity);
}
if (req.getEntityVersion().getVersion() != null && version != null
&& !req.getEntityVersion().getVersion().equals(version)) {
throw Error.get(RestCrudConstants.ERR_NO_VERSION_MATCH, version);
}
}
开发者ID:lightblue-platform,项目名称:lightblue-rest,代码行数:21,代码来源:AbstractRestCommand.java
示例7: recursiveTranslateArrayElemMatch
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
protected void recursiveTranslateArrayElemMatch(TranslationContext translationContext, ArrayMatchExpression arrayMatchExpression) {
/*
TODO Need to define what would happen in this scenario (not supported yet)
FieldTreeNode arrayNode = resolve(translationContext.fieldTreeNode, arrayMatchExpression.getArray());
if (arrayNode instanceof ArrayField) {
ArrayElement arrayElement = ((ArrayField) arrayNode).getElement();
if (arrayElement instanceof ObjectArrayElement) {
FieldTreeNode tmpFieldTreeNode = translationContext.fieldTreeNode;
translationContext.fieldTreeNode = arrayElement;
recursiveTranslateQuery(translationContext, arrayMatchExpression.getElemMatch());
String path = translatePath(arrayMatchExpression.getArray());
translationContext.fieldTreeNode = tmpFieldTreeNode;
throw Error.get(RDBMSConstants.ERR_NO_OPERATOR, arrayMatchExpression.toString());
}
}
*/
throw com.redhat.lightblue.util.Error.get(RDBMSConstants.INV_FIELD, arrayMatchExpression.toString());
}
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:19,代码来源:Translator.java
示例8: recursiveTranslateRegexMatchExpression
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
@Override
protected void recursiveTranslateRegexMatchExpression(TranslationContext translationContext, RegexMatchExpression regexMatchExpression) {
String regex = regexMatchExpression.getRegex();
Path lField = regexMatchExpression.getField();
String f = lField.toString();
ProjectionMapping fpm = translationContext.fieldToProjectionMap.get(f);
Join fJoin = translationContext.projectionToJoinMap.get(fpm);
fillTables(translationContext, translationContext.baseStmt.getFromTables(), fJoin);
fillWhere(translationContext, translationContext.baseStmt.getWhereConditionals(), fJoin);
if(translationContext.notOp){
throw Error.get(RDBMSConstants.ERR_NO_OPERATOR, regexMatchExpression.toString());
}
String options = regexMatchExpression.isCaseInsensitive()?"i":"c";
options = options + (regexMatchExpression.isDotAll()?"n":"");
options = options + (regexMatchExpression.isMultiline()?"m":"");
String s = "REGEXP_LIKE("+ fpm.getColumn() +",'"+ regex + "','"+ options +"')";
addConditional(translationContext, s);
}
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:22,代码来源:OracleTranslator.java
示例9: recursiveTranslateQuery
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
protected void recursiveTranslateQuery(TranslationContext translationContext, QueryExpression queryExpression) {
if (queryExpression instanceof ArrayContainsExpression) {
recursiveTranslateArrayContains(translationContext, (ArrayContainsExpression) queryExpression);
} else if (queryExpression instanceof ArrayMatchExpression) {
recursiveTranslateArrayElemMatch(translationContext, (ArrayMatchExpression) queryExpression);
} else if (queryExpression instanceof FieldComparisonExpression) {
recursiveTranslateFieldComparison(translationContext, (FieldComparisonExpression) queryExpression);
} else if (queryExpression instanceof NaryLogicalExpression) {
recursiveTranslateNaryLogicalExpression(translationContext, (NaryLogicalExpression) queryExpression);
} else if (queryExpression instanceof NaryRelationalExpression) {
recursiveTranslateNaryRelationalExpression(translationContext, (NaryRelationalExpression) queryExpression);
} else if (queryExpression instanceof RegexMatchExpression) {
recursiveTranslateRegexMatchExpression(translationContext, (RegexMatchExpression) queryExpression);
} else if (queryExpression instanceof UnaryLogicalExpression) {
recursiveTranslateUnaryLogicalExpression(translationContext, (UnaryLogicalExpression) queryExpression);
} else if (queryExpression instanceof ValueComparisonExpression) {
recursiveTranslateValueComparisonExpression(translationContext, (ValueComparisonExpression) queryExpression);
} else {
throw Error.get(RDBMSConstants.ERR_SUP_QUERY, queryExpression!=null?queryExpression.toString():"q=null");
}
}
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:22,代码来源:Translator.java
示例10: getDBObject
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
public static Object getDBObject(DBObject start, Path p) {
int n = p.numSegments();
Object trc = start;
for (int seg = 0; seg < n; seg++) {
String segment = p.head(seg);
if (segment.equals(Path.ANY)) {
throw Error.get(MongoCrudConstants.ERR_TRANSLATION_ERROR, p.toString());
} else if (trc != null && Util.isNumber(segment)) {
trc = ((List) trc).get(Integer.valueOf(segment));
} else if (trc != null) {
trc = ((DBObject) trc).get(segment);
}
if (trc == null && seg + 1 < n) {
//At least one element in the Path is optional and does not exist in the document. Just return null.
LOGGER.debug("Error retrieving path {} with {} segments from {}", p, p.numSegments(), start);
return null;
}
}
return trc;
}
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:21,代码来源:DocTranslator.java
示例11: recursiveTranslateNaryRelationalExpression
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
protected void recursiveTranslateNaryRelationalExpression(TranslationContext translationContext, NaryRelationalExpression naryRelationalExpression){
Type t = resolve(translationContext.fieldTreeNode, naryRelationalExpression.getField()).getType();
if (t.supportsEq()) {
List<Object> values = translateValueList(t, naryRelationalExpression.getValues());
String field = naryRelationalExpression.getField().toString();
String operator = naryRelationalExpression.getOp().toString().equals(NaryRelationalOperator._in.toString()) ?"IN" : "NOT IN";
ProjectionMapping fpm = translationContext.fieldToProjectionMap.get(field);
Join fJoin = translationContext.projectionToJoinMap.get(fpm);
fillTables(translationContext, translationContext.baseStmt.getFromTables(), fJoin);
fillWhere(translationContext, translationContext.baseStmt.getWhereConditionals(), fJoin);
String result = fpm.getColumn() + " " + operator + " " + "('" +StringUtils.join(values, "','")+"')";
addConditional(translationContext, result);
} else {
throw Error.get(RDBMSConstants.INV_FIELD, naryRelationalExpression.toString());
}
}
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:18,代码来源:Translator.java
示例12: convertArrayFieldToBson
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
private void convertArrayFieldToBson(JsonNode node, JsonNodeCursor cursor, BasicDBObject ret, FieldTreeNode fieldMdNode, Path path, EntityMetadata md,ResultMetadata rmd) {
if (node != null) {
if (node instanceof ArrayNode) {
if (cursor.firstChild()) {
ret.append(path.tail(0), arrayToBson(cursor, ((ArrayField) fieldMdNode).getElement(), md,rmd));
cursor.parent();
} else {
// empty array! add an empty list.
ret.append(path.tail(0), new ArrayList());
}
} else if (node instanceof NullNode) {
ret.append(path.tail(0), null);
} else {
throw Error.get(ERR_INVALID_FIELD, path.toString());
}
}
}
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:18,代码来源:DocTranslator.java
示例13: setResultSizeThresholds
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
public void setResultSizeThresholds(int maxResultSetSizeB, int warnResultSetSizeB, final QueryExpression forQuery) {
this.memoryMonitor = new MemoryMonitor<>((doc) -> {
int size = JsonUtils.size(doc.getRoot());
// account for docs copied by DocCtx.startModifications()
if (doc.getOriginalDocument() != null) {
size += JsonUtils.size(doc.getOriginalDocument().getRoot());
}
if (doc.getUpdatedDocument() != null) {
size += JsonUtils.size(doc.getUpdatedDocument().getRoot());
}
return size;
});
memoryMonitor.registerMonitor(new ThresholdMonitor<DocCtx>(maxResultSetSizeB, (current, threshold, doc) -> {
throw Error.get(MongoCrudConstants.ERROR_RESULT_SIZE_TOO_LARGE, current+"B > "+threshold+"B");
}));
memoryMonitor.registerMonitor(new ThresholdMonitor<DocCtx>(warnResultSetSizeB, (current, threshold, doc) -> {
LOGGER.warn("{}: query={}, responseDataSizeB={}", MongoCrudConstants.WARN_RESULT_SIZE_LARGE,forQuery, current);
}));
}
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:24,代码来源:IterateAndUpdate.java
示例14: ensureObjectClassField
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
/**
* Ensures the objectClass field is present on the entity. If not, then it will added. If so, but
* is defined incorrectly, then an {@link Error} will be thrown.
*/
private void ensureObjectClassField(EntityMetadata md, Path objectClassFieldPath) {
FieldTreeNode objectClassNode;
try{
objectClassNode = md.resolve(objectClassFieldPath);
}
catch(Error e){
addFieldToParent(md, objectClassFieldPath,
(Field) (objectClassNode = new ArrayField(objectClassFieldPath.getLast(), new SimpleArrayElement(StringType.TYPE))));
}
if(!(objectClassNode instanceof ArrayField)){
throw Error.get(MetadataConstants.ERR_FIELD_WRONG_TYPE, objectClassNode.getFullPath().toString());
}
ArrayField objectClassField = (ArrayField) objectClassNode;
if(!(objectClassField.getElement().getType() instanceof StringType)){
throw Error.get(MetadataConstants.ERR_FIELD_WRONG_TYPE, objectClassField.getFullPath().toString());
}
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:22,代码来源:LdapMetadataListener.java
示例15: translateNaryFieldRelationalExpression
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
/**
* <pre>
* in:
* var r0=false;
* nin:
* var r=true;
* for(var i=0;i<this.arr.length;i++) {
* if(this.arr[i]==this.field) {
* in:
* r0=true;
* nin:
* r0=false;
* break;
* }
* }
* return r0
* </pre>
*/
private Block translateNaryFieldRelationalExpression(Context ctx,NaryFieldRelationalExpression query) {
FieldTreeNode fieldMd=ctx.contextNode.resolve(query.getField());
if(!fieldMd.getType().supportsEq()) {
throw Error.get(ERR_INVALID_COMPARISON, query.toString());
}
Block block=new Block(ctx.topLevel.newGlobal(ctx,query.getOp()==NaryRelationalOperator._in?"false":"true"));
Name rname=ctx.varName(new Name(query.getRfield()));
Name lname=ctx.varName(new Name(query.getField()));
ArrForLoop loop=new ArrForLoop(ctx.newName("i"),rname);
block.add(IfStatement.ifDefined(rname,lname,loop));
SimpleExpression cmpExpression=new SimpleExpression(fieldMd.getType() instanceof DateType?
"this.%s[%s].valueOf()==this.%s.valueOf()":
"this.%s[%s]==this.%s",rname,
loop.loopVar,
lname);
loop.add(new IfStatement(cmpExpression,
new SimpleStatement("%s=%s",block.resultVar,query.getOp()==NaryRelationalOperator._in?"true":"false"),
SimpleStatement.S_BREAK));
return block;
}
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:39,代码来源:JSQueryTranslator.java
示例16: translateRegexMatchExpression
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
/**
* <pre>
* var r0=new RegExp("pattern","options");
* var r1=false;
* r1=r0.test(field);
* return r1;
* </pre>
*/
private Block translateRegexMatchExpression(Context ctx,RegexMatchExpression query) {
FieldTreeNode fieldMd=ctx.contextNode.resolve(query.getField());
if(fieldMd.getType() instanceof StringType) {
Name fieldName=ctx.varName(new Name(query.getField()));
String regexVar=ctx.topLevel.newGlobal(ctx,String.format("new RegExp(\"%s\",\"%s\")",
query.getRegex().replaceAll("\"","\\\""),
regexFlags(query)));
Block block=new Block(ctx.topLevel.newGlobalBoolean(ctx));
block.add(IfStatement.ifDefined(fieldName,new SimpleStatement("%s=%s.test(this.%s)",
block.resultVar,
regexVar,
fieldName.toString())));
return block;
} else
throw Error.get(ERR_INVALID_COMPARISON,query.toString());
}
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:26,代码来源:JSQueryTranslator.java
示例17: varName
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
public Name varName(Name localName) {
FieldTreeNode current=contextNode;
Name p=new Name();
if(contextBlock!=null)
p.add(contextBlock.getDocumentLoopVarAsPrefix());
int n=localName.length();
for(int i=0;i<n;i++) {
Name.Part seg=localName.getPart(i);
if(Path.PARENT.equals(seg.name)) {
p.removeLast();
current=current.getParent();
if(current==null)
throw Error.get(JSQueryTranslator.ERR_INVALID_FIELD,localName.toString());
} else if(Path.THIS.equals(seg.name)) {
; // Stay here
} else {
p.add(seg);
// This will throw an exception if it cannot resolve seg
if(seg.index)
current=current.resolve(Path.ANYPATH);
else
current=current.resolve(new Path(seg.name));
}
}
return p;
}
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:27,代码来源:Context.java
示例18: translateValueComparisonExpression
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
private DBObject translateValueComparisonExpression(FieldTreeNode context, EntityMetadata md, ValueComparisonExpression expr,MutablePath fullPath) {
FieldInfo finfo=resolveFieldForQuery(context,fullPath.immutableCopy(),expr.getField());
Type t = finfo.fieldMd.getType();
Object value = expr.getRvalue().getValue();
if (expr.getOp() == BinaryComparisonOperator._eq
|| expr.getOp() == BinaryComparisonOperator._neq) {
if (!t.supportsEq() && value != null) {
throw Error.get(ERR_INVALID_COMPARISON, expr.toString());
}
} else if (!t.supportsOrdering()) {
throw Error.get(ERR_INVALID_COMPARISON, expr.toString());
}
Object valueObject = DocTranslator.filterBigNumbers(t.cast(value));
if (finfo.field.equals(ID_PATH)) {
valueObject = DocTranslator.createIdFrom(valueObject);
}
if (expr.getOp() == BinaryComparisonOperator._eq) {
return new BasicDBObject(translatePath(finfo.field), valueObject);
} else {
return new BasicDBObject(translatePath(finfo.field),
new BasicDBObject(BINARY_COMPARISON_OPERATOR_MAP.get(expr.getOp()), valueObject));
}
}
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:25,代码来源:ExpressionTranslator.java
示例19: translateArrayContains
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
private DBObject translateArrayContains(FieldTreeNode context, EntityMetadata md, ArrayContainsExpression expr,MutablePath fullPath) {
DBObject ret = null;
FieldInfo finfo=resolveFieldForQuery(context,fullPath.immutableCopy(),expr.getArray());
if (finfo.fieldMd instanceof ArrayField) {
Type t = ((ArrayField) finfo.fieldMd).getElement().getType();
switch (expr.getOp()) {
case _all:
ret = translateArrayContainsAll(t, finfo.field, expr.getValues());
break;
case _any:
ret = translateArrayContainsAny(t, finfo.field, expr.getValues());
break;
case _none:
ret = translateArrayContainsNone(t, finfo.field, expr.getValues());
break;
}
} else {
throw Error.get(ERR_INVALID_FIELD, expr.toString());
}
return ret;
}
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:22,代码来源:ExpressionTranslator.java
示例20: checkDataStoreIsValid
import com.redhat.lightblue.util.Error; //导入依赖的package包/类
@Override
protected void checkDataStoreIsValid(EntityInfo md) {
DataStore store = md.getDataStore();
if (factory.getCRUDController(md.getDataStore().getBackend()) == null) {
throw new IllegalArgumentException(MongoMetadataConstants.ERR_INVALID_DATASTORE);
}
if (store instanceof MongoDataStore) {
for (char c : INVALID_COLLECTION_CHARS) {
if (((MongoDataStore) store).getCollectionName().indexOf(c) >= 0) {
throw Error.get(MongoMetadataConstants.ERR_INVALID_DATASTORE, ((MongoDataStore) store).getCollectionName());
}
}
}
}
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:17,代码来源:MongoMetadata.java
注:本文中的com.redhat.lightblue.util.Error类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论