|
|
@@ -29,7 +29,7 @@ public class HandlingEventServiceEndpointImpl implements HandlingEventServiceEnd
|
|
29
|
29
|
Date date = parseIso8601Date(completionTime);
|
|
30
|
30
|
TrackingId tid = new TrackingId(trackingId);
|
|
31
|
31
|
CarrierMovementId cid;
|
|
32
|
|
- if (StringUtils.isNotBlank(carrierMovementId)) {
|
|
|
32
|
+ if (StringUtils.isNotEmpty(carrierMovementId)) {
|
|
33
|
33
|
cid = new CarrierMovementId(carrierMovementId);
|
|
34
|
34
|
} else {
|
|
35
|
35
|
cid = null;
|
|
|
@@ -39,18 +39,41 @@ public class HandlingEventServiceEndpointImpl implements HandlingEventServiceEnd
|
|
39
|
39
|
UnLocode ul = new UnLocode(unlocode);
|
|
40
|
40
|
|
|
41
|
41
|
handlingEventService.register(date, tid, cid, ul, type);
|
|
|
42
|
+
|
|
|
43
|
+ } catch (IllegalArgumentException iae) {
|
|
|
44
|
+ handleIllegalArgument(iae);
|
|
|
45
|
+
|
|
42
|
46
|
} catch (ParseException pe) {
|
|
43
|
|
- logger.error("Invalid date format: " + completionTime + ", must be on ISO 8601 format: " + ISO_8601_FORMAT);
|
|
|
47
|
+ handleInvalidDateFormat(completionTime);
|
|
|
48
|
+
|
|
44
|
49
|
} catch (UnknownTrackingIdException utid) {
|
|
45
|
|
- handleRetry(utid);
|
|
|
50
|
+ handleUnknownTrackingId(utid);
|
|
|
51
|
+
|
|
46
|
52
|
} catch (UnknownCarrierMovementIdException ucmi) {
|
|
47
|
|
- handleRetry(ucmi);
|
|
|
53
|
+ handleUnknownCarrierMovementId(ucmi);
|
|
|
54
|
+
|
|
48
|
55
|
} catch (InvalidEventTypeException iete) {
|
|
49
|
|
- logger.error(iete, iete);
|
|
|
56
|
+ handleInvalidEventType(iete);
|
|
|
57
|
+
|
|
50
|
58
|
} catch (Exception e) {
|
|
51
|
|
- logger.error(e, e);
|
|
|
59
|
+ handleOtherError(e);
|
|
52
|
60
|
}
|
|
53
|
|
- // TODO: possibly handle "Duplicate event" exceptions due to unique constraint violations
|
|
|
61
|
+ }
|
|
|
62
|
+
|
|
|
63
|
+ private void handleIllegalArgument(IllegalArgumentException iae) {
|
|
|
64
|
+ logger.error(iae, iae);
|
|
|
65
|
+ }
|
|
|
66
|
+
|
|
|
67
|
+ private void handleOtherError(Exception e) {
|
|
|
68
|
+ logger.error(e, e);
|
|
|
69
|
+ }
|
|
|
70
|
+
|
|
|
71
|
+ private void handleInvalidEventType(InvalidEventTypeException iete) {
|
|
|
72
|
+ logger.error(iete, iete);
|
|
|
73
|
+ }
|
|
|
74
|
+
|
|
|
75
|
+ private void handleInvalidDateFormat(String completionTime) {
|
|
|
76
|
+ logger.error("Invalid date format: " + completionTime + ", must be on ISO 8601 format: " + ISO_8601_FORMAT);
|
|
54
|
77
|
}
|
|
55
|
78
|
|
|
56
|
79
|
private HandlingEvent.Type parseEventType(final String eventType) throws InvalidEventTypeException {
|
|
|
@@ -61,9 +84,12 @@ public class HandlingEventServiceEndpointImpl implements HandlingEventServiceEnd
|
|
61
|
84
|
}
|
|
62
|
85
|
}
|
|
63
|
86
|
|
|
64
|
|
- private void handleRetry(Exception e) {
|
|
|
87
|
+ private void handleUnknownCarrierMovementId(UnknownCarrierMovementIdException e) {
|
|
|
88
|
+ logger.info("Placing event in retry queue due to: " + e.getMessage());
|
|
|
89
|
+ }
|
|
|
90
|
+
|
|
|
91
|
+ private void handleUnknownTrackingId(Exception e) {
|
|
65
|
92
|
logger.info("Placing event in retry queue due to: " + e.getMessage());
|
|
66
|
|
- // TODO: actually place in a retry queue
|
|
67
|
93
|
}
|
|
68
|
94
|
|
|
69
|
95
|
private Date parseIso8601Date(final String completionTime) throws ParseException {
|