本文整理汇总了Java中com.redhat.lightblue.util.Error.push方法的典型用法代码示例。如果您正苦于以下问题:Java Error.push方法的具体用法?Java Error.push怎么用?Java Error.push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.redhat.lightblue.util.Error
的用法示例。
在下文中一共展示了Error.push方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConnection
import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
public static Connection getConnection(RDBMSContext context) {
if (context.getDataSource() == null) {
throw new IllegalArgumentException("No dataSource supplied");
}
LOGGER.debug("getConnection() start");
Error.push("RDBMSUtils");
Error.push("getConnection");
Connection c = null;
try {
c = context.getDataSource().getConnection();
} catch (SQLException e) {
// throw new Error (preserves current error context)
LOGGER.error(e.getMessage(), e);
throw Error.get(RDBMSConstants.ERR_GET_CONNECTION_FAILED, e.getMessage());
} finally {
Error.pop();
Error.pop();
}
context.setConnection(c);
LOGGER.debug("getConnection() stop");
return c;
}
示例2: getDataSource
import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
/**
* This method search in the javax.naming.InitialContext for the given JNDI name. An Error will rise if not found.
*
* @param name
* The JNDI name
* @return
* If found, it will return the DataSource bound into the InitialContext
*/
public static DataSource getDataSource(String name) {
LOGGER.debug("getDataSource() start");
Error.push("RDBMSUtils");
Error.push("getDataSource");
DataSource ds = null;
try {
// relying on garbage collection to close context
InitialContext context = new InitialContext();
ds = (DataSource) context.lookup(name);
} catch (NamingException e) {
LOGGER.error(e.getMessage(), e);
throw Error.get(RDBMSConstants.ERR_DATASOURCE_NOT_FOUND, e.getMessage());
} finally {
Error.pop();
Error.pop();
}
LOGGER.debug("getDataSource() stop");
return ds;
}
示例3: getLockCommand
import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
public static AbstractLockCommand getLockCommand(String request, RequestMetrics metrics) {
AbstractLockCommand command = null;
try {
ObjectMapper mapper = new ObjectMapper();
JsonNode rootNode = mapper.readValue(request, JsonNode.class);
String operation = rootNode.get("operation").asText();
String domain = rootNode.get("domain").asText();
String callerId = rootNode.get("callerId").asText();
String resourceId = rootNode.get("resourceId").asText();
switch(operation) {
case OPERATION_ACQUIRE :
Long ttl = null;
if(null != rootNode.get("ttl")) {
ttl = rootNode.get("ttl").asLong();
}
command = new AcquireCommand(domain, callerId, resourceId, ttl, metrics);
break;
case OPERATION_RELEASE :
command = new ReleaseCommand(domain, callerId, resourceId, metrics);
break;
case OPERATION_COUNT :
command = new GetLockCountCommand(domain, callerId, resourceId, metrics);
break;
case OPERATION_PING :
command = new LockPingCommand(domain, callerId, resourceId, metrics);
break;
default :
Error.push("Error parsing lock request");
}
} catch (Exception e) {
Error.push("Error parsing lock request");
}
return command;
}
示例4: translate
import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
public ModifyRequest translate(JsonDoc document, String dn) {
Error.push(LdapConstant.ATTRIBUTE_DN + "=" + dn);
try {
return new ModifyRequest(dn, translate(document));
} finally {
Error.pop();
}
}
示例5: translate
import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
@Override
public JsonDoc translate(SearchResultEntry entry){
Error.push(LdapConstant.ATTRIBUTE_DN + "=" + entry.getDN());
try{
JsonDoc jdoc = super.translate(entry);
jdoc.modify(dnPath, toJson(StringType.TYPE, entry.getDN()), true);
return jdoc;
}
finally{
Error.pop();
}
}
示例6: translate
import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
@Override
public void translate(JsonDoc document, Entry target){
Error.push(LdapConstant.ATTRIBUTE_DN + "=" + target.getDN());
try{
super.translate(document, target);
}
finally{
Error.pop();
}
}
示例7: insert
import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
@Override
public CRUDInsertionResponse insert(CRUDOperationContext crudOperationContext, Projection projection) {
LOGGER.debug("insert() start");
Error.push("insert");
//crudOperationContext.getDocuments(); // input? or maybe the projection mapping the values to be processed
CRUDInsertionResponse response = new CRUDInsertionResponse();
int n = 0;
try {
EntityMetadata md = crudOperationContext.getEntityMetadata(crudOperationContext.getEntityName());
if (md.getAccess().getInsert().hasAccess(crudOperationContext.getCallerRoles())) {
FieldAccessRoleEvaluator roleEval = new FieldAccessRoleEvaluator(md, crudOperationContext.getCallerRoles());
RDBMSContext rdbmsContext = new RDBMSContext(null,null,null,projection,md,nodeFactory,rds,roleEval, crudOperationContext,"insert");
RDBMSProcessor.process(rdbmsContext);
crudOperationContext.getHookManager().queueHooks(crudOperationContext);
n= rdbmsContext.getResultInteger() == null? 0 : rdbmsContext.getResultInteger() ;
} else {
crudOperationContext.addError(Error.get(RDBMSConstants.ERR_NO_ACCESS, "find:" + crudOperationContext.getEntityName()));
}
} finally {
Error.pop();
}
response.setNumInserted(n);
Error.pop();
LOGGER.debug("insert() stop");
return response;
}
示例8: save
import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
@Override
public CRUDSaveResponse save(CRUDOperationContext crudOperationContext, boolean upsert, Projection projection) {
LOGGER.debug("save() start");
Error.push("save");
CRUDSaveResponse response = new CRUDSaveResponse();
int n = 0;
try {
EntityMetadata md = crudOperationContext.getEntityMetadata(crudOperationContext.getEntityName());
if (md.getAccess().getUpdate().hasAccess(crudOperationContext.getCallerRoles()) && md.getAccess().getInsert().hasAccess(crudOperationContext.getCallerRoles())) {
FieldAccessRoleEvaluator roleEval = new FieldAccessRoleEvaluator(md, crudOperationContext.getCallerRoles());
RDBMSContext rdbmsContext = new RDBMSContext(null,null,null,projection,md,nodeFactory,rds,roleEval, crudOperationContext,"save");
RDBMSProcessor.process(rdbmsContext);
crudOperationContext.getHookManager().queueHooks(crudOperationContext);
n= rdbmsContext.getResultInteger();
} else {
crudOperationContext.addError(Error.get(RDBMSConstants.ERR_NO_ACCESS, "find:" + crudOperationContext.getEntityName()));
}
} finally {
Error.pop();
}
response.setNumSaved(n);
Error.pop();
LOGGER.debug("save() stop");
return response;
}
示例9: update
import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
@Override
public CRUDUpdateResponse update(CRUDOperationContext crudOperationContext,
QueryExpression queryExpression,
UpdateExpression updateExpression,
Projection projection) {
if (queryExpression == null) {
throw new IllegalArgumentException("No queryExpression informed");
}
LOGGER.debug("update start: q:{} u:{} p:{}", queryExpression, updateExpression, projection);
Error.push("update");
CRUDUpdateResponse response = new CRUDUpdateResponse();
try {
EntityMetadata md = crudOperationContext.getEntityMetadata(crudOperationContext.getEntityName());
if (md.getAccess().getUpdate().hasAccess(crudOperationContext.getCallerRoles())) {
FieldAccessRoleEvaluator roleEval = new FieldAccessRoleEvaluator(md, crudOperationContext.getCallerRoles());
RDBMSContext rdbmsContext = new RDBMSContext(null,null,queryExpression,projection,md,nodeFactory,rds,roleEval, crudOperationContext,"update");
rdbmsContext.setUpdateExpression(updateExpression);
RDBMSProcessor.process(rdbmsContext);
crudOperationContext.getHookManager().queueHooks(crudOperationContext);
} else {
crudOperationContext.addError(Error.get(RDBMSConstants.ERR_NO_ACCESS, "find:" + crudOperationContext.getEntityName()));
}
} finally {
Error.pop();
}
Error.pop();
LOGGER.debug("update end: updated: {}, failed: {}", response.getNumUpdated(), response.getNumFailed());
return response;
}
示例10: delete
import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
@Override
public CRUDDeleteResponse delete(CRUDOperationContext crudOperationContext,
QueryExpression queryExpression) {
if (queryExpression == null) {
throw new IllegalArgumentException("No queryExpression informed");
}
LOGGER.debug("delete start: q:{}", queryExpression);
Error.push("delete");
CRUDDeleteResponse response = new CRUDDeleteResponse();
try {
EntityMetadata md = crudOperationContext.getEntityMetadata(crudOperationContext.getEntityName());
if (md.getAccess().getDelete().hasAccess(crudOperationContext.getCallerRoles())) {
FieldAccessRoleEvaluator roleEval = new FieldAccessRoleEvaluator(md, crudOperationContext.getCallerRoles());
RDBMSContext rdbmsContext = new RDBMSContext(null,null,queryExpression,null,md,nodeFactory,rds,roleEval, crudOperationContext,"delete");
RDBMSProcessor.process(rdbmsContext);
crudOperationContext.getHookManager().queueHooks(crudOperationContext);
} else {
crudOperationContext.addError(Error.get(RDBMSConstants.ERR_NO_ACCESS, "find:" + crudOperationContext.getEntityName()));
}
} finally {
Error.pop();
}
Error.pop();
LOGGER.debug("delete end: deleted: {}}", response.getNumDeleted());
return response;
}
示例11: find
import com.redhat.lightblue.util.Error; //导入方法依赖的package包/类
@Override
public CRUDFindResponse find(CRUDOperationContext crudOperationContext,
QueryExpression queryExpression,
Projection projection,
Sort sort,
Long from,
Long to) {
if (queryExpression == null) {
throw new IllegalArgumentException("No query informed");
}
if (projection == null) {
throw new IllegalArgumentException("No projection informed");
}
LOGGER.debug("find start: q:{} p:{} sort:{} from:{} to:{}", queryExpression, projection, sort, from, to);
Error.push("find");
CRUDFindResponse response = new CRUDFindResponse();
try {
EntityMetadata md = crudOperationContext.getEntityMetadata(crudOperationContext.getEntityName());
if (md.getAccess().getFind().hasAccess(crudOperationContext.getCallerRoles())) {
FieldAccessRoleEvaluator roleEval = new FieldAccessRoleEvaluator(md, crudOperationContext.getCallerRoles());
RDBMSContext rdbmsContext = new RDBMSContext(from,to,queryExpression,projection,md,nodeFactory,rds,roleEval, crudOperationContext,"find");
RDBMSProcessor.process(rdbmsContext);
crudOperationContext.getHookManager().queueHooks(crudOperationContext);
} else {
crudOperationContext.addError(Error.get(RDBMSConstants.ERR_NO_ACCESS, "find:" + crudOperationContext.getEntityName()));
}
} finally {
Error.pop();
}
LOGGER.debug("find end: query: {} results: {}", response.getSize());
return response;
}
示例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;
}
示例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;
}