diff --git a/.classpath b/.classpath index 002ad570e2e589f29101a6f361e1e4c36eac358d..0fb79cfe69b2c407027c6a76a12fc59553c9e195 100644 --- a/.classpath +++ b/.classpath @@ -24,7 +24,7 @@ <attribute name="test" value="true"/> </attributes> </classpathentry> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"> <attributes> <attribute name="maven.pomderived" value="true"/> </attributes> diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 2f5cc74c3a8577df9faafd82992b0c62e56352be..2af1e7b99c98d3fc61561c085022741062a7820e 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,8 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.source=11 diff --git a/src/main/java/beamline/models/algorithms/InfiniteSizeDirectlyFollowsMapper.java b/src/main/java/beamline/models/algorithms/InfiniteSizeDirectlyFollowsMapper.java index 6eadf941de91fb083154c5d4ff466a3029863226..0df27ff69a383dd1b62807a2204c3fafaf73def3 100644 --- a/src/main/java/beamline/models/algorithms/InfiniteSizeDirectlyFollowsMapper.java +++ b/src/main/java/beamline/models/algorithms/InfiniteSizeDirectlyFollowsMapper.java @@ -26,7 +26,7 @@ public class InfiniteSizeDirectlyFollowsMapper extends StreamMiningAlgorithm<Dir private Map<String, BEvent> map = new HashMap<>(); @Override - public DirectlyFollowsRelation ingest(BEvent event) throws Exception { + public DirectlyFollowsRelation ingest(BEvent event) { String caseId = event.getTraceName(); DirectlyFollowsRelation toRet = null; diff --git a/src/main/java/beamline/models/algorithms/StreamMiningAlgorithm.java b/src/main/java/beamline/models/algorithms/StreamMiningAlgorithm.java index 9c249a76fe0e68e883089fbd930d16ba870da344..0a4e694c81df1b5a1f4ba30606dadf2cd59f40ba 100644 --- a/src/main/java/beamline/models/algorithms/StreamMiningAlgorithm.java +++ b/src/main/java/beamline/models/algorithms/StreamMiningAlgorithm.java @@ -44,10 +44,8 @@ public abstract class StreamMiningAlgorithm<T extends Response> extends RichFlat * * @param event the new event being observed * @return the result of the mining of the event - * @throws Exception general exception that can occur with the ingestion of - * the event */ - public abstract T ingest(BEvent event) throws Exception; + public abstract T ingest(BEvent event); /** * Returns the total number of events processed so far diff --git a/src/main/java/beamline/sources/XesLogSource.java b/src/main/java/beamline/sources/XesLogSource.java index 7aa38937984fe514199f0ff1413f6a86c54b8745..71098b92cb40fdca7450e1a936ea54434094a156 100644 --- a/src/main/java/beamline/sources/XesLogSource.java +++ b/src/main/java/beamline/sources/XesLogSource.java @@ -4,12 +4,18 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.FileAttribute; +import java.nio.file.attribute.PosixFilePermission; +import java.nio.file.attribute.PosixFilePermissions; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Set; +import org.apache.commons.lang3.SystemUtils; import org.deckfour.xes.extension.std.XConceptExtension; import org.deckfour.xes.extension.std.XTimeExtension; import org.deckfour.xes.in.XMxmlGZIPParser; @@ -61,9 +67,9 @@ public class XesLogSource extends BeamlineAbstractSource { * is created */ public XesLogSource(XLog log) throws IOException { - File tmpFile = Files.createTempFile("file", ".xes.gz").toFile(); - new XesXmlGZIPSerializer().serialize(log, new FileOutputStream(tmpFile)); - this.fileName = tmpFile.getAbsolutePath(); + Path tmpFile = getTempFile(); + new XesXmlGZIPSerializer().serialize(log, new FileOutputStream(tmpFile.toFile())); + this.fileName = tmpFile.toFile().getAbsolutePath(); } @Override @@ -148,4 +154,19 @@ public class XesLogSource extends BeamlineAbstractSource { // sort events Collections.sort(events); } + + private Path getTempFile() throws IOException { + Path p = null; + if (SystemUtils.IS_OS_UNIX) { + FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwx------")); + p = Files.createTempFile("log", ".xes.gz", attr); // Compliant + } else { + File f = Files.createTempFile("log", ".xes.gz").toFile(); // Compliant + f.setReadable(true, true); + f.setWritable(true, true); + f.setExecutable(true, true); + p = f.toPath(); + } + return p; + } } diff --git a/src/test/java/beamline/tests/AlgorithmTest.java b/src/test/java/beamline/tests/AlgorithmTest.java index 53c284315e64d3ff024c538712fb9a79f42019c2..e1ca19e9d291d5691da1572ba82fba47e85e9a19 100644 --- a/src/test/java/beamline/tests/AlgorithmTest.java +++ b/src/test/java/beamline/tests/AlgorithmTest.java @@ -22,7 +22,7 @@ public class AlgorithmTest { private static final long serialVersionUID = -8445717838576941924L; @Override - public StringResponse ingest(BEvent event) throws Exception { + public StringResponse ingest(BEvent event) { return new StringResponse(event.getProcessName() + event.getEventName() + event.getTraceName()); } }; @@ -51,7 +51,7 @@ public class AlgorithmTest { private static final long serialVersionUID = -8445717838576941924L; @Override - public StringResponse ingest(BEvent event) throws Exception { + public StringResponse ingest(BEvent event) { return new StringResponse(event.getProcessName() + event.getEventName() + event.getTraceName()); } }; diff --git a/src/test/java/beamline/tests/ResponsesTest.java b/src/test/java/beamline/tests/ResponsesTest.java index 26d22588bb04aef7b4db4f3e4a374429153dc954..3b933e22faf832b7892fd42a8db97544fd5fd9b9 100644 --- a/src/test/java/beamline/tests/ResponsesTest.java +++ b/src/test/java/beamline/tests/ResponsesTest.java @@ -5,7 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.util.Date; +import java.util.Random; import java.util.UUID; import org.junit.jupiter.api.Test; @@ -22,9 +22,9 @@ public class ResponsesTest { public void response_tests() { Response r = new Response(); - Date now = new Date(); - r.setProcessedEvents(now.getTime()); - assertEquals(now, r.getProcessedEvents()); + long rand = new Random().nextLong(); + r.setProcessedEvents(rand); + assertEquals(rand, r.getProcessedEvents()); } @Test diff --git a/src/test/java/beamline/tests/SourcesTest.java b/src/test/java/beamline/tests/SourcesTest.java index 95d18d441df00775183484ae24bd01ee20c6a0aa..415d548b3857a2304d2603a4c7cb0b25586410c6 100644 --- a/src/test/java/beamline/tests/SourcesTest.java +++ b/src/test/java/beamline/tests/SourcesTest.java @@ -212,12 +212,10 @@ public class SourcesTest { java.nio.file.Files.write(tmpFile.toPath(), toWrite.getBytes(), StandardOpenOption.APPEND); } }); -// JobClient job = env.executeAsync(); env.executeAsync(); Thread.sleep(2000); - System.out.println("going"); MqttClient client = new MqttClient("tcp://localhost:9999", "clientid", new MemoryPersistence()); client.connect(); publish(client, "c1", "a11"); @@ -227,8 +225,6 @@ public class SourcesTest { publish(client, "c2", "a23"); Thread.sleep(2000); -// job.cancel(); - System.out.println("Done"); assertEquals( "name-c1-a11/name-c2-a21/name-c2-a22/name-c1-a12/name-c2-a23/", org.apache.commons.io.FileUtils.readFileToString(tmpFile, "utf-8"));