Skip to content

Commit

Permalink
Merge branch 'release/2022.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sfeilmeier committed Feb 1, 2022
2 parents 2313a00 + 90bcb33 commit 9fe71be
Show file tree
Hide file tree
Showing 381 changed files with 10,931 additions and 9,475 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
node-version: '14'

- name: Setup Cache for Node.js
uses: actions/cache@v2
Expand Down Expand Up @@ -59,4 +59,28 @@ jobs:
run: |
cd ui
npm ci --prefer-offline --cache ~/.npm
node_modules/@angular/cli/bin/ng build -c "openems,openems-edge-prod,prod"
node_modules/@angular/cli/bin/ng build -c "openems,openems-edge-prod,prod"
#
# Is this a Tag? Prepare release assets and create a draft release
#
- name: Prepare Edge+Backend assets
if: startsWith(github.ref, 'refs/tags/')
run: |
./gradlew buildEdge buildBackend
- name: Prepare UI asset
if: startsWith(github.ref, 'refs/tags/')
uses: edgarrc/action-7z@v1
with:
args: 7z a openems-ui.zip ./ui/target/*

- name: Create draft Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
draft: true
files: |
build/openems-edge.jar
build/openems-backend.jar
openems-ui.zip
2 changes: 1 addition & 1 deletion cnf/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<message key="name.invalidPattern" value="Parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="LambdaParameterName">
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*?$"/>
<message key="name.invalidPattern" value="Lambda parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="CatchParameterName">
Expand Down
22 changes: 13 additions & 9 deletions cnf/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>local</groupId>
Expand Down Expand Up @@ -77,11 +75,17 @@
<artifactId>retrofit</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<!-- JavaBeans Activation Framework -->
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<!-- HikariCP A solid, high-performance, JDBC connection pool at last. -->
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>4.0.3</version>
<version>5.0.1</version>
</dependency>
<!-- commons -->
<dependency>
Expand Down Expand Up @@ -144,7 +148,7 @@
<!-- Changelog: https://github.com/apache/felix-dev/blob/master/configadmin/changelog.txt -->
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.configadmin</artifactId>
<version>1.9.20</version>
<version>1.9.22</version>
</dependency>
<dependency>
<!-- Apache Felix EventAdmin -->
Expand Down Expand Up @@ -203,7 +207,7 @@
<dependency>
<groupId>org.dhatim</groupId>
<artifactId>fastexcel</artifactId>
<version>0.12.12</version>
<version>0.12.14</version>
</dependency>
<dependency>
<!-- Eclipse Paho MQTTv5 Client -->
Expand Down Expand Up @@ -282,12 +286,12 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.32</version>
<version>1.7.35</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.32</version>
<version>1.7.35</version>
</dependency>
</dependencies>
</project>
</project>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/modules/ROOT/assets/images/config-backend-metadata.dummy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/modules/ROOT/assets/images/config-backend-timedata.dummy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/modules/ROOT/assets/images/config-backend-ui.websocket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/modules/ROOT/assets/images/config-controller-api-backend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/modules/ROOT/assets/images/config-controller-debug-log.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/modules/ROOT/assets/images/eclipse-workspace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/modules/ROOT/assets/images/openems-ui-edge-overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/modules/ROOT/assets/images/sourcetree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/modules/ROOT/assets/images/ui-via-backend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
208 changes: 113 additions & 95 deletions doc/modules/ROOT/pages/gettingstarted.adoc

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/modules/ROOT/pages/single_document.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
= OpenEMS - Open Energy Management System
ifndef::toc[]
(c) 2022 OpenEMS Association e.V.
Version 2022.1.0-SNAPSHOT
Version 2022.2.0
:sectnums:
:sectnumlevels: 4
:toc:
Expand Down
4 changes: 2 additions & 2 deletions io.openems.backend.application/BackendApp.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
com.google.gson;version='[2.8.9,2.8.10)',\
com.google.guava;version='[31.0.1,31.0.2)',\
com.google.guava.failureaccess;version='[1.0.1,1.0.2)',\
com.zaxxer.HikariCP;version='[4.0.3,4.0.4)',\
com.zaxxer.HikariCP;version='[5.0.1,5.0.2)',\
io.openems.backend.application;version=snapshot,\
io.openems.backend.b2brest;version=snapshot,\
io.openems.backend.b2bwebsocket;version=snapshot,\
Expand All @@ -68,7 +68,7 @@
io.openems.wrapper.opczip;version=snapshot,\
org.apache.commons.commons-fileupload;version='[1.4.0,1.4.1)',\
org.apache.commons.commons-io;version='[2.8.0,2.8.1)',\
org.apache.felix.configadmin;version='[1.9.20,1.9.21)',\
org.apache.felix.configadmin;version='[1.9.22,1.9.23)',\
org.apache.felix.http.jetty;version='[4.1.14,4.1.15)',\
org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
org.apache.felix.inventory;version='[1.1.0,1.1.1)',\
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.openems.backend.application;

import java.io.IOException;
import java.util.Dictionary;
import java.util.Hashtable;

import org.osgi.service.cm.Configuration;
Expand All @@ -23,22 +22,22 @@ public class BackendApp {
private final Logger log = LoggerFactory.getLogger(BackendApp.class);

@Reference
ConfigurationAdmin cm;
private ConfigurationAdmin cm;

@Activate
void activate() {
String message = "OpenEMS Backend version [" + OpenemsConstants.VERSION + "] started";
String line = Strings.repeat("=", message.length());
log.info(line);
log.info(message);
log.info(line);
private void activate() {
final var message = "OpenEMS Backend version [" + OpenemsConstants.VERSION + "] started";
final var line = Strings.repeat("=", message.length());
this.log.info(line);
this.log.info(message);
this.log.info(line);

Configuration config;
try {
config = cm.getConfiguration("org.ops4j.pax.logging", null);
Dictionary<String, Object> properties = config.getProperties();
config = this.cm.getConfiguration("org.ops4j.pax.logging", null);
final var properties = config.getProperties();
if (properties == null || properties.isEmpty() || properties.get("log4j2.rootLogger.level") == null) {
Hashtable<String, Object> log4j = new Hashtable<>();
final var log4j = new Hashtable<String, Object>();
log4j.put("log4j2.appender.console.type", "Console");
log4j.put("log4j2.appender.console.name", "console");
log4j.put("log4j2.appender.console.layout.type", "PatternLayout");
Expand All @@ -58,8 +57,8 @@ void activate() {
}

@Deactivate
void deactivate() {
log.info("Deactivate BackendApp");
private void deactivate() {
this.log.info("Deactivate BackendApp");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ public B2bRest() {
}

@Activate
void activate(Config config) throws OpenemsException {
private void activate(Config config) throws OpenemsException {
this.startServer(config.port());
}

@Deactivate
void deactivate() {
private void deactivate() {
this.stopServer();
}

/**
* Create and start new server.
*
*
* @param port the port
* @throws OpenemsException on error
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques

/**
* Authenticate a user.
*
*
* @param request the HttpServletRequest
* @return the {@link User}
* @throws OpenemsNamedException on error
*/
private User authenticate(HttpServletRequest request) throws OpenemsNamedException {
String authHeader = request.getHeader("Authorization");
if (authHeader != null) {
StringTokenizer st = new StringTokenizer(authHeader);
var st = new StringTokenizer(authHeader);
if (st.hasMoreTokens()) {
String basic = st.nextToken();
if (basic.equalsIgnoreCase("Basic")) {
Expand All @@ -92,8 +92,8 @@ private User authenticate(HttpServletRequest request) throws OpenemsNamedExcepti
}
int p = credentials.indexOf(":");
if (p != -1) {
String username = credentials.substring(0, p).trim();
String password = credentials.substring(p + 1).trim();
var username = credentials.substring(0, p).trim();
var password = credentials.substring(p + 1).trim();
// authenticate using username & password
return this.parent.metadata.authenticate(username, password);
}
Expand Down Expand Up @@ -140,7 +140,7 @@ private void sendErrorResponse(Request baseRequest, HttpServletResponse response

/**
* Parses a Request to JSON.
*
*
* @param baseRequest the Request
* @return the {@link JsonObject}
* @throws OpenemsException on error
Expand All @@ -159,15 +159,15 @@ private static JsonObject parseJson(Request baseRequest) throws OpenemsException

/**
* Handles an http request to 'jsonrpc' endpoint.
*
*
* @param user the {@link User}
* @param baseRequest the {@link Request}
* @param httpRequest the {@link HttpServletRequest}
* @param httpResponse the {@link HttpServletResponse}
*/
private void handleJsonRpc(User user, Request baseRequest, HttpServletRequest httpRequest,
HttpServletResponse httpResponse) {
UUID requestId = new UUID(0L, 0L); /* dummy UUID */
var requestId = new UUID(0L, 0L); /* dummy UUID */
try {
// call handler methods
if (!httpRequest.getMethod().equals("POST")) {
Expand All @@ -176,17 +176,17 @@ private void handleJsonRpc(User user, Request baseRequest, HttpServletRequest ht
}

// parse json and add "jsonrpc" and "id" properties if missing
JsonObject json = RestHandler.parseJson(baseRequest);
var json = RestHandler.parseJson(baseRequest);
if (!json.has("jsonrpc")) {
json.addProperty("jsonrpc", "2.0");
}
if (!json.has("id")) {
json.addProperty("id", UUID.randomUUID().toString());
}
if (json.has("params")) {
JsonObject params = JsonUtils.getAsJsonObject(json, "params");
var params = JsonUtils.getAsJsonObject(json, "params");
if (params.has("payload")) {
JsonObject payload = JsonUtils.getAsJsonObject(params, "payload");
var payload = JsonUtils.getAsJsonObject(params, "payload");
if (!payload.has("jsonrpc")) {
payload.addProperty("jsonrpc", "2.0");
}
Expand All @@ -198,11 +198,11 @@ private void handleJsonRpc(User user, Request baseRequest, HttpServletRequest ht
json.add("params", params);
}
// parse JSON-RPC Request
JsonrpcMessage message = JsonrpcMessage.from(json);
var message = JsonrpcMessage.from(json);
if (!(message instanceof JsonrpcRequest)) {
throw new OpenemsException("Only JSON-RPC Request is supported here.");
}
JsonrpcRequest request = (JsonrpcRequest) message;
var request = (JsonrpcRequest) message;

// handle the request
CompletableFuture<? extends JsonrpcResponseSuccess> responseFuture = this.parent.jsonRpcRequestHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,25 @@ public B2bWebsocket() {
private Config config;

private final Runnable startServerWhenMetadataIsInitialized = () -> {
this.startServer(config.port(), config.poolSize(), config.debugMode());
this.startServer(this.config.port(), this.config.poolSize(), this.config.debugMode());
};

@Activate
void activate(Config config) {
private void activate(Config config) {
this.config = config;
this.metadata.addOnIsInitializedListener(this.startServerWhenMetadataIsInitialized);
}

@Deactivate
void deactivate() {
private void deactivate() {
ThreadPoolUtils.shutdownAndAwaitTermination(this.executor, 5);
this.metadata.removeOnIsInitializedListener(this.startServerWhenMetadataIsInitialized);
this.stopServer();
}

/**
* Create and start new server.
*
*
* @param port the port
* @param poolSize number of threads dedicated to handle the tasks
* @param debugMode activate a regular debug log about the state of the tasks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package io.openems.backend.b2bwebsocket;

import java.util.Optional;

import org.java_websocket.WebSocket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.openems.backend.common.metadata.User;
import io.openems.common.exceptions.OpenemsException;

public class OnClose implements io.openems.common.websocket.OnClose {
Expand All @@ -21,7 +18,7 @@ public OnClose(B2bWebsocket parent) {
@Override
public void run(WebSocket ws, int code, String reason, boolean remote) throws OpenemsException {
WsData wsData = ws.getAttachment();
Optional<User> user = wsData.getUserOpt();
var user = wsData.getUserOpt();
if (user.isPresent()) {
this.parent.logInfo(this.log, "User [" + user.get().getName() + "] closed connection");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ public void run(WebSocket ws, JsonObject handshake) throws OpenemsNamedException
try {
// Read "Authorization" header for Simple HTTP authentication. Source:
// https://stackoverflow.com/questions/16000517/how-to-get-password-from-http-basic-authentication
final String authorization = JsonUtils.getAsString(handshake, "Authorization");
final var authorization = JsonUtils.getAsString(handshake, "Authorization");
if (authorization == null || !authorization.toLowerCase().startsWith("basic")) {
throw OpenemsError.COMMON_AUTHENTICATION_FAILED.exception();
}

String base64Credentials = authorization.substring("Basic".length()).trim();
byte[] credDecoded = Base64.getDecoder().decode(base64Credentials);
String credentials = new String(credDecoded, StandardCharsets.UTF_8);
var credentials = new String(credDecoded, StandardCharsets.UTF_8);
// credentials = username:password
final String[] values = credentials.split(":", 2);
final var values = credentials.split(":", 2);
if (values.length != 2) {
throw OpenemsError.COMMON_AUTHENTICATION_FAILED.exception();
}
String username = values[0];
String password = values[1];
var username = values[0];
var password = values[1];
User user = this.parent.metadata.authenticate(username, password);

WsData wsData = ws.getAttachment();
Expand Down
Loading

0 comments on commit 9fe71be

Please sign in to comment.