This repository has been archived by the owner on Oct 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 531986 - Change isQueryResult logic (#88)
Previously, all arrays were treated as OSLC Query results unless the array type was explicitly marked with @OslcNotQueryResult annotation. This prevented from returning arrays of mixed-typed OSLC resources (as Object[] or IResource[]) because there is no way to annotate those classes accordingly. From now on, only arrays returned from JAX-RS methods annotated with @OslcQueryCapability will be automatically treated as OSLC Query results (again, unless the returned array type is annotated with the @OslcNotQueryResult). Signed-off-by: Andrew Berezovskyi <[email protected]>
- Loading branch information
1 parent
dd371dd
commit 631c78a
Showing
4 changed files
with
46 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...-jena-provider/src/main/java/org/eclipse/lyo/oslc4j/provider/jena/JenaProviderHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.eclipse.lyo.oslc4j.provider.jena; | ||
|
||
import java.lang.annotation.Annotation; | ||
import org.eclipse.lyo.oslc4j.core.annotation.OslcNotQueryResult; | ||
import org.eclipse.lyo.oslc4j.core.annotation.OslcQueryCapability; | ||
|
||
/** | ||
* TODO | ||
* | ||
* @since TODO | ||
*/ | ||
public class JenaProviderHelper { | ||
static boolean hasNotQueryResultTypeAnnot(final Class<?> type) { | ||
OslcNotQueryResult notQueryResult = type.getComponentType() | ||
.getAnnotation(OslcNotQueryResult.class); | ||
return (notQueryResult != null && notQueryResult.value()); | ||
} | ||
|
||
static boolean hasOslcQueryCapabilityMethodAnnot(final Annotation[] annotations) { | ||
if (annotations != null) { | ||
for (int i = 0; i < annotations.length; i++) { | ||
if (annotations[i] != null && annotations[i] instanceof OslcQueryCapability) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
static boolean isQueryResult(final Class<?> type, final Annotation[] annotations) { | ||
return hasOslcQueryCapabilityMethodAnnot(annotations) && | ||
!hasNotQueryResultTypeAnnot(type); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters