Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Use CriteriaQueryGenerator's bug to inject extra params on the expres…
Browse files Browse the repository at this point in the history
…sion query.
  • Loading branch information
josejulio committed Apr 27, 2017
1 parent eb92f7d commit 6d6fe7a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
Expand Up @@ -2655,17 +2655,24 @@ private void handlePDS(final Subject subject, Resource resource, Resource parent

Predicate<Resource> baseResourcePredicate = null;
if (expressionScope == PropertyOptionsSource.ExpressionScope.BASE_RESOURCE) {
int halfCommaIndex = expression.indexOf(";");
if (halfCommaIndex > -1) {
String[] expressionTokens = expression.split("\\s+");
String ancestorType = null;
final Pattern ancestorTypePattern = Pattern.compile("(.*);baseResource\\.plugin");

for (String token : expressionTokens) {
Matcher ancestorTypeMatcher = ancestorTypePattern.matcher(token);
if (ancestorTypeMatcher.lookingAt()) {
ancestorType = ancestorTypeMatcher.group(1);
break;
}
}
if (ancestorType != null) {
if (resource == null && parentResource == null) {
LOG.warn("Different base resource type requested but resource id and parent_resource_id are not valid."
+ "Option source expression:" + expression);
return;
}
Resource nonNullResource = (resource == null? parentResource : resource);
String ancestorType = expression.substring(
halfCommaIndex + 1, expression.length());
expression = expression.substring(0, halfCommaIndex);
Resource foundBaseResource = ResourceUtility.getAncestorResourceOfType(
nonNullResource, ancestorType);
if (foundBaseResource != null) {
Expand Down
Expand Up @@ -7411,7 +7411,7 @@
<resource-configuration>
<c:simple-property name="name" required="false" type="string" readOnly="false" description="The name of the BootstrapContext"/>
<c:simple-property name="workmanager" required="false" type="string" readOnly="false" description="The WorkManager instance for the BootstrapContext">
<c:option-source target="resource" expression="type=Workmanager profile.plugin=&pluginName;" expressionScope="baseResource"/>
<c:option-source target="resource" expression="type=Workmanager Profile;baseResource.plugin=&pluginName;" expressionScope="baseResource"/>
</c:simple-property>
</resource-configuration>
</service>
Expand Down Expand Up @@ -8742,7 +8742,7 @@
<resource-configuration>
<c:simple-property name="factory-class" required="true" type="string" readOnly="false" description="The factory class."/>
<c:simple-property name="socket-binding" required="false" type="string" readOnly="false" description="The socket binding reference.">
<c:option-source target="configuration" expression="*/socket-binding=name:type=SocketBindingGroup profile.plugin=&pluginName;" expressionScope="baseResource"/>
<c:option-source target="configuration" expression="*/socket-binding=name:type=SocketBindingGroup Profile;baseResource.plugin=&pluginName;" expressionScope="baseResource"/>
</c:simple-property>
</resource-configuration>
</service>
Expand All @@ -8759,7 +8759,7 @@
<resource-configuration>
<c:simple-property name="factory-class" required="true" type="string" readOnly="false" description="The factory class."/>
<c:simple-property name="socket-binding" required="false" type="string" readOnly="false" description="The socket binding reference.">
<c:option-source target="configuration" expression="*/socket-binding=name:type=SocketBindingGroup profile.plugin=&pluginName;" expressionScope="baseResource"/>
<c:option-source target="configuration" expression="*/socket-binding=name:type=SocketBindingGroup Profile;baseResource.plugin=&pluginName;" expressionScope="baseResource"/>
</c:simple-property>
</resource-configuration>
</service>
Expand Down Expand Up @@ -8803,7 +8803,7 @@

<resource-configuration>
<c:simple-property name="socket-binding" required="false" type="string" readOnly="false" description="The socket binding reference.">
<c:option-source target="configuration" expression="*/socket-binding=name:type=SocketBindingGroup profile.plugin=&pluginName;" expressionScope="baseResource"/>
<c:option-source target="configuration" expression="*/socket-binding=name:type=SocketBindingGroup Profile;baseResource.plugin=&pluginName;" expressionScope="baseResource"/>
</c:simple-property>
</resource-configuration>
</service>
Expand All @@ -8819,7 +8819,7 @@

<resource-configuration>
<c:simple-property name="socket-binding" required="false" type="string" readOnly="false" description="The socket binding reference.">
<c:option-source target="configuration" expression="*/socket-binding=name:type=SocketBindingGroup profile.plugin=&pluginName;" expressionScope="baseResource"/>
<c:option-source target="configuration" expression="*/socket-binding=name:type=SocketBindingGroup Profile;baseResource.plugin=&pluginName;" expressionScope="baseResource"/>
</c:simple-property>
</resource-configuration>
</service>
Expand Down Expand Up @@ -8962,7 +8962,7 @@
<c:simple-property name="connectors" />
</c:list-property>
<c:simple-property name="socket-binding" required="true" type="string" readOnly="false" description="The broadcast group socket binding.">
<c:option-source target="configuration" expression="*/socket-binding=name:type=SocketBindingGroup profile.plugin=&pluginName;" expressionScope="baseResource"/>
<c:option-source target="configuration" expression="*/socket-binding=name:type=SocketBindingGroup Profile;baseResource.plugin=&pluginName;" expressionScope="baseResource"/>
</c:simple-property>
</resource-configuration>
</service>
Expand Down Expand Up @@ -9050,7 +9050,7 @@
<c:simple-property name="initial-wait-timeout" required="false" type="long" readOnly="false" defaultValue="10000" description="Period, in ms, to wait for an initial broadcast to give us at least one node in the cluster. The default value is 10000."/>
<c:simple-property name="refresh-timeout" required="false" type="long" readOnly="false" defaultValue="10000" description="Period the discovery group waits after receiving the last broadcast from a particular server before removing that server&apos;s connector pair entry from its list. The default value is 10000."/>
<c:simple-property name="socket-binding" required="true" type="string" readOnly="false" description="The discovery group socket binding.">
<c:option-source target="configuration" expression="*/socket-binding=name:type=SocketBindingGroup profile.plugin=&pluginName;" expressionScope="baseResource"/>
<c:option-source target="configuration" expression="*/socket-binding=name:type=SocketBindingGroup Profile;baseResource.plugin=&pluginName;" expressionScope="baseResource"/>
</c:simple-property>
</resource-configuration>
</service>
Expand Down Expand Up @@ -12623,7 +12623,7 @@
<resource-configuration>
<c:simple-property name="name" required="false" type="string" readOnly="false" description="The name of the BootstrapContext"/>
<c:simple-property name="workmanager" required="false" type="string" readOnly="false" description="The WorkManager instance for the BootstrapContext">
<c:option-source target="resource" expression="type=Workmanager plugin=&pluginName;"/>
<c:option-source target="resource" expression="type=Workmanager plugin=&pluginName;" expressionScope="baseResource"/>
</c:simple-property>
</resource-configuration>
</service>
Expand Down

0 comments on commit 6d6fe7a

Please sign in to comment.