From d1b15c602b3d35a9ed0913e4df9f175ec5fe9393 Mon Sep 17 00:00:00 2001
From: jakubs <jakubs>
Date: Tue, 26 Jun 2012 15:21:34 +0000
Subject: [PATCH] SP-169 BIS-90 improve null object behaviour

SVN: 25880
---
 .../cisd/openbis/generic/server/ETLService.java  | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java
index 26698160e37..a6383ba18b0 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java
@@ -146,6 +146,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.EntityOperationsLogEntryPE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.EntityTypePE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentTypePE;
+import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataManagementSystemPE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.ListSamplesByPropertyCriteria;
 import ch.systemsx.cisd.openbis.generic.shared.dto.NewContainerDataSet;
@@ -2049,8 +2050,17 @@ public class ETLService extends AbstractCommonServer<IETLLIMSService> implements
     {
         checkSession(token);
 
-        return ExternalDataManagementSystemTranslator.translate(getDAOFactory()
-                .getExternalDataManagementSystemDAO().tryToFindExternalDataManagementSystemByCode(
-                        externalDataManagementSystemCode));
+        ExternalDataManagementSystemPE externalSystem =
+                getDAOFactory().getExternalDataManagementSystemDAO()
+                        .tryToFindExternalDataManagementSystemByCode(
+                                externalDataManagementSystemCode);
+
+        if (externalSystem != null)
+        {
+            return ExternalDataManagementSystemTranslator.translate(externalSystem);
+        } else
+        {
+            return null;
+        }
     }
 }
-- 
GitLab