Skip to content
Snippets Groups Projects
Commit 98a940b6 authored by felmer's avatar felmer
Browse files

SSDM-3284: V3ApiDtoTestService: throwing an exception of the deserialized...

SSDM-3284: V3ApiDtoTestService: throwing an exception of the deserialized object isn't an instance of a class from a package starting with 'cs.etz.sis.'.

SVN: 35909
parent 7f6e2430
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,8 @@ import ch.ethz.sis.openbis.generic.server.sharedapi.v3.json.GenericObjectMapper;
*/
public class V3ApiDtoTestService implements ICustomASServiceExecutor
{
private static final String PACKAGE_PREFIX = "ch.ethz.sis.";
public V3ApiDtoTestService(Properties properties)
{
}
......@@ -49,7 +51,19 @@ public class V3ApiDtoTestService implements ICustomASServiceExecutor
System.out.println("PARAMETERS:");
Object obj = parameters.get("object");
boolean echo = parameters.containsKey("echo");
System.out.println("echo: " + echo + ", object: " + obj + " (" + obj.getClass().getName() + ")");
String name = obj.getClass().getName();
System.out.println("echo: " + echo + ", object: " + obj + " (" + name + ")");
if (name.startsWith(PACKAGE_PREFIX) == false)
{
if (name.startsWith("java.") && name.endsWith("Map"))
{
throw new IllegalArgumentException("Map class detected (" + name + "). This is a hint "
+ "that no appropirated class found for deserialization. "
+ "This is most probably caused by missing default constructor. Object: " + obj);
}
throw new IllegalArgumentException("Fully qualified class named doesn't start with '" + PACKAGE_PREFIX
+ "': " + name + ". Object: " + obj);
}
return echo ? obj : populate(obj);
}
......
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