Skip to content
Snippets Groups Projects
Commit 9e218ced authored by ribeaudc's avatar ribeaudc
Browse files

[LMS-436] add: - 'AuthorizationFailureException' to 'lims' and 'lims_webclient'.

- 'DatabaseInstanceIdentifierPredicate'.
change: - Webclient should logout in case of an 'AuthorizationFailureException'.
remove: - TODO from 'ClassUtils.tryGetInterfaceTypeArgument'.
fix: - Some problems in authorization.

SVN: 7218
parent 17e571ad
No related branches found
No related tags found
No related merge requests found
...@@ -16,10 +16,8 @@ ...@@ -16,10 +16,8 @@
package ch.systemsx.cisd.common.utilities; package ch.systemsx.cisd.common.utilities;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType; import java.lang.reflect.ParameterizedType;
...@@ -357,13 +355,13 @@ public final class ClassUtils ...@@ -357,13 +355,13 @@ public final class ClassUtils
} }
/** /**
* Returns the type argument found at given <var>index</var> of given generic interface * For given <var>clazz</var> tries to retrieve the generic interface of given class, then
* <var>genericInterfaceClass</var>. * returns the type argument found at given <var>index</var>.
* *
* @return <code>null</code> if not found. * @return <code>null</code> if not found.
*/ */
public final static <I> Class<?> tryGetInterfaceTypeArgument(final Class<?> clazz, public final static Class<?> tryGetInterfaceTypeArgument(final Class<?> clazz,
final Class<I> genericInterfaceClass, final int index) final Class<?> genericInterfaceClass, final int index)
{ {
assert clazz != null : "Unspecified class"; assert clazz != null : "Unspecified class";
assert genericInterfaceClass != null && genericInterfaceClass.isInterface() : "Is not defined or not an interface"; assert genericInterfaceClass != null && genericInterfaceClass.isInterface() : "Is not defined or not an interface";
...@@ -371,23 +369,19 @@ public final class ClassUtils ...@@ -371,23 +369,19 @@ public final class ClassUtils
final Type[] genericInterfaces = clazz.getGenericInterfaces(); final Type[] genericInterfaces = clazz.getGenericInterfaces();
for (final Type genericInterface : genericInterfaces) for (final Type genericInterface : genericInterfaces)
{ {
// Only typed interface are instance of ParameterizedType. Other is just a Class. // Only typed interface is an instance of 'ParameterizedType'.
// Other is just a 'Class'.
if (genericInterface instanceof ParameterizedType) if (genericInterface instanceof ParameterizedType)
{ {
final ParameterizedType parameterizedType = (ParameterizedType) genericInterface; final ParameterizedType parameterizedType = (ParameterizedType) genericInterface;
if (genericInterfaceClass.isAssignableFrom((Class<?>) parameterizedType if (genericInterfaceClass.isAssignableFrom((Class<?>) parameterizedType
.getRawType())) .getRawType()))
{ {
Type typeArgument = parameterizedType.getActualTypeArguments()[index]; final Type typeArgument = parameterizedType.getActualTypeArguments()[index];
if (typeArgument instanceof GenericArrayType) if (typeArgument instanceof Class)
{ {
final GenericArrayType genericArrayType = (GenericArrayType) typeArgument; return (Class<?>) typeArgument;
// TODO 2008-07-12, Christian Ribeaud: Is there a better way to do this?
return Array.newInstance(
((Class<?>) genericArrayType.getGenericComponentType()), 0)
.getClass();
} }
return (Class<?>) typeArgument;
} }
} }
} }
......
...@@ -223,6 +223,11 @@ public final class ClassUtilsTest ...@@ -223,6 +223,11 @@ public final class ClassUtilsTest
typeArgument = typeArgument =
ClassUtils.tryGetInterfaceTypeArgument(ExtendingExtendingA.class, IB.class, 0); ClassUtils.tryGetInterfaceTypeArgument(ExtendingExtendingA.class, IB.class, 0);
assertNull(typeArgument); assertNull(typeArgument);
// We do not support array type argument
typeArgument =
ClassUtils
.tryGetInterfaceTypeArgument(ExtendingArrayA.class, IExtendingIA.class, 0);
assertNull(typeArgument);
} }
// //
...@@ -304,6 +309,10 @@ public final class ClassUtilsTest ...@@ -304,6 +309,10 @@ public final class ClassUtilsTest
{ {
} }
private static class ExtendingArrayA extends A implements IExtendingIA<String[]>
{
}
private static class ExtendingExtendingA extends ExtendingA implements IB, IA<String> private static class ExtendingExtendingA extends ExtendingA implements IB, IA<String>
{ {
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment