Skip to content

Commit a155192

Browse files
Merge pull request #2 from Ericsson/master
Updating fork
2 parents 643fea5 + a74e5a5 commit a155192

29 files changed

+471
-361
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ target/
1717

1818
# Others
1919
derby.log
20+
work/
2021

pom.xml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4-
<groupId>com.ericsson.ei</groupId>
4+
<groupId>com.github.ericsson</groupId>
55
<artifactId>eiffel-intelligence</artifactId>
6-
<version>0.0.1</version>
6+
<version>0.0.2</version>
7+
8+
<packaging>war</packaging>
79

810
<parent>
911
<groupId>org.springframework.boot</groupId>
@@ -47,6 +49,12 @@
4749
<dependency>
4850
<groupId>org.springframework.boot</groupId>
4951
<artifactId>spring-boot-starter-web</artifactId>
52+
<exclusions>
53+
<exclusion>
54+
<groupId>org.springframework.boot</groupId>
55+
<artifactId>spring-boot-starter-tomcat</artifactId>
56+
</exclusion>
57+
</exclusions>
5058
</dependency>
5159

5260
<dependency>
@@ -69,6 +77,12 @@
6977
<artifactId>spring-boot-starter-test</artifactId>
7078
<scope>test</scope>
7179
</dependency>
80+
81+
<dependency>
82+
<groupId>org.springframework.boot</groupId>
83+
<artifactId>spring-boot-starter-tomcat</artifactId>
84+
<scope>provided</scope>
85+
</dependency>
7286

7387
<dependency>
7488
<groupId>com.fasterxml.jackson.core</groupId>
@@ -245,6 +259,14 @@
245259
</includes>
246260
</configuration>
247261
</plugin>
262+
263+
<plugin>
264+
<groupId>org.apache.maven.plugins</groupId>
265+
<artifactId>maven-war-plugin</artifactId>
266+
<configuration>
267+
<failOnMissingWebXml>false</failOnMissingWebXml>
268+
</configuration>
269+
</plugin>
248270

249271
</plugins>
250272
</build>

src/main/java/com/ericsson/ei/App.java

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import org.springframework.boot.SpringApplication;
2020
import org.springframework.boot.autoconfigure.SpringBootApplication;
21+
import org.springframework.boot.builder.SpringApplicationBuilder;
22+
import org.springframework.boot.web.support.SpringBootServletInitializer;
2123
import org.springframework.scheduling.annotation.EnableAsync;
2224
import org.springframework.scheduling.annotation.EnableScheduling;
2325

@@ -28,24 +30,29 @@
2830
@SpringBootApplication
2931
@EnableAsync
3032
@EnableScheduling
31-
public class App {
32-
33-
public static void main(String[] args) {
34-
35-
List<String> logLevels = new ArrayList<>();
36-
Collections.addAll(logLevels, "ALL", "DEBUG", "ERROR", "FATAL", "INFO", "TRACE", "WARN");
37-
38-
if(args != null && args.length > 0 && logLevels.contains(args[0])) {
39-
System.setProperty("logging.level.root", args[0]);
40-
System.setProperty("logging.level.org.springframework.web", args[0]);
41-
System.setProperty("logging.level.com.ericsson.ei", args[0]);
42-
} else {
43-
System.setProperty("logging.level.root", "OFF");
44-
System.setProperty("logging.level.org.springframework.web", "OFF");
45-
System.setProperty("logging.level.com.ericsson.ei", "OFF");
46-
}
47-
48-
SpringApplication.run(App.class, args);
49-
}
33+
public class App extends SpringBootServletInitializer {
34+
35+
@Override
36+
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
37+
return application.sources(App.class);
38+
}
39+
40+
public static void main(String[] args) {
41+
42+
List<String> logLevels = new ArrayList<>();
43+
Collections.addAll(logLevels, "ALL", "DEBUG", "ERROR", "FATAL", "INFO", "TRACE", "WARN");
44+
45+
if (args != null && args.length > 0 && logLevels.contains(args[0])) {
46+
System.setProperty("logging.level.root", args[0]);
47+
System.setProperty("logging.level.org.springframework.web", args[0]);
48+
System.setProperty("logging.level.com.ericsson.ei", args[0]);
49+
} else {
50+
System.setProperty("logging.level.root", "OFF");
51+
System.setProperty("logging.level.org.springframework.web", "OFF");
52+
System.setProperty("logging.level.com.ericsson.ei", "OFF");
53+
}
54+
55+
SpringApplication.run(App.class, args);
56+
}
5057

5158
}

src/main/java/com/ericsson/ei/controller/AggregatedObjectController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
/**
1313
* No description
14-
* (Generated with springmvc-raml-parser v.0.8.6)
14+
* (Generated with springmvc-raml-parser v.0.10.11)
1515
*
1616
*/
1717
@RestController

src/main/java/com/ericsson/ei/controller/InformationController.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/main/java/com/ericsson/ei/controller/MissedNotificationController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
/**
1313
* No description
14-
* (Generated with springmvc-raml-parser v.0.8.6)
14+
* (Generated with springmvc-raml-parser v.0.10.11)
1515
*
1616
*/
1717
@RestController

src/main/java/com/ericsson/ei/controller/MissedNotificationControllerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public class MissedNotificationControllerImpl implements MissedNotificationContr
4242
private ProcessMissedNotification processMissedNotification;
4343

4444
/**
45-
* This method is responsible for the REST GET mechanism to extract the data
46-
* on the basis of the SubscriptionName from the Missed Notification Object.
45+
* This method is responsible for the REST GET mechanism to extract the data on
46+
* the basis of the SubscriptionName from the Missed Notification Object.
4747
*
4848
* @param subscriptionName
4949
* @return ResponseEntity
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
package com.ericsson.ei.controller;
3+
4+
import org.springframework.http.ResponseEntity;
5+
import org.springframework.web.bind.annotation.RequestMapping;
6+
import org.springframework.web.bind.annotation.RequestMethod;
7+
import org.springframework.web.bind.annotation.RequestParam;
8+
import org.springframework.web.bind.annotation.RestController;
9+
10+
11+
/**
12+
* No description
13+
* (Generated with springmvc-raml-parser v.0.10.11)
14+
*
15+
*/
16+
@RestController
17+
@RequestMapping(value = "/jmespathrule/ruleCheck", produces = "application/json")
18+
public interface RuleCheckController {
19+
20+
21+
/**
22+
* No description
23+
*
24+
*/
25+
@RequestMapping(value = "", method = RequestMethod.POST)
26+
public ResponseEntity<?> updateJmespathruleRuleCheck(
27+
@RequestParam
28+
String rule,
29+
@RequestParam
30+
String jsonContent);
31+
32+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package com.ericsson.ei.controller;
2+
3+
import org.json.JSONObject;
4+
import org.slf4j.Logger;
5+
import org.slf4j.LoggerFactory;
6+
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.http.HttpStatus;
8+
import org.springframework.http.ResponseEntity;
9+
import org.springframework.stereotype.Component;
10+
import org.springframework.web.bind.annotation.CrossOrigin;
11+
import org.springframework.web.bind.annotation.RequestMapping;
12+
import org.springframework.web.bind.annotation.RequestMethod;
13+
14+
import com.ericsson.ei.jmespath.JmesPathInterface;
15+
16+
import io.swagger.annotations.Api;
17+
import io.swagger.annotations.ApiOperation;
18+
19+
/**
20+
* This class implements the Interface for JMESPath API, generated by RAML 0.8
21+
* Provides interaction with JmesPathInterface class
22+
*
23+
* Usage: 1. If input contains a rule as an argument and json expression in a
24+
* text file, then the following curl command may be used. curl -H
25+
* "Content-type: application/x-www-form-urlencoded" -X POST --data-urlencode
26+
* jsonContent@testjson.txt
27+
* http://localhost:8090/jmespathrule/runRule?rule=data.outcome
28+
*
29+
* 2. If input contains rule and json expression as two String arguments, then
30+
* the following curl command may be used. curl -H "Content-type:
31+
* application/x-www-form-urlencoded" -X POST -d
32+
* jsonContent={"data":{"outcome":{"conclusion":"SUCCESSFUL"},"test":"persistentLogs"}}
33+
* http://localhost:8090/jmespathrule/runRule?rule=data.outcome
34+
*
35+
*/
36+
37+
@Component
38+
@CrossOrigin
39+
@Api(value = "jmespath")
40+
@RequestMapping(value = "/jmespathrule/ruleCheck", produces = "application/json")
41+
public class RuleCheckControllerImpl implements RuleCheckController {
42+
43+
private static final Logger LOG = LoggerFactory.getLogger(SubscriptionControllerImpl.class);
44+
45+
@Autowired
46+
JmesPathInterface jmesPathInterface;
47+
48+
/**
49+
* This method interacts with JmesPathInterface class method runRuleOnEvent to
50+
* evaluate a rule on JSON object.
51+
*
52+
* @param rule-
53+
* takes a String as a rule that need to be evaluated on JSON content
54+
* @param jsonContent-
55+
* takes JSON object as a String
56+
* @return return a String object
57+
*
58+
*/
59+
@Override
60+
@CrossOrigin
61+
@ApiOperation(value = "run rule on event")
62+
@RequestMapping(value = "", method = RequestMethod.POST)
63+
public ResponseEntity<?> updateJmespathruleRuleCheck(String rule, String jsonContent) {
64+
String res = new String("[]");
65+
66+
try {
67+
JSONObject jsonObj = new JSONObject(jsonContent);
68+
String jsonString = jsonObj.toString();
69+
res = jmesPathInterface.runRuleOnEvent(rule, jsonString).toString();
70+
LOG.info("Query :" + rule + " executed Successfully");
71+
return new ResponseEntity<String>(res, HttpStatus.OK);
72+
73+
} catch (Exception e) {
74+
LOG.error(e.getMessage(), e);
75+
return new ResponseEntity<String>(res, HttpStatus.BAD_REQUEST);
76+
}
77+
}
78+
79+
}

src/main/java/com/ericsson/ei/controller/SubscriptionController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
/**
1313
* Provides interaction with Subscription resource
14-
* (Generated with springmvc-raml-parser v.0.8.6)
14+
* (Generated with springmvc-raml-parser v.0.10.11)
1515
*
1616
*/
1717
@RestController
@@ -52,7 +52,7 @@ public ResponseEntity<com.ericsson.ei.controller.model.SubscriptionResponse> upd
5252
*/
5353
@RequestMapping(value = "/{subscriptionName}", method = RequestMethod.GET)
5454
public ResponseEntity<List<com.ericsson.ei.controller.model.Subscription>> getSubscriptionById(
55-
@PathVariable
55+
@PathVariable(required = false)
5656
String subscriptionName);
5757

5858
/**
@@ -61,7 +61,7 @@ public ResponseEntity<List<com.ericsson.ei.controller.model.Subscription>> getSu
6161
*/
6262
@RequestMapping(value = "/{subscriptionName}", method = RequestMethod.DELETE)
6363
public ResponseEntity<com.ericsson.ei.controller.model.SubscriptionResponse> deleteSubscriptionById(
64-
@PathVariable
64+
@PathVariable(required = false)
6565
String subscriptionName);
6666

6767
}

0 commit comments

Comments
 (0)