Author: scabanovich
Date: 2012-05-24 20:41:02 -0400 (Thu, 24 May 2012)
New Revision: 41400
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeAuthorityMethod.java
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeConfigPropertyExtension.java
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeSecurityExtension.java
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/text/ext/AuthorizerHyperlinkDetector.java
Log:
JBIDE-11552
https://issues.jboss.org/browse/JBIDE-11552
Search for authorizer methods is done in parent projects.
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeAuthorityMethod.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeAuthorityMethod.java 2012-05-25
00:37:18 UTC (rev 41399)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeAuthorityMethod.java 2012-05-25
00:41:02 UTC (rev 41400)
@@ -16,6 +16,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.cdi.internal.core.impl.CDIProject;
import org.jboss.tools.cdi.internal.core.impl.definition.MethodDefinition;
import org.jboss.tools.common.java.IAnnotationDeclaration;
@@ -75,4 +76,30 @@
}
return false;
}
+
+ public boolean equals(Object o) {
+ if(!(o instanceof DeltaspikeAuthorityMethod)) {
+ return false;
+ }
+ DeltaspikeAuthorityMethod other = (DeltaspikeAuthorityMethod)o;
+ if(!other.declaringTypeName.equals(declaringTypeName)) {
+ return false;
+ }
+ if(!other.path.equals(path)) {
+ return false;
+ }
+ if(!method.getMethod().getElementName().equals(other.getMethod().getMethod().getElementName()))
{
+ return false;
+ }
+ try {
+ String kThis = method.getMethod().getSignature();
+ String kThat = other.method.getMethod().getSignature();
+ if(!kThis.equals(kThat)) {
+ return false;
+ }
+ } catch (JavaModelException e) {
+ DeltaspikeCorePlugin.getDefault().logError(e);
+ }
+ return true;
+ }
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeConfigPropertyExtension.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeConfigPropertyExtension.java 2012-05-25
00:37:18 UTC (rev 41399)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeConfigPropertyExtension.java 2012-05-25
00:41:02 UTC (rev 41400)
@@ -10,8 +10,12 @@
******************************************************************************/
package org.jboss.tools.cdi.deltaspike.core;
+import java.util.Set;
+
import org.eclipse.jdt.core.IType;
import org.jboss.tools.cdi.core.IInjectionPoint;
+import org.jboss.tools.cdi.core.IQualifier;
+import org.jboss.tools.cdi.core.IQualifierDeclaration;
import org.jboss.tools.cdi.core.extension.ICDIExtension;
import org.jboss.tools.cdi.core.extension.feature.IInjectionPointValidatorFeature;
@@ -26,9 +30,16 @@
@Override
public boolean shouldIgnoreInjection(IType typeOfInjectionPoint,
IInjectionPoint injection) {
- if(injection.getAnnotation(CONFIG_PROPERTY_ANNOTATION_TYPE_NAME) != null) {
+ if(injection.isAnnotationPresent(CONFIG_PROPERTY_ANNOTATION_TYPE_NAME)) {
return true;
}
+ Set<IQualifierDeclaration> qs = injection.getQualifierDeclarations();
+ for (IQualifierDeclaration d: qs) {
+ IQualifier q = d.getQualifier();
+ if(q.isAnnotationPresent(CONFIG_PROPERTY_ANNOTATION_TYPE_NAME)) {
+ return true;
+ }
+ }
return false;
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeSecurityExtension.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeSecurityExtension.java 2012-05-25
00:37:18 UTC (rev 41399)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeSecurityExtension.java 2012-05-25
00:41:02 UTC (rev 41400)
@@ -12,6 +12,7 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -238,10 +239,16 @@
}
}
+
+ Set<DeltaspikeSecurityExtension> parents = null;
for (DeltaspikeSecurityBindingConfiguration c: context.getConfigurations().values()) {
if(c.getInvolvedTypes().contains(file.getFullPath())) {
- Set<DeltaspikeAuthorityMethod> authorizers2 = c.getAuthorizerMembers();
+ if(parents == null) {
+ parents = getParents(getContext().getRootContext().getProject());
+ }
+ Set<DeltaspikeAuthorityMethod> authorizers2 = collectAuthorizerMethods(parents,
c.getSecurityBindingTypeName());
+ authorizers2.addAll(c.getAuthorizerMembers());
Map<AbstractMemberDefinition, SecurityBindingDeclaration> bound =
c.getBoundMembers();
for (AbstractMemberDefinition d: bound.keySet()) {
String name = d instanceof MethodDefinition ?
((MethodDefinition)d).getMethod().getElementName()
@@ -280,4 +287,26 @@
return DeltaspikeSeverityPreferences.getInstance();
}
+ public static Set<DeltaspikeSecurityExtension> getParents(CDICoreNature nature) {
+ Set<CDICoreNature> ps = nature.getCDIProjects(true);
+ Set<DeltaspikeSecurityExtension> parents = new
HashSet<DeltaspikeSecurityExtension>();
+ for (CDICoreNature p: ps) {
+ DeltaspikeSecurityExtension ext = DeltaspikeSecurityExtension.getExtension(p);
+ if(ext != null) parents.add(ext);
+ }
+ return parents;
+ }
+
+ public static Set<DeltaspikeAuthorityMethod>
collectAuthorizerMethods(Set<DeltaspikeSecurityExtension> parents, String
securityBindingTypeName) {
+ Set<DeltaspikeAuthorityMethod> result = new
HashSet<DeltaspikeAuthorityMethod>();
+ for (DeltaspikeSecurityExtension ext: parents) {
+ DeltaspikeSecurityDefinitionContext context =
(DeltaspikeSecurityDefinitionContext)ext.getContext();
+ DeltaspikeSecurityBindingConfiguration c =
context.getConfiguration(securityBindingTypeName);
+ if(c != null) {
+ result.addAll(c.getAuthorizerMembers());
+ }
+ }
+ return result;
+ }
+
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/text/ext/AuthorizerHyperlinkDetector.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/text/ext/AuthorizerHyperlinkDetector.java 2012-05-25
00:37:18 UTC (rev 41399)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/text/ext/AuthorizerHyperlinkDetector.java 2012-05-25
00:41:02 UTC (rev 41400)
@@ -127,13 +127,15 @@
DeltaspikeSecurityExtension extension =
DeltaspikeSecurityExtension.getExtension(nature);
if(extension == null) return;
+ Set<DeltaspikeSecurityExtension> parents =
DeltaspikeSecurityExtension.getParents(nature);
+
DeltaspikeSecurityDefinitionContext context =
(DeltaspikeSecurityDefinitionContext)extension.getContext();
Map<String, DeltaspikeSecurityBindingConfiguration> cs =
context.getConfigurations();
-
for (DeltaspikeSecurityBindingConfiguration c: cs.values()) {
Map<AbstractMemberDefinition, SecurityBindingDeclaration> ms =
c.getBoundMembers();
- Set<DeltaspikeAuthorityMethod> as = c.getAuthorizerMembers();
+ Set<DeltaspikeAuthorityMethod> as =
DeltaspikeSecurityExtension.collectAuthorizerMethods(parents,
c.getSecurityBindingTypeName());
+ as.addAll(c.getAuthorizerMembers());
Set<String> authorityMethods = new HashSet<String>();
for (AbstractMemberDefinition m: ms.keySet()) {
if(element.equals(m.getMember())) {
@@ -146,10 +148,11 @@
}
if(a.isMatching(b)) {
IMethod method = a.getMethod().getMethod();
- if(authorityMethods.contains(method.getSignature())) {
+ String k = "" + method.getElementName() + method.getSignature();
+ if(authorityMethods.contains(k)) {
continue;
}
- authorityMethods.add(method.getSignature());
+ authorityMethods.add(k);
JavaElementHyperlink h = new JavaElementHyperlink(region, method, document);
hyperlinks.add(h);
}