Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fiqare perseo-core improvements #151

Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
6d25f8d
Add JaCoCo plugin
fiqare-emergya-dev Feb 5, 2019
ab122f2
Merge pull request #2 from Emergya/configuration-branch
fiqare-emergya-dev Feb 6, 2019
f651423
#284620
fiqare-emergya-dev Feb 6, 2019
a1c8d23
Delete innecesary comments
fiqare-emergya-dev Feb 7, 2019
fa2197f
Merge pull request #3 from Emergya/configuration-branch
fiqare-emergya-dev Feb 7, 2019
99263f2
Merge pull request #4 from Emergya/284620
fiqare-emergya-dev Feb 7, 2019
5c7825b
#284620
fiqare-emergya-dev Feb 11, 2019
cbfad26
Merge pull request #5 from Emergya/284620
fiqare-emergya-dev Feb 11, 2019
18d5393
Fixed Dockerfile
fiqare-emergya-dev Feb 11, 2019
c4c89f3
Fixed Dockerfile
fiqare-emergya-dev Feb 11, 2019
04e9cbb
284621
fiqare-emergya-dev Feb 11, 2019
e90be87
284621
fiqare-emergya-dev Feb 11, 2019
9dc7421
Fixed Dockerfile
fiqare-emergya-dev Feb 12, 2019
032f6b8
Merge pull request #7 from Emergya/Dockerfile-fixed
fiqare-emergya-dev Feb 12, 2019
c361bf3
Merge pull request #9 from Emergya/284621
fiqare-emergya-dev Feb 12, 2019
8ff7828
Add 'default' clauses
fiqare-emergya-dev Feb 14, 2019
8050a3d
Added comment in default clauses
fiqare-emergya-dev Feb 14, 2019
86f9044
Merge pull request #10 from Emergya/defaultclauses#284631
fiqare-emergya-dev Feb 14, 2019
6fa32ad
Fill in the empty statements
fiqare-emergya-dev Feb 14, 2019
7de5632
Merge branch 'ci' of https://github.com/Emergya/cdti-fiqare-perseo-co…
fiqare-emergya-dev Feb 14, 2019
40094b8
Merge pull request #11 from Emergya/emptystatements#284630
fiqare-emergya-dev Feb 14, 2019
3e386ac
Refactor code
fiqare-emergya-dev Feb 14, 2019
2ad08b7
Merge pull request #12 from Emergya/emptystatements#284630
fiqare-emergya-dev Feb 14, 2019
bc7419d
Separate variables
fiqare-emergya-dev Feb 15, 2019
30ef6b4
Merge pull request #13 from Emergya/multiplevariables#284636
fiqare-emergya-dev Feb 15, 2019
4ab8d47
Fixed issue #284627 in src/main/java/com/telefonica/iot/perseo/Events…
fiqare-emergya-dev Feb 26, 2019
149d591
Fixed issue #284627 in pom.xml
fiqare-emergya-dev Feb 26, 2019
cd90313
Merge pull request #14 from Emergya/284627
fiqare-emergya-dev Feb 26, 2019
5e43ec8
Fixed issue #284639 in src/main/java/com/telefonica/iot/perseo/Config…
fiqare-emergya-dev Feb 27, 2019
65ac79d
Merge pull request #15 from Emergya/284639
fiqare-emergya-dev Feb 27, 2019
7ccb457
Merge pull request #16 from telefonicaid/master
fiqare-emergya-dev Mar 18, 2019
c0dfb12
Merge pull request #17 from Emergya/master
fiqare-emergya-dev Mar 18, 2019
dd1ad0e
fixed issues EventsServlet.java #~290936
fiqare-emergya-dev Mar 19, 2019
5852c95
fixed issues GenericListener #290956
fiqare-emergya-dev Mar 19, 2019
0ac3d7e
#291109
fiqare-emergya-dev Mar 19, 2019
33c8328
Merge pull request #18 from Emergya/ci
fiqare-emergya-dev Mar 20, 2019
e53c7eb
fixed issues Configuration #291280
fiqare-emergya-dev Mar 20, 2019
4eb356c
fixed issues EventsServlet #290936
fiqare-emergya-dev Mar 20, 2019
7883507
fixed issues LogLevelServlet #291283
fiqare-emergya-dev Mar 20, 2019
1395a50
fixed issues RulesManager #290959
fiqare-emergya-dev Mar 20, 2019
b510393
fixed issues RulesServlet #291109
fiqare-emergya-dev Mar 20, 2019
4ddbdb4
fixed issues TimeRulesStore #291284
fiqare-emergya-dev Mar 20, 2019
6e26193
fixed issues Utils #~91285
fiqare-emergya-dev Mar 20, 2019
5adca52
fixed issues JSONArray #291298
fiqare-emergya-dev Mar 20, 2019
f73d8f1
fixed issues JSONObject #291299
fiqare-emergya-dev Mar 20, 2019
d08fdcd
fixed issues Kim 291301
fiqare-emergya-dev Mar 20, 2019
b694d53
fixed issues EventsServletTest #291302
fiqare-emergya-dev Mar 20, 2019
ed78f2f
fixed issues GenericListenerTest #291303
fiqare-emergya-dev Mar 20, 2019
8e42d0e
fixed issues LogLevelServletTest #291304
fiqare-emergya-dev Mar 20, 2019
f94f1bf
fixed issues RulesManagerTest #291305
fiqare-emergya-dev Mar 20, 2019
b38f18b
fixed issues TimeRulesStoreTest #291306
fiqare-emergya-dev Mar 20, 2019
5491d95
fixed issues TimeRulesStoreTest #291306
fiqare-emergya-dev Mar 20, 2019
fb3005d
fixed issues UtilsTest #291307
fiqare-emergya-dev Mar 20, 2019
a17edf1
fixed issues Help.java #291308
fiqare-emergya-dev Mar 20, 2019
9eb801a
merge with ci brunch
fiqare-emergya-dev Mar 20, 2019
0413a41
merged with ci branch
fiqare-emergya-dev Mar 20, 2019
5b174d7
Merge pull request #19 from Emergya/284645
fiqare-emergya-dev Mar 20, 2019
6ad2461
Merge pull request #20 from Emergya/ci
fiqare-emergya-dev Mar 20, 2019
97b23e9
Updated to 1.4.0 release from telefonicaid/perseo-core
fiqare-emergya-dev Nov 21, 2019
7a1e6e5
Merge branch 'telefonicaid-release/1.4.0'
fiqare-emergya-dev Nov 21, 2019
90a8cba
Travis I
fiqare-emergya-dev Nov 21, 2019
5c7b891
Travis CI
fiqare-emergya-dev Nov 21, 2019
64f4713
Fixed Travis errors
fiqare-emergya-dev Nov 21, 2019
a5ff18a
Fixed Travis errors(2)
fiqare-emergya-dev Nov 21, 2019
660056e
Fixed org.json dependency
fiqare-emergya-dev Dec 17, 2019
654f7bc
Merged with telefonica master
fiqare-emergya-dev Dec 17, 2019
d3cd3f4
Merge branch 'telefonicaid-master' into fiqare-perseo-core-improvements
fiqare-emergya-dev Dec 17, 2019
4d08aff
Fixes
fiqare-emergya-dev Dec 17, 2019
05982ba
pr fixes
fiqare-emergya-dev Jan 16, 2020
c8154a4
Merge pull request #3 from telefonicaid/master
fiqare-emergya-dev Jan 16, 2020
61b8a4c
pr fixes
fiqare-emergya-dev Jan 23, 2020
cff907d
Merge branch 'fiqare-perseo-core-improvements' of https://github.com/…
fiqare-emergya-dev Jan 23, 2020
47ab836
pr fixes
fiqare-emergya-dev Jan 28, 2020
b4a4d73
pr fixed
fiqare-emergya-dev Jan 29, 2020
b6d7148
pr fixed
fiqare-emergya-dev Jan 31, 2020
728e600
travis fixed
fiqare-emergya-dev Feb 3, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

.idea
.swp
.classpath
.project
.scannerwork
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok to add .project, .settings and .classpath, as they are typically used by IDES. However, what about .scannerwork?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4d08aff

.settings

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
Expand All @@ -18,3 +22,4 @@ target
nb-configuration.xml
nbactions.xml

""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this "" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4d08aff

3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ jdk:
- openjdk11
branches:
only:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be changed in .travis.yml. Please, rollback the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4d08aff

- /.*/

- fiqare-perseo-core-improvements
install:
- mvn test -B

Expand Down
32 changes: 6 additions & 26 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
<version>1.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.owasp.encoder</groupId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this new dependency does ?

Copy link
Contributor Author

@fiqare-emergya-dev fiqare-emergya-dev Dec 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In several classes the following issue has been detected:

Security - Potential XSS in Servlet
A potential XSS was found. It could be used to execute unwanted JavaScript in a client's browser.

For example:
Vulnerable Code:

protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String input1 = req.getParameter("input1");
    [...]
    resp.getWriter().write(input1);
}

Solution:

protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String input1 = req.getParameter("input1");
    [...]
    resp.getWriter().write(Encode.forHtml(input1));
}

References:
http://projects.webappsec.org/w/page/13246920/Cross%20Site%20Scripting
https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet
https://www.owasp.org/index.php/Top_10_2013-A3-Cross-Site_Scripting_%28XSS%29
http://cwe.mitre.org/data/definitions/79.html
https://code.google.com/p/owasp-java-encoder/

Due to this issue, org.owasp.encoder dependency has been added.

<artifactId>encoder</artifactId>
<version>1.2.2</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -122,31 +127,6 @@
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate on the removal of this plugin, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d3cd3f4

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>6.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
Expand Down Expand Up @@ -194,4 +174,4 @@
</plugin>
</plugins>
</reporting>
</project>
</project>
9 changes: 9 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
sonar.projectKey=fiware-perseo-core-dev-jafernandez
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this connect with some sonar server out there. Could you elaborate on this? Where is that server located? Who is managing it?

If this is a local configuration (i.e. for a local sonar server) it shouldn't be included in perseo master branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4d08aff

sonar.projectName=Fiware Perseo Core Dev JaFernandez
sonar.projectVersion=1.0
sonar.sources=.
sonar.java.binaries=.
sonar.exclusions=target/**
sonar.junit.reportPaths=target/surefire-reports
sonar.jacoco.reportPaths=target/jacoco.exec
sonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml
16 changes: 9 additions & 7 deletions src/main/java/com/telefonica/iot/perseo/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.ResourceBundle;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -45,15 +47,15 @@ private Configuration() {
private static final String PERSEO_MAX_AGE_ENV = "MAX_AGE";

private static final Properties PROPERTIES = new Properties();
private static final String PATH = "/etc/perseo-core.properties";
private static final String PATH = ResourceBundle.getBundle("perseo-core").getString("properties.path");
private static final String ACTION_URL_PROP = "action.url";
private static final String MAX_AGE_PROP = "rule.max_age";

private static String actionRule;
private static long maxAge;

static {
LOGGER.debug("Configuration init: " + reload());
LOGGER.debug(String.format("Configuration init: %s",reload()));
}

/**
Expand All @@ -67,7 +69,7 @@ public static synchronized boolean reload() {
InputStream stream;
String defaultMaxAge;
String defaultURL;
String actionPath = "/actions/do";
String actionPath = ResourceBundle.getBundle("perseo-core").getString("action.path");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure of understanding this change... where "action.path" configuration is located in the resources of the proyect? Some .properties file? Which one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is this is due to an issue of the portability axis (URIs should not be hardcoded).

"action.path" as been located in perseo-core.properties file.

References:
https://wiki.sei.cmu.edu/confluence/display/java/MSC03-J.+Never+hard+code+sensitive+information

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NTC


// Check configuration file. If exist, set as default configuration for perseo-core
try {
Expand Down Expand Up @@ -95,21 +97,21 @@ public static synchronized boolean reload() {
// Add actions/do path if perseoFeURLEnv not contains it yet
actionRule = perseoFeURLEnv.contains(actionPath) ? perseoFeURLEnv : perseoFeURLEnv + actionPath;
} else {
LOGGER.error("Invalid value for " + PERSEO_FE_URL_ENV + ": " + perseoFeURLEnv);
LOGGER.error(String.format("Invalid value for %s: %s",PERSEO_FE_URL_ENV, perseoFeURLEnv));
return false;
}
LOGGER.info("actionRule configuration is: " + actionRule);
LOGGER.info(String.format("actionRule configuration is: %s",actionRule));

// Get MAX_AGE from env var if exist, else default
String maxAgeEnv = System.getenv(PERSEO_MAX_AGE_ENV);
// Check maxAge numerical value
try {
maxAge = maxAgeEnv != null ? Long.parseLong(maxAgeEnv) : Long.parseLong(defaultMaxAge);
} catch (NumberFormatException nfe) {
LOGGER.error("Invalid value for " + PERSEO_MAX_AGE_ENV + ": " + nfe);
LOGGER.error(String.format("Invalid value for %s: %s",PERSEO_MAX_AGE_ENV,nfe));
return false;
}
LOGGER.info("maxAge configuration is: " + maxAge);
LOGGER.info(String.format("maxAge configuration is: %s",maxAge));

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/telefonica/iot/perseo/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @author brox
*/
public final class Constants {
private Constants() { };
private Constants() {}
public static final String SERVICE_FIELD = "service";
public static final String SUBSERVICE_FIELD = "subservice";
public static final String CORRELATOR_HEADER = "fiware-correlator";
Expand Down
33 changes: 18 additions & 15 deletions src/main/java/com/telefonica/iot/perseo/EventsServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.log4j.MDC;
import org.json.JSONException;
import org.json.JSONObject;
import org.owasp.encoder.Encode;

/**
*
Expand All @@ -42,7 +43,7 @@
public class EventsServlet extends HttpServlet {

private static final Logger logger = LoggerFactory.getLogger(EventsServlet.class);
EPServiceProvider epService;
private static EPServiceProvider epService;

@Override
public void init() {
Expand Down Expand Up @@ -76,25 +77,27 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
Utils.putCorrelatorAndTrans(request);
logger.debug("events doPost");
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
StringBuilder sb = new StringBuilder();
response.setContentType("application/json;charset=UTF-8");
try {
String eventText = Utils.getBodyAsString(request);
logger.info("incoming event:" + eventText);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a general change from string concatenation style (+) to format(). Why this change is neeed? Or, in other words, why usage of format() is prefereable over string concatenation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is this is due to an issue of the maintainability axis that suggests using format() instead of string concatenation.

References:
https://wiki.sei.cmu.edu/confluence/display/c/FIO47-C.+Use+valid+format+strings

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine. NTC.

logger.info(String.format("incoming event: %s", eventText));
org.json.JSONObject jo = new JSONObject(eventText);
logger.debug("event as JSONObject: " + jo);
logger.debug(String.format("event as JSONObject: %s", jo));
Map<String, Object> eventMap = Utils.JSONObject2Map(jo);
logger.debug("event as map: " + eventMap);
logger.debug(String.format("event as map: %s" , eventMap));
epService.getEPRuntime().sendEvent(eventMap, Constants.IOT_EVENT);
logger.debug("event was sent: " + eventMap);
} catch (JSONException je) {
logger.error("error: " + je);
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
out.printf("{\"error\":\"%s\"}\n", je.getMessage());

} finally {
out.close();
logger.debug(String.format("event was sent: %s", eventMap));
} catch (Exception je) {
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review indentation on this block. Have you done a checkstyle pass (configured using telefonica_checkstyle.xml file in the root of the repository) after the changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d3cd3f4

logger.error(String.format("error: %s" ,je));
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
response.getOutputStream().print(String.format("{\"error\":\"%s\"}%n", Encode.forHtmlContent(je.getMessage())));
}catch(IOException exception) {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
}


}
}

Expand Down
13 changes: 6 additions & 7 deletions src/main/java/com/telefonica/iot/perseo/GenericListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public class GenericListener implements UpdateListener {
*/
@Override
public void update(EventBean[] newEvents, EventBean[] oldEvents) {
try {
HashMap<String, JSONObject> rules = TimeRulesStore.getInstance().getAllRulesInfo();
try {
for (EventBean event : newEvents) {

JSONObject jo = Utils.Event2JSONObject(event);
Expand All @@ -64,23 +63,23 @@ public void update(EventBean[] newEvents, EventBean[] oldEvents) {

// Is a timed Rule. Set special headers using rule saved information
Utils.setTimerRuleHeaders(rule);
LOGGER.info("Firing temporal rule: " + event);
LOGGER.info(String.format("Firing temporal rule: %s",event));

} else {

LOGGER.info("Firing Rule: " + event);
LOGGER.info(String.format("Firing Rule: %s",event));
}

LOGGER.debug("result errors: " + jo.optJSONObject("errors"));
LOGGER.debug("result json: " + jo);
LOGGER.debug(String.format("result errors: %s",jo.optJSONObject("errors")));
LOGGER.debug(String.format("result json: %s", jo));

boolean ok = Utils.DoHTTPPost(Configuration.getActionURL(), jo.toString());
if (!ok) {
LOGGER.error("action post failed");
}
}
} catch (PropertyAccessException pae) {
LOGGER.error("doing action " + pae);
LOGGER.error(String.format("doing action %s",pae));
}
}
}
53 changes: 34 additions & 19 deletions src/main/java/com/telefonica/iot/perseo/LogLevelServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.owasp.encoder.Encode;


/**
Expand Down Expand Up @@ -65,21 +66,28 @@ public class LogLevelServlet extends HttpServlet {
@Override
protected void doPut(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String levelName = request.getParameter("level");
logger.info("changing log level to " + levelName);
Level level = levels.get(levelName);
if (level == null) {
logger.error("invalid log level: " + levelName);
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json");
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
response.getOutputStream().print("{\"errorMessage\":\"invalid log level\"}");
return;
try {
String levelName = request.getParameter("level");
logger.info(String.format("changing log level to %s",levelName));
Level level = levels.get(levelName);
if (level == null) {
logger.error(String.format("invalid log level: %s",levelName));
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json");
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
response.getOutputStream().print("{\"errorMessage\":\"invalid log level\"}");
return;
}
synchronized (mutex) {
LogManager.getRootLogger().setLevel(level);
}
response.setStatus(HttpServletResponse.SC_OK);
}catch(IOException e) {
logger.error("IOException in log level");
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return;
}
synchronized (mutex) {
LogManager.getRootLogger().setLevel(level);
}
response.setStatus(HttpServletResponse.SC_OK);

}

/**
Expand All @@ -95,11 +103,18 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
logger.debug("getting log level");
synchronized (mutex) {
String currentLevel = LogManager.getRootLogger().getLevel().toString();
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json");
response.setStatus(HttpServletResponse.SC_OK);
response.getOutputStream().print("{\"level\":\""+ currentLevel +"\"}");
try {
String currentLevel = LogManager.getRootLogger().getLevel().toString();
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json");
response.setStatus(HttpServletResponse.SC_OK);
response.getOutputStream().print(String.format("{\"level\":\"%s\"}",Encode.forHtmlContent(currentLevel)));
}catch(IOException e) {
logger.error("IOException in log level");
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return;
}

}
}
/**
Expand Down
Loading