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


Java Error类代码示例

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


Error类属于com.redhat.lightblue.util包,在下文中一共展示了Error类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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