ws-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "C.h. Lee" <lee...@gmail.com>
Subject Re: [neethi 3.0.2] if root element is not a policy element
Date Thu, 02 Aug 2012 21:10:57 GMT
Daniel,

Thanks for answering my question, following is my current workaround:

		StAXOMBuilder builder = new StAXOMBuilder(is);
		OMElement documentElement = builder.getDocumentElement();
		Iterator<OMElement> itr =
documentElement.getChildrenWithLocalName(Constants.ELEM_POLICY);
		
		Policy policy = new Policy();
		while(itr.hasNext()) {
			OMElement e = itr.next();
			Policy subPolicy = PolicyEngine.getPolicy(e);
			policy.addPolicyComponent(subPolicy);
		}


On Thu, Aug 2, 2012 at 6:19 AM, Daniel Kulp <dkulp@apache.org> wrote:
> On Wednesday, August 01, 2012 01:46:14 PM C.h. Lee wrote:
>> Hi Dev,
>>
>> Thanks for the good work, this library helps us a lot!
>>
>> In version 2.0.5, org.apache.neethi.PolicyEngine:
>>
>>     public static Policy getPolicy(OMElement element) {
>>         return getPolicyOperator(element);
>>     }
>>
>> Above method handles just fine if root element is not a policy element.
>>
>> In version 3.0.2, org.apache.neethi.PolicyEngine:
>>
>>     public static Policy getPolicy(OMElement element) {
>>         return getBuilder().getPolicy(element);
>>     }
>>
>> Above method throws IllegalArgumentException if root element is not a
>> policy element.
>> I suppose this is due to following fix:
>> https://issues.apache.org/jira/browse/NEETHI-12
>>
>> Question: Is the behavior in 3.0.2 by design and the behavior in 2.0.5 is
>> a bug?
>
> Yes.   Neethi is a library to parse/process Policy documents.  Thus, making
> sure proper policy documents are passed in is important for the methods that
> are supposed to actually return a Policy object.
>
> That said, I had thought about adding method like:
>
> PolicyComponent getPolicyFragment(Object)
>
> or similar for parsing subsections of a policy document, but even that may
> require the "root" to be a known policy, although that would at least allow
> you to manually iterate over the child elements and process one at a time.
>
> Just never got around to that.
>
> --
> Daniel Kulp
> dkulp@apache.org - http://dankulp.com/blog
> Talend Community Coder - http://coders.talend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
For additional commands, e-mail: dev-help@ws.apache.org


Mime
View raw message