14
14
*/
15
15
package com .ericsson .eiffel .remrem .semantics ;
16
16
17
- import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .*;
17
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .ACTIVITY_CANCELED ;
18
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .ACTIVITY_FINISHED ;
19
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .ACTIVITY_STARTED ;
20
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .ACTIVITY_TRIGGERED ;
21
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .ALERT_ACKNOWLEDGED ;
22
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .ALERT_CEASED ;
23
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .ALERT_RAISED ;
24
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .ANNOUNCEMENT_PUBLISHED ;
25
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .ARTIFACT_CREATED ;
26
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .ARTIFACT_DEPLOYED ;
27
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .ARTIFACT_PUBLISHED ;
28
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .ARTIFACT_REUSED ;
29
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .COMPOSITION_DEFINED ;
30
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .CONFIDENCELEVEL_MODIFIED ;
31
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .ENVIRONMENT_DEFINED ;
32
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .EXECUTION_RECIPE_COLLECTION_CREATED ;
33
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .FLOWCONTEXT_DEFINED ;
34
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .ISSUE_DEFINED ;
35
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .ISSUE_VERIFIED ;
36
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .SERVICE_ALLOCATED ;
37
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .SERVICE_DEPLOYED ;
38
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .SERVICE_DISCONTINUED ;
39
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .SERVICE_RETURNED ;
40
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .SERVICE_STARTED ;
41
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .SERVICE_STOPPED ;
42
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .SOURCECHANGE_CREATED ;
43
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .SOURCECHANGE_SUBMITTED ;
44
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .TESTCASE_CANCELED ;
45
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .TESTCASE_FINISHED ;
46
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .TESTCASE_STARTED ;
47
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .TESTCASE_TRIGGERED ;
48
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .TESTSUITE_FINISHED ;
49
+ import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .TESTSUITE_STARTED ;
18
50
19
51
import java .io .InputStream ;
20
52
import java .io .InputStreamReader ;
52
84
import com .ericsson .eiffel .semantics .events .EiffelConfidenceLevelModifiedEvent ;
53
85
import com .ericsson .eiffel .semantics .events .EiffelEnvironmentDefinedEvent ;
54
86
import com .ericsson .eiffel .semantics .events .EiffelFlowContextDefinedEvent ;
87
+ import com .ericsson .eiffel .semantics .events .EiffelIssueDefinedEvent ;
55
88
import com .ericsson .eiffel .semantics .events .EiffelIssueVerifiedEvent ;
56
89
import com .ericsson .eiffel .semantics .events .EiffelServiceAllocatedEvent ;
57
90
import com .ericsson .eiffel .semantics .events .EiffelServiceDeployedEvent ;
69
102
import com .ericsson .eiffel .semantics .events .EiffelTestSuiteFinishedEvent ;
70
103
import com .ericsson .eiffel .semantics .events .EiffelTestSuiteStartedEvent ;
71
104
import com .ericsson .eiffel .semantics .events .Event ;
72
- import com .ericsson .eiffel .semantics .events .Gav ;
73
- import com .ericsson .eiffel .semantics .events .Serializer ;
74
105
import com .ericsson .eiffel .semantics .events .Source ;
75
106
import com .google .gson .Gson ;
76
107
import com .google .gson .JsonElement ;
@@ -99,8 +130,8 @@ public class SemanticsService implements MsgService {
99
130
private final ArrayList <String > supportedEventTypes = new ArrayList <String >();
100
131
public static final Logger log = LoggerFactory .getLogger (SemanticsService .class );
101
132
private Event event = new Event ();
102
- public static Gav semanticsGAV ;
103
- private boolean semanticsGavFlag = false ;
133
+ public static String purlSerializer ;
134
+ private boolean purlSerializerFlag = false ;
104
135
private static Gson gson = new Gson ();
105
136
private static Map <EiffelEventType , Class <? extends Event >> eventTypes = SemanticsService .eventType ();
106
137
@@ -113,10 +144,9 @@ public SemanticsService() {
113
144
@ PostConstruct
114
145
public void readManifest () {
115
146
ManifestHandler manifastHandler = new ManifestHandler ();
116
- semanticsGAV = manifastHandler .readGavfromManifest ();
117
- if (semanticsGAV == null || semanticsGAV .getArtifactId () == null || semanticsGAV .getGroupId () == null
118
- || semanticsGAV .getVersion () == null ) {
119
- semanticsGavFlag = true ;
147
+ purlSerializer = manifastHandler .readSemanticsSerializerFromManifest ();
148
+ if (purlSerializer != null && !purlSerializer .isEmpty ()) {
149
+ purlSerializerFlag = true ;
120
150
}
121
151
}
122
152
@@ -154,16 +184,17 @@ public static Map<EiffelEventType, Class<? extends Event>> eventType() {
154
184
eventTypes .put (ALERT_ACKNOWLEDGED , EiffelAlertAcknowledgedEvent .class );
155
185
eventTypes .put (ALERT_CEASED , EiffelAlertCeasedEvent .class );
156
186
eventTypes .put (ALERT_RAISED , EiffelAlertRaisedEvent .class );
187
+ eventTypes .put (ISSUE_DEFINED , EiffelIssueDefinedEvent .class );
157
188
158
189
return eventTypes ;
159
190
}
160
191
161
192
@ Override
162
193
public String generateMsg (String msgType , JsonObject bodyJson ) {
163
194
try {
164
- if (semanticsGavFlag ) {
165
- return createErrorResponse ("GAV info of eiffel-remrem-semantics is missing" ,
166
- "Required Serializer GAV information of eiffel-remrem-semantics is missing in MANIFEST.MF" );
195
+ if (purlSerializerFlag ) {
196
+ return createErrorResponse ("Serializer info of eiffel-remrem-semantics is missing" ,
197
+ "Required Serializer information of eiffel-remrem-semantics is missing in MANIFEST.MF" );
167
198
}
168
199
EiffelEventType eiffelType = EiffelEventType .fromString (msgType );
169
200
if (eiffelType == null ) {
@@ -175,12 +206,15 @@ public String generateMsg(String msgType, JsonObject bodyJson) {
175
206
JsonObject msgNodes = bodyJson .get (MSG_PARAMS ).getAsJsonObject ();
176
207
JsonObject eventNodes = bodyJson .get (EVENT_PARAMS ).getAsJsonObject ();
177
208
178
- // Compare the input JSON EventType with query parameter(-t) and also
209
+ // Compare the input JSON EventType with query parameter(-t) and
210
+ // also
179
211
// check type exist or not,
180
- // if input JSON EventType is missing adding query parameter as Type.
212
+ // if input JSON EventType is missing adding query parameter as
213
+ // Type.
181
214
String inputEventType = getInputEventType (bodyJson );
182
215
if (inputEventType == null || inputEventType .isEmpty ()) {
183
- bodyJson .get (MSG_PARAMS ).getAsJsonObject ().get (META ).getAsJsonObject ().addProperty (TYPE , eiffelType .getEventName ());
216
+ bodyJson .get (MSG_PARAMS ).getAsJsonObject ().get (META ).getAsJsonObject ().addProperty (TYPE ,
217
+ eiffelType .getEventName ());
184
218
} else if (!(inputEventType .equals (eiffelType .getEventName ()))) {
185
219
log .error ("check the input json message type : " + inputEventType );
186
220
return createErrorResponse (eiffelType .getEventName (),
@@ -196,8 +230,10 @@ public String generateMsg(String msgType, JsonObject bodyJson) {
196
230
log .error ("Could not validate message. Reason:" + e .getMessage () + "\n Cause: " + e .getCause ().toString ());
197
231
return createErrorResponse (e .getMessage (), e .getCause ().toString ());
198
232
} catch (JsonSyntaxException e ) {
199
- log .error ("Json Syntax exception occurred. Reason:" + e .getMessage () + "\n Cause: " + e .getCause ().toString ());
200
- return createErrorResponse ("Json Syntax exception occured while processing input schema" , e .getCause ().toString ());
233
+ log .error (
234
+ "Json Syntax exception occurred. Reason:" + e .getMessage () + "\n Cause: " + e .getCause ().toString ());
235
+ return createErrorResponse ("Json Syntax exception occured while processing input schema" ,
236
+ e .getCause ().toString ());
201
237
}
202
238
203
239
}
@@ -266,25 +302,25 @@ public String getEventType(JsonObject json) {
266
302
}
267
303
return null ;
268
304
}
269
-
305
+
270
306
@ Override
271
307
public Collection <String > getSupportedEventTypes () {
272
- return supportedEventTypes ;
308
+ return supportedEventTypes ;
273
309
}
274
-
310
+
275
311
/**
276
- * Gets the path to an event template file that must be in lowercase
277
- * and read through a resource stream. Stream is parsed into a
278
- * JsonElement.
312
+ * Gets the path to an event template file that must be in lowercase and
313
+ * read through a resource stream. Stream is parsed into a JsonElement.
279
314
*
280
- * @param String eventType
315
+ * @param String
316
+ * eventType
281
317
*
282
318
* @return json element containing an event template
283
319
*/
284
320
@ Override
285
- public JsonElement getEventTemplate (String eventType ) {
286
- String path = "templates/" + eventType .toLowerCase ()+ ".json" ;
287
- InputStream fileStream = getClass ().getClassLoader ().getResourceAsStream (path );
321
+ public JsonElement getEventTemplate (String eventType ) {
322
+ String path = "templates/" + eventType .toLowerCase () + ".json" ;
323
+ InputStream fileStream = getClass ().getClassLoader ().getResourceAsStream (path );
288
324
JsonElement json = null ;
289
325
JsonParser parser = new JsonParser ();
290
326
try {
@@ -403,10 +439,7 @@ public String generateRoutingKey(JsonObject eiffelMessage, String tag, String do
403
439
*/
404
440
public static Source setSerializerGav (Source source ) {
405
441
source = source == null ? new Source () : source ;
406
- Serializer serializer = source .getSerializer () == null ? new Serializer () : source .getSerializer ();
407
- serializer .setGroupId (semanticsGAV .getGroupId ());
408
- serializer .setArtifactId (semanticsGAV .getArtifactId ());
409
- serializer .setVersion (semanticsGAV .getVersion ());
442
+ String serializer = source .getSerializer () == null ? purlSerializer : source .getSerializer ();
410
443
source .setSerializer (serializer );
411
444
return source ;
412
445
}
0 commit comments