List of usage examples for javax.xml.registry RegistryException getMessage
public String getMessage()
JAXRException
object. From source file:it.cnr.icar.eric.server.security.authorization.ClassificationNodeCompare.java
public EvaluationResult evaluate(@SuppressWarnings("rawtypes") List inputs, EvaluationCtx context) { // Evaluate the arguments using the helper method...this will // catch any errors, and return values that can be compared AttributeValue[] argValues = new AttributeValue[inputs.size()]; EvaluationResult result = evalArgs(inputs, context, argValues, minParams); if (result != null) { return result; }//from ww w .j av a2s .c o m // cast the resolved values into specific types String cnode1Id = (argValues[0]).encode().trim(); String cnode2Id = (argValues[1]).encode().trim(); boolean evalResult = false; //First see if we have an exact match on cnode id if (cnode1Id.equals(cnode2Id)) { evalResult = true; } else { // now see if the ClassificationNode identified by str1 ancestor //of ClassificationNode identified by str2 try { ServerRequestContext requestContext = AuthorizationServiceImpl.getRequestContext(context); RegistryObjectType cnode1 = qm.getRegistryObject(requestContext, cnode1Id); if (!(cnode1 instanceof ClassificationNodeType)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.ClassificationNodeExpected", new Object[] { cnode1.getClass() })); } RegistryObjectType cnode2 = qm.getRegistryObject(requestContext, cnode2Id); if (!(cnode2 instanceof ClassificationNodeType)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.ClassificationNodeExpected", new Object[] { cnode2.getClass() })); } String path1 = ((ClassificationNodeType) cnode1).getPath(); String path2 = ((ClassificationNodeType) cnode2).getPath(); if (path2.startsWith(path1)) { evalResult = true; } } catch (RegistryException e) { log.error(ServerResourceBundle.getInstance().getString("message.xacmlExtFunctionEvalError", new Object[] { getFunctionName() }), e); ArrayList<String> codes = new ArrayList<String>(); codes.add(Status.STATUS_PROCESSING_ERROR); return new EvaluationResult(new Status(codes, e.getMessage())); } } // boolean returns are common, so there's a getInstance() for that return EvaluationResult.getInstance(evalResult); }
From source file:it.cnr.icar.eric.server.security.authorization.AbstractRegistryFunction.java
/** * Extends 'evalArgs' to check for required parameters. * * @param params// www . j a v a 2 s . c om * @param context * @param args * @param minParams Minimal number of parameters in 'params'. * * @return EvaluationResult if something is wrong. Null otherwise. */ protected EvaluationResult evalArgs(List<?> params, EvaluationCtx context, AttributeValue[] args, int minParams) { EvaluationResult result = super.evalArgs(params, context, args); if (result == null) { if (params.size() < minParams) { // Check which arguments are missing StringBuffer sb = new StringBuffer(); for (int i = params.size(); i < minParams; i++) { sb.append(ServerResourceBundle.getInstance().getString("message.xacmlExtFunctionParamMissing", new Object[] { getFunctionName(), getParameterNames()[i], String.valueOf(i + 1) })); if (i + 1 < minParams) { sb.append(' '); } } // Use an Exception to log RegistryException e = new RegistryException(sb.toString()); log.error(ServerResourceBundle.getInstance().getString("message.xacmlExtFunctionEvalError", new Object[] { getFunctionName() }), e); // Return EvaluationResult with missing attribute code List<String> codes = new ArrayList<String>(); codes.add(Status.STATUS_MISSING_ATTRIBUTE); result = new EvaluationResult(new Status(codes, e.getMessage())); } } return result; }
From source file:it.cnr.icar.eric.server.security.authorization.RegistryPolicyFinderModule.java
/** * Tries to find one and only one matching policy given the idReference * First it tries to find a RegistryObject with specified URI as id. * If none is found, it tries to find an ACP with specified URI as * a value for a Slot named "ComposedPolicies". * * * @param idReference an identifier specifying some policy * @param type type of reference (policy or policySet) as identified by * the fields in <code>PolicyReference</code> * * @return the result of looking for a matching policy *//*from w ww. j a va 2 s.c om*/ public PolicyFinderResult findPolicy(URI idReference, int type) { AbstractPolicy policy = null; //??XACML: WHy does this call from xacml code not provide EvaluationCtx where we could get ServerRequestContext //TODO: Figure out a solution to this ServerRequestContext context = null; try { context = new ServerRequestContext("RegistryPolicyFinderModule.findPolicy", null); String id = idReference.toString(); policy = loadPolicy(context, id); } catch (RegistryException e) { log.error(e); } finally { try { context.rollback(); } catch (Exception e) { log.error(e.getMessage(), e); } } if (policy == null) { log.warn(ServerResourceBundle.getInstance().getString("message.findPolicyFailedToFindPolicyWithId", new Object[] { idReference })); return new PolicyFinderResult(); } else { return new PolicyFinderResult(policy); } }
From source file:org.openhealthtools.openxds.registry.adapter.omar31.XdsRegistryQueryServiceImpl.java
public OMElement sqlQuery(RegistrySQLQueryContext context) throws RegistryQueryException { OMElement ret = null;//from www .j a va 2 s . c om String sql = context.getSql(); boolean returnLeafClass = context.isLeafClass(); if (sql == null || sql.equals("")) { throw new RegistryQueryException("Invalid SQL query"); } if (log.isDebugEnabled()) { log.debug("Invoking SQL Query: " + sql); } SQLQueryProcessor qp = SQLQueryProcessor.getInstance(); org.oasis.ebxml.registry.bindings.query.ResponseOption responseOption = null; try { responseOption = BindingUtility.getInstance().queryFac.createResponseOption(); responseOption.setReturnComposedObjects(true); if (returnLeafClass) { responseOption.setReturnType(org.oasis.ebxml.registry.bindings.query.ReturnType.LEAF_CLASS); } else { responseOption.setReturnType(org.oasis.ebxml.registry.bindings.query.ReturnType.OBJECT_REF); } } catch (javax.xml.bind.JAXBException e) { throw new RegistryQueryException("Failed to create ResponseOption - " + e.getMessage(), e); } String contextId = "org:openhealthexchange:openxds:registry:adapter:omar31:XdsRegistryQueryManager:sqlQuery:context"; ServerRequestContext src = null; RegistryObjectListType rolt = null; IterativeQueryParams paramHolder = new IterativeQueryParams(0, -1); try { src = new ServerRequestContext(contextId, null); rolt = qp.executeQuery(src, null, sql, responseOption, paramHolder); } catch (RegistryException e) { try { src.rollback(); } catch (RegistryException re) { throw new RegistryQueryException("Failed to rollback - " + re.getMessage(), re); } throw new RegistryQueryException("Failed to create ResponseOption - " + e.getMessage(), e); } try { org.oasis.ebxml.registry.bindings.query.AdhocQueryResponse ahqr = BindingUtility.getInstance().queryFac .createAdhocQueryResponse(); ahqr.setRegistryObjectList(rolt); ahqr.setStatus(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success); ahqr.setStartIndex(BigInteger.valueOf(paramHolder.startIndex)); ahqr.setTotalResultCount(BigInteger.valueOf(paramHolder.totalResultCount)); String response = BindingUtility.getInstance().marshalObject(ahqr); if (log.isDebugEnabled()) { log.debug("SQL Response:\n" + response); } ret = OMUtil.xmlStringToOM(response); } catch (javax.xml.bind.JAXBException e) { throw new RegistryQueryException("Failed to create AdhocQueryResponse - " + e.getMessage(), e); } catch (XMLStreamException e) { throw new RegistryQueryException( "Could not create XMLStream from AdhocQueryResponse - " + e.getMessage(), e); } try { src.commit(); } catch (RegistryException re) { throw new RegistryQueryException("Failed to commmit - " + re.getMessage(), re); } //Finally return the result return ret; }