diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..00a51af --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# These are explicitly windows files and should use crlf +*.bat text eol=crlf + diff --git a/.github/workflows/docker-CI.yml b/.github/workflows/docker-CI.yml index 4bdb80a..a06ed70 100644 --- a/.github/workflows/docker-CI.yml +++ b/.github/workflows/docker-CI.yml @@ -5,7 +5,26 @@ on: branches: [ master, develop ] jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 17 + uses: actions/setup-java@v1 + with: + java-version: 17 + - name: Set up MySQL + run: | + sudo /etc/init.d/mysql start + mysql -e 'CREATE DATABASE LAS2PEERMON;' -uroot -proot + - name: Create db tables + run: mysql -u root -proot LAS2PEERMON < etc/create_database.sql + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Run tests with Gradle + run: ./gradlew test build: + needs: test runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/.gitignore b/.gitignore index f4b5178..12e78ef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,23 @@ /tmp /node-storage /log -/export +/mobsos-data-processing/export /output /lib /etc/ivy/ivy.jar /service -/bin -/bin/* .DS_Store -.DS_Store* \ No newline at end of file +.DS_Store* +etc/launcher-configuration.ini +/.idea/ +*.iml +# Ignore Gradle project-specific cache directory +.gradle + +# Ignore Gradle build output directory +build + +export +mobsos-data-processing/output +etc/launcher-configuration.ini +app/output/* diff --git a/.project b/.project index 5511807..1240eb4 100644 --- a/.project +++ b/.project @@ -6,7 +6,7 @@ - org.eclipse.jdt.core.javabuilder + org.eclipse.buildship.core.gradleprojectbuilder @@ -18,7 +18,7 @@ org.eclipse.wst.common.project.facet.core.nature - org.eclipse.jdt.core.javanature + org.eclipse.buildship.core.gradleprojectnature diff --git a/.travis.install-mysql-5.7.sh b/.travis.install-mysql-5.7.sh deleted file mode 100644 index a9128e5..0000000 --- a/.travis.install-mysql-5.7.sh +++ /dev/null @@ -1,8 +0,0 @@ -echo mysql-apt-config mysql-apt-config/select-server select mysql-5.7 | sudo debconf-set-selections -wget http://dev.mysql.com/get/mysql-apt-config_0.7.3-1_all.deb -sudo dpkg --install mysql-apt-config_0.7.3-1_all.deb -sudo apt-get update -q -sudo apt-get install --allow-unauthenticated -q -y -o Dpkg::Options::=--force-confnew mysql-server -sudo mysql_upgrade -sudo service mysql restart -sudo apt-get install ant-optional \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100755 index 2ac9227..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: java -jdk: - - openjdk14 -install: - - sudo apt-get install -y ant ant-optional -services: - - mysql -script: - - export JAVA_HOME=~/openjdk14 - - export JDK_HOME=~/openjdk14 - - ant all -sudo: required -before_script: - - bash .travis.install-mysql-5.7.sh - - mysql -u root -e 'CREATE DATABASE LAS2PEERMON;' - - mysql -u root LAS2PEERMON < etc/create_database.sql -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/Dockerfile b/Dockerfile index 1748d62..b723a5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,19 @@ -FROM openjdk:14-jdk-alpine +FROM openjdk:17-jdk-alpine ENV LAS2PEER_PORT=9011 -RUN apk add --update bash mysql-client apache-ant curl && rm -f /var/cache/apk/* +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 + # run the rest as unprivileged user USER las2peer -RUN ant jar +RUN chmod +x gradlew && ./gradlew build --exclude-task test EXPOSE $LAS2PEER_PORT ENTRYPOINT ["/src/docker-entrypoint.sh"] diff --git a/README.md b/README.md index 17d028c..5aa2a89 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MobSOS Data Processing -[![Build Status](https://travis-ci.org/rwth-acis/mobsos-data-processing.svg?branch=master)](https://travis-ci.org/rwth-acis/mobsos-data-processing) [![codecov](https://codecov.io/gh/rwth-acis/mobsos-data-processing/branch/master/graph/badge.svg)](https://codecov.io/gh/rwth-acis/mobsos-data-processing) [![Join the chat at https://gitter.im/rwth-acis/mobsos](https://badges.gitter.im/rwth-acis/mobsos.svg)](https://gitter.im/rwth-acis/mobsos?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Build Status](https://github.com/rwth-acis/mobsos-data-processing/workflows/Java%20CI%20with%20Gradle/badge.svg?branch=master)](https://github.com/rwth-acis/mobsos-data-processing/actions?query=workflow%3A%22Java+CI+with+Gradle%22+branch%3Amaster) [![codecov](https://codecov.io/gh/rwth-acis/mobsos-data-processing/branch/master/graph/badge.svg)](https://codecov.io/gh/rwth-acis/mobsos-data-processing) [![Join the chat at https://gitter.im/rwth-acis/mobsos](https://badges.gitter.im/rwth-acis/mobsos.svg)](https://gitter.im/rwth-acis/mobsos?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) This service is part of the MobSOS monitoring concept and processes incoming monitoring data. @@ -17,7 +17,7 @@ After that, configure the [property](etc/i5.las2peer.services.mobsos.dataProcess Execute the following command on your shell: ```shell -ant all +./gradlew build ``` ### Start diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..8108fab --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,259 @@ +plugins { + // Apply the application plugin to add support for building a CLI application in Java. + id 'application' + id 'eclipse' +} + +repositories { + // Use maven central for resolving dependencies. + mavenCentral() + + // DBIS Archiva + maven { + url "https://archiva.dbis.rwth-aachen.de:9911/repository/internal/" + } + + maven { + url "https://archiva.dbis.rwth-aachen.de:9911/repository/snapshots/" + } +} + +dependencies { + // Use JUnit test framework. + testImplementation "junit:junit:4.13.2" + + // las2peer bundle which is not necessary in the runtime path + implementation "i5:las2peer-bundle:${project.property('core.version')}" + + implementation "com.googlecode.json-simple:json-simple:1.1.1" + implementation("org.apache.commons:commons-dbcp2:2.7.0") { + exclude module: "asm" + exclude module: "asm-commons" + } + implementation "commons-codec:commons-codec:1.13" + implementation "mysql:mysql-connector-java:8.0.13" +} + +configurations { + // This ensures las2peer is available in the tests, but won't be bundled + testImplementation.extendsFrom implementation +} + +jar { + duplicatesStrategy = DuplicatesStrategy.INCLUDE + + manifest { + attributes "Main-Class": "${project.property('service.name')}.${project.property('service.class')}" + attributes "Library-Version": "${project.property('service.version')}" + attributes "Library-SymbolicName": "${project.property('service.name')}" + } + + from { (configurations.runtimeClasspath).collect { it.isDirectory() ? it : zipTree(it) } } { + // Exclude signatures to be able to natively bundle signed jars + exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA' + } +} + +application { + // Define the main class for the application. + mainClass = "${project.property('service.name')}.${project.property('service.class')}" + + group = "${project.property('service.name')}" + archivesBaseName = group + + version = "${project.property('service.version')}" + mainClass.set("i5.las2peer.tools.L2pNodeLauncher") + sourceCompatibility = "${project.property('java.version')}" + targetCompatibility = "${project.property('java.version')}" +} + +// put all .jar files into export/jars folder +tasks.withType(Jar) { + destinationDirectory = file("$projectDir/export/jars") +} + +javadoc { + destinationDir = file("$projectDir/export/doc") +} + +build.dependsOn "javadoc" + +compileJava { + dependsOn "copyMain" +} + +compileTestJava { + dependsOn "copyTest" +} + +// Copies .xml files into build directory +task copyMain(type: Copy) { + from "src/main/java" + include "**/*.xml" + into "$buildDir/classes/java/main" +} + +// Copies .xml files into build directory +task copyTest(type: Copy) { + from "src/test/java" + include "**/*.xml" + into "$buildDir/classes/java/test" +} + +// These two tasks restore the build and runtime environment used +// in the ant environment +task copyJar(type: Copy) { + from jar // here it automatically reads jar file produced from jar task + into "$rootDir/service" +} + +task copyToLib(type: Copy) { + from configurations.compileClasspath + into "$rootDir/lib" +} + +build.dependsOn copyJar +build.dependsOn copyToLib + +task startscripts { + new File("$rootDir/bin", "start_network.sh").text = """#!/bin/bash +# this script is autogenerated by 'gradle startscripts' +# it starts a las2peer node providing the service '${project.property('service.name')}.${project.property('service.class')}' of this project +# pls execute it from the root folder of your deployment, e. g. ./bin/start_network.sh +java -cp "lib/*" --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED i5.las2peer.tools.L2pNodeLauncher --port 9011 --service-directory service uploadStartupDirectory startService\\(\\'${project.property('service.name')}.${project.property('service.class')}@${project.property('service.version')}\\'\\) startWebConnector interactive +""" + new File("$rootDir/bin", "start_network.bat").text = """:: this script is autogenerated by 'gradle startscripts' +:: it starts a las2peer node providing the service '${project.property('service.name')}.${project.property('service.class')}' of this project +:: pls execute it from the bin folder of your deployment by double-clicking on it +%~d0 +cd %~p0 +cd .. +set BASE=%CD% +set CLASSPATH="%BASE%/lib/*;" +set ADD_OPENS=--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED + +java -cp %CLASSPATH% %ADD_OPENS% i5.las2peer.tools.L2pNodeLauncher --port 9011 --service-directory service uploadStartupDirectory startService('${project.property('service.name')}.${project.property('service.class')}@${project.property('service.version')}') startWebConnector interactive +pause +""" +} + +build.dependsOn "startscripts" + +def startup = "$rootDir/etc/startup" +def userAgent1Path = "${startup}/agent-user-${project.property('las2peer_user1.name')}.xml" +def userAgent2Path = "${startup}/agent-user-${project.property('las2peer_user2.name')}.xml" +def userAgent3Path = "${startup}/agent-user-${project.property('las2peer_user3.name')}.xml" +def passphrasesPath = "${startup}/passphrases.txt" + +task generateUserAgent1 { + dependsOn "jar" + + onlyIf { !(new File(userAgent1Path).exists()) } + + doLast { + tasks.create("generateUserAgent1Help", JavaExec) { + println "Writing User Agent xml to ${userAgent1Path}" + + main = "i5.las2peer.tools.UserAgentGenerator" + classpath = sourceSets.main.compileClasspath + args "${project.property('las2peer_user1.password')}", "${project.property('las2peer_user1.name')}", "${project.property('las2peer_user1.email')}" + mkdir "${startup}" + standardOutput new FileOutputStream(userAgent1Path) + }.exec() + } +} + +task generateUserAgent2 { + dependsOn "jar" + + onlyIf { !(new File(userAgent2Path).exists()) } + + doLast { + tasks.create("generateUserAgent2Help", JavaExec) { + println "Writing User Agent xml to ${userAgent2Path}" + + main = "i5.las2peer.tools.UserAgentGenerator" + classpath = sourceSets.main.compileClasspath + args "${project.property('las2peer_user2.password')}", "${project.property('las2peer_user2.name')}", "${project.property('las2peer_user2.email')}" + mkdir "${startup}" + standardOutput new FileOutputStream(userAgent2Path) + }.exec() + } +} + +task generateUserAgent3 { + dependsOn "jar" + + onlyIf { !(new File(userAgent3Path).exists()) } + + doLast { + tasks.create("generateUserAgent3Help", JavaExec) { + println "Writing User Agent xml to ${userAgent3Path}" + + main = "i5.las2peer.tools.UserAgentGenerator" + classpath = sourceSets.main.compileClasspath + args "${project.property('las2peer_user3.password')}", "${project.property('las2peer_user3.name')}", "${project.property('las2peer_user3.email')}" + mkdir "${startup}" + standardOutput new FileOutputStream(userAgent3Path) + }.exec() + } +} + +// generate example user agents +task generateAgents { + description "Generate example user agents" + dependsOn "generateUserAgent1" + dependsOn "generateUserAgent2" + dependsOn "generateUserAgent3" + + doLast { + new File(passphrasesPath).text = """agent-user-${project.property('las2peer_user1.name')}.xml;${project.property('las2peer_user1.password')} +agent-user-${project.property('las2peer_user2.name')}.xml;${project.property('las2peer_user2.password')} +agent-user-${project.property('las2peer_user3.name')}.xml;${project.property('las2peer_user3.password')} + """ + } +} + +build.dependsOn "generateAgents" + +clean.doLast { + file("$rootDir/tmp").deleteDir() + file("$rootDir/lib").deleteDir() + file("$rootDir/servicebundle").deleteDir() + file("$rootDir/service").deleteDir() + file("$rootDir/etc/startup").deleteDir() + file("$projectDir/export").deleteDir() +} + +task cleanAll { + dependsOn "clean" + + doLast { + file("$rootDir/log").deleteDir() + file("$rootDir/node-storage").deleteDir() + } +} + +test { + workingDir = file("$rootDir") +} + +// Only required when using Eclipse: +// configuration for eclipse (this allows to import the project as a gradle project in eclipse without any problems) +eclipse { + classpath { + file { + whenMerged { + // change output directory for test, main, resources and default + def main = entries.find { it.path == "src/main/java" } + main.output = "output/main" + + def test = entries.find { it.path == "src/test/java" } + test.output = "output/test" + + def defaultEntry = entries.find { it.kind == "output" && it.path == "bin/default" } + defaultEntry.path = "output/default" + } + } + } +} \ No newline at end of file diff --git a/src/main/i5/las2peer/services/mobsos/dataProcessing/MobSOSDataProcessingService.java b/app/src/main/java/i5/las2peer/services/mobsos/dataProcessing/MobSOSDataProcessingService.java similarity index 94% rename from src/main/i5/las2peer/services/mobsos/dataProcessing/MobSOSDataProcessingService.java rename to app/src/main/java/i5/las2peer/services/mobsos/dataProcessing/MobSOSDataProcessingService.java index f60e7cb..9933237 100644 --- a/src/main/i5/las2peer/services/mobsos/dataProcessing/MobSOSDataProcessingService.java +++ b/app/src/main/java/i5/las2peer/services/mobsos/dataProcessing/MobSOSDataProcessingService.java @@ -54,6 +54,7 @@ public class MobSOSDataProcessingService extends Service { private Set triggerFunctions = new HashSet(); private ArrayList botMessages = new ArrayList(); private ArrayList xAPIstatements = new ArrayList(); + //private boolean sendStatementsToBots = true; // True if xAPI statements should also be sent to the social bot manager service /** * Configuration parameters, values will be set by the configuration file. @@ -121,7 +122,7 @@ public boolean getMessages(MonitoringMessage[] messages) { * Checks the messages content and calls {@link #persistMessage(MonitoringMessage, String)} with the corresponding * values. * - * @param messages an array of {@link i5.las2peer.logging.monitoring.MonitoringMessage}s + * @param messages an array of {@link i5.las2peer.logging.monitoring.MonitoringMessage} * @return true, if message persistence did work */ private boolean processMessages(MonitoringMessage[] messages) { @@ -155,7 +156,7 @@ private boolean processMessages(MonitoringMessage[] messages) { for (int i = 0; i < jra.size(); i++) { triggerFunctions.add(((String) jra.get(i)).toLowerCase()); } - + returnStatement = persistMessage(message, "MESSAGE"); if (!returnStatement) counter++; @@ -248,6 +249,11 @@ else if (Math.abs(message.getEvent().getCode()) >= 7000 if (message.getRemarks() != null) { String serviceClassName = monitoredServices.get(message.getSourceAgentId()); + System.out.println("\u001B[33mDebug --- Monitored: \u001B[0m"); + for (String svc : monitoredServices.values()) { + System.out.println("\u001B[33m" + svc + "\u001B[0m"); + } + /* if (sendToLRS && serviceClassName != null && (serviceClassName.contains( "i5.las2peer.services.moodleDataProxyService.MoodleDataProxyService@1.3.0") @@ -256,10 +262,14 @@ else if (Math.abs(message.getEvent().getCode()) >= 7000 || serviceClassName.contains( "i5.las2peer.services.AssessmentHandler.AssessmentHandlerService@1.0.0") || serviceClassName.contains("i5.las2peer.services.tmitocar"))) { + */ String statement = message.getRemarks(); - if (statement.contains("actor") && statement.contains("verb") && statement.contains("object")) + if (statement.contains("actor") && statement.contains("verb") && statement.contains("object")) { + xAPIstatements.add(statement); - } + System.out.println("Statement added"); + } + //} JSONParser p = new JSONParser(JSONParser.MODE_PERMISSIVE); try { Object jo = p.parse(message.getRemarks()); @@ -296,8 +306,19 @@ else if (Math.abs(message.getEvent().getCode()) >= 7000 if (!xAPIstatements.isEmpty()) { try { - Context.get().invoke("i5.las2peer.services.learningLockerService.LearningLockerService@1.1.0", + Context.get().invoke("i5.las2peer.services.learningLockerService.LearningLockerService", "sendXAPIstatement", (Serializable) xAPIstatements); + +// if (monitoredServices.values().stream().anyMatch(s -> +// s.contains("i5.las2peer.services.socialBotManagerService.SocialBotManagerService"))) { +// Context.getCurrent().invoke("i5.las2peer.services.socialBotManagerService.SocialBotManagerService", +// "getXapiStatements", (Serializable) xAPIstatements); +// } + if (hasBot()) { + Context.getCurrent().invoke("i5.las2peer.services.socialBotManagerService.SocialBotManagerService", + "getXapiStatements", (Serializable) xAPIstatements); + } + // TODO Handle Exceptions! } catch (ServiceNotFoundException e) { e.printStackTrace(); diff --git a/src/main/i5/las2peer/services/mobsos/dataProcessing/MonitoringMessageWithEncryptedAgents.java b/app/src/main/java/i5/las2peer/services/mobsos/dataProcessing/MonitoringMessageWithEncryptedAgents.java similarity index 96% rename from src/main/i5/las2peer/services/mobsos/dataProcessing/MonitoringMessageWithEncryptedAgents.java rename to app/src/main/java/i5/las2peer/services/mobsos/dataProcessing/MonitoringMessageWithEncryptedAgents.java index 6a95792..05b9ef3 100644 --- a/src/main/i5/las2peer/services/mobsos/dataProcessing/MonitoringMessageWithEncryptedAgents.java +++ b/app/src/main/java/i5/las2peer/services/mobsos/dataProcessing/MonitoringMessageWithEncryptedAgents.java @@ -1,110 +1,110 @@ -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; - -/** - * - * 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 MonitoringMessageWithEncryptedAgents { - - private Long timestamp; - private MonitoringEvent event; - private String sourceNode; - private String sourceAgentId = null; - private String destinationNode; - private String destinationAgentId = null; - private String remarks; - private String jsonRemarks; - - /** - * - * Constructor of a MonitoringMessageWithEncryptedAgents. - * - * @param monitoringMessage a {@link i5.las2peer.logging.monitoring.MonitoringMessage} - * @param hashRemarks Whether you want to hash the remarks or not - * - */ - public MonitoringMessageWithEncryptedAgents(MonitoringMessage monitoringMessage, boolean hashRemarks) { - this.timestamp = monitoringMessage.getTimestamp(); - this.event = monitoringMessage.getEvent(); - this.sourceNode = monitoringMessage.getSourceNode(); - if (monitoringMessage.getSourceAgentId() != null) - this.sourceAgentId = DigestUtils.md5Hex((monitoringMessage.getSourceAgentId().toString())); - this.destinationNode = monitoringMessage.getDestinationNode(); - if (monitoringMessage.getDestinationAgentId() != null) - this.destinationAgentId = DigestUtils.md5Hex((monitoringMessage.getDestinationAgentId().toString())); - // Custom service messages - if (Math.abs(this.getEvent().getCode()) >= 7500 && (Math.abs(this.getEvent().getCode()) < 7600) - && hashRemarks) { - this.remarks = "{\"msg\":\"" + DigestUtils.md5Hex((monitoringMessage.getRemarks())) + "\"}"; - } else { - if (monitoringMessage.getRemarks() == null) { - this.remarks = ""; - this.jsonRemarks = "{}"; - } else { - this.remarks = monitoringMessage.getRemarks(); - if (isJSONValid(monitoringMessage.getRemarks())) { - this.jsonRemarks = monitoringMessage.getRemarks(); - } else { - this.jsonRemarks = "{\"msg\":\"" + JSONObject.escape(monitoringMessage.getRemarks()) + "\"}"; - } - } - } - } - - public Long getTimestamp() { - return timestamp; - } - - public MonitoringEvent getEvent() { - return event; - } - - public String getSourceNode() { - return sourceNode; - } - - public String getSourceAgentId() { - return sourceAgentId; - } - - public String getDestinationNode() { - return destinationNode; - } - - public String getDestinationAgentId() { - return destinationAgentId; - } - - public String getRemarks() { - return remarks; - } - - public String getJsonRemarks() { - return jsonRemarks; - } - - private boolean isJSONValid(String jsonString) { - try { - JSONParser parser = new JSONParser(); - parser.parse(jsonString); - } catch (ParseException ex) { - return false; - } - return true; - } - -} +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; + +/** + * + * 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 MonitoringMessageWithEncryptedAgents { + + private Long timestamp; + private MonitoringEvent event; + private String sourceNode; + private String sourceAgentId = null; + private String destinationNode; + private String destinationAgentId = null; + private String remarks; + private String jsonRemarks; + + /** + * + * Constructor of a MonitoringMessageWithEncryptedAgents. + * + * @param monitoringMessage a {@link i5.las2peer.logging.monitoring.MonitoringMessage} + * @param hashRemarks Whether you want to hash the remarks or not + * + */ + public MonitoringMessageWithEncryptedAgents(MonitoringMessage monitoringMessage, boolean hashRemarks) { + this.timestamp = monitoringMessage.getTimestamp(); + this.event = monitoringMessage.getEvent(); + this.sourceNode = monitoringMessage.getSourceNode(); + if (monitoringMessage.getSourceAgentId() != null) + this.sourceAgentId = DigestUtils.md5Hex((monitoringMessage.getSourceAgentId().toString())); + this.destinationNode = monitoringMessage.getDestinationNode(); + if (monitoringMessage.getDestinationAgentId() != null) + this.destinationAgentId = DigestUtils.md5Hex((monitoringMessage.getDestinationAgentId().toString())); + // Custom service messages + if (Math.abs(this.getEvent().getCode()) >= 7500 && (Math.abs(this.getEvent().getCode()) < 7600) + && hashRemarks) { + this.remarks = "{\"msg\":\"" + DigestUtils.md5Hex((monitoringMessage.getRemarks())) + "\"}"; + } else { + if (monitoringMessage.getRemarks() == null) { + this.remarks = ""; + this.jsonRemarks = "{}"; + } else { + this.remarks = monitoringMessage.getRemarks(); + if (isJSONValid(monitoringMessage.getRemarks())) { + this.jsonRemarks = monitoringMessage.getRemarks(); + } else { + this.jsonRemarks = "{\"msg\":\"" + JSONObject.escape(monitoringMessage.getRemarks()) + "\"}"; + } + } + } + } + + public Long getTimestamp() { + return timestamp; + } + + public MonitoringEvent getEvent() { + return event; + } + + public String getSourceNode() { + return sourceNode; + } + + public String getSourceAgentId() { + return sourceAgentId; + } + + public String getDestinationNode() { + return destinationNode; + } + + public String getDestinationAgentId() { + return destinationAgentId; + } + + public String getRemarks() { + return remarks; + } + + public String getJsonRemarks() { + return jsonRemarks; + } + + private boolean isJSONValid(String jsonString) { + try { + JSONParser parser = new JSONParser(); + parser.parse(jsonString); + } catch (ParseException ex) { + return false; + } + return true; + } + +} diff --git a/src/main/i5/las2peer/services/mobsos/dataProcessing/database/DatabaseInsertStatement.java b/app/src/main/java/i5/las2peer/services/mobsos/dataProcessing/database/DatabaseInsertStatement.java similarity index 100% rename from src/main/i5/las2peer/services/mobsos/dataProcessing/database/DatabaseInsertStatement.java rename to app/src/main/java/i5/las2peer/services/mobsos/dataProcessing/database/DatabaseInsertStatement.java diff --git a/src/main/i5/las2peer/services/mobsos/dataProcessing/database/DatabaseQuery.java b/app/src/main/java/i5/las2peer/services/mobsos/dataProcessing/database/DatabaseQuery.java similarity index 100% rename from src/main/i5/las2peer/services/mobsos/dataProcessing/database/DatabaseQuery.java rename to app/src/main/java/i5/las2peer/services/mobsos/dataProcessing/database/DatabaseQuery.java diff --git a/src/main/i5/las2peer/services/mobsos/dataProcessing/database/SQLDatabase.java b/app/src/main/java/i5/las2peer/services/mobsos/dataProcessing/database/SQLDatabase.java similarity index 96% rename from src/main/i5/las2peer/services/mobsos/dataProcessing/database/SQLDatabase.java rename to app/src/main/java/i5/las2peer/services/mobsos/dataProcessing/database/SQLDatabase.java index fcc2b7e..f41c006 100644 --- a/src/main/i5/las2peer/services/mobsos/dataProcessing/database/SQLDatabase.java +++ b/app/src/main/java/i5/las2peer/services/mobsos/dataProcessing/database/SQLDatabase.java @@ -1,126 +1,126 @@ -package i5.las2peer.services.mobsos.dataProcessing.database; - -import java.sql.SQLException; -import java.sql.Statement; - -import org.apache.commons.dbcp2.BasicDataSource; - -/** - * - * Stores the database credentials and provides access to query execution. The - * original code was taken from the QueryVisualizationService. - * - * @author Peter de Lange - * - */ -public class SQLDatabase { - - private BasicDataSource dataSource; - - private SQLDatabaseType jdbcInfo = null; - private String username = null; - private String password = null; - private String database = null; - private String host = null; - private int port = -1; - - /** - * - * Constructor for a database instance. - * - * @param jdbcInfo the driver you are using - * @param username login name - * @param password password - * @param database database name - * @param host host for the connection - * @param port port of the SQL server - * - */ - public SQLDatabase(SQLDatabaseType jdbcInfo, String username, String password, String database, String host, - int port) { - - this.jdbcInfo = jdbcInfo; - this.username = username; - this.password = password; - this.host = host; - this.port = port; - this.database = database; - - BasicDataSource ds = new BasicDataSource(); - String urlPrefix = jdbcInfo.getURLPrefix(this.host, this.database, this.port) - + "?autoReconnect=true&useSSL=false&serverTimezone=UTC"; - ds.setUrl(urlPrefix); - ds.setUsername(username); - ds.setPassword(password); - ds.setDriverClassName(jdbcInfo.getDriverName()); - ds.setPoolPreparedStatements(true); - ds.setTestOnBorrow(true); - ds.setRemoveAbandonedOnBorrow(true); - ds.setRemoveAbandonedOnMaintenance(true); - ds.setMaxOpenPreparedStatements(100); - ds.setMaxConnLifetimeMillis(1000 * 60 * 60); - - dataSource = ds; - setValidationQuery(); - } - - /** - * - * Executes a SQL statement to insert an entry into the database. - * - * @param SQLStatment a SQLStatement - * - * @return true, if correctly inserted - * - * @throws SQLException problems inserting - * - */ - @Deprecated - public boolean store(String SQLStatment) throws SQLException { - // make sure one is connected to a database - if (!dataSource.getConnection().isValid(5000)) { - System.err.println("No database connection."); - return false; - } - Statement statement = dataSource.getConnection().createStatement(); - statement.executeUpdate(SQLStatment); - return true; - - } - - public String getUser() { - return this.username; - } - - public String getPassword() { - return this.password; - } - - public String getDatabase() { - return this.database; - } - - public String getHost() { - return this.host; - } - - public int getPort() { - return this.port; - } - - public SQLDatabaseType getJdbcInfo() { - return jdbcInfo; - } - - public BasicDataSource getDataSource() { - return dataSource; - } - - private void setValidationQuery() { - switch (jdbcInfo.getCode()) { - case 1: - dataSource.setValidationQuery("SELECT 1;"); - } - } - -} +package i5.las2peer.services.mobsos.dataProcessing.database; + +import java.sql.SQLException; +import java.sql.Statement; + +import org.apache.commons.dbcp2.BasicDataSource; + +/** + * + * Stores the database credentials and provides access to query execution. The + * original code was taken from the QueryVisualizationService. + * + * @author Peter de Lange + * + */ +public class SQLDatabase { + + private BasicDataSource dataSource; + + private SQLDatabaseType jdbcInfo = null; + private String username = null; + private String password = null; + private String database = null; + private String host = null; + private int port = -1; + + /** + * + * Constructor for a database instance. + * + * @param jdbcInfo the driver you are using + * @param username login name + * @param password password + * @param database database name + * @param host host for the connection + * @param port port of the SQL server + * + */ + public SQLDatabase(SQLDatabaseType jdbcInfo, String username, String password, String database, String host, + int port) { + + this.jdbcInfo = jdbcInfo; + this.username = username; + this.password = password; + this.host = host; + this.port = port; + this.database = database; + + BasicDataSource ds = new BasicDataSource(); + String urlPrefix = jdbcInfo.getURLPrefix(this.host, this.database, this.port) + + "?autoReconnect=true&useSSL=false&serverTimezone=UTC"; + ds.setUrl(urlPrefix); + ds.setUsername(username); + ds.setPassword(password); + ds.setDriverClassName(jdbcInfo.getDriverName()); + ds.setPoolPreparedStatements(true); + ds.setTestOnBorrow(true); + ds.setRemoveAbandonedOnBorrow(true); + ds.setRemoveAbandonedOnMaintenance(true); + ds.setMaxOpenPreparedStatements(100); + ds.setMaxConnLifetimeMillis(1000 * 60 * 60); + + dataSource = ds; + setValidationQuery(); + } + + /** + * + * Executes a SQL statement to insert an entry into the database. + * + * @param SQLStatment a SQLStatement + * + * @return true, if correctly inserted + * + * @throws SQLException problems inserting + * + */ + @Deprecated + public boolean store(String SQLStatment) throws SQLException { + // make sure one is connected to a database + if (!dataSource.getConnection().isValid(5000)) { + System.err.println("No database connection."); + return false; + } + Statement statement = dataSource.getConnection().createStatement(); + statement.executeUpdate(SQLStatment); + return true; + + } + + public String getUser() { + return this.username; + } + + public String getPassword() { + return this.password; + } + + public String getDatabase() { + return this.database; + } + + public String getHost() { + return this.host; + } + + public int getPort() { + return this.port; + } + + public SQLDatabaseType getJdbcInfo() { + return jdbcInfo; + } + + public BasicDataSource getDataSource() { + return dataSource; + } + + private void setValidationQuery() { + switch (jdbcInfo.getCode()) { + case 1: + dataSource.setValidationQuery("SELECT 1;"); + } + } + +} diff --git a/src/main/i5/las2peer/services/mobsos/dataProcessing/database/SQLDatabaseType.java b/app/src/main/java/i5/las2peer/services/mobsos/dataProcessing/database/SQLDatabaseType.java similarity index 95% rename from src/main/i5/las2peer/services/mobsos/dataProcessing/database/SQLDatabaseType.java rename to app/src/main/java/i5/las2peer/services/mobsos/dataProcessing/database/SQLDatabaseType.java index 61cd502..ff90e47 100644 --- a/src/main/i5/las2peer/services/mobsos/dataProcessing/database/SQLDatabaseType.java +++ b/app/src/main/java/i5/las2peer/services/mobsos/dataProcessing/database/SQLDatabaseType.java @@ -1,83 +1,83 @@ -package i5.las2peer.services.mobsos.dataProcessing.database; - -/** - * - * Enumeration class that provides the right drivers according to the database - * type. The original code was taken from the QueryVisualizationService. - * - * This implementation currently only supports MySQL. - * - */ -public enum SQLDatabaseType { - - /** - * A MySQL database. Works with the "mysqlConnectorJava-8.0.13.jar" archive. - */ - MySQL(1, "com.mysql.cj.jdbc.Driver", "mysql"); - - private final int code; - private final String driver; - private final String jdbc; - - SQLDatabaseType(int code, String driverName, String jdbc) { - this.driver = driverName; - this.jdbc = jdbc; - this.code = code; - } - - /** - * - * Returns the code of the database. - * - * @return a code - * - */ - public int getCode() { - return this.code; - } - - /** - * - * Returns the database type. - * - * @param code the number corresponding to a database type - * - * @return the corresponding {@link SQLDatabaseType} representation - * - */ - public static SQLDatabaseType getSQLDatabaseType(int code) { - switch (code) { - case 1: - return SQLDatabaseType.MySQL; - } - return null; - } - - /** - * - * Returns the driver name of the corresponding database. The library of this - * driver has to be in the "lib" folder. - * - * @return a driver name - * - */ - public String getDriverName() { - return driver; - } - - /** - * - * Constructs a URL prefix that can be used for addressing a database. - * - * @param host a database host address - * @param database the database name - * @param port the port the database is running at - * - * @return a String representing the URL prefix - * - */ - public String getURLPrefix(String host, String database, int port) { - return "jdbc:" + jdbc + "://" + host + ":" + port + "/" + database; - } - -} +package i5.las2peer.services.mobsos.dataProcessing.database; + +/** + * + * Enumeration class that provides the right drivers according to the database + * type. The original code was taken from the QueryVisualizationService. + * + * This implementation currently only supports MySQL. + * + */ +public enum SQLDatabaseType { + + /** + * A MySQL database. Works with the "mysqlConnectorJava-8.0.13.jar" archive. + */ + MySQL(1, "com.mysql.cj.jdbc.Driver", "mysql"); + + private final int code; + private final String driver; + private final String jdbc; + + SQLDatabaseType(int code, String driverName, String jdbc) { + this.driver = driverName; + this.jdbc = jdbc; + this.code = code; + } + + /** + * + * Returns the code of the database. + * + * @return a code + * + */ + public int getCode() { + return this.code; + } + + /** + * + * Returns the database type. + * + * @param code the number corresponding to a database type + * + * @return the corresponding {@link SQLDatabaseType} representation + * + */ + public static SQLDatabaseType getSQLDatabaseType(int code) { + switch (code) { + case 1: + return SQLDatabaseType.MySQL; + } + return null; + } + + /** + * + * Returns the driver name of the corresponding database. The library of this + * driver has to be in the "lib" folder. + * + * @return a driver name + * + */ + public String getDriverName() { + return driver; + } + + /** + * + * Constructs a URL prefix that can be used for addressing a database. + * + * @param host a database host address + * @param database the database name + * @param port the port the database is running at + * + * @return a String representing the URL prefix + * + */ + public String getURLPrefix(String host, String database, int port) { + return "jdbc:" + jdbc + "://" + host + ":" + port + "/" + database; + } + +} diff --git a/src/test/i5/las2peer/services/mobsos/dataProcessing/MobSOSDataProcessingServiceTest.java b/app/src/test/java/i5/las2peer/services/mobsos/dataProcessing/MobSOSDataProcessingServiceTest.java similarity index 100% rename from src/test/i5/las2peer/services/mobsos/dataProcessing/MobSOSDataProcessingServiceTest.java rename to app/src/test/java/i5/las2peer/services/mobsos/dataProcessing/MobSOSDataProcessingServiceTest.java diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..d855e7c --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1,2 @@ +start_network.bat +start_network.sh \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..da92a1d --- /dev/null +++ b/build.gradle @@ -0,0 +1,6 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * This is a general purpose Gradle build. + * Learn more about Gradle by exploring our samples at https://docs.gradle.org/7.2/samples + */ diff --git a/build.xml b/build.xml deleted file mode 100644 index 6df2523..0000000 --- a/build.xml +++ /dev/null @@ -1,248 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #!/bin/bash - - # this script is autogenerated by 'ant startscripts' - # it starts a las2peer node providing the service '${service.name}.${service.class}' of this project - # pls execute it from the root folder of your deployment, e. g. ./bin/start_network.sh - - java -cp "lib/*" i5.las2peer.tools.L2pNodeLauncher -p 9011 -s ./service/ uploadStartupDirectory startService\(\'${service.name}.${service.class}@${service.version}\',\'${service.passphrase}\'\) interactive - - - :: this script is autogenerated by 'ant startscripts' - :: it starts a las2peer node providing the service '${service.name}.${service.class}' of this project - :: pls execute it from the bin folder of your deployment by double-clicking on it - - %~d0 - cd %~p0 - cd .. - set BASE=%CD% - set CLASSPATH="%BASE%/lib/*;" - - java -cp %CLASSPATH% i5.las2peer.tools.L2pNodeLauncher -p 9011 -s ./service/ uploadStartupDirectory startService('${service.name}.${service.class}@${service.version}','${service.passphrase}') interactive - - pause - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 8c6aa13..7a014c2 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -10,9 +10,9 @@ NODE_ID_SEED=${NODE_ID_SEED:-$RANDOM} # set some helpful variables export SERVICE_PROPERTY_FILE='etc/i5.las2peer.services.mobsos.dataProcessing.MobSOSDataProcessingService.properties' -export SERVICE_VERSION=$(awk -F "=" '/service.version/ {print $2}' etc/ant_configuration/service.properties) -export SERVICE_NAME=$(awk -F "=" '/service.name/ {print $2}' etc/ant_configuration/service.properties) -export SERVICE_CLASS=$(awk -F "=" '/service.class/ {print $2}' etc/ant_configuration/service.properties) +export SERVICE_VERSION=$(awk -F "=" '/service.version/ {print $2}' gradle.properties) +export SERVICE_NAME=$(awk -F "=" '/service.name/ {print $2}' gradle.properties) +export SERVICE_CLASS=$(awk -F "=" '/service.class/ {print $2}' gradle.properties) export SERVICE=${SERVICE_NAME}.${SERVICE_CLASS}@${SERVICE_VERSION} export CREATE_DB_SQL='etc/create_database.sql' export DATABASE_TYPE='1' @@ -74,7 +74,7 @@ fi # prevent glob expansion in lib/* set -f -LAUNCH_COMMAND='java -cp lib/* i5.las2peer.tools.L2pNodeLauncher -s service -p '"${LAS2PEER_PORT} ${SERVICE_EXTRA_ARGS}" +LAUNCH_COMMAND='java -cp lib/* --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED i5.las2peer.tools.L2pNodeLauncher -s service -p '"${LAS2PEER_PORT} ${SERVICE_EXTRA_ARGS}" if [[ ! -z "${BOOTSTRAP}" ]]; then LAUNCH_COMMAND="${LAUNCH_COMMAND} -b ${BOOTSTRAP}" fi diff --git a/etc/ant_configuration/service.properties b/etc/ant_configuration/service.properties deleted file mode 100755 index 328afbd..0000000 --- a/etc/ant_configuration/service.properties +++ /dev/null @@ -1,5 +0,0 @@ -service.version=1.1.0 -service.name=i5.las2peer.services.mobsos.dataProcessing -service.path=i5/las2peer/services/mobsos/dataProcessing -service.class=MobSOSDataProcessingService -service.passphrase=processing diff --git a/etc/i5.las2peer.services.mobsos.dataProcessing.MobSOSDataProcessingService.properties b/etc/i5.las2peer.services.mobsos.dataProcessing.MobSOSDataProcessingService.properties index 1b2e31d..4551e3f 100755 --- a/etc/i5.las2peer.services.mobsos.dataProcessing.MobSOSDataProcessingService.properties +++ b/etc/i5.las2peer.services.mobsos.dataProcessing.MobSOSDataProcessingService.properties @@ -1,6 +1,6 @@ databaseTypeInt = 1 databaseUser = root -databasePassword = +databasePassword = root databaseName = LAS2PEERMON databaseHost = 127.0.0.1 databasePort = 3306 diff --git a/etc/ivy/ivy.xml b/etc/ivy/ivy.xml deleted file mode 100644 index 3614dcb..0000000 --- a/etc/ivy/ivy.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/etc/ivy/ivysettings.xml b/etc/ivy/ivysettings.xml deleted file mode 100644 index acda8d4..0000000 --- a/etc/ivy/ivysettings.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/etc/ant_configuration/user.properties b/gradle.properties old mode 100755 new mode 100644 similarity index 64% rename from etc/ant_configuration/user.properties rename to gradle.properties index 0608770..27365e6 --- a/etc/ant_configuration/user.properties +++ b/gradle.properties @@ -1,3 +1,9 @@ +core.version=1.2.2 +service.name=i5.las2peer.services.mobsos.dataProcessing +service.class=MobSOSDataProcessingService +service.version=1.2.0 +java.version=17 + las2peer_user1.name=alice las2peer_user1.password=pwalice las2peer_user1.email=alice@example.org diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..7454180 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..e750102 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..1b6c787 --- /dev/null +++ b/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..253b706 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,11 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * The settings file is used to specify which projects to include in your build. + * + * Detailed information about configuring a multi-project build in Gradle can be found + * in the user manual at https://docs.gradle.org/7.2/userguide/multi_project_builds.html + */ + +rootProject.name = 'mobsos-data-processing' +include('app') \ No newline at end of file