Skip to content

Commit

Permalink
New build with scripting (#191)
Browse files Browse the repository at this point in the history
* Working outgoing incoming

* Working outgoing incoming

* Fix for scripting in build
  • Loading branch information
farion authored Jul 3, 2024
1 parent 1684517 commit c0924f0
Show file tree
Hide file tree
Showing 67 changed files with 59 additions and 45 deletions.
7 changes: 1 addition & 6 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</developers>

<properties>
<graalvm.version>23.1.1</graalvm.version>
<graalvm.version>23.1.2</graalvm.version>
</properties>

<repositories>
Expand Down Expand Up @@ -148,11 +148,6 @@
<version>${graalvm.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-api</artifactId>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>io.github.classgraph</groupId>
<artifactId>classgraph</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package org.correomqtt.core.fileprovider;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.io.FileUtils;
import org.correomqtt.core.model.HooksDTO;
import org.correomqtt.core.utils.DirectoryUtils;
import org.correomqtt.di.Inject;
import org.correomqtt.di.SingletonBean;
import org.correomqtt.di.SoyEvents;
import org.correomqtt.core.model.HooksDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.correomqtt.di.Inject;
import org.correomqtt.di.SingletonBean;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
Expand All @@ -26,9 +27,10 @@ public class PluginConfigProvider extends BaseUserFileProvider {
private static final String EX_MSG_PREPARE_PLUGIN_FOLDER = "Could not create plugin folder.";
private static final String PLUGIN_FOLDER = "plugins";

private HooksDTO hooksDTO;
private String pluginPath;
private JsonNode hooksNode;

//private Map<, >
private String pluginPath;
@Inject
public PluginConfigProvider(SoyEvents soyEvents) {
super(soyEvents);
Expand All @@ -43,7 +45,12 @@ public PluginConfigProvider(SoyEvents soyEvents) {
preparePluginPath();

try {
hooksDTO = new ObjectMapper().readValue(getFile(), HooksDTO.class);
hooksNode = new ObjectMapper().readTree(getFile());
hooksNode.fields().forEachRemaining(entry -> {
String pluginName = entry.getKey();


});
} catch (IOException e) {
LOGGER.error("Exception parsing hooks file {}", HOOK_FILE_NAME, e);
soyEvents.fire(new InvalidHooksFileEvent(e));
Expand All @@ -52,19 +59,25 @@ public PluginConfigProvider(SoyEvents soyEvents) {
}

public List<HooksDTO.Extension> getOutgoingMessageHooks() {
return hooksDTO.getOutgoingMessages();
return null; //TODO


// return hooksNode.getOutgoingMessages();
}

public List<HooksDTO.Extension> getIncomingMessageHooks() {
return hooksDTO.getIncomingMessages();
// return hooksNode.getIncomingMessages();
return null; //TODO
}

public List<HooksDTO.DetailViewTask> getDetailViewTasks() {
return hooksDTO.getDetailViewTasks();
// return hooksNode.getDetailViewTasks();
return null; //TODO
}

public List<HooksDTO.MessageValidator> getMessageValidators() {
return hooksDTO.getMessageValidators();
// return hooksNode.getMessageValidators();
return null; //TODO
}

private void preparePluginPath() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.correomqtt.core.scripting.binding.ClientFactory;
import org.correomqtt.core.scripting.binding.Queue;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.HostAccess;
import org.graalvm.polyglot.Value;
import org.slf4j.Logger;
import org.slf4j.Marker;
Expand Down Expand Up @@ -70,6 +71,8 @@ Context build() {

private void createContext() {
context = Context.newBuilder("js")
.allowHostAccess(HostAccess.ALL)
.allowHostClassLookup(className -> true)
.allowExperimentalOptions(true) // required for top level await
.out(out)
.err(out)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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>

<artifactId>advanced-validator-plugin</artifactId>
<artifactId>advanced-validator</artifactId>
<name>CorreoMQTT Plugin: Advanced Validator</name>

<parent>
Expand All @@ -14,7 +14,7 @@
</parent>

<properties>
<plugin.id>advanced-validator-plugin</plugin.id>
<plugin.id>${artifactId}</plugin.id>
<plugin.class/>
<plugin.name>Advanced Validator Plugin</plugin.name>
<plugin.provider>Exxeta AG</plugin.provider>
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions plugins/base64-plugin/pom.xml → plugins/base64/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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>

<artifactId>base64-plugin</artifactId>
<artifactId>base64</artifactId>
<name>CorreoMQTT Plugin: Base64</name>

<parent>
Expand All @@ -14,7 +14,7 @@
</parent>

<properties>
<plugin.id>base64-plugin</plugin.id>
<plugin.id>${artifactId}</plugin.id>
<plugin.name>Base64</plugin.name>
<plugin.provider>Exxeta AG</plugin.provider>
<plugin.class />
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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>

<artifactId>contains-string-validator-plugin</artifactId>
<artifactId>contains-string-validator</artifactId>
<name>CorreoMQTT Plugin: Contains String Validator</name>

<parent>
Expand All @@ -15,7 +15,7 @@


<properties>
<plugin.id>contains-string-validator-plugin</plugin.id>
<plugin.id>${artifactId}</plugin.id>
<plugin.name>Contains String Validator Plugin</plugin.name>
<plugin.provider>Exxeta AG</plugin.provider>
<plugin.class />
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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>

<artifactId>json-format-plugin</artifactId>
<artifactId>json-format</artifactId>
<name>CorreoMQTT Plugin: JSON Format</name>

<parent>
Expand All @@ -14,7 +14,7 @@
</parent>

<properties>
<plugin.id>json-format-plugin</plugin.id>
<plugin.id>${artifactId}</plugin.id>
<plugin.name>JSON Format Plugin</plugin.name>
<plugin.provider>Exxeta AG</plugin.provider>
<plugin.class>org.correomqtt.plugin.json_format.JsonFormatPlugin</plugin.class>
Expand Down
18 changes: 9 additions & 9 deletions plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
</properties>

<modules>
<module>advanced-validator-plugin</module>
<module>base64-plugin</module>
<module>contains-string-validator-plugin</module>
<module>json-format-plugin</module>
<module>save-manipulator-plugin</module>
<module>systopic-plugin</module>
<module>xml-format-plugin</module>
<module>xml-xsd-validator-plugin</module>
<module>zip-manipulator-plugin</module>
<module>advanced-validator</module>
<module>base64</module>
<module>contains-string-validator</module>
<module>json-format</module>
<module>save-manipulator</module>
<module>systopic</module>
<module>xml-format</module>
<module>xml-xsd-validator</module>
<module>zip-manipulator</module>

</modules>

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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>

<artifactId>save-manipulator-plugin</artifactId>
<artifactId>save-manipulator</artifactId>

<name>CorreoMQTT Plugin: Save Manipulator</name>

Expand All @@ -15,7 +15,7 @@
</parent>

<properties>
<plugin.id>save-manipulator-plugin</plugin.id>
<plugin.id>${artifactId}</plugin.id>
<plugin.name>Save Manipulator Plugin</plugin.name>
<plugin.provider>Exxeta AG</plugin.provider>
<plugin.class>org.correomqtt.plugin.save.SavePlugin</plugin.class>
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions plugins/systopic-plugin/pom.xml → plugins/systopic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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>

<artifactId>systopic-plugin</artifactId>
<artifactId>systopic</artifactId>

<name>CorreoMQTT Plugin: Systopic</name>

Expand All @@ -15,7 +15,7 @@
</parent>

<properties>
<plugin.id>systopic-plugin</plugin.id>
<plugin.id>${artifactId}</plugin.id>
<plugin.name>Systopic Plugin</plugin.name>
<plugin.provider>Exxeta AG</plugin.provider>
<plugin.class>org.correomqtt.plugins.systopic.SysTopicPlugin</plugin.class>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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>

<artifactId>xml-format-plugin</artifactId>
<artifactId>xml-format</artifactId>

<name>CorreoMQTT Plugin: XML Format</name>

Expand All @@ -15,7 +15,7 @@
</parent>

<properties>
<plugin.id>xml-format-plugin</plugin.id>
<plugin.id>${artifactId}</plugin.id>
<plugin.name>XML Format Plugin</plugin.name>
<plugin.provider>Exxeta AG</plugin.provider>
<plugin.class />
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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>

<artifactId>xml-xsd-validator-plugin</artifactId>
<artifactId>xml-xsd-validator</artifactId>

<name>CorreoMQTT Plugin: XML/XSD Validator</name>

Expand All @@ -16,7 +16,7 @@
</parent>

<properties>
<plugin.id>xml-xsd-validator-plugin</plugin.id>
<plugin.id>${artifactId}</plugin.id>
<plugin.name>XML/XSD Validator Plugin</plugin.name>
<plugin.provider>Exxeta AG</plugin.provider>
<plugin.class>org.correomqtt.plugin.xml_xsd_validator.XmlXsdValidatorPlugin</plugin.class>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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>

<artifactId>zip-manipulator-plugin</artifactId>
<artifactId>zip-manipulator</artifactId>

<name>CorreoMQTT Plugin: ZIP Manipulator</name>

Expand All @@ -15,7 +15,7 @@
</parent>

<properties>
<plugin.id>zip-manipulator-plugin</plugin.id>
<plugin.id>${artifactId}</plugin.id>
<plugin.name>ZIP Manipulator Plugin</plugin.name>
<plugin.provider>Exxeta AG</plugin.provider>
<plugin.class />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,11 @@ private static RepoPluginInfoDTO getRepoPluginInfoDto(String moduleId,
Element propertiesElement = (Element) project.getElementsByTagName("properties").item(0);
File f = new File(PLUGINS_FOLDER + File.separator + moduleId + File.separator + TARGET_FOLDER);
File[] files = f.listFiles((dir, name) -> name.startsWith(moduleId) && name.endsWith("jar"));
if (files == null || files.length != 1) {
throw new IllegalStateException("None or more than one jars found.");
if (files == null || files.length == 0) {
throw new IllegalStateException("jar was not found for moduleId " + moduleId + " in " + f);
}
if (files.length != 1) {
throw new IllegalStateException("More than one jars found for moduleId " + moduleId + " in " + f + ": " + Arrays.stream(files).map(File::getName).collect(Collectors.joining(", ")));
}
String jarFileName = files[0].getName();
String sha512sum = DigestUtils.sha512Hex(
Expand Down

0 comments on commit c0924f0

Please sign in to comment.