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


Java Error.get方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: toBson

import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
/**
 * Translates a JSON document to DBObject. Translation is metadata driven.
 */
public TranslatedBsonDoc toBson(JsonDoc doc) {
    LOGGER.debug("toBson() enter");
    JsonNode node = doc.get(OBJECT_TYPE);
    if (node == null) {
        throw Error.get(ERR_NO_OBJECT_TYPE);
    }
    EntityMetadata md = mdResolver.getEntityMetadata(node.asText());
    if (md == null) {
        throw Error.get(ERR_INVALID_OBJECTTYPE, node.asText());
    }
    ResultMetadata rmd=new ResultMetadata();
    DBObject bsonDoc = toBson(doc, md,rmd);
    LOGGER.debug("toBson() return");
    return new TranslatedBsonDoc(bsonDoc,rmd);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:19,代码来源:DocTranslator.java

示例5: 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

示例6: getLockingInstance

import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
@Override
public Locking getLockingInstance(String domain) {
    ObjectNode domainNode = findDomainNode(domain);
    if (domainNode == null) {
        throw Error.get(MongoCrudConstants.ERR_INVALID_LOCKING_DOMAIN, domain);
    }
    JsonNode datasourceName = domainNode.get("datasource");
    if (datasourceName == null) {
        throw Error.get(MongoCrudConstants.ERR_CONFIGURATION_ERROR, "locking." + domain + ".datasource");
    }
    MongoDataStore store = new MongoDataStore();
    store.setDatasourceName(datasourceName.asText());
    DB db = controller.getDbResolver().get(store);
    if (db == null) {
        throw Error.get(MongoCrudConstants.ERR_CONFIGURATION_ERROR, "locking." + domain + ".datasource");
    }
    JsonNode collection = domainNode.get("collection");
    if (collection == null) {
        throw Error.get(MongoCrudConstants.ERR_CONFIGURATION_ERROR, "locking." + domain + ".collection");
    }
    return new MongoLocking(db.getCollection(collection.asText()));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:23,代码来源:MongoLockingSupport.java

示例7: 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

示例8: getJSONParser

import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
protected JSONMetadataParser getJSONParser() {
    JSONMetadataParser parser = null;
    try {
        parser = RestConfiguration.getFactory().getJSONParser();
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        throw Error.get(RestMetadataConstants.ERR_CANT_GET_PARSER, e.getMessage());
    }
    return parser;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rest,代码行数:11,代码来源:AbstractRestCommand.java

示例9: getJsonTranslator

import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
protected JsonTranslator getJsonTranslator() {
    JsonTranslator tx = null;
    try {
        tx = RestConfiguration.getFactory().getJsonTranslator();
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        throw Error.get(RestMetadataConstants.ERR_CANT_GET_TRANSLATOR, e.getMessage());
    }
    return tx;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rest,代码行数:11,代码来源:AbstractRestCommand.java

示例10: removeEntity

import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
@Override
public void removeEntity(String entityName) {
    if (entityName == null || entityName.length() == 0) {
        throw new IllegalArgumentException(LITERAL_ENTITY_NAME);
    }
    // All versions must be disabled. Search for a schema that is not disabled
    DBObject query = new BasicDBObject(LITERAL_NAME, entityName).
            append(LITERAL_VERSION, new BasicDBObject("$exists", 1)).
            append(LITERAL_STATUS_VALUE, new BasicDBObject("$ne", MetadataParser.toString(MetadataStatus.DISABLED)));
    LOGGER.debug("Checking if there are entity versions that are not disabled: {}", query);

    DBObject result = collection.findOne(query);
    if (result != null) {
        LOGGER.debug("There is at least one enabled version {}", result);
        throw Error.get(MongoMetadataConstants.ERR_CANNOT_DELETE, entityName);
    }

    LOGGER.warn("All versions of {} are disabled, deleting {}", entityName, entityName);
    query = new BasicDBObject(LITERAL_ID, Pattern.compile(entityName + "\\" + BSONParser.DELIMITER_ID + ".*"));
    LOGGER.debug("Removal query:{}", query);
    try {
        WriteResult r = collection.remove(query);
        LOGGER.debug("Removal result:{}", r);
        if (cache != null) {
            cache.updateCollectionVersion(collection);
        }
    } catch (Exception e) {
        LOGGER.error("Error during delete", e);
        throw analyzeException(e, MongoMetadataConstants.ERR_DB_ERROR);
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:32,代码来源:MongoMetadata.java

示例11: convertObjectFieldToBson

import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
private void convertObjectFieldToBson(JsonNode node, JsonNodeCursor cursor, BasicDBObject ret, Path path, EntityMetadata md,ResultMetadata rmd) {
    if (node != null) {
        if (node instanceof ObjectNode) {
            if (cursor.firstChild()) {
                ret.append(path.tail(0), objectToBson(cursor, md,rmd));
                cursor.parent();
            }
        } 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,代码行数:15,代码来源:DocTranslator.java

示例12: getPreparedStatement

import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
public static PreparedStatement getPreparedStatement(RDBMSContext context) {
    if (context.getConnection() == null) {
        throw new IllegalArgumentException("No connection supplied");
    }
    if (context.getSql() == null) {
        throw new IllegalArgumentException("No sql statement supplied");
    }
    if (context.getType() == null) {
        throw new IllegalArgumentException("No sql statement type supplied");
    }
    LOGGER.debug("getPreparedStatement() start");
    Error.push("RDBMSUtils");
    Error.push("getStatement");
    PreparedStatement ps = null;
    try {
        ps = context.getConnection().prepareStatement(context.getSql());
    } catch (SQLException e) {
        // throw new Error (preserves current error context)
        LOGGER.error(e.getMessage(), e);
        throw Error.get(RDBMSConstants.ERR_GET_STATEMENT_FAILED, e.getMessage());
    } finally {
        Error.pop();
        Error.pop();
    }
    context.setPreparedStatement(ps);
    LOGGER.debug("getPreparedStatement() stop");
    return ps;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:29,代码来源:RDBMSUtilsMetadata.java

示例13: getStatement

import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
public static PreparedStatement getStatement(RDBMSContext context) {
    if (context.getConnection() == null) {
        throw new IllegalArgumentException("No connection supplied");
    }
    if (context.getSql() == null) {
        throw new IllegalArgumentException("No sql statement supplied");
    }
    if (context.getType() == null) {
        throw new IllegalArgumentException("No sql statement type supplied");
    }
    LOGGER.debug("getStatement() start");
    Error.push("RDBMSUtils");
    Error.push("getStatement");
    PreparedStatement ps = null;
    try {
        NamedParameterStatement nps = new NamedParameterStatement(context.getConnection(), context.getSql());
        DynVar dynVar = context.getInVar();
        processDynVar(context,nps,dynVar);
        dynVar = context.getOutVar();
        processDynVar(context,nps,dynVar);
        ps = nps.getPrepareStatement();
    } catch (SQLException e) {
        // throw new Error (preserves current error context)
        LOGGER.error(e.getMessage(), e);
        throw Error.get(RDBMSConstants.ERR_GET_STATEMENT_FAILED, e.getMessage());
    } finally {
        Error.pop();
        Error.pop();
    }
    context.setPreparedStatement(ps);
    LOGGER.debug("getStatement() stop");
    return ps;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:34,代码来源:RDBMSUtilsMetadata.java

示例14: validateArrayIndexes

import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
/**
 * Array indexes must not end with `*`
 * @param indexes
 */
private void validateArrayIndexes(List<Index> indexes) {
    boolean endsWithAny = indexes.stream().flatMap(i -> i.getFields().stream()).map(f -> f.getField()).anyMatch(p -> p.getLast().equals(Path.ANY));
    if(endsWithAny) {
        throw Error.get(MongoCrudConstants.ERR_INVALID_INDEX_FIELD);
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:11,代码来源:MongoCRUDController.java

示例15: validateNoHiddenInMetaData

import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
private void validateNoHiddenInMetaData(EntityMetadata emd) {
    FieldCursor cursor = emd.getFieldCursor();
    while (cursor.next()) {
        if (cursor.getCurrentPath().getLast().equals(DocTranslator.HIDDEN_SUB_PATH.getLast())) {
            throw Error.get(MongoCrudConstants.ERR_RESERVED_FIELD);
        }
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:9,代码来源:MongoCRUDController.java


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