improved logging in case a device mapping points to an object of unknown type or a null object

Change-Id: I54accd8b386af796b12bcfe95f0cbdba55a6b265
This commit is contained in:
Axel Uhl committed 2016-03-31 18:37:55 +02:00
1 parent a5795fe70c
commit 8911951cba
1 file changed
+7 -3
@@ -447,6 +447,7 @@ import com.sap.sse.common.TypeBasedServiceFinderFactory;
import com.sap.sse.common.Util;
import com.sap.sse.common.Util.Pair;
import com.sap.sse.common.Util.Triple;
import com.sap.sse.common.WithID;
import com.sap.sse.common.impl.MillisecondsTimePoint;
import com.sap.sse.common.impl.TimeRangeImpl;
import com.sap.sse.common.mail.MailException;
@@ -5356,12 +5357,15 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
Date to = mapping.getTimeRange().to() == null || mapping.getTimeRange().to().asMillis() == Long.MAX_VALUE ?
null : mapping.getTimeRange().to().asDate();
MappableToDevice item = null;
if (mapping.getMappedTo() instanceof Competitor) {
final WithID mappedTo = mapping.getMappedTo();
if (mappedTo == null) {
throw new RuntimeException("Device mapping not mapped to any object");
} else if (mappedTo instanceof Competitor) {
item = baseDomainFactory.convertToCompetitorDTO((Competitor) mapping.getMappedTo());
} else if (mapping.getMappedTo() instanceof Mark) {
} else if (mappedTo instanceof Mark) {
item = convertToMarkDTO((Mark) mapping.getMappedTo(), null);
} else {
throw new RuntimeException("Can only handle Competitor or Mark as mapped item type");
throw new RuntimeException("Can only handle Competitor or Mark as mapped item type, but not "+mappedTo.getClass().getName());
}
//Only deal with UUIDs - otherwise we would have to pass Serializable to browser context - which
//has a large performance implact for GWT.