Skip to content

Commit

Permalink
Merge pull request #37 from rwth-acis/releases/1.2.4
Browse files Browse the repository at this point in the history
Releases/1.2.4
  • Loading branch information
lakhoune authored Sep 20, 2023
2 parents 614cb8e + 86053e4 commit 78be5ae
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 37 deletions.
4 changes: 3 additions & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<classpathentry kind="lib" path="lib/hamcrest-core-1.3.jar"/>
<classpathentry kind="lib" path="lib/junit-4.12.jar"/>
<classpathentry kind="lib" path="lib/mysql-connector-java-8.0.13.jar"/>
<classpathentry kind="lib" path="lib/las2peer-bundle-1.0.0.jar"/>
<classpathentry kind="lib" path="lib/las2peer-bundle-1.3.1.jar"/>


<classpathentry kind="lib" path="lib/json-simple-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/commons-codec-1.13.jar"/>
<classpathentry kind="lib" path="lib/commons-dbcp2-2.7.0.jar"/>
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/docker-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ jobs:
run: mysql -u root -proot LAS2PEERMON < etc/create_database.sql
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Copy properties file
run: cp etc/i5.las2peer.services.mobsos.dataProcessing.MobSOSDataProcessingService.properties.sample etc/i5.las2peer.services.mobsos.dataProcessing.MobSOSDataProcessingService.properties
- name: Run tests with Gradle
run: ./gradlew test
run: ./gradlew test --info --stacktrace
build:
needs: test
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ export
mobsos-data-processing/output
etc/launcher-configuration.ini
app/output/*
etc/i5.las2peer.services.mobsos.dataProcessing.MobSOSDataProcessingService.properties
.vscode/settings.json
4 changes: 2 additions & 2 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
</natures>
<filteredResources>
<filter>
<id>1605890426175</id>
<id>1688911432767</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
Expand Down
38 changes: 30 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
FROM openjdk:17-jdk-alpine
# first stage: build using gradle
FROM --platform=${BUILDPLATFORM:-amd64} gradle:7.5.0-jdk17 AS build

ENV GRADLE_OPTS="-Xmx2048m -Xms512m -Dorg.gradle.daemon=true -Dorg.gradle.parallel=true"

COPY --chown=gradle:gradle . /src
WORKDIR /src
RUN chmod -R a+rwx /src
RUN chmod +x /src/docker-entrypoint.sh

RUN gradle clean
RUN gradle build --exclude-task test

FROM --platform=amd64 openjdk:17-jdk-alpine

ENV LAS2PEER_PORT=9011

RUN apk add --update bash mysql-client curl && rm -f /var/cache/apk/*

RUN addgroup -g 1000 -S las2peer && \
adduser -u 1000 -S las2peer -G las2peer

COPY --chown=las2peer:las2peer . /src
WORKDIR /src

RUN dos2unix docker-entrypoint.sh

COPY --chown=las2peer:las2peer . /app
WORKDIR /app
RUN chmod -R a+rwx /app
RUN chmod +x /app/docker-entrypoint.sh
# run the rest as unprivileged user
USER las2peer
RUN chmod +x gradlew && ./gradlew build --exclude-task test

COPY --from=build --chown=las2peer:las2peer /src/app/export /app/app/export/
COPY --from=build --chown=las2peer:las2peer /src/service /app/service/
COPY --from=build --chown=las2peer:las2peer /src/lib /app/lib/

RUN dos2unix /app/gradle.properties
RUN dos2unix /app/docker-entrypoint.sh

RUN dos2unix /app/etc/i5.las2peer.services.mobsos.dataProcessing.MobSOSDataProcessingService.properties.sample
RUN mv /app/etc/i5.las2peer.services.mobsos.dataProcessing.MobSOSDataProcessingService.properties.sample /app/etc/i5.las2peer.services.mobsos.dataProcessing.MobSOSDataProcessingService.properties

EXPOSE $LAS2PEER_PORT
ENTRYPOINT ["/src/docker-entrypoint.sh"]
ENTRYPOINT ["/app/docker-entrypoint.sh"]
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ tasks.withType(Jar) {
}

javadoc {
dependsOn(':app:copyToLib')
destinationDir = file("$projectDir/export/doc")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package i5.las2peer.services.mobsos.dataProcessing;

import org.apache.commons.codec.digest.DigestUtils;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

import i5.las2peer.api.logging.MonitoringEvent;
import i5.las2peer.logging.monitoring.MonitoringMessage;
import i5.las2peer.logging.monitoring.XESEventMessage;

/**
*
* Data class that takes a
* {@link i5.las2peer.logging.monitoring.MonitoringMessage} and encrypts the
* source and
* destination agents as an MD5 hash-string for privacy reasons. Service
* Messages will have an encrypted remarks field
* as well to prevent service developers from gathering user specific
* information via their custom service messages.
* This is how data will be persisted in the database later on.
*
* @author Peter de Lange
*
*/
public class XESEventMessageWithEncryptedAgents extends MonitoringMessageWithEncryptedAgents {

private String caseId;
private String activityName;
private String resourceId;
private String resourceType;
private String lifecyclePhase;
private Long timeOfEvent;

/**
*
* Constructor of a MonitoringMessageWithEncryptedAgents.
*
* @param eventMessage a
* {@link i5.las2peer.logging.monitoring.MonitoringMessage}
* @param hashRemarks Whether you want to hash the remarks or not
*
*/
public XESEventMessageWithEncryptedAgents(XESEventMessage eventMessage, boolean hashRemarks) {
super(eventMessage, hashRemarks);
this.caseId = eventMessage.getCaseId();
this.activityName = eventMessage.getActivityName();
this.resourceId = eventMessage.getResourceId();
this.resourceType = eventMessage.getResourceType();
this.lifecyclePhase = eventMessage.getLifecyclePhase();
this.timeOfEvent = eventMessage.getTimeOfEvent();
}

public String getCaseId() {
return caseId;
}

public String getActivityName() {
return activityName;
}

public String getResourceId() {
return resourceId;
}

public String getResourceType() {
return resourceType;
}

public String getLifecyclePhase() {
return lifecyclePhase;
}

public Long getTimeOfEvent() {
return timeOfEvent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import i5.las2peer.api.logging.MonitoringEvent;
import i5.las2peer.logging.monitoring.MonitoringMessage;
import i5.las2peer.logging.monitoring.XESEventMessage;
import i5.las2peer.services.mobsos.dataProcessing.XESEventMessageWithEncryptedAgents;
import i5.las2peer.services.mobsos.dataProcessing.MonitoringMessageWithEncryptedAgents;

/**
Expand Down Expand Up @@ -45,8 +47,15 @@ public class DatabaseInsertStatement {
*/
public static PreparedStatement returnInsertStatement(Connection con, MonitoringMessage monitoringMessage,
SQLDatabaseType databaseType, String table, boolean hashRemarks) throws Exception {
MonitoringMessageWithEncryptedAgents message = new MonitoringMessageWithEncryptedAgents(monitoringMessage,
hashRemarks);
MonitoringMessageWithEncryptedAgents message = null;
if (monitoringMessage instanceof XESEventMessage) {
message = new XESEventMessageWithEncryptedAgents((XESEventMessage) monitoringMessage,
hashRemarks);
} else {
message = new MonitoringMessageWithEncryptedAgents(monitoringMessage,
hashRemarks);
}

if (databaseType == SQLDatabaseType.MySQL) {
if (table.equals("MESSAGE")) {
return returnMySQLMessageStatement(con, message);
Expand Down Expand Up @@ -94,8 +103,14 @@ private static PreparedStatement returnMySQLMessageStatement(Connection con,
MonitoringMessageWithEncryptedAgents message) {
PreparedStatement statement = null;
try {
statement = con.prepareStatement("INSERT INTO MESSAGE (`EVENT`, `TIME_STAMP`, `SOURCE_NODE`, `SOURCE_AGENT`, "
if (message instanceof XESEventMessageWithEncryptedAgents) {
statement = con.prepareStatement("INSERT INTO MESSAGE (`EVENT`, `TIME_STAMP`, `SOURCE_NODE`, `SOURCE_AGENT`, "
+ "`DESTINATION_NODE`, `DESTINATION_AGENT`, `REMARKS` , `CASE_ID`, `ACTIVITY_NAME`, `RESOURCE`, `RESOURCE_TYPE`,`LIFECYCLE_PHASE`, `TIME_OF_EVENT`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?);");
} else {
statement = con.prepareStatement("INSERT INTO MESSAGE (`EVENT`, `TIME_STAMP`, `SOURCE_NODE`, `SOURCE_AGENT`, "
+ "`DESTINATION_NODE`, `DESTINATION_AGENT`, `REMARKS`) VALUES (?,?,?,?,?,?,?);");
}

statement.setString(1, message.getEvent().toString()); // EVENT
statement.setString(2, new Timestamp(message.getTimestamp()).toString()); // TIME_STAMP
if (message.getSourceNode() != null) {
Expand Down Expand Up @@ -123,6 +138,15 @@ private static PreparedStatement returnMySQLMessageStatement(Connection con,
} else {
statement.setString(7, "");
}
if (message instanceof XESEventMessageWithEncryptedAgents) {
statement.setString(8, ((XESEventMessageWithEncryptedAgents) message).getCaseId()); // CASE_ID
statement.setString(9, ((XESEventMessageWithEncryptedAgents) message).getActivityName()); // ACTIVITY_NAME
statement.setString(10, ((XESEventMessageWithEncryptedAgents) message).getResourceId()); // RESOURCE
statement.setString(11, ((XESEventMessageWithEncryptedAgents) message).getResourceType()); // RESOURCE_TYPE
statement.setString(12, ((XESEventMessageWithEncryptedAgents) message).getLifecyclePhase()); // LIFECYCLE_PHASE
statement.setTimestamp(13,
new Timestamp(((XESEventMessageWithEncryptedAgents) message).getTimeOfEvent())); // TIME_OF_EVENT
}
} catch (Exception e) {
// TODO LOG
System.out.println(e.getMessage());
Expand Down
36 changes: 16 additions & 20 deletions etc/create_database.sql
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
CREATE DATABASE IF NOT EXISTS `LAS2PEERMON`;
USE LAS2PEERMON;


CREATE TABLE IF NOT EXISTS MESSAGE
(
ID INT NOT NULL
auto_increment,
EVENT VARCHAR
(255) NOT NULL,
TIME_STAMP TIMESTAMP NOT NULL,
SOURCE_NODE VARCHAR
(255),
SOURCE_AGENT CHAR
(32),
DESTINATION_NODE VARCHAR
(255),
DESTINATION_AGENT CHAR
(32),
REMARKS json DEFAULT NULL,
CONSTRAINT MESSAGE_PK PRIMARY KEY
(ID)
CREATE TABLE `MESSAGE` (
`ID` int NOT NULL AUTO_INCREMENT,
`EVENT` varchar(255) NOT NULL,
`TIME_STAMP` timestamp NOT NULL,
`SOURCE_NODE` varchar(255) DEFAULT NULL,
`SOURCE_AGENT` char(32) DEFAULT NULL,
`DESTINATION_NODE` varchar(255) DEFAULT NULL,
`DESTINATION_AGENT` char(32) DEFAULT NULL,
`REMARKS` json DEFAULT NULL,
`CASE_ID` varchar(63) DEFAULT NULL,
`ACTIVITY_NAME` varchar(255) DEFAULT NULL,
`RESOURCE` varchar(255) DEFAULT NULL,
`RESOURCE_TYPE` varchar(255) DEFAULT NULL,
`LIFECYCLE_PHASE` varchar(32) DEFAULT NULL,
`TIME_OF_EVENT` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`ID`)
);


CREATE TABLE IF NOT EXISTS AGENT
(
AGENT_ID CHAR(32) NOT NULL,
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
core.version=1.2.3
core.version=1.3.1
service.name=i5.las2peer.services.mobsos.dataProcessing
service.class=MobSOSDataProcessingService
service.version=1.2.3
service.version=1.2.4
java.version=17

las2peer_user1.name=alice
Expand Down

0 comments on commit 78be5ae

Please sign in to comment.