From 98a940b6d613d05b7ef7c3ae6cc314633eb28d51 Mon Sep 17 00:00:00 2001 From: felmer <felmer> Date: Tue, 15 Mar 2016 14:15:47 +0000 Subject: [PATCH] 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 --- .../jstest/service/V3ApiDtoTestService.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/js-test/source/java/ch/systemsx/cisd/openbis/jstest/service/V3ApiDtoTestService.java b/js-test/source/java/ch/systemsx/cisd/openbis/jstest/service/V3ApiDtoTestService.java index 174e1b4db21..43eb04e0820 100644 --- a/js-test/source/java/ch/systemsx/cisd/openbis/jstest/service/V3ApiDtoTestService.java +++ b/js-test/source/java/ch/systemsx/cisd/openbis/jstest/service/V3ApiDtoTestService.java @@ -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); } -- GitLab