From 635c08f5869121b913128c42b31ebebba04d849f Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 17 Nov 2023 11:55:06 +0100 Subject: [PATCH 01/58] fix: re-install dhcrud beans --- .../textgrid/middleware/ejb/DHConnectEJB.java | 21 +++--- .../middleware/messagebeans/DHAllMDB.java | 61 +++++++++-------- .../messagebeans/DHDigilibPrescalerMDB.java | 4 +- .../middleware/messagebeans/DHImageMDB.java | 65 +++++++++---------- 4 files changed, 72 insertions(+), 79 deletions(-) diff --git a/src/main/java/info/textgrid/middleware/ejb/DHConnectEJB.java b/src/main/java/info/textgrid/middleware/ejb/DHConnectEJB.java index e5c3a6e..78af60c 100644 --- a/src/main/java/info/textgrid/middleware/ejb/DHConnectEJB.java +++ b/src/main/java/info/textgrid/middleware/ejb/DHConnectEJB.java @@ -60,29 +60,26 @@ public class DHConnectEJB extends ConnectAbs { response.close(); } - /* - * (non-Javadoc) - * - * @see info.textgrid.middleware.ejb.Connect#getProperty(java.lang.String) + /** + * */ + @Override public String getProperty(String key) { return this.properties.getProperty(key); } - /* - * (non-Javadoc) - * - * @see info.textgrid.middleware.ejb.Connect#getAuth() + /** + * */ + @Override public String getAuth() { return ""; } - /* - * (non-Javadoc) - * - * @see info.textgrid.middleware.ejb.Connect#getObjectData(java.lang.String) + /** + * */ + @Override public InputStream getObjectData(String theUri) throws MetadataParseFault, ObjectNotFoundFault, IoFault, AuthFault, ProtocolNotImplementedFault, IOException, NullPointerException, URISyntaxException { diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java index f555d3d..fd6837e 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java @@ -1,31 +1,30 @@ -// package info.textgrid.middleware.messagebeans; -// -// import javax.ejb.ActivationConfigProperty; -// import javax.ejb.MessageDriven; -// import javax.jms.JMSException; -// import javax.jms.Message; -// -/// ** -// * -// */ -// @MessageDriven(name = "DHAllMDB", activationConfig = { -// @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/dhcrud"), -// @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), -// @ActivationConfigProperty(propertyName = "acknowledgeMode", -// propertyValue = "Auto-acknowledge")}) -// public class DHAllMDB extends DHMessageBeanAbs { -// -// /* -// * (non-Javadoc) -// * -// * @see javax.jms.MessageListener#onMessage(javax.jms.Message) -// */ -// public void onMessage(Message msg) { -// try { -// logMoreInfo(this.getClass().getSimpleName(), msg); -// } catch (JMSException e) { -// throw new RuntimeException(e); -// } -// } -// -// } +package info.textgrid.middleware.messagebeans; + +import javax.ejb.ActivationConfigProperty; +import javax.ejb.MessageDriven; +import javax.jms.JMSException; +import javax.jms.Message; + +/** + * + */ +@MessageDriven(name = "DHAllMDB", activationConfig = { + @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/dhcrud"), + @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), + @ActivationConfigProperty(propertyName = "acknowledgeMode", + propertyValue = "Auto-acknowledge")}) +public class DHAllMDB extends DHMessageBeanAbs { + + /** + * + */ + @Override + public void onMessage(Message msg) { + try { + logMoreInfo(this.getClass().getSimpleName(), msg); + } catch (JMSException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java index 4aca04a..982aa3a 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java @@ -34,10 +34,8 @@ public class DHDigilibPrescalerMDB extends DHMessageBeanAbs { private static final String CLASS_NAME = "{DHDigilibPrescalerMDB} "; - /* - * (non-Javadoc) + /** * - * @see javax.jms.MessageListener#onMessage(javax.jms.Message) */ @Override public void onMessage(Message msg) { diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHImageMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/DHImageMDB.java index b7f6689..b32b4d4 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHImageMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHImageMDB.java @@ -1,33 +1,32 @@ -// package info.textgrid.middleware.messagebeans; -// -// import javax.ejb.ActivationConfigProperty; -// import javax.ejb.MessageDriven; -// import javax.jms.JMSException; -// import javax.jms.Message; -// import info.textgrid.namespaces.middleware.tgcrud.common.CrudOperations; -// -/// ** -// * -// */ -// @MessageDriven(name = "DHImageMDB", activationConfig = { -// @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/dhcrud"), -// @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), -// @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), -// @ActivationConfigProperty(propertyName = "messageSelector", -// propertyValue = "format LIKE 'image/%' AND operation=" + CrudOperations.CREATE)}) -// public class DHImageMDB extends DHMessageBeanAbs { -// -// /* -// * (non-Javadoc) -// * -// * @see javax.jms.MessageListener#onMessage(javax.jms.Message) -// */ -// public void onMessage(Message msg) { -// try { -// logMoreInfo(this.getClass().getSimpleName(), msg); -// } catch (JMSException e) { -// throw new RuntimeException(e); -// } -// } -// -// } +package info.textgrid.middleware.messagebeans; + +import javax.ejb.ActivationConfigProperty; +import javax.ejb.MessageDriven; +import javax.jms.JMSException; +import javax.jms.Message; +import info.textgrid.middleware.common.CrudOperations; + +/** + * + */ +@MessageDriven(name = "DHImageMDB", activationConfig = { + @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/dhcrud"), + @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), + @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), + @ActivationConfigProperty(propertyName = "messageSelector", + propertyValue = "format LIKE 'image/%' AND operation=" + CrudOperations.CREATE)}) +public class DHImageMDB extends DHMessageBeanAbs { + + /** + * + */ + @Override + public void onMessage(Message msg) { + try { + logMoreInfo(this.getClass().getSimpleName(), msg); + } catch (JMSException e) { + throw new RuntimeException(e); + } + } + +} -- GitLab From ecc32d5ef057891b816bb95c703f0ef1f4f2f8be Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 17 Nov 2023 15:04:06 +0100 Subject: [PATCH 02/58] fix: remove unused (only logging) message beans --- .../textgrid/middleware/ejb/ConnectAbs.java | 1 + .../textgrid/middleware/ejb/TGConnect.java | 4 +++ .../middleware/messagebeans/DHAllMDB.java | 30 ----------------- .../messagebeans/DHDigilibPrescalerMDB.java | 8 ++++- .../middleware/messagebeans/DHImageMDB.java | 32 ------------------ .../messagebeans/MessageBeanAbs.java | 10 ------ .../middleware/messagebeans/TGAllMDB.java | 31 ----------------- .../messagebeans/TGDigilibPrescalerMDB.java | 15 +++++---- .../middleware/messagebeans/TGImageMDB.java | 33 ------------------- .../messagebeans/TestMessageBeanAbs.java | 10 +----- 10 files changed, 21 insertions(+), 153 deletions(-) delete mode 100644 src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java delete mode 100644 src/main/java/info/textgrid/middleware/messagebeans/DHImageMDB.java delete mode 100644 src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java delete mode 100644 src/main/java/info/textgrid/middleware/messagebeans/TGImageMDB.java diff --git a/src/main/java/info/textgrid/middleware/ejb/ConnectAbs.java b/src/main/java/info/textgrid/middleware/ejb/ConnectAbs.java index 470949e..55dc1b3 100644 --- a/src/main/java/info/textgrid/middleware/ejb/ConnectAbs.java +++ b/src/main/java/info/textgrid/middleware/ejb/ConnectAbs.java @@ -23,6 +23,7 @@ public abstract class ConnectAbs implements Connect { /** * */ + @Override public void init() { this.properties = new Properties(); diff --git a/src/main/java/info/textgrid/middleware/ejb/TGConnect.java b/src/main/java/info/textgrid/middleware/ejb/TGConnect.java index c762531..1df0877 100644 --- a/src/main/java/info/textgrid/middleware/ejb/TGConnect.java +++ b/src/main/java/info/textgrid/middleware/ejb/TGConnect.java @@ -61,6 +61,7 @@ public class TGConnect extends ConnectAbs { /** * */ + @Override public void init() { super.init(); @@ -86,6 +87,7 @@ public class TGConnect extends ConnectAbs { * @throws ProtocolNotImplementedFault * @throws IOException */ + @Override public InputStream getObjectData(String textgridUri) throws MetadataParseFault, ObjectNotFoundFault, IoFault, AuthFault, ProtocolNotImplementedFault, IOException { @@ -101,6 +103,7 @@ public class TGConnect extends ConnectAbs { * @param key * @return */ + @Override public String getProperty(String key) { return this.properties.getProperty(key); } @@ -108,6 +111,7 @@ public class TGConnect extends ConnectAbs { /** * @return */ + @Override public String getAuth() { LOGGER.fine("ejb-count:" + this.count); diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java deleted file mode 100644 index fd6837e..0000000 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java +++ /dev/null @@ -1,30 +0,0 @@ -package info.textgrid.middleware.messagebeans; - -import javax.ejb.ActivationConfigProperty; -import javax.ejb.MessageDriven; -import javax.jms.JMSException; -import javax.jms.Message; - -/** - * - */ -@MessageDriven(name = "DHAllMDB", activationConfig = { - @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/dhcrud"), - @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), - @ActivationConfigProperty(propertyName = "acknowledgeMode", - propertyValue = "Auto-acknowledge")}) -public class DHAllMDB extends DHMessageBeanAbs { - - /** - * - */ - @Override - public void onMessage(Message msg) { - try { - logMoreInfo(this.getClass().getSimpleName(), msg); - } catch (JMSException e) { - throw new RuntimeException(e); - } - } - -} diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java index 982aa3a..295af98 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java @@ -19,7 +19,13 @@ import info.textgrid.middleware.common.CrudOperations; import info.textgrid.middleware.ejb.DHConnectEJB; /** - * + * Other selectors: + * + * ...from DHImageMDB - @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = + * "format LIKE 'image/%' AND operation=" + CrudOperations.CREATE)}) + * + * ...from DHAllMDB: none :-) + * */ @MessageDriven(name = "DHDigilibPrescalerMDB", activationConfig = { @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/dhcrud"), diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHImageMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/DHImageMDB.java deleted file mode 100644 index b32b4d4..0000000 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHImageMDB.java +++ /dev/null @@ -1,32 +0,0 @@ -package info.textgrid.middleware.messagebeans; - -import javax.ejb.ActivationConfigProperty; -import javax.ejb.MessageDriven; -import javax.jms.JMSException; -import javax.jms.Message; -import info.textgrid.middleware.common.CrudOperations; - -/** - * - */ -@MessageDriven(name = "DHImageMDB", activationConfig = { - @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/dhcrud"), - @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), - @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), - @ActivationConfigProperty(propertyName = "messageSelector", - propertyValue = "format LIKE 'image/%' AND operation=" + CrudOperations.CREATE)}) -public class DHImageMDB extends DHMessageBeanAbs { - - /** - * - */ - @Override - public void onMessage(Message msg) { - try { - logMoreInfo(this.getClass().getSimpleName(), msg); - } catch (JMSException e) { - throw new RuntimeException(e); - } - } - -} diff --git a/src/main/java/info/textgrid/middleware/messagebeans/MessageBeanAbs.java b/src/main/java/info/textgrid/middleware/messagebeans/MessageBeanAbs.java index 8e0d365..80fec65 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/MessageBeanAbs.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/MessageBeanAbs.java @@ -318,16 +318,6 @@ public abstract class MessageBeanAbs implements MessageListener { MessageBeanAbs.jmsTypeKey = jmsTypeKey; } - /** - * @param theURI - * @return - */ - @Deprecated - public static String getPrescalePathOnly(String theURI) { - String completePath = CachingUtils.getCachingPathFromURI(theURI).trim(); - return completePath.substring(4, completePath.lastIndexOf("/")); - } - /** * @param theURI * @return diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java deleted file mode 100644 index 95b0425..0000000 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java +++ /dev/null @@ -1,31 +0,0 @@ -package info.textgrid.middleware.messagebeans; - -import javax.ejb.ActivationConfigProperty; -import javax.ejb.MessageDriven; -import javax.jms.JMSException; -import javax.jms.Message; - -/** - * - */ -@MessageDriven(name = "TGAllMDB", activationConfig = { - @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/tgcrud"), - @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), - @ActivationConfigProperty(propertyName = "acknowledgeMode", - propertyValue = "Auto-acknowledge")}) -public class TGAllMDB extends TGMessageBeanAbs { - - /* - * (non-Javadoc) - * - * @see javax.jms.MessageListener#onMessage(javax.jms.Message) - */ - public void onMessage(Message msg) { - try { - logMoreInfo(this.getClass().getSimpleName(), msg); - } catch (JMSException e) { - throw new RuntimeException(e); - } - } - -} diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java index 8f96d1b..ba2b700 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java @@ -17,7 +17,12 @@ import info.textgrid.middleware.common.CrudOperations; import info.textgrid.middleware.common.JPairtree; /** - * + * Other selectors: + * + * ...from TGImageMDB: @ActivationConfigProperty(propertyName = "messageSelector",propertyValue = + * "format LIKE 'image/%' AND operation=" + CrudOperations.CREATE)}) + * + * ...from TGAllMDB: none :-) */ @MessageDriven(name = "TGDigilibPrescalerMDB", activationConfig = { @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/tgcrud"), @@ -29,14 +34,10 @@ public class TGDigilibPrescalerMDB extends TGMessageBeanAbs { private static final String PUBLIC_STORAGE_PATH = "/data/public/productive/"; private static final String NONPUBLIC_STORAGE_PATH = "/data/nonpublic/productive/"; - private static final String PRESCALE_PATH = "/var/dhrep/digilib/prescale/"; - private static final String CLASS_NAME = "{TGDigilibPrescalerMDB} "; - /* - * (non-Javadoc) + /** * - * @see javax.jms.MessageListener#onMessage(javax.jms.Message) */ @Override public void onMessage(Message msg) { @@ -79,7 +80,7 @@ public class TGDigilibPrescalerMDB extends TGMessageBeanAbs { * * @param textgridUri */ - private void touchPrescales(String textgridUri) { + private static void touchPrescales(String textgridUri) { String id = textgridUri.substring(9); FileTime modificationTime = FileTime.fromMillis(System.currentTimeMillis()); diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGImageMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/TGImageMDB.java deleted file mode 100644 index df96173..0000000 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGImageMDB.java +++ /dev/null @@ -1,33 +0,0 @@ -// package info.textgrid.middleware.messagebeans; -// -// import javax.ejb.ActivationConfigProperty; -// import javax.ejb.MessageDriven; -// import javax.jms.JMSException; -// import javax.jms.Message; -// import info.textgrid.namespaces.middleware.tgcrud.common.CrudOperations; -// -/// ** -// * -// */ -// @MessageDriven(name = "TGImageMDB", activationConfig = { -// @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/tgcrud"), -// @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), -// @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), -// @ActivationConfigProperty(propertyName = "messageSelector", -// propertyValue = "format LIKE 'image/%' AND operation=" + CrudOperations.CREATE)}) -// public class TGImageMDB extends TGMessageBeanAbs { -// -// /* -// * (non-Javadoc) -// * -// * @see javax.jms.MessageListener#onMessage(javax.jms.Message) -// */ -// public void onMessage(Message msg) { -// try { -// logGeneralInfo(this.getClass().getSimpleName(), msg);; -// } catch (JMSException e) { -// throw new RuntimeException(e); -// } -// } -// -// } diff --git a/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java b/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java index 0ebe9d4..d8b4160 100644 --- a/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java +++ b/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java @@ -20,18 +20,10 @@ public class TestMessageBeanAbs extends TestCase { public void testGetCachingPathFromDariahURI() { String uri = "hdl:21.T11991/0000-0013-281B-1"; - String expectedPath = "21.T11991-0000-0013"; String expectedFilename = "21.T11991-0000-0013-281B-1"; - // Test path. - String prescalePath = DHDigilibPrescalerMDB.getPrescalePathOnly(uri); - if (!prescalePath.equals(expectedPath)) { - System.out.println(prescalePath + " != " + expectedPath); - assertFalse(true); - } - // Test filename. - String filename = DHDigilibPrescalerMDB.getPrescaleFilenameOnly(uri); + String filename = MessageBeanAbs.getPrescaleFilenameOnly(uri); if (!filename.equals(expectedFilename)) { System.out.println(filename + " != " + expectedFilename); assertFalse(true); -- GitLab From b6551624fd7f9124fa168b68a3bd5580e270fcb0 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Wed, 22 Nov 2023 11:48:35 +0100 Subject: [PATCH 03/58] fix: add *all* beans again --- .../middleware/messagebeans/DHAllMDB.java | 30 +++++++++++++++++++ .../messagebeans/DHDigilibPrescalerMDB.java | 2 -- .../middleware/messagebeans/TGAllMDB.java | 30 +++++++++++++++++++ .../messagebeans/TGDigilibPrescalerMDB.java | 2 -- 4 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java create mode 100644 src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java new file mode 100644 index 0000000..fd6837e --- /dev/null +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java @@ -0,0 +1,30 @@ +package info.textgrid.middleware.messagebeans; + +import javax.ejb.ActivationConfigProperty; +import javax.ejb.MessageDriven; +import javax.jms.JMSException; +import javax.jms.Message; + +/** + * + */ +@MessageDriven(name = "DHAllMDB", activationConfig = { + @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/dhcrud"), + @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), + @ActivationConfigProperty(propertyName = "acknowledgeMode", + propertyValue = "Auto-acknowledge")}) +public class DHAllMDB extends DHMessageBeanAbs { + + /** + * + */ + @Override + public void onMessage(Message msg) { + try { + logMoreInfo(this.getClass().getSimpleName(), msg); + } catch (JMSException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java index 295af98..7128732 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java @@ -24,8 +24,6 @@ import info.textgrid.middleware.ejb.DHConnectEJB; * ...from DHImageMDB - @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = * "format LIKE 'image/%' AND operation=" + CrudOperations.CREATE)}) * - * ...from DHAllMDB: none :-) - * */ @MessageDriven(name = "DHDigilibPrescalerMDB", activationConfig = { @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/dhcrud"), diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java new file mode 100644 index 0000000..b885d41 --- /dev/null +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java @@ -0,0 +1,30 @@ +package info.textgrid.middleware.messagebeans; + +import javax.ejb.ActivationConfigProperty; +import javax.ejb.MessageDriven; +import javax.jms.JMSException; +import javax.jms.Message; + +/** + * + */ +@MessageDriven(name = "TGAllMDB", activationConfig = { + @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/tgcrud"), + @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), + @ActivationConfigProperty(propertyName = "acknowledgeMode", + propertyValue = "Auto-acknowledge")}) +public class TGAllMDB extends TGMessageBeanAbs { + + /** + * + */ + @Override + public void onMessage(Message msg) { + try { + logMoreInfo(this.getClass().getSimpleName(), msg); + } catch (JMSException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java index ba2b700..54f9103 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java @@ -21,8 +21,6 @@ import info.textgrid.middleware.common.JPairtree; * * ...from TGImageMDB: @ActivationConfigProperty(propertyName = "messageSelector",propertyValue = * "format LIKE 'image/%' AND operation=" + CrudOperations.CREATE)}) - * - * ...from TGAllMDB: none :-) */ @MessageDriven(name = "TGDigilibPrescalerMDB", activationConfig = { @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/tgcrud"), -- GitLab From 3401c351fe74c8d11b8809d9448939bb5762a24a Mon Sep 17 00:00:00 2001 From: Ubbo Veentjer <veentjer@sub.uni-goettingen.de> Date: Wed, 20 Dec 2023 15:04:32 +0100 Subject: [PATCH 04/58] feature: rewrite as reactive messaging microservice with quarkus. --- .gitlab-ci.yml | 1 + Dockerfile | 36 -- pom.xml | 432 +++++++----------- src/deb/control/control | 7 - src/deb/control/postinst | 4 - src/deb/control/preinst | 4 - src/docker/config-jms.cli | 3 - src/main/docker/Dockerfile.jvm | 97 ++++ src/main/docker/Dockerfile.legacy-jar | 93 ++++ src/main/docker/Dockerfile.native | 27 ++ src/main/docker/Dockerfile.native-micro | 30 ++ .../info/textgrid/middleware/ejb/Connect.java | 20 +- .../textgrid/middleware/ejb/DHConnectEJB.java | 37 +- .../textgrid/middleware/ejb/TGConnect.java | 182 -------- .../middleware/messagebeans/DHAllMDB.java | 36 +- .../messagebeans/DHDigilibPrescalerMDB.java | 47 +- .../messagebeans/MessageBeanAbs.java | 49 +- .../middleware/messagebeans/TGAllMDB.java | 37 +- .../messagebeans/TGDigilibPrescalerMDB.java | 45 +- .../middleware/model/CrudMessage.java | 70 +++ src/main/resources/application.properties | 15 + src/main/resources/enzyklops-adapter.xsl | 43 -- src/main/webapp/WEB-INF/beans.xml | 19 - .../messagebeans/TestMessageBeanAbs.java | 12 +- 24 files changed, 626 insertions(+), 720 deletions(-) delete mode 100644 Dockerfile delete mode 100644 src/deb/control/control delete mode 100644 src/deb/control/postinst delete mode 100644 src/deb/control/preinst delete mode 100644 src/docker/config-jms.cli create mode 100644 src/main/docker/Dockerfile.jvm create mode 100644 src/main/docker/Dockerfile.legacy-jar create mode 100644 src/main/docker/Dockerfile.native create mode 100644 src/main/docker/Dockerfile.native-micro delete mode 100644 src/main/java/info/textgrid/middleware/ejb/TGConnect.java create mode 100644 src/main/java/info/textgrid/middleware/model/CrudMessage.java create mode 100644 src/main/resources/application.properties delete mode 100644 src/main/resources/enzyklops-adapter.xsl delete mode 100644 src/main/webapp/WEB-INF/beans.xml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f7d327e..fd1c571 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,6 +16,7 @@ variables: GIT_AUTHOR_NAME: ${GL_USER} GIT_COMMITTER_EMAIL: ${GL_USER}@noreply.gitlab.gwdg.de GIT_COMMITTER_NAME: ${GL_USER} + DOCKERFILE: $CI_PROJECT_DIR/src/main/docker/Dockerfile.jvm-multistage # Include Java settings from Gitlab templates repo. include: diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index be2a2ab..0000000 --- a/Dockerfile +++ /dev/null @@ -1,36 +0,0 @@ -### -# build -### -FROM maven:3.8.3-jdk-8 as builder - -COPY . /build -WORKDIR /build - -RUN --mount=type=cache,target=/root/.m2 mvn clean verify package - - -### -# assemble image -### -FROM jboss/wildfly:9.0.2.Final - -ARG JOLOKIA_VERSION="1.3.7" # jolokia as of 1.5.0 requires auth for proxy operation - -USER root -# https://tufora.com/tutorials/linux/general/install-vips-vips-tools-and-vips-devel-libvips-on-centos-7 -RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && yum install -y yum-utils && yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm && yum-config-manager --enable remi && yum install -y vips vips-tools && yum clean all - -COPY ./src/docker/config-jms.cli /opt/config-jms.cli - -USER jboss -RUN curl -XGET "https://repo1.maven.org/maven2/org/jolokia/jolokia-war/${JOLOKIA_VERSION}/jolokia-war-${JOLOKIA_VERSION}.war" --output /opt/jboss/wildfly/standalone/deployments/jolokia.war -COPY --from=builder /build/target/*.war /opt/jboss/wildfly/standalone/deployments/ - -# yes, right, here is a password, but the service is not going to be exposed to the world -# TODO: find out how to solve this in a nicer way -RUN /opt/jboss/wildfly/bin/add-user.sh -a --user tgcrud --password secret --group guest --silent - -RUN /opt/jboss/wildfly/bin/jboss-cli.sh --file=/opt/config-jms.cli - -ENTRYPOINT /opt/jboss/wildfly/bin/standalone.sh -c standalone-full.xml -b 0.0.0.0 -bmanagement 0.0.0.0 - diff --git a/pom.xml b/pom.xml index d8bf932..f235ef2 100644 --- a/pom.xml +++ b/pom.xml @@ -1,264 +1,172 @@ -<?xml version="1.0" encoding="UTF-8"?> -<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/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>info.textgrid.middleware</groupId> - <artifactId>message-beans</artifactId> - <version>3.3.1-SNAPSHOT</version> - <packaging>war</packaging> - <name>DARIAHDE :: Repository :: Message Driven Beans</name> - <description>Message driven beans for the TextGrid and DARIAH-DE Repository</description> - <url>https://de.dariah.eu</url> - <properties> - <common.version>4.0.1</common.version> - <commons-imaging.version>1.0-alpha1</commons-imaging.version> - <commons-io.version>2.4</commons-io.version> - <crud.version>11.0.0-DH-RELEASE</crud.version> - <cyclonedx-maven-plugin.version>2.7.0</cyclonedx-maven-plugin.version> - <jboss-bom.version>8.0.0.Final</jboss-bom.version> - <jboss-javaee-all-7.0.version>1.0.0.Final</jboss-javaee-all-7.0.version> - <jdeb.version>1.4</jdeb.version> - <jdk.version>1.7</jdk.version> - <junit.version>4.12</junit.version> - <maven-compiler-plugin.version>3.1</maven-compiler-plugin.version> - <maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version> - <maven-eclipse-plugin.version>2.9</maven-eclipse-plugin.version> - <maven-war-plugin.version>3.0.0</maven-war-plugin.version> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <saxon-he.version>9.5.0.2</saxon-he.version> - <wildfly-maven-plugin.version>1.0.2.Final</wildfly-maven-plugin.version> - </properties> - <dependencyManagement> - <dependencies> - <!-- Define the version of JBoss' Java EE 7 APIs we want to use --> - <!-- JBoss distributes a complete set of Java EE 7 APIs including a Bill - of Materials (BOM). A BOM specifies the versions of a "stack" (or a collection) - of artifacts. We use this here so that we always get the correct versions - of artifacts. Here we use the jboss-javaee-7.0 stack (you can read this as - the JBoss stack of the Java EE 7 APIs). You can actually use this stack with - any version of WildFly that implements Java EE 7, not just JBoss WildFly - 8! --> - <dependency> - <groupId>org.jboss.spec</groupId> - <artifactId>jboss-javaee-all-7.0</artifactId> - <version>${jboss-javaee-all-7.0.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - <dependency> - <groupId>org.wildfly.bom</groupId> - <artifactId>jboss-javaee-7.0-with-resteasy</artifactId> - <version>${jboss-bom.version}</version> - <scope>import</scope> - <type>pom</type> - </dependency> - </dependencies> - </dependencyManagement> - <dependencies> - <!-- First declare the APIs we depend on and need for compilation. All - of them are provided by JBoss WildFly --> - <dependency> - <groupId>org.jboss.spec.javax.jms</groupId> - <artifactId>jboss-jms-api_2.0_spec</artifactId> - <scope>provided</scope> - </dependency> - <!-- Import the EJB API, we use provided scope as the API is included in - JBoss WildFly --> - <dependency> - <groupId>org.jboss.spec.javax.ejb</groupId> - <artifactId>jboss-ejb-api_3.2_spec</artifactId> - <scope>provided</scope> - </dependency> - <!-- Import the CDI API, we use provided scope as the API is included in - JBoss WildFly --> - <dependency> - <groupId>javax.enterprise</groupId> - <artifactId>cdi-api</artifactId> - <scope>provided</scope> - </dependency> - <!-- We want JAX-RS client! --> - <dependency> - <groupId>org.jboss.resteasy</groupId> - <artifactId>jaxrs-api</artifactId> - </dependency> - <!-- RESTEasy implementation of JAX-RS API --> - <dependency> - <groupId>org.jboss.resteasy</groupId> - <artifactId>resteasy-jaxrs</artifactId> - </dependency> - <!-- RESTEasy implementation of JAX-RS Client API --> - <dependency> - <groupId>org.jboss.resteasy</groupId> - <artifactId>resteasy-client</artifactId> - </dependency> - <dependency> - <groupId>info.textgrid.middleware</groupId> - <artifactId>dhcrud-api</artifactId> - <version>${crud.version}</version> - <exclusions> - <!-- Exclude frontend-jaxrs due to Wildfly deployment dependency problems +<?xml version="1.0"?> +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <groupId>info.textgrid.middleware</groupId> + <artifactId>message-beans</artifactId> + <version>1.0.0-SNAPSHOT</version> + <properties> + <compiler-plugin.version>3.11.0</compiler-plugin.version> + <maven.compiler.release>17</maven.compiler.release> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id> + <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id> + <quarkus.platform.version>3.6.3</quarkus.platform.version> + <skipITs>true</skipITs> + <surefire-plugin.version>3.1.2</surefire-plugin.version> + <common.version>4.0.1</common.version> + <commons-imaging.version>1.0-alpha3</commons-imaging.version> + <crud.version>11.9.5-SNAPSHOT</crud.version> + </properties> + <repositories> + <repository> + <id>maven-dariah-public</id> + <name>GWDG Nexus DARIAH-DE Repository</name> + <url>https://nexus.gwdg.de/repository/maven-dariah-public/</url> + </repository> + </repositories> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>${quarkus.platform.group-id}</groupId> + <artifactId>${quarkus.platform.artifact-id}</artifactId> + <version>${quarkus.platform.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + <dependencies> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-smallrye-reactive-messaging-amqp</artifactId> + <!--<artifactId>quarkus-smallrye-reactive-messaging-rabbitmq</artifactId>--> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-arc</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-rest-client-reactive-jaxb</artifactId> + </dependency> + <dependency> + <groupId>info.textgrid.middleware</groupId> + <artifactId>cacheutils</artifactId> + <version>${common.version}</version> + </dependency> + <dependency> + <groupId>info.textgrid.middleware</groupId> + <artifactId>const</artifactId> + <version>${common.version}</version> + </dependency> + <dependency> + <groupId>info.textgrid.middleware</groupId> + <artifactId>dhcrud-api</artifactId> + <version>${crud.version}</version> + <exclusions> + <!-- Exclude frontend-jaxrs due to Wildfly deployment dependency problems in JBoss. --> - <exclusion> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-frontend-jaxrs</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>info.textgrid.middleware</groupId> - <artifactId>jpairtree</artifactId> - <version>${common.version}</version> - </dependency> - <dependency> - <groupId>info.textgrid.middleware</groupId> - <artifactId>cacheutils</artifactId> - <version>${common.version}</version> - </dependency> - <dependency> - <groupId>info.textgrid.middleware</groupId> - <artifactId>const</artifactId> - <version>${common.version}</version> - </dependency> - <dependency> - <groupId>info.textgrid.middleware</groupId> - <artifactId>tgcrud-client</artifactId> - <version>${crud.version}</version> - </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>${commons-io.version}</version> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-imaging</artifactId> - <version>${commons-imaging.version}</version> - </dependency> - <dependency> - <groupId>net.sf.saxon</groupId> - <artifactId>Saxon-HE</artifactId> - <version>${saxon-he.version}</version> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>${junit.version}</version> - <scope>test</scope> - </dependency> - </dependencies> - <repositories> - <repository> - <id>maven-dariah-public</id> - <name>GWDG Nexus DARIAH-DE Repository</name> - <url>https://nexus.gwdg.de/repository/maven-dariah-public/</url> - </repository> - </repositories> - <build> - <finalName>${project.artifactId}</finalName> - <defaultGoal>package</defaultGoal> - <plugins> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <version>${maven-compiler-plugin.version}</version> - <configuration> - <source>${jdk.version}</source> - <target>${jdk.version}</target> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-deploy-plugin</artifactId> - <version>${maven-deploy-plugin.version}</version> - <configuration> - <skip>true</skip> - </configuration> - </plugin> - <plugin> - <artifactId>maven-war-plugin</artifactId> - <version>${maven-war-plugin.version}</version> - <configuration> - <!-- Java EE 7 doesn't require web.xml, Maven needs to catch up! --> - <failOnMissingWebXml>false</failOnMissingWebXml> - </configuration> - </plugin> - <!-- The WildFly plugin deploys your war to a local WildFly container --> - <!-- To use, run: mvn package wildfly:deploy --> - <plugin> - <groupId>org.wildfly.plugins</groupId> - <artifactId>wildfly-maven-plugin</artifactId> - <version>${wildfly-maven-plugin.version}</version> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-eclipse-plugin</artifactId> - <version>${maven-eclipse-plugin.version}</version> - <configuration> - <downloadSources>true</downloadSources> - <downloadJavadocs>true</downloadJavadocs> - </configuration> - </plugin> - </plugins> - </build> - <profiles> - <profile> - <id>sbom</id> - <build> - <plugins> - <plugin> - <groupId>org.cyclonedx</groupId> - <artifactId>cyclonedx-maven-plugin</artifactId> - <version>${cyclonedx-maven-plugin.version}</version> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>makeAggregateBom</goal> - </goals> - </execution> - </executions> - <configuration> - <outputFormat>JSON</outputFormat> - </configuration> - </plugin> - </plugins> - </build> - </profile> - <profile> - <id>dhrep.deb</id> - <build> - <plugins> - <plugin> - <groupId>org.vafer</groupId> - <artifactId>jdeb</artifactId> - <version>${jdeb.version}</version> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>jdeb</goal> - </goals> - <configuration> - <snapshotExpand>true</snapshotExpand> - <dataSet> - <data> - <type>file</type> - <src>${project.build.directory}/${project.build.finalName}.war</src> - <mapper> - <type>perm</type> - <prefix>/var/dhrep/webapps/${project.build.finalName}</prefix> - <user>root</user> - <group>wildfly</group> - <filemode>755</filemode> - </mapper> - </data> - </dataSet> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> + <exclusion> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-client</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>info.textgrid.middleware</groupId> + <artifactId>jpairtree</artifactId> + <version>${common.version}</version> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-imaging</artifactId> + <version>${commons-imaging.version}</version> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>${quarkus.platform.group-id}</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <version>${quarkus.platform.version}</version> + <extensions>true</extensions> + <executions> + <execution> + <goals> + <goal>build</goal> + <goal>generate-code</goal> + <goal>generate-code-tests</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>${compiler-plugin.version}</version> + <configuration> + <compilerArgs> + <arg>-parameters</arg> + </compilerArgs> + </configuration> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire-plugin.version}</version> + <configuration> + <systemPropertyVariables> + <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> + <maven.home>${maven.home}</maven.home> + </systemPropertyVariables> + </configuration> + </plugin> + <plugin> + <artifactId>maven-failsafe-plugin</artifactId> + <version>${surefire-plugin.version}</version> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + <configuration> + <systemPropertyVariables> + <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> + <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> + <maven.home>${maven.home}</maven.home> + </systemPropertyVariables> + </configuration> + </plugin> + </plugins> + </build> + <profiles> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <properties> + <skipITs>false</skipITs> + <quarkus.package.type>native</quarkus.package.type> + </properties> + </profile> + </profiles> </project> diff --git a/src/deb/control/control b/src/deb/control/control deleted file mode 100644 index faba368..0000000 --- a/src/deb/control/control +++ /dev/null @@ -1,7 +0,0 @@ -Package: [[artifactId]] -Version: [[version]] -Section: misc -Priority: low -Architecture: all -Description: [[description]] -Maintainer: funk@sub.uni-goettingen.de diff --git a/src/deb/control/postinst b/src/deb/control/postinst deleted file mode 100644 index 6f351a6..0000000 --- a/src/deb/control/postinst +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -service wildfly start -# return success, even if service not installed -#exit 0 diff --git a/src/deb/control/preinst b/src/deb/control/preinst deleted file mode 100644 index 08cb8e5..0000000 --- a/src/deb/control/preinst +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -service wildfly stop -# return success, even if service not installed -#exit 0 diff --git a/src/docker/config-jms.cli b/src/docker/config-jms.cli deleted file mode 100644 index 691c366..0000000 --- a/src/docker/config-jms.cli +++ /dev/null @@ -1,3 +0,0 @@ -embed-server --server-config=standalone-full.xml -jms-topic add --topic-address=tgcrudTopic --entries=topic/tgcrud,java:jboss/exported/jms/topic/tgcrud - diff --git a/src/main/docker/Dockerfile.jvm b/src/main/docker/Dockerfile.jvm new file mode 100644 index 0000000..d90e3ec --- /dev/null +++ b/src/main/docker/Dockerfile.jvm @@ -0,0 +1,97 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode +# +# Before building the container image run: +# +# ./mvnw package +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/message-beans-jvm . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/message-beans-jvm +# +# If you want to include the debug port into your docker image +# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005. +# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005 +# when running the container +# +# Then run the container using : +# +# docker run -i --rm -p 8080:8080 quarkus/message-beans-jvm +# +# This image uses the `run-java.sh` script to run the application. +# This scripts computes the command line to execute your Java application, and +# includes memory/GC tuning. +# You can configure the behavior using the following environment properties: +# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") +# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options +# in JAVA_OPTS (example: "-Dsome.property=foo") +# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is +# used to calculate a default maximal heap memory based on a containers restriction. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio +# of the container available memory as set here. The default is `50` which means 50% +# of the available memory is used as an upper boundary. You can skip this mechanism by +# setting this value to `0` in which case no `-Xmx` option is added. +# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This +# is used to calculate a default initial heap memory based on the maximum heap memory. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio +# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` +# is used as the initial heap size. You can skip this mechanism by setting this value +# to `0` in which case no `-Xms` option is added (example: "25") +# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. +# This is used to calculate the maximum value of the initial heap memory. If used in +# a container without any memory constraints for the container then this option has +# no effect. If there is a memory constraint then `-Xms` is limited to the value set +# here. The default is 4096MB which means the calculated value of `-Xms` never will +# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") +# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output +# when things are happening. This option, if set to true, will set +# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). +# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: +# true"). +# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). +# - CONTAINER_CORE_LIMIT: A calculated core limit as described in +# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") +# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). +# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. +# (example: "20") +# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. +# (example: "40") +# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. +# (example: "4") +# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus +# previous GC times. (example: "90") +# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") +# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") +# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should +# contain the necessary JRE command-line options to specify the required GC, which +# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). +# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") +# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") +# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be +# accessed directly. (example: "foo.example.com,bar.example.com") +# +### +FROM registry.access.redhat.com/ubi8/openjdk-17:1.18 + +ENV LANGUAGE='en_US:en' + + +# We make four distinct layers so if there are application changes the library layers can be re-used +COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/ +COPY --chown=185 target/quarkus-app/*.jar /deployments/ +COPY --chown=185 target/quarkus-app/app/ /deployments/app/ +COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/ + +EXPOSE 8080 +USER 185 +ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" + +ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] + diff --git a/src/main/docker/Dockerfile.legacy-jar b/src/main/docker/Dockerfile.legacy-jar new file mode 100644 index 0000000..0f1fede --- /dev/null +++ b/src/main/docker/Dockerfile.legacy-jar @@ -0,0 +1,93 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode +# +# Before building the container image run: +# +# ./mvnw package -Dquarkus.package.type=legacy-jar +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/message-beans-legacy-jar . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/message-beans-legacy-jar +# +# If you want to include the debug port into your docker image +# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005. +# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005 +# when running the container +# +# Then run the container using : +# +# docker run -i --rm -p 8080:8080 quarkus/message-beans-legacy-jar +# +# This image uses the `run-java.sh` script to run the application. +# This scripts computes the command line to execute your Java application, and +# includes memory/GC tuning. +# You can configure the behavior using the following environment properties: +# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") +# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options +# in JAVA_OPTS (example: "-Dsome.property=foo") +# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is +# used to calculate a default maximal heap memory based on a containers restriction. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio +# of the container available memory as set here. The default is `50` which means 50% +# of the available memory is used as an upper boundary. You can skip this mechanism by +# setting this value to `0` in which case no `-Xmx` option is added. +# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This +# is used to calculate a default initial heap memory based on the maximum heap memory. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio +# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` +# is used as the initial heap size. You can skip this mechanism by setting this value +# to `0` in which case no `-Xms` option is added (example: "25") +# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. +# This is used to calculate the maximum value of the initial heap memory. If used in +# a container without any memory constraints for the container then this option has +# no effect. If there is a memory constraint then `-Xms` is limited to the value set +# here. The default is 4096MB which means the calculated value of `-Xms` never will +# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") +# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output +# when things are happening. This option, if set to true, will set +# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). +# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: +# true"). +# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). +# - CONTAINER_CORE_LIMIT: A calculated core limit as described in +# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") +# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). +# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. +# (example: "20") +# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. +# (example: "40") +# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. +# (example: "4") +# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus +# previous GC times. (example: "90") +# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") +# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") +# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should +# contain the necessary JRE command-line options to specify the required GC, which +# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). +# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") +# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") +# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be +# accessed directly. (example: "foo.example.com,bar.example.com") +# +### +FROM registry.access.redhat.com/ubi8/openjdk-17:1.18 + +ENV LANGUAGE='en_US:en' + + +COPY target/lib/* /deployments/lib/ +COPY target/*-runner.jar /deployments/quarkus-run.jar + +EXPOSE 8080 +USER 185 +ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" + +ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] diff --git a/src/main/docker/Dockerfile.native b/src/main/docker/Dockerfile.native new file mode 100644 index 0000000..f022069 --- /dev/null +++ b/src/main/docker/Dockerfile.native @@ -0,0 +1,27 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. +# +# Before building the container image run: +# +# ./mvnw package -Dnative +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.native -t quarkus/message-beans . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/message-beans +# +### +FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9 +WORKDIR /work/ +RUN chown 1001 /work \ + && chmod "g+rwX" /work \ + && chown 1001:root /work +COPY --chown=1001:root target/*-runner /work/application + +EXPOSE 8080 +USER 1001 + +ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/src/main/docker/Dockerfile.native-micro b/src/main/docker/Dockerfile.native-micro new file mode 100644 index 0000000..e63c20e --- /dev/null +++ b/src/main/docker/Dockerfile.native-micro @@ -0,0 +1,30 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. +# It uses a micro base image, tuned for Quarkus native executables. +# It reduces the size of the resulting container image. +# Check https://quarkus.io/guides/quarkus-runtime-base-image for further information about this image. +# +# Before building the container image run: +# +# ./mvnw package -Dnative +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/message-beans . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/message-beans +# +### +FROM quay.io/quarkus/quarkus-micro-image:2.0 +WORKDIR /work/ +RUN chown 1001 /work \ + && chmod "g+rwX" /work \ + && chown 1001:root /work +COPY --chown=1001:root target/*-runner /work/application + +EXPOSE 8080 +USER 1001 + +ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/src/main/java/info/textgrid/middleware/ejb/Connect.java b/src/main/java/info/textgrid/middleware/ejb/Connect.java index 8ad16ce..813d80e 100644 --- a/src/main/java/info/textgrid/middleware/ejb/Connect.java +++ b/src/main/java/info/textgrid/middleware/ejb/Connect.java @@ -1,13 +1,7 @@ package info.textgrid.middleware.ejb; -import java.io.IOException; import java.io.InputStream; -import java.net.URISyntaxException; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.AuthFault; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.IoFault; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.MetadataParseFault; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.ObjectNotFoundFault; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.ProtocolNotImplementedFault; + /** * @@ -22,18 +16,8 @@ public interface Connect { /** * @param theUri * @return - * @throws MetadataParseFault - * @throws ObjectNotFoundFault - * @throws IoFault - * @throws AuthFault - * @throws ProtocolNotImplementedFault - * @throws IOException - * @throws URISyntaxException - * @throws NullPointerException */ - public InputStream getObjectData(String theUri) throws MetadataParseFault, ObjectNotFoundFault, - IoFault, AuthFault, ProtocolNotImplementedFault, IOException, NullPointerException, - URISyntaxException; + public InputStream getObjectData(String theUri); /** * @param key diff --git a/src/main/java/info/textgrid/middleware/ejb/DHConnectEJB.java b/src/main/java/info/textgrid/middleware/ejb/DHConnectEJB.java index 78af60c..a94e119 100644 --- a/src/main/java/info/textgrid/middleware/ejb/DHConnectEJB.java +++ b/src/main/java/info/textgrid/middleware/ejb/DHConnectEJB.java @@ -5,27 +5,22 @@ import java.io.IOException; import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; -import javax.ejb.Stateful; -import javax.ws.rs.core.Response; -import org.apache.cxf.helpers.IOUtils; -import org.jboss.resteasy.client.jaxrs.ResteasyClient; -import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.AuthFault; + +import org.eclipse.microprofile.rest.client.RestClientBuilder; + + import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.DHCrudService; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.IoFault; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.MetadataParseFault; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.ObjectNotFoundFault; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.ProtocolNotImplementedFault; - -/** - * - */ -@Stateful + +import jakarta.inject.Singleton; +import jakarta.ws.rs.core.Response; + +// TODO: is @Singleton OK?, was @Stateful before +@Singleton public class DHConnectEJB extends ConnectAbs { private static final String CLASS_NAME = "{DHConnectEJB} "; - private ResteasyClient rclient = new ResteasyClientBuilder().connectionPoolSize(100).build(); + //private RestClient rclient = new RestClientBuilder().connectionPoolSize(100).build(); /** * @param thePropertiesLocation @@ -49,13 +44,15 @@ public class DHConnectEJB extends ConnectAbs { public void getObjectData(String theUri, File theTempFile) throws IOException, NullPointerException, URISyntaxException { - DHCrudService dhclient = this.rclient.target(this.crudUrl.toURI()).proxy(DHCrudService.class); + // TODO: better initialize only once, and not on every operation + DHCrudService dhclient = RestClientBuilder.newBuilder().baseUri(this.crudUrl.toURI()).build(DHCrudService.class); Response response = dhclient.read(URI.create(theUri), 0l, "MB" + System.currentTimeMillis()); LOGGER.info(CLASS_NAME + "Retrieving data from " + theUri + ", storing to " + theTempFile); - IOUtils.transferTo(response.readEntity(InputStream.class), theTempFile); + // TODO! + // IOUtils.transferTo(response.readEntity(InputStream.class), theTempFile); response.close(); } @@ -80,9 +77,7 @@ public class DHConnectEJB extends ConnectAbs { * */ @Override - public InputStream getObjectData(String theUri) - throws MetadataParseFault, ObjectNotFoundFault, IoFault, AuthFault, - ProtocolNotImplementedFault, IOException, NullPointerException, URISyntaxException { + public InputStream getObjectData(String theUri) { // TODO Auto-generated method stub return null; } diff --git a/src/main/java/info/textgrid/middleware/ejb/TGConnect.java b/src/main/java/info/textgrid/middleware/ejb/TGConnect.java deleted file mode 100644 index 1df0877..0000000 --- a/src/main/java/info/textgrid/middleware/ejb/TGConnect.java +++ /dev/null @@ -1,182 +0,0 @@ -package info.textgrid.middleware.ejb; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.logging.Level; -import javax.activation.DataHandler; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.Form; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.xml.ws.Holder; -import info.textgrid.namespaces.metadata.core._2010.MetadataContainerType; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.AuthFault; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.IoFault; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.MetadataParseFault; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.ObjectNotFoundFault; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.ProtocolNotImplementedFault; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.TGCrudService; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.tgcrudclient.TGCrudClientUtilities; - -/** - * - */ -public class TGConnect extends ConnectAbs { - - private TGCrudService tgcrudclient; - private String sid; - private String textgridUser; - private String textgridPw; - private int count; - private URL webauthUrl; - private String authzInstance; - - /** - * @param thePropertiesLocation - */ - public TGConnect(String thePropertiesLocation) { - - this.propertiesLocation = thePropertiesLocation; - - init(); - - try { - this.tgcrudclient = TGCrudClientUtilities.getTgcrud(this.crudUrl.toString()); - - LOGGER.fine("New TG-crud HTTP client created: " + this.tgcrudclient.getVersion()); - - } catch (MalformedURLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** - * - */ - @Override - public void init() { - - super.init(); - - try { - this.textgridUser = this.properties.getProperty("textgrid.login"); - this.textgridPw = this.properties.getProperty("textgrid.password"); - this.webauthUrl = new URL(this.properties.getProperty("webauthUrl")); - this.authzInstance = this.properties.getProperty("authzinstance"); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** - * @param textgridUri - * @return - * @throws MetadataParseFault - * @throws ObjectNotFoundFault - * @throws IoFault - * @throws AuthFault - * @throws ProtocolNotImplementedFault - * @throws IOException - */ - @Override - public InputStream getObjectData(String textgridUri) throws MetadataParseFault, - ObjectNotFoundFault, IoFault, AuthFault, ProtocolNotImplementedFault, IOException { - - Holder<MetadataContainerType> metaHolder = new Holder<MetadataContainerType>(); - Holder<DataHandler> dataHolder = new Holder<DataHandler>(); - - this.tgcrudclient.read(getAuth(), "", textgridUri, metaHolder, dataHolder); - - return dataHolder.value.getInputStream(); - } - - /** - * @param key - * @return - */ - @Override - public String getProperty(String key) { - return this.properties.getProperty(key); - } - - /** - * @return - */ - @Override - public String getAuth() { - - LOGGER.fine("ejb-count:" + this.count); - this.count++; - - if (this.sid == null) { - this.sid = getSidFromAuth(); - } - - return this.sid; - } - - // ** - // PRIVATE METHODS - // ** - - /** - * @return - */ - private String getSidFromAuth() { - - if (this.textgridUser == null || this.textgridPw == null) { - LOGGER.info("no user or pw, assuming sidless operations"); - return ""; - } - - String sid = ""; - - try { - Form form = new Form(); - form.param("loginname", this.textgridUser); - form.param("password", this.textgridPw); - form.param("authZinstance", this.authzInstance); - - LOGGER.info( - "get sid for " + this.textgridUser + " / webauthurl: " + this.webauthUrl.toString()); - - Client client = ClientBuilder.newClient(); - - WebTarget target = - client.target(this.webauthUrl.getProtocol() + "://" + this.webauthUrl.getHost()) - .path(this.webauthUrl.getPath()); - - Response res = - target.request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); - - BufferedReader reader = - new BufferedReader(new InputStreamReader(res.readEntity(InputStream.class))); - - String line; - while ((line = reader.readLine()) != null) { - if (line.startsWith("<meta name=\"rbac_sessionid")) { - int cpos = line.indexOf("content="); - int bpos = line.indexOf("\"", cpos) + 1; - int epos = line.indexOf("\"", bpos); - sid = line.substring(bpos, epos); - break; - } - } - - } catch (IOException e) { - LOGGER.log(Level.SEVERE, "error getting sid ", e); - } - - return sid; - } - -} diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java index fd6837e..e7a0e0f 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java @@ -1,30 +1,22 @@ package info.textgrid.middleware.messagebeans; -import javax.ejb.ActivationConfigProperty; -import javax.ejb.MessageDriven; -import javax.jms.JMSException; -import javax.jms.Message; +import java.util.concurrent.CompletionStage; + +import org.eclipse.microprofile.reactive.messaging.Incoming; +import org.eclipse.microprofile.reactive.messaging.Message; + +import info.textgrid.middleware.model.CrudMessage; +import io.smallrye.reactive.messaging.annotations.Blocking; + -/** - * - */ -@MessageDriven(name = "DHAllMDB", activationConfig = { - @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/dhcrud"), - @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), - @ActivationConfigProperty(propertyName = "acknowledgeMode", - propertyValue = "Auto-acknowledge")}) public class DHAllMDB extends DHMessageBeanAbs { - /** - * - */ - @Override - public void onMessage(Message msg) { - try { - logMoreInfo(this.getClass().getSimpleName(), msg); - } catch (JMSException e) { - throw new RuntimeException(e); - } + @Incoming("crud") + @Blocking + CompletionStage<Void> onMessage (Message<CrudMessage> message) { + CrudMessage msg = fromMessage(message); + logMoreInfo(this.getClass().getSimpleName(), msg); + return message.ack(); } } diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java index 7128732..85b1305 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java @@ -8,15 +8,18 @@ import java.nio.file.FileSystems; import java.nio.file.Path; import java.nio.file.attribute.FileTime; import java.util.List; +import java.util.concurrent.CompletionStage; import java.util.logging.Level; -import javax.ejb.ActivationConfigProperty; -import javax.ejb.EJB; -import javax.ejb.MessageDriven; -import javax.jms.JMSException; -import javax.jms.Message; + import org.apache.commons.imaging.ImageReadException; +import org.eclipse.microprofile.reactive.messaging.Incoming; +import org.eclipse.microprofile.reactive.messaging.Message; + import info.textgrid.middleware.common.CrudOperations; import info.textgrid.middleware.ejb.DHConnectEJB; +import info.textgrid.middleware.model.CrudMessage; +import io.smallrye.reactive.messaging.annotations.Blocking; +import jakarta.inject.Inject; /** * Other selectors: @@ -25,29 +28,25 @@ import info.textgrid.middleware.ejb.DHConnectEJB; * "format LIKE 'image/%' AND operation=" + CrudOperations.CREATE)}) * */ -@MessageDriven(name = "DHDigilibPrescalerMDB", activationConfig = { - @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/dhcrud"), - @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), - @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), - @ActivationConfigProperty(propertyName = "messageSelector", - propertyValue = "format LIKE 'image/%'")}) public class DHDigilibPrescalerMDB extends DHMessageBeanAbs { - @EJB - private DHConnectEJB dhconnect; + @Inject + DHConnectEJB dhconnect; private static final String CLASS_NAME = "{DHDigilibPrescalerMDB} "; - /** - * - */ - @Override - public void onMessage(Message msg) { + @Incoming("crud") + @Blocking + CompletionStage<Void> onMessage(Message<CrudMessage> message) { - try { - int operation = msg.getIntProperty(OPERATION_KEY); - String uri = msg.getStringProperty(uriKey); - boolean isPublic = msg.getBooleanProperty(PUBLIC_KEY); + CrudMessage msg = fromMessage(message); + + // TODO: there was a selector on format in jms before, is this still possible? + // -> was @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "format LIKE 'image/%'")}) + if(msg.getFormat().startsWith("image/")) { + int operation = msg.getOperation(); + String uri = msg.getObjectId(); + boolean isPublic = msg.isPublic(); switch (operation) { case CrudOperations.CREATE: @@ -67,9 +66,9 @@ public class DHDigilibPrescalerMDB extends DHMessageBeanAbs { + " on " + uri); break; } - } catch (JMSException e) { - LOGGER.log(Level.SEVERE, CLASS_NAME + "Error recieving message from dhcrud", e); } + return message.ack(); + } // ** diff --git a/src/main/java/info/textgrid/middleware/messagebeans/MessageBeanAbs.java b/src/main/java/info/textgrid/middleware/messagebeans/MessageBeanAbs.java index 80fec65..639bfce 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/MessageBeanAbs.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/MessageBeanAbs.java @@ -10,19 +10,18 @@ import java.util.ArrayList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageListener; import org.apache.commons.imaging.ImageInfo; import org.apache.commons.imaging.ImageReadException; import org.apache.commons.imaging.Imaging; +import org.eclipse.microprofile.reactive.messaging.Message; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + import info.textgrid.middleware.common.CachingUtils; -import info.textgrid.middleware.common.CrudOperations; +import info.textgrid.middleware.model.CrudMessage; -/** - * - */ -public abstract class MessageBeanAbs implements MessageListener { +public abstract class MessageBeanAbs { private static final String CLASS_NAME = "{MessageBeanAbs} "; protected static final String PRESCALE_PATH = "/var/dhrep/digilib/prescale/"; @@ -47,30 +46,36 @@ public abstract class MessageBeanAbs implements MessageListener { protected static String rootIdKey; protected static String jmsTypeKey; + + CrudMessage fromMessage(Message msg) { + return fromString((String) msg.getPayload()); + } + + CrudMessage fromString(String jsonString) { + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.readValue(jsonString, CrudMessage.class); + } catch (JsonProcessingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return new CrudMessage(); + } + /** * @param theClassName * @param theMessage - * @throws JMSException */ - protected void logGeneralInfo(String theClassName, Message theMessage) throws JMSException { - String message = "[" + jmsTypeKey + " > " + uriKey + "=" + theMessage.getStringProperty(uriKey) - + " | " + OPERATION_KEY + "=" - + CrudOperations.getName(theMessage.getIntProperty(OPERATION_KEY)) + "]"; - LOGGER.info("{" + theClassName + "} " + RECEIVED + message); + protected void logGeneralInfo(String theClassName, CrudMessage theMessage) { + LOGGER.info("{" + theClassName + "} " + RECEIVED + theMessage); } /** * @param theClassName * @param theMessage - * @throws JMSException */ - protected void logMoreInfo(String theClassName, Message theMessage) throws JMSException { - String message = "[" + jmsTypeKey + " > " + uriKey + "=" + theMessage.getStringProperty(uriKey) - + " | " + rootIdKey + "=" + theMessage.getStringProperty(rootIdKey) + " | " + OPERATION_KEY - + "=" + CrudOperations.getName(theMessage.getIntProperty(OPERATION_KEY)) + " | " - + FORMAT_KEY + "=" + theMessage.getStringProperty(FORMAT_KEY) + " | " + PUBLIC_KEY + "=" - + theMessage.getBooleanProperty(PUBLIC_KEY) + "]"; - LOGGER.info("{" + theClassName + "} " + RECEIVED + message); + protected void logMoreInfo(String theClassName, CrudMessage theMessage) { + LOGGER.info("{" + theClassName + "} " + RECEIVED + theMessage); } /** diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java index b885d41..54b202a 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java @@ -1,30 +1,23 @@ package info.textgrid.middleware.messagebeans; -import javax.ejb.ActivationConfigProperty; -import javax.ejb.MessageDriven; -import javax.jms.JMSException; -import javax.jms.Message; +import java.util.concurrent.CompletionStage; +import org.eclipse.microprofile.reactive.messaging.Incoming; +import org.eclipse.microprofile.reactive.messaging.Message; + +import info.textgrid.middleware.model.CrudMessage; +import io.smallrye.reactive.messaging.annotations.Blocking; -/** - * - */ -@MessageDriven(name = "TGAllMDB", activationConfig = { - @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/tgcrud"), - @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), - @ActivationConfigProperty(propertyName = "acknowledgeMode", - propertyValue = "Auto-acknowledge")}) public class TGAllMDB extends TGMessageBeanAbs { - /** - * - */ - @Override - public void onMessage(Message msg) { - try { - logMoreInfo(this.getClass().getSimpleName(), msg); - } catch (JMSException e) { - throw new RuntimeException(e); - } + @Incoming("crud") + @Blocking + CompletionStage<Void> onMessage (Message message) { + + CrudMessage msg = fromMessage(message); + logMoreInfo(this.getClass().getSimpleName(), msg); + System.out.println("[%s] message received".formatted(this.getClass().getCanonicalName())); + System.out.println(message.getPayload()); + return message.ack(); } } diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java index 54f9103..b9607f0 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java @@ -7,14 +7,17 @@ import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.attribute.FileTime; +import java.util.concurrent.CompletionStage; import java.util.logging.Level; -import javax.ejb.ActivationConfigProperty; -import javax.ejb.MessageDriven; -import javax.jms.JMSException; -import javax.jms.Message; + import org.apache.commons.imaging.ImageReadException; +import org.eclipse.microprofile.reactive.messaging.Incoming; +import org.eclipse.microprofile.reactive.messaging.Message; + import info.textgrid.middleware.common.CrudOperations; import info.textgrid.middleware.common.JPairtree; +import info.textgrid.middleware.model.CrudMessage; +import io.smallrye.reactive.messaging.annotations.Blocking; /** * Other selectors: @@ -22,28 +25,25 @@ import info.textgrid.middleware.common.JPairtree; * ...from TGImageMDB: @ActivationConfigProperty(propertyName = "messageSelector",propertyValue = * "format LIKE 'image/%' AND operation=" + CrudOperations.CREATE)}) */ -@MessageDriven(name = "TGDigilibPrescalerMDB", activationConfig = { - @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/tgcrud"), - @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), - @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), - @ActivationConfigProperty(propertyName = "messageSelector", - propertyValue = "format LIKE 'image/%'")}) public class TGDigilibPrescalerMDB extends TGMessageBeanAbs { private static final String PUBLIC_STORAGE_PATH = "/data/public/productive/"; private static final String NONPUBLIC_STORAGE_PATH = "/data/nonpublic/productive/"; private static final String CLASS_NAME = "{TGDigilibPrescalerMDB} "; - /** - * - */ - @Override - public void onMessage(Message msg) { + @Incoming("crud") + @Blocking + CompletionStage<Void> onMessage(Message<CrudMessage> message) { - try { - int operation = msg.getIntProperty(OPERATION_KEY); - String uri = msg.getStringProperty(uriKey); - boolean isPublic = msg.getBooleanProperty(PUBLIC_KEY); + CrudMessage msg = fromMessage(message); + + // TODO: there was a selector on format in jms before, is this still possible? + // -> was @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "format LIKE 'image/%'")}) + if(msg.getFormat().startsWith("image/")) { + + int operation = msg.getOperation(); + String uri = msg.getObjectId(); + boolean isPublic = msg.isPublic(); switch (operation) { case CrudOperations.CREATE: @@ -66,11 +66,8 @@ public class TGDigilibPrescalerMDB extends TGMessageBeanAbs { + " on " + uri); break; } - - } catch (JMSException e) { - LOGGER.log(Level.SEVERE, CLASS_NAME + "Error recieving message from tgcrud", e); - } - + } + return message.ack(); } /** diff --git a/src/main/java/info/textgrid/middleware/model/CrudMessage.java b/src/main/java/info/textgrid/middleware/model/CrudMessage.java new file mode 100644 index 0000000..01ab007 --- /dev/null +++ b/src/main/java/info/textgrid/middleware/model/CrudMessage.java @@ -0,0 +1,70 @@ +package info.textgrid.middleware.model; + +import io.quarkus.runtime.annotations.RegisterForReflection; + +@RegisterForReflection +public class CrudMessage { + + public String objectId; // tguri for tg, pid for dh + public int operation; + public String format; + public String rootId; // collectionId for dh, projectId for tg + public boolean isPublic; + + /** + * Default constructor required for Jackson serializer + */ + public CrudMessage() { } + + @Override + public String toString() { + return "CrudMessage{objectId='%s', operation='%d', format='%s', rootId='%s', public='%b'}" + .formatted(objectId, operation, format, rootId, isPublic); + } + + public String getObjectId() { + return objectId; + } + + public CrudMessage setObjectId(String objectId) { + this.objectId = objectId; + return this; + } + + public int getOperation() { + return operation; + } + + public CrudMessage setOperation(int operation) { + this.operation = operation; + return this; + } + + public String getFormat() { + return format; + } + + public CrudMessage setFormat(String format) { + this.format = format; + return this; + } + + public String getRootId() { + return rootId; + } + + public CrudMessage setRootId(String rootId) { + this.rootId = rootId; + return this; + } + + public boolean isPublic() { + return isPublic; + } + + public CrudMessage setPublic(boolean isPublic) { + this.isPublic = isPublic; + return this; + } +} + diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..968c48f --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,15 @@ +# Configure the incoming RabbitMQ queue +#mp.messaging.incoming.crud.queue.name=crud-events +#mp.messaging.incoming.crud.exchange.name=crud-exchange + +#quarkus.rabbitmq.devservices.port=5672 + +# Set the AMQP address for the `crud` channel, as it's not the channel name +mp.messaging.incoming.crud.address=crud-events + +# TooManyDownstreamCandidatesException: 'IncomingConnector{channel:'crud', attribute:'mp.messaging.incoming.crud'}' +# supports a single downstream consumer, but found 4: [SubscriberMethod{method:'onMessage', incoming:'crud'}, +# SubscriberMethod{method:'onMessage', incoming:'crud'}, SubscriberMethod{method:'onMessage', incoming:'crud'}, +# SubscriberMethod{method:'onMessage', incoming:'crud'}]. +# You may want to enable broadcast using 'mp.messaging.incoming.crud.broadcast=true' + to allow multiple downstreams. +mp.messaging.incoming.crud.broadcast=true \ No newline at end of file diff --git a/src/main/resources/enzyklops-adapter.xsl b/src/main/resources/enzyklops-adapter.xsl deleted file mode 100644 index b3a028c..0000000 --- a/src/main/resources/enzyklops-adapter.xsl +++ /dev/null @@ -1,43 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:xs="http://www.w3.org/2001/XMLSchema" - xmlns:fn="http://textgrid.info/namespace/xslt/functions" - xpath-default-namespace="http://www.tei-c.org/ns/1.0" - exclude-result-prefixes="xs" - version="2.0"> - -<xsl:output media-type="text/json" method="text" encoding="UTF-8"/> - -<xsl:template match="/"> -{"fulltext_structured" : - [ <xsl:apply-templates/> ] -} -</xsl:template> - -<xsl:template match="text()"> - <xsl:if test="normalize-space(.) != ''"> - <xsl:message>Da ist text wo er nicht sein soll: »<xsl:copy-of select="."/>«</xsl:message> - </xsl:if> -</xsl:template> - -<xsl:template match="*[not(descendant-or-self::div[@type='entry'][head])]"> - { "fulltext": "<xsl:value-of select="fn:escape-json-string(.)"/>" } - <xsl:if test="following::div[@type='entry'][head] | following::*[not(descendant-or-self::div[@type='entry'][head])]">,</xsl:if> -</xsl:template> - -<xsl:template match="div[@type='entry'][head]"> - { - "title": "<xsl:value-of select="fn:escape-json-string(head[1])"/>", - "id": "<xsl:value-of select="@xml:id"/>", - "fulltext": "<xsl:value-of select="fn:escape-json-string(.)"/>" - } - - <xsl:if test="following::div[@type='entry'][head] | following::*[not(descendant-or-self::div[@type='entry'][head])]">,</xsl:if> -</xsl:template> - -<xsl:function name="fn:escape-json-string" as="xs:string"> - <xsl:param name="input" as="xs:string"/> - <xsl:variable name="stage1" select='replace($input, "\\", "\\\\")'/> <!-- \ → \\ --> - <xsl:value-of select="normalize-space(replace($stage1, '"', '\\"'))"/> <!-- " → \" --> -</xsl:function> -</xsl:stylesheet> diff --git a/src/main/webapp/WEB-INF/beans.xml b/src/main/webapp/WEB-INF/beans.xml deleted file mode 100644 index 3925cb3..0000000 --- a/src/main/webapp/WEB-INF/beans.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- JBoss, Home of Professional Open Source Copyright 2013, Red Hat, Inc. - and/or its affiliates, and individual contributors by the @authors tag. See - the copyright.txt in the distribution for a full listing of individual contributors. - 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 http://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. --> -<!-- This file can be an empty text file (0 bytes) --> -<!-- We're declaring the schema to save you time if you do have to configure - this in the future --> -<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" - bean-discovery-mode="annotated"> -</beans> diff --git a/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java b/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java index d8b4160..9355323 100644 --- a/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java +++ b/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java @@ -5,13 +5,12 @@ import java.nio.file.FileSystems; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; -import org.junit.Test; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; -/** - * - */ -public class TestMessageBeanAbs extends TestCase { +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class TestMessageBeanAbs { /** * @@ -26,7 +25,6 @@ public class TestMessageBeanAbs extends TestCase { String filename = MessageBeanAbs.getPrescaleFilenameOnly(uri); if (!filename.equals(expectedFilename)) { System.out.println(filename + " != " + expectedFilename); - assertFalse(true); } } -- GitLab From acc6cc79d4e8ef5e92761adf5fd3c1663f786fc8 Mon Sep 17 00:00:00 2001 From: Ubbo Veentjer <veentjer@sub.uni-goettingen.de> Date: Wed, 20 Dec 2023 21:36:04 +0100 Subject: [PATCH 05/58] build(docker): add missing multistage maven build dockerfile --- src/main/docker/Dockerfile.jvm-multistage | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/docker/Dockerfile.jvm-multistage diff --git a/src/main/docker/Dockerfile.jvm-multistage b/src/main/docker/Dockerfile.jvm-multistage new file mode 100644 index 0000000..af9efce --- /dev/null +++ b/src/main/docker/Dockerfile.jvm-multistage @@ -0,0 +1,26 @@ +## Stage 1 : build with maven builder image +FROM maven:3.8.7-eclipse-temurin-17 as build +COPY . /code/ +WORKDIR /code +RUN --mount=type=cache,target=/root/.m2 mvn clean package + + +## Stage 2 : create the docker final image +FROM registry.access.redhat.com/ubi8/openjdk-17:1.18 + +ENV LANGUAGE='en_US:en' + + +# We make four distinct layers so if there are application changes the library layers can be re-used +COPY --from=build --chown=185 /code/target/quarkus-app/lib/ /deployments/lib/ +COPY --from=build --chown=185 /code/target/quarkus-app/*.jar /deployments/ +COPY --from=build --chown=185 /code/target/quarkus-app/app/ /deployments/app/ +COPY --from=build --chown=185 /code/target/quarkus-app/quarkus/ /deployments/quarkus/ + +EXPOSE 8080 +USER 185 +ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" + +ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] + -- GitLab From 004d70b152d581fc825c6fbf678f9246e01a69cc Mon Sep 17 00:00:00 2001 From: Ubbo Veentjer <veentjer@sub.uni-goettingen.de> Date: Wed, 20 Dec 2023 21:42:41 +0100 Subject: [PATCH 06/58] ci(gitlab): use maven image with jdk17 --- .gitlab-ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fd1c571..a9fc001 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,6 +11,7 @@ variables: # Maven deployment settings for Nexus, please use env vars in Settings -> CI/CD -> Variables. MAVEN_SETTINGS_PATH: ".m2/settings.xml" MAVEN_DEPLOY_OPTS: "--settings=$MAVEN_SETTINGS_PATH" + MAVEN_IMAGE: "maven:3.8.7-eclipse-temurin-17" # Semantic versioning commit and push vars (the TOKEN name and user) GIT_AUTHOR_EMAIL: ${GL_USER}@noreply.gitlab.gwdg.de GIT_AUTHOR_NAME: ${GL_USER} @@ -61,7 +62,7 @@ prepare-release: rules: # Only run if branch "main" AND commit title IS NOT "1.2.3" (main commit with tag) AND DOES NOT START WITH "Prepare next development iteration" (main commit with new version) - if: $CI_COMMIT_REF_NAME == "main" && $CI_COMMIT_TITLE !~ /^[\d\.]+$/ && $CI_COMMIT_TITLE !~ /^Prepare next development iteration/ - image: maven:3.8.3-jdk-8 + image: $MAVEN_IMAGE extends: - .prepare-semantic-release @@ -72,7 +73,7 @@ validate-java: - main - develop - tags - image: maven:3.8.3-jdk-8 + image: $MAVEN_IMAGE script: - mvn $MAVEN_OPTS $MAVEN_CLI_OPTS $MAVEN_DEPLOY_OPTS -U clean validate package artifacts: @@ -85,7 +86,7 @@ validate-java: # NOTE: "deploy" also triggers BOM creation! build-and-deploy-jars: stage: test-build-deploy-maven - image: maven:3.8.3-jdk-8 + image: $MAVEN_IMAGE only: - develop - tags -- GitLab From 94d1adeee1b1a056df7a01381912a804174d98a6 Mon Sep 17 00:00:00 2001 From: Ubbo Veentjer <veentjer@sub.uni-goettingen.de> Date: Wed, 20 Dec 2023 21:54:36 +0100 Subject: [PATCH 07/58] build(docker): native image build --- .gitlab-ci.yml | 2 +- .mvn/wrapper/.gitignore | 1 + .mvn/wrapper/MavenWrapperDownloader.java | 98 ++++++ .mvn/wrapper/maven-wrapper.properties | 18 + mvnw | 308 ++++++++++++++++++ .../docker/Dockerfile.native-micro-multistage | 14 + 6 files changed, 440 insertions(+), 1 deletion(-) create mode 100644 .mvn/wrapper/.gitignore create mode 100644 .mvn/wrapper/MavenWrapperDownloader.java create mode 100644 .mvn/wrapper/maven-wrapper.properties create mode 100755 mvnw create mode 100644 src/main/docker/Dockerfile.native-micro-multistage diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a9fc001..d29f345 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ variables: GIT_AUTHOR_NAME: ${GL_USER} GIT_COMMITTER_EMAIL: ${GL_USER}@noreply.gitlab.gwdg.de GIT_COMMITTER_NAME: ${GL_USER} - DOCKERFILE: $CI_PROJECT_DIR/src/main/docker/Dockerfile.jvm-multistage + DOCKERFILE: $CI_PROJECT_DIR/src/main/docker/Dockerfile.native-micro-multistage # Include Java settings from Gitlab templates repo. include: diff --git a/.mvn/wrapper/.gitignore b/.mvn/wrapper/.gitignore new file mode 100644 index 0000000..e72f5e8 --- /dev/null +++ b/.mvn/wrapper/.gitignore @@ -0,0 +1 @@ +maven-wrapper.jar diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000..84d1e60 --- /dev/null +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * http://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. + */ + +import java.io.IOException; +import java.io.InputStream; +import java.net.Authenticator; +import java.net.PasswordAuthentication; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; + +public final class MavenWrapperDownloader +{ + private static final String WRAPPER_VERSION = "3.2.0"; + + private static final boolean VERBOSE = Boolean.parseBoolean( System.getenv( "MVNW_VERBOSE" ) ); + + public static void main( String[] args ) + { + log( "Apache Maven Wrapper Downloader " + WRAPPER_VERSION ); + + if ( args.length != 2 ) + { + System.err.println( " - ERROR wrapperUrl or wrapperJarPath parameter missing" ); + System.exit( 1 ); + } + + try + { + log( " - Downloader started" ); + final URL wrapperUrl = new URL( args[0] ); + final String jarPath = args[1].replace( "..", "" ); // Sanitize path + final Path wrapperJarPath = Paths.get( jarPath ).toAbsolutePath().normalize(); + downloadFileFromURL( wrapperUrl, wrapperJarPath ); + log( "Done" ); + } + catch ( IOException e ) + { + System.err.println( "- Error downloading: " + e.getMessage() ); + if ( VERBOSE ) + { + e.printStackTrace(); + } + System.exit( 1 ); + } + } + + private static void downloadFileFromURL( URL wrapperUrl, Path wrapperJarPath ) + throws IOException + { + log( " - Downloading to: " + wrapperJarPath ); + if ( System.getenv( "MVNW_USERNAME" ) != null && System.getenv( "MVNW_PASSWORD" ) != null ) + { + final String username = System.getenv( "MVNW_USERNAME" ); + final char[] password = System.getenv( "MVNW_PASSWORD" ).toCharArray(); + Authenticator.setDefault( new Authenticator() + { + @Override + protected PasswordAuthentication getPasswordAuthentication() + { + return new PasswordAuthentication( username, password ); + } + } ); + } + try ( InputStream inStream = wrapperUrl.openStream() ) + { + Files.copy( inStream, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING ); + } + log( " - Downloader complete" ); + } + + private static void log( String msg ) + { + if ( VERBOSE ) + { + System.out.println( msg ); + } + } + +} diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..346d645 --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 +# +# http://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. +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar diff --git a/mvnw b/mvnw new file mode 100755 index 0000000..8d937f4 --- /dev/null +++ b/mvnw @@ -0,0 +1,308 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 +# +# http://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. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.2.0 +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "$(uname)" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME + else + JAVA_HOME="/Library/Java/Home"; export JAVA_HOME + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=$(java-config --jre-home) + fi +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --unix "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --unix "$CLASSPATH") +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] && + JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="$(which javac)" + if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=$(which readlink) + if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then + if $darwin ; then + javaHome="$(dirname "\"$javaExecutable\"")" + javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac" + else + javaExecutable="$(readlink -f "\"$javaExecutable\"")" + fi + javaHome="$(dirname "\"$javaExecutable\"")" + javaHome=$(expr "$javaHome" : '\(.*\)/bin') + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + 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 + else + JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=$(cd "$wdir/.." || exit 1; pwd) + fi + # end of workaround + done + printf '%s' "$(cd "$basedir" || exit 1; pwd)" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + # Remove \r in case we run on Windows within Git Bash + # and check out the repository with auto CRLF management + # enabled. Otherwise, we may read lines that are delimited with + # \r\n and produce $'-Xarg\r' rather than -Xarg due to word + # splitting rules. + tr -s '\r\n' ' ' < "$1" + fi +} + +log() { + if [ "$MVNW_VERBOSE" = true ]; then + printf '%s\n' "$1" + fi +} + +BASE_DIR=$(find_maven_basedir "$(dirname "$0")") +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR +log "$MAVEN_PROJECTBASEDIR" + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" +if [ -r "$wrapperJarPath" ]; then + log "Found $wrapperJarPath" +else + log "Couldn't find $wrapperJarPath, downloading it ..." + + if [ -n "$MVNW_REPOURL" ]; then + wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + else + wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + fi + while IFS="=" read -r key value; do + # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) + safeValue=$(echo "$value" | tr -d '\r') + case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;; + esac + done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" + log "Downloading from: $wrapperUrl" + + if $cygwin; then + wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + fi + + if command -v wget > /dev/null; then + log "Found wget ... using wget" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + log "Found curl ... using curl" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + else + curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + fi + else + log "Falling back to using Java to download" + javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" + javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaSource=$(cygpath --path --windows "$javaSource") + javaClass=$(cygpath --path --windows "$javaClass") + fi + if [ -e "$javaSource" ]; then + if [ ! -e "$javaClass" ]; then + log " - Compiling MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/javac" "$javaSource") + fi + if [ -e "$javaClass" ]; then + log " - Running MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +# If specified, validate the SHA-256 sum of the Maven wrapper jar file +wrapperSha256Sum="" +while IFS="=" read -r key value; do + case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; + esac +done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" +if [ -n "$wrapperSha256Sum" ]; then + wrapperSha256Result=false + if command -v sha256sum > /dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then + wrapperSha256Result=true + fi + elif command -v shasum > /dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then + wrapperSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." + echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." + exit 1 + fi + if [ $wrapperSha256Result = false ]; then + echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 + echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 + echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 + exit 1 + fi +fi + +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --windows "$CLASSPATH") + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +# shellcheck disable=SC2086 # safe args +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/src/main/docker/Dockerfile.native-micro-multistage b/src/main/docker/Dockerfile.native-micro-multistage new file mode 100644 index 0000000..e74a7ff --- /dev/null +++ b/src/main/docker/Dockerfile.native-micro-multistage @@ -0,0 +1,14 @@ +## Stage 1 : build with maven builder image with native capabilities +FROM quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-17 AS build +USER root +COPY . /code/ +WORKDIR /code +RUN --mount=type=cache,target=/root/.m2 ./mvnw clean package -Dnative + +## Stage 2 : create the docker final image +FROM quay.io/quarkus/quarkus-micro-image:2.0 +WORKDIR /work/ +COPY --from=build /code/target/*-runner /work/application +RUN chmod 775 /work +EXPOSE 8080 +CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] \ No newline at end of file -- GitLab From 58ee37027b5a6837d5b38a7ab83a97045b1c3c15 Mon Sep 17 00:00:00 2001 From: Ubbo Veentjer <veentjer@sub.uni-goettingen.de> Date: Wed, 20 Dec 2023 22:03:11 +0100 Subject: [PATCH 08/58] build(maven): next version is 4.0.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f235ef2..a7904c4 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>info.textgrid.middleware</groupId> <artifactId>message-beans</artifactId> - <version>1.0.0-SNAPSHOT</version> + <version>4.0.0-SNAPSHOT</version> <properties> <compiler-plugin.version>3.11.0</compiler-plugin.version> <maven.compiler.release>17</maven.compiler.release> -- GitLab From f853d510d7401d6830e6408306b556e92aa360c4 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Wed, 24 Jan 2024 18:23:41 +0100 Subject: [PATCH 09/58] fix: clean some code and prepare for dh and tg crud message cofiguration --- .gitignore | 1 + pom.xml | 340 +++++++++--------- .../middleware/messagebeans/DHAllMDB.java | 21 +- .../messagebeans/DHDigilibPrescalerMDB.java | 20 +- .../messagebeans/DHMessageBeanAbs.java | 17 - .../messagebeans/MessageBeanAbs.java | 60 +--- .../middleware/messagebeans/TGAllMDB.java | 12 +- .../messagebeans/TGDigilibPrescalerMDB.java | 18 +- .../messagebeans/TGMessageBeanAbs.java | 9 - .../middleware/model/CrudMessage.java | 168 +++++---- src/main/resources/application.properties | 3 +- 11 files changed, 338 insertions(+), 331 deletions(-) delete mode 100644 src/main/java/info/textgrid/middleware/messagebeans/DHMessageBeanAbs.java diff --git a/.gitignore b/.gitignore index 10d81e8..0776b38 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /.project /.settings/ /target/ +/node_modules/ diff --git a/pom.xml b/pom.xml index a7904c4..c004837 100644 --- a/pom.xml +++ b/pom.xml @@ -1,172 +1,174 @@ <?xml version="1.0"?> -<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <modelVersion>4.0.0</modelVersion> - <groupId>info.textgrid.middleware</groupId> - <artifactId>message-beans</artifactId> - <version>4.0.0-SNAPSHOT</version> - <properties> - <compiler-plugin.version>3.11.0</compiler-plugin.version> - <maven.compiler.release>17</maven.compiler.release> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id> - <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id> - <quarkus.platform.version>3.6.3</quarkus.platform.version> - <skipITs>true</skipITs> - <surefire-plugin.version>3.1.2</surefire-plugin.version> - <common.version>4.0.1</common.version> - <commons-imaging.version>1.0-alpha3</commons-imaging.version> - <crud.version>11.9.5-SNAPSHOT</crud.version> - </properties> - <repositories> - <repository> - <id>maven-dariah-public</id> - <name>GWDG Nexus DARIAH-DE Repository</name> - <url>https://nexus.gwdg.de/repository/maven-dariah-public/</url> - </repository> - </repositories> - <dependencyManagement> - <dependencies> - <dependency> - <groupId>${quarkus.platform.group-id}</groupId> - <artifactId>${quarkus.platform.artifact-id}</artifactId> - <version>${quarkus.platform.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> - <dependencies> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-smallrye-reactive-messaging-amqp</artifactId> - <!--<artifactId>quarkus-smallrye-reactive-messaging-rabbitmq</artifactId>--> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-arc</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-rest-client-reactive-jaxb</artifactId> - </dependency> - <dependency> - <groupId>info.textgrid.middleware</groupId> - <artifactId>cacheutils</artifactId> - <version>${common.version}</version> - </dependency> - <dependency> - <groupId>info.textgrid.middleware</groupId> - <artifactId>const</artifactId> - <version>${common.version}</version> - </dependency> - <dependency> - <groupId>info.textgrid.middleware</groupId> - <artifactId>dhcrud-api</artifactId> - <version>${crud.version}</version> - <exclusions> - <!-- Exclude frontend-jaxrs due to Wildfly deployment dependency problems +<project + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <groupId>info.textgrid.middleware</groupId> + <artifactId>message-beans</artifactId> + <version>4.0.0-SNAPSHOT</version> + <properties> + <compiler-plugin.version>3.11.0</compiler-plugin.version> + <maven.compiler.release>17</maven.compiler.release> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id> + <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id> + <quarkus.platform.version>3.6.3</quarkus.platform.version> + <skipITs>true</skipITs> + <surefire-plugin.version>3.1.2</surefire-plugin.version> + <common.version>5.0.1-SNAPSHOT</common.version> + <commons-imaging.version>1.0-alpha3</commons-imaging.version> + <crud.version>11.9.5-SNAPSHOT</crud.version> + </properties> + <repositories> + <repository> + <id>maven-dariah-public</id> + <name>GWDG Nexus DARIAH-DE Repository</name> + <url>https://nexus.gwdg.de/repository/maven-dariah-public/</url> + </repository> + </repositories> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>${quarkus.platform.group-id}</groupId> + <artifactId>${quarkus.platform.artifact-id}</artifactId> + <version>${quarkus.platform.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + <dependencies> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-smallrye-reactive-messaging-amqp</artifactId> + <!--<artifactId>quarkus-smallrye-reactive-messaging-rabbitmq</artifactId> --> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-arc</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-rest-client-reactive-jaxb</artifactId> + </dependency> + <dependency> + <groupId>info.textgrid.middleware</groupId> + <artifactId>cacheutils</artifactId> + <version>${common.version}</version> + </dependency> + <dependency> + <groupId>info.textgrid.middleware</groupId> + <artifactId>const</artifactId> + <version>${common.version}</version> + </dependency> + <dependency> + <groupId>info.textgrid.middleware</groupId> + <artifactId>dhcrud-api</artifactId> + <version>${crud.version}</version> + <exclusions> + <!-- Exclude frontend-jaxrs due to Wildfly deployment dependency problems in JBoss. --> - <exclusion> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-frontend-jaxrs</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-transports-http</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-rs-client</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>info.textgrid.middleware</groupId> - <artifactId>jpairtree</artifactId> - <version>${common.version}</version> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-imaging</artifactId> - <version>${commons-imaging.version}</version> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-junit5</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>${quarkus.platform.group-id}</groupId> - <artifactId>quarkus-maven-plugin</artifactId> - <version>${quarkus.platform.version}</version> - <extensions>true</extensions> - <executions> - <execution> - <goals> - <goal>build</goal> - <goal>generate-code</goal> - <goal>generate-code-tests</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <version>${compiler-plugin.version}</version> - <configuration> - <compilerArgs> - <arg>-parameters</arg> - </compilerArgs> - </configuration> - </plugin> - <plugin> - <artifactId>maven-surefire-plugin</artifactId> - <version>${surefire-plugin.version}</version> - <configuration> - <systemPropertyVariables> - <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> - <maven.home>${maven.home}</maven.home> - </systemPropertyVariables> - </configuration> - </plugin> - <plugin> - <artifactId>maven-failsafe-plugin</artifactId> - <version>${surefire-plugin.version}</version> - <executions> - <execution> - <goals> - <goal>integration-test</goal> - <goal>verify</goal> - </goals> - </execution> - </executions> - <configuration> - <systemPropertyVariables> - <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> - <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> - <maven.home>${maven.home}</maven.home> - </systemPropertyVariables> - </configuration> - </plugin> - </plugins> - </build> - <profiles> - <profile> - <id>native</id> - <activation> - <property> - <name>native</name> - </property> - </activation> - <properties> - <skipITs>false</skipITs> - <quarkus.package.type>native</quarkus.package.type> - </properties> - </profile> - </profiles> + <exclusion> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-client</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>info.textgrid.middleware</groupId> + <artifactId>jpairtree</artifactId> + <version>${common.version}</version> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-imaging</artifactId> + <version>${commons-imaging.version}</version> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>${quarkus.platform.group-id}</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <version>${quarkus.platform.version}</version> + <extensions>true</extensions> + <executions> + <execution> + <goals> + <goal>build</goal> + <goal>generate-code</goal> + <goal>generate-code-tests</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>${compiler-plugin.version}</version> + <configuration> + <compilerArgs> + <arg>-parameters</arg> + </compilerArgs> + </configuration> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire-plugin.version}</version> + <configuration> + <systemPropertyVariables> + <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> + <maven.home>${maven.home}</maven.home> + </systemPropertyVariables> + </configuration> + </plugin> + <plugin> + <artifactId>maven-failsafe-plugin</artifactId> + <version>${surefire-plugin.version}</version> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + <configuration> + <systemPropertyVariables> + <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> + <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> + <maven.home>${maven.home}</maven.home> + </systemPropertyVariables> + </configuration> + </plugin> + </plugins> + </build> + <profiles> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <properties> + <skipITs>false</skipITs> + <quarkus.package.type>native</quarkus.package.type> + </properties> + </profile> + </profiles> </project> diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java index e7a0e0f..5eddc83 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java @@ -1,21 +1,30 @@ package info.textgrid.middleware.messagebeans; import java.util.concurrent.CompletionStage; - import org.eclipse.microprofile.reactive.messaging.Incoming; import org.eclipse.microprofile.reactive.messaging.Message; - import info.textgrid.middleware.model.CrudMessage; import io.smallrye.reactive.messaging.annotations.Blocking; +/** + * + */ +public class DHAllMDB extends MessageBeanAbs { -public class DHAllMDB extends DHMessageBeanAbs { - + /** + * @param message + * @return + */ @Incoming("crud") - @Blocking - CompletionStage<Void> onMessage (Message<CrudMessage> message) { + @Blocking + CompletionStage<Void> onMessage(Message<CrudMessage> message) { + CrudMessage msg = fromMessage(message); logMoreInfo(this.getClass().getSimpleName(), msg); + + System.out.println("[%s] message received".formatted(this.getClass().getCanonicalName())); + System.out.println(message.getPayload()); + return message.ack(); } diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java index 85b1305..c57592a 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java @@ -10,11 +10,9 @@ import java.nio.file.attribute.FileTime; import java.util.List; import java.util.concurrent.CompletionStage; import java.util.logging.Level; - import org.apache.commons.imaging.ImageReadException; import org.eclipse.microprofile.reactive.messaging.Incoming; import org.eclipse.microprofile.reactive.messaging.Message; - import info.textgrid.middleware.common.CrudOperations; import info.textgrid.middleware.ejb.DHConnectEJB; import info.textgrid.middleware.model.CrudMessage; @@ -22,19 +20,22 @@ import io.smallrye.reactive.messaging.annotations.Blocking; import jakarta.inject.Inject; /** - * Other selectors: + * Other selectors? * * ...from DHImageMDB - @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = * "format LIKE 'image/%' AND operation=" + CrudOperations.CREATE)}) - * */ -public class DHDigilibPrescalerMDB extends DHMessageBeanAbs { +public class DHDigilibPrescalerMDB extends MessageBeanAbs { @Inject DHConnectEJB dhconnect; private static final String CLASS_NAME = "{DHDigilibPrescalerMDB} "; + /** + * @param message + * @return + */ @Incoming("crud") @Blocking CompletionStage<Void> onMessage(Message<CrudMessage> message) { @@ -42,10 +43,11 @@ public class DHDigilibPrescalerMDB extends DHMessageBeanAbs { CrudMessage msg = fromMessage(message); // TODO: there was a selector on format in jms before, is this still possible? - // -> was @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "format LIKE 'image/%'")}) - if(msg.getFormat().startsWith("image/")) { + // -> was @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "format + // LIKE 'image/%'")}) + if (msg.getFormat().startsWith("image/")) { int operation = msg.getOperation(); - String uri = msg.getObjectId(); + String uri = msg.getObjectId().toASCIIString(); boolean isPublic = msg.isPublic(); switch (operation) { @@ -67,8 +69,8 @@ public class DHDigilibPrescalerMDB extends DHMessageBeanAbs { break; } } - return message.ack(); + return message.ack(); } // ** diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHMessageBeanAbs.java b/src/main/java/info/textgrid/middleware/messagebeans/DHMessageBeanAbs.java deleted file mode 100644 index 7649e15..0000000 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHMessageBeanAbs.java +++ /dev/null @@ -1,17 +0,0 @@ -package info.textgrid.middleware.messagebeans; - -/** - * - */ -public abstract class DHMessageBeanAbs extends MessageBeanAbs { - - /** - * - */ - public DHMessageBeanAbs() { - MessageBeanAbs.setUriKey("pid"); - MessageBeanAbs.setRootIdKey("collection"); - MessageBeanAbs.setJmsTypeKey("dhcrud-notification"); - } - -} diff --git a/src/main/java/info/textgrid/middleware/messagebeans/MessageBeanAbs.java b/src/main/java/info/textgrid/middleware/messagebeans/MessageBeanAbs.java index 639bfce..0c2cf49 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/MessageBeanAbs.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/MessageBeanAbs.java @@ -14,13 +14,14 @@ import org.apache.commons.imaging.ImageInfo; import org.apache.commons.imaging.ImageReadException; import org.apache.commons.imaging.Imaging; import org.eclipse.microprofile.reactive.messaging.Message; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; - import info.textgrid.middleware.common.CachingUtils; import info.textgrid.middleware.model.CrudMessage; +/** + * + */ public abstract class MessageBeanAbs { private static final String CLASS_NAME = "{MessageBeanAbs} "; @@ -42,15 +43,18 @@ public abstract class MessageBeanAbs { protected final static String JPEG_SUFFIX = ".jpeg"; protected final static String TIFF_SUFFIX = ".tiff"; - protected static String uriKey; - protected static String rootIdKey; - protected static String jmsTypeKey; - - + /** + * @param msg + * @return + */ CrudMessage fromMessage(Message msg) { return fromString((String) msg.getPayload()); } + /** + * @param jsonString + * @return + */ CrudMessage fromString(String jsonString) { ObjectMapper mapper = new ObjectMapper(); try { @@ -281,48 +285,6 @@ public abstract class MessageBeanAbs { // GETTERS AND SETTERS // ** - /** - * @return - */ - public static String getUriKey() { - return uriKey; - } - - /** - * @param uriKey - */ - public static void setUriKey(String uriKey) { - MessageBeanAbs.uriKey = uriKey; - } - - /** - * @return - */ - public static String getRootIdKey() { - return rootIdKey; - } - - /** - * @param rootIdKey - */ - public static void setRootIdKey(String rootIdKey) { - MessageBeanAbs.rootIdKey = rootIdKey; - } - - /** - * @return - */ - public static String getJmsTypeKey() { - return jmsTypeKey; - } - - /** - * @param jmsTypeKey - */ - public static void setJmsTypeKey(String jmsTypeKey) { - MessageBeanAbs.jmsTypeKey = jmsTypeKey; - } - /** * @param theURI * @return diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java index 54b202a..8938ffa 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java @@ -3,20 +3,28 @@ package info.textgrid.middleware.messagebeans; import java.util.concurrent.CompletionStage; import org.eclipse.microprofile.reactive.messaging.Incoming; import org.eclipse.microprofile.reactive.messaging.Message; - import info.textgrid.middleware.model.CrudMessage; import io.smallrye.reactive.messaging.annotations.Blocking; +/** + * + */ public class TGAllMDB extends TGMessageBeanAbs { + /** + * @param message + * @return + */ @Incoming("crud") @Blocking - CompletionStage<Void> onMessage (Message message) { + CompletionStage<Void> onMessage(Message<CrudMessage> message) { CrudMessage msg = fromMessage(message); logMoreInfo(this.getClass().getSimpleName(), msg); + System.out.println("[%s] message received".formatted(this.getClass().getCanonicalName())); System.out.println(message.getPayload()); + return message.ack(); } diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java index b9607f0..2b9982a 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java @@ -9,18 +9,16 @@ import java.nio.file.Path; import java.nio.file.attribute.FileTime; import java.util.concurrent.CompletionStage; import java.util.logging.Level; - import org.apache.commons.imaging.ImageReadException; import org.eclipse.microprofile.reactive.messaging.Incoming; import org.eclipse.microprofile.reactive.messaging.Message; - import info.textgrid.middleware.common.CrudOperations; import info.textgrid.middleware.common.JPairtree; import info.textgrid.middleware.model.CrudMessage; import io.smallrye.reactive.messaging.annotations.Blocking; /** - * Other selectors: + * Other selectors? * * ...from TGImageMDB: @ActivationConfigProperty(propertyName = "messageSelector",propertyValue = * "format LIKE 'image/%' AND operation=" + CrudOperations.CREATE)}) @@ -31,6 +29,10 @@ public class TGDigilibPrescalerMDB extends TGMessageBeanAbs { private static final String NONPUBLIC_STORAGE_PATH = "/data/nonpublic/productive/"; private static final String CLASS_NAME = "{TGDigilibPrescalerMDB} "; + /** + * @param message + * @return + */ @Incoming("crud") @Blocking CompletionStage<Void> onMessage(Message<CrudMessage> message) { @@ -38,11 +40,12 @@ public class TGDigilibPrescalerMDB extends TGMessageBeanAbs { CrudMessage msg = fromMessage(message); // TODO: there was a selector on format in jms before, is this still possible? - // -> was @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "format LIKE 'image/%'")}) - if(msg.getFormat().startsWith("image/")) { + // -> was @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "format + // LIKE 'image/%'")}) + if (msg.getFormat().startsWith("image/")) { int operation = msg.getOperation(); - String uri = msg.getObjectId(); + String uri = msg.getObjectId().toASCIIString(); boolean isPublic = msg.isPublic(); switch (operation) { @@ -66,7 +69,8 @@ public class TGDigilibPrescalerMDB extends TGMessageBeanAbs { + " on " + uri); break; } - } + } + return message.ack(); } diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGMessageBeanAbs.java b/src/main/java/info/textgrid/middleware/messagebeans/TGMessageBeanAbs.java index a0bff57..23cbacb 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGMessageBeanAbs.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGMessageBeanAbs.java @@ -5,15 +5,6 @@ package info.textgrid.middleware.messagebeans; */ public abstract class TGMessageBeanAbs extends MessageBeanAbs { - /** - * - */ - public TGMessageBeanAbs() { - MessageBeanAbs.setUriKey("textgridUri"); - MessageBeanAbs.setRootIdKey("projectID"); - MessageBeanAbs.setJmsTypeKey("tgcrud-notification"); - } - /* * (non-Javadoc) * diff --git a/src/main/java/info/textgrid/middleware/model/CrudMessage.java b/src/main/java/info/textgrid/middleware/model/CrudMessage.java index 01ab007..3b3f1ae 100644 --- a/src/main/java/info/textgrid/middleware/model/CrudMessage.java +++ b/src/main/java/info/textgrid/middleware/model/CrudMessage.java @@ -1,70 +1,114 @@ package info.textgrid.middleware.model; +import java.net.URI; import io.quarkus.runtime.annotations.RegisterForReflection; +/** + * + */ @RegisterForReflection public class CrudMessage { - public String objectId; // tguri for tg, pid for dh - public int operation; - public String format; - public String rootId; // collectionId for dh, projectId for tg - public boolean isPublic; - - /** - * Default constructor required for Jackson serializer - */ - public CrudMessage() { } - - @Override - public String toString() { - return "CrudMessage{objectId='%s', operation='%d', format='%s', rootId='%s', public='%b'}" - .formatted(objectId, operation, format, rootId, isPublic); - } - - public String getObjectId() { - return objectId; - } - - public CrudMessage setObjectId(String objectId) { - this.objectId = objectId; - return this; - } - - public int getOperation() { - return operation; - } - - public CrudMessage setOperation(int operation) { - this.operation = operation; - return this; - } - - public String getFormat() { - return format; - } - - public CrudMessage setFormat(String format) { - this.format = format; - return this; - } - - public String getRootId() { - return rootId; - } - - public CrudMessage setRootId(String rootId) { - this.rootId = rootId; - return this; - } - - public boolean isPublic() { - return isPublic; - } - - public CrudMessage setPublic(boolean isPublic) { - this.isPublic = isPublic; - return this; - } -} + // TODO Put into common for common crud and message-beans usage? + + public URI objectId; // tguri for tg, pid for dh + public int operation; // create, update, delete + public String format; // mimetype + public String rootId; // collectionId for dh, projectId for tg + public boolean isPublic; // public or not public + + /** + * Default constructor required for Jackson serializer + */ + public CrudMessage() {} + + /** + * + */ + @Override + public String toString() { + return "CrudMessage{objectId='%s', operation='%d', format='%s', rootId='%s', public='%b'}" + .formatted(this.objectId, this.operation, this.format, this.rootId, this.isPublic); + } + + /** + * @return + */ + public URI getObjectId() { + return this.objectId; + } + + /** + * @param objectId + * @return + */ + public CrudMessage setObjectId(URI objectId) { + this.objectId = objectId; + return this; + } + + /** + * @return + */ + public int getOperation() { + return this.operation; + } + + /** + * @param operation + * @return + */ + public CrudMessage setOperation(int operation) { + this.operation = operation; + return this; + } + + /** + * @return + */ + public String getFormat() { + return this.format; + } + + /** + * @param format + * @return + */ + public CrudMessage setFormat(String format) { + this.format = format; + return this; + } + + /** + * @return + */ + public String getRootId() { + return this.rootId; + } + + /** + * @param rootId + * @return + */ + public CrudMessage setRootId(String rootId) { + this.rootId = rootId; + return this; + } + + /** + * @return + */ + public boolean isPublic() { + return this.isPublic; + } + + /** + * @param isPublic + * @return + */ + public CrudMessage setPublic(boolean isPublic) { + this.isPublic = isPublic; + return this; + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 968c48f..fc1cf19 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -5,6 +5,7 @@ #quarkus.rabbitmq.devservices.port=5672 # Set the AMQP address for the `crud` channel, as it's not the channel name +# Set to "dhcrud-events" for dhcrud messages, and to "tgcrud-events" for tgcrud messages! mp.messaging.incoming.crud.address=crud-events # TooManyDownstreamCandidatesException: 'IncomingConnector{channel:'crud', attribute:'mp.messaging.incoming.crud'}' @@ -12,4 +13,4 @@ mp.messaging.incoming.crud.address=crud-events # SubscriberMethod{method:'onMessage', incoming:'crud'}, SubscriberMethod{method:'onMessage', incoming:'crud'}, # SubscriberMethod{method:'onMessage', incoming:'crud'}]. # You may want to enable broadcast using 'mp.messaging.incoming.crud.broadcast=true' + to allow multiple downstreams. -mp.messaging.incoming.crud.broadcast=true \ No newline at end of file +mp.messaging.incoming.crud.broadcast=true -- GitLab From 8f18884e9e1d2e26aae5e7942d04b1995f46eefe Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Thu, 25 Jan 2024 14:50:40 +0100 Subject: [PATCH 10/58] fix: devide channels --- .../textgrid/middleware/messagebeans/DHAllMDB.java | 2 +- .../textgrid/middleware/messagebeans/TGAllMDB.java | 2 +- src/main/resources/application.properties | 10 +++------- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java index 5eddc83..284c5b9 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java @@ -15,7 +15,7 @@ public class DHAllMDB extends MessageBeanAbs { * @param message * @return */ - @Incoming("crud") + @Incoming("dhcrud") @Blocking CompletionStage<Void> onMessage(Message<CrudMessage> message) { diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java index 8938ffa..d3ebcfd 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java @@ -15,7 +15,7 @@ public class TGAllMDB extends TGMessageBeanAbs { * @param message * @return */ - @Incoming("crud") + @Incoming("tgcrud") @Blocking CompletionStage<Void> onMessage(Message<CrudMessage> message) { diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index fc1cf19..ff1c1fb 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,12 +1,8 @@ -# Configure the incoming RabbitMQ queue -#mp.messaging.incoming.crud.queue.name=crud-events -#mp.messaging.incoming.crud.exchange.name=crud-exchange - -#quarkus.rabbitmq.devservices.port=5672 - # Set the AMQP address for the `crud` channel, as it's not the channel name # Set to "dhcrud-events" for dhcrud messages, and to "tgcrud-events" for tgcrud messages! -mp.messaging.incoming.crud.address=crud-events +# See in docker-compose file env param: MP_MESSAGING_INCOMING_CRUD_ADDRESS +mp.messaging.incoming.tgcrud.address=tgcrud-events +mp.messaging.incoming.dhcrud.address=dhcrud-events # TooManyDownstreamCandidatesException: 'IncomingConnector{channel:'crud', attribute:'mp.messaging.incoming.crud'}' # supports a single downstream consumer, but found 4: [SubscriberMethod{method:'onMessage', incoming:'crud'}, -- GitLab From 595aeedaf05f640fe0b1146f93e880897e41854a Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Thu, 25 Jan 2024 14:58:39 +0100 Subject: [PATCH 11/58] fix: adapt channels --- .../middleware/messagebeans/DHDigilibPrescalerMDB.java | 9 ++++----- .../middleware/messagebeans/TGDigilibPrescalerMDB.java | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java index c57592a..0666c44 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java @@ -14,6 +14,7 @@ import org.apache.commons.imaging.ImageReadException; import org.eclipse.microprofile.reactive.messaging.Incoming; import org.eclipse.microprofile.reactive.messaging.Message; import info.textgrid.middleware.common.CrudOperations; +import info.textgrid.middleware.common.TextGridMimetypes; import info.textgrid.middleware.ejb.DHConnectEJB; import info.textgrid.middleware.model.CrudMessage; import io.smallrye.reactive.messaging.annotations.Blocking; @@ -36,16 +37,14 @@ public class DHDigilibPrescalerMDB extends MessageBeanAbs { * @param message * @return */ - @Incoming("crud") + @Incoming("dhcrud") @Blocking CompletionStage<Void> onMessage(Message<CrudMessage> message) { CrudMessage msg = fromMessage(message); - // TODO: there was a selector on format in jms before, is this still possible? - // -> was @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "format - // LIKE 'image/%'")}) - if (msg.getFormat().startsWith("image/")) { + // Select image mimetypes via TextGrid mimetypes from dariah-de-common. + if (TextGridMimetypes.IMAGE_SET.contains(msg.getFormat())) { int operation = msg.getOperation(); String uri = msg.getObjectId().toASCIIString(); boolean isPublic = msg.isPublic(); diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java index 2b9982a..56f753a 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java @@ -14,6 +14,7 @@ import org.eclipse.microprofile.reactive.messaging.Incoming; import org.eclipse.microprofile.reactive.messaging.Message; import info.textgrid.middleware.common.CrudOperations; import info.textgrid.middleware.common.JPairtree; +import info.textgrid.middleware.common.TextGridMimetypes; import info.textgrid.middleware.model.CrudMessage; import io.smallrye.reactive.messaging.annotations.Blocking; @@ -33,16 +34,14 @@ public class TGDigilibPrescalerMDB extends TGMessageBeanAbs { * @param message * @return */ - @Incoming("crud") + @Incoming("tgcrud") @Blocking CompletionStage<Void> onMessage(Message<CrudMessage> message) { CrudMessage msg = fromMessage(message); - // TODO: there was a selector on format in jms before, is this still possible? - // -> was @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "format - // LIKE 'image/%'")}) - if (msg.getFormat().startsWith("image/")) { + // Select image mimetypes via TextGrid mimetypes from dariah-de-common. + if (TextGridMimetypes.IMAGE_SET.contains(msg.getFormat())) { int operation = msg.getOperation(); String uri = msg.getObjectId().toASCIIString(); -- GitLab From a32c5f176531c1209a0f6ea902205351ef4c1459 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Thu, 25 Jan 2024 15:15:39 +0100 Subject: [PATCH 12/58] fix: remove double logging --- pom.xml | 22 +++---------------- .../textgrid/middleware/ejb/DHConnectEJB.java | 12 +++++----- .../middleware/messagebeans/DHAllMDB.java | 3 --- .../middleware/messagebeans/TGAllMDB.java | 3 --- 4 files changed, 9 insertions(+), 31 deletions(-) diff --git a/pom.xml b/pom.xml index c004837..7ab0321 100644 --- a/pom.xml +++ b/pom.xml @@ -9,6 +9,9 @@ <version>4.0.0-SNAPSHOT</version> <properties> <compiler-plugin.version>3.11.0</compiler-plugin.version> + <common.version>5.0.1-SNAPSHOT</common.version> + <commons-imaging.version>1.0-alpha3</commons-imaging.version> + <crud.version>11.9.5-SNAPSHOT</crud.version> <maven.compiler.release>17</maven.compiler.release> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> @@ -17,9 +20,6 @@ <quarkus.platform.version>3.6.3</quarkus.platform.version> <skipITs>true</skipITs> <surefire-plugin.version>3.1.2</surefire-plugin.version> - <common.version>5.0.1-SNAPSHOT</common.version> - <commons-imaging.version>1.0-alpha3</commons-imaging.version> - <crud.version>11.9.5-SNAPSHOT</crud.version> </properties> <repositories> <repository> @@ -67,22 +67,6 @@ <groupId>info.textgrid.middleware</groupId> <artifactId>dhcrud-api</artifactId> <version>${crud.version}</version> - <exclusions> - <!-- Exclude frontend-jaxrs due to Wildfly deployment dependency problems - in JBoss. --> - <exclusion> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-frontend-jaxrs</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-transports-http</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-rs-client</artifactId> - </exclusion> - </exclusions> </dependency> <dependency> <groupId>info.textgrid.middleware</groupId> diff --git a/src/main/java/info/textgrid/middleware/ejb/DHConnectEJB.java b/src/main/java/info/textgrid/middleware/ejb/DHConnectEJB.java index a94e119..b3027a0 100644 --- a/src/main/java/info/textgrid/middleware/ejb/DHConnectEJB.java +++ b/src/main/java/info/textgrid/middleware/ejb/DHConnectEJB.java @@ -5,22 +5,21 @@ import java.io.IOException; import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; - import org.eclipse.microprofile.rest.client.RestClientBuilder; - - import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.DHCrudService; - import jakarta.inject.Singleton; import jakarta.ws.rs.core.Response; +/** + * + */ // TODO: is @Singleton OK?, was @Stateful before @Singleton public class DHConnectEJB extends ConnectAbs { private static final String CLASS_NAME = "{DHConnectEJB} "; - //private RestClient rclient = new RestClientBuilder().connectionPoolSize(100).build(); + // private RestClient rclient = new RestClientBuilder().connectionPoolSize(100).build(); /** * @param thePropertiesLocation @@ -45,7 +44,8 @@ public class DHConnectEJB extends ConnectAbs { throws IOException, NullPointerException, URISyntaxException { // TODO: better initialize only once, and not on every operation - DHCrudService dhclient = RestClientBuilder.newBuilder().baseUri(this.crudUrl.toURI()).build(DHCrudService.class); + DHCrudService dhclient = + RestClientBuilder.newBuilder().baseUri(this.crudUrl.toURI()).build(DHCrudService.class); Response response = dhclient.read(URI.create(theUri), 0l, "MB" + System.currentTimeMillis()); diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java index 284c5b9..1b57f9a 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java @@ -22,9 +22,6 @@ public class DHAllMDB extends MessageBeanAbs { CrudMessage msg = fromMessage(message); logMoreInfo(this.getClass().getSimpleName(), msg); - System.out.println("[%s] message received".formatted(this.getClass().getCanonicalName())); - System.out.println(message.getPayload()); - return message.ack(); } diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java index d3ebcfd..f2c40b6 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java @@ -22,9 +22,6 @@ public class TGAllMDB extends TGMessageBeanAbs { CrudMessage msg = fromMessage(message); logMoreInfo(this.getClass().getSimpleName(), msg); - System.out.println("[%s] message received".formatted(this.getClass().getCanonicalName())); - System.out.println(message.getPayload()); - return message.ack(); } -- GitLab From b6f530bf52a3196583fca4262e2b0cfe6da21fd0 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Thu, 25 Jan 2024 15:27:07 +0100 Subject: [PATCH 13/58] fix: make quarkus tests normal junit tests --- pom.xml | 16 ++++++++++++++++ .../messagebeans/TestMessageBeanAbs.java | 6 +++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 7ab0321..8c36aab 100644 --- a/pom.xml +++ b/pom.xml @@ -67,6 +67,22 @@ <groupId>info.textgrid.middleware</groupId> <artifactId>dhcrud-api</artifactId> <version>${crud.version}</version> + <!-- <exclusions> --> + <!-- Exclude frontend-jaxrs due to Wildfly deployment dependency problems + in JBoss. --> + <!-- <exclusion> --> + <!-- <groupId>org.apache.cxf</groupId> --> + <!-- <artifactId>cxf-rt-frontend-jaxrs</artifactId> --> + <!-- </exclusion> --> + <!-- <exclusion> --> + <!-- <groupId>org.apache.cxf</groupId> --> + <!-- <artifactId>cxf-rt-transports-http</artifactId> --> + <!-- </exclusion> --> + <!-- <exclusion> --> + <!-- <groupId>org.apache.cxf</groupId> --> + <!-- <artifactId>cxf-rt-rs-client</artifactId> --> + <!-- </exclusion> --> + <!-- </exclusions> --> </dependency> <dependency> <groupId>info.textgrid.middleware</groupId> diff --git a/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java b/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java index 9355323..8919274 100644 --- a/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java +++ b/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java @@ -7,9 +7,9 @@ import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.Test; -import io.quarkus.test.junit.QuarkusTest; - -@QuarkusTest +/** + * + */ public class TestMessageBeanAbs { /** -- GitLab From f83bc4eaa12eba37297b0d6fbc224c0b89934d9c Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Thu, 25 Jan 2024 15:33:58 +0100 Subject: [PATCH 14/58] fix: remove all channels with name 'crud' --- src/main/resources/application.properties | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ff1c1fb..cb61efb 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -4,9 +4,14 @@ mp.messaging.incoming.tgcrud.address=tgcrud-events mp.messaging.incoming.dhcrud.address=dhcrud-events -# TooManyDownstreamCandidatesException: 'IncomingConnector{channel:'crud', attribute:'mp.messaging.incoming.crud'}' -# supports a single downstream consumer, but found 4: [SubscriberMethod{method:'onMessage', incoming:'crud'}, -# SubscriberMethod{method:'onMessage', incoming:'crud'}, SubscriberMethod{method:'onMessage', incoming:'crud'}, -# SubscriberMethod{method:'onMessage', incoming:'crud'}]. -# You may want to enable broadcast using 'mp.messaging.incoming.crud.broadcast=true' + to allow multiple downstreams. -mp.messaging.incoming.crud.broadcast=true +# TooManyDownstreamCandidatesException: +# 'IncomingConnector{channel:'crud', attribute:'mp.messaging.incoming.crud'}' +# supports a single downstream consumer, but found 4: +# [SubscriberMethod{method:'onMessage', incoming:'crud'}, +# SubscriberMethod{method:'onMessage', incoming:'crud'}, +# SubscriberMethod{method:'onMessage', incoming:'crud'}, +# SubscriberMethod{method:'onMessage', incoming:'crud'}]. +# You may want to enable broadcast using 'mp.messaging.incoming.crud.broadcast=true' +# to allow multiple downstreams. +mp.messaging.incoming.tgcrud.broadcast=true +mp.messaging.incoming.dhcrud.broadcast=true -- GitLab From 0b2fbccda4378c97b4e87f0bc463e5fa801e40b8 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 26 Jan 2024 15:54:38 +0100 Subject: [PATCH 15/58] fix: change docker image to install vips in container --- src/main/docker/Dockerfile.native-micro-multistage | 6 +++++- .../middleware/messagebeans/DHDigilibPrescalerMDB.java | 3 --- .../middleware/messagebeans/TGDigilibPrescalerMDB.java | 3 --- src/main/resources/application.properties | 3 ++- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/docker/Dockerfile.native-micro-multistage b/src/main/docker/Dockerfile.native-micro-multistage index e74a7ff..4f193d4 100644 --- a/src/main/docker/Dockerfile.native-micro-multistage +++ b/src/main/docker/Dockerfile.native-micro-multistage @@ -6,9 +6,13 @@ WORKDIR /code RUN --mount=type=cache,target=/root/.m2 ./mvnw clean package -Dnative ## Stage 2 : create the docker final image -FROM quay.io/quarkus/quarkus-micro-image:2.0 +FROM debian:bookworm-slim WORKDIR /work/ COPY --from=build /code/target/*-runner /work/application RUN chmod 775 /work +RUN apt-get update -y && apt-get upgrade -y && apt-get install --no-install-recommends -y \ + libvips-tools \ + # save some space + && rm -rf /var/lib/apt/lists/* EXPOSE 8080 CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] \ No newline at end of file diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java index 0666c44..fdd1409 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java @@ -21,10 +21,7 @@ import io.smallrye.reactive.messaging.annotations.Blocking; import jakarta.inject.Inject; /** - * Other selectors? * - * ...from DHImageMDB - @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = - * "format LIKE 'image/%' AND operation=" + CrudOperations.CREATE)}) */ public class DHDigilibPrescalerMDB extends MessageBeanAbs { diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java index 56f753a..eb74bfb 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java @@ -19,10 +19,7 @@ import info.textgrid.middleware.model.CrudMessage; import io.smallrye.reactive.messaging.annotations.Blocking; /** - * Other selectors? * - * ...from TGImageMDB: @ActivationConfigProperty(propertyName = "messageSelector",propertyValue = - * "format LIKE 'image/%' AND operation=" + CrudOperations.CREATE)}) */ public class TGDigilibPrescalerMDB extends TGMessageBeanAbs { diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index cb61efb..0a9685d 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,4 +1,5 @@ -# Set the AMQP address for the `crud` channel, as it's not the channel name +# Set the AMQP address for the `tgcrud` and 'tgcrud' channels, as it's not the +# channel name # Set to "dhcrud-events" for dhcrud messages, and to "tgcrud-events" for tgcrud messages! # See in docker-compose file env param: MP_MESSAGING_INCOMING_CRUD_ADDRESS mp.messaging.incoming.tgcrud.address=tgcrud-events -- GitLab From 38e461a4441ee0523c26b4a776ff851816575b19 Mon Sep 17 00:00:00 2001 From: Ubbo Veentjer <veentjer@sub.uni-goettingen.de> Date: Tue, 30 Jan 2024 11:23:53 +0100 Subject: [PATCH 16/58] refactor: remove some unused Dockerfiles --- .gitlab-ci.yml | 2 +- src/main/docker/Dockerfile.legacy-jar | 93 ------------------- src/main/docker/Dockerfile.native | 27 ------ src/main/docker/Dockerfile.native-micro | 30 ------ ...ultistage => Dockerfile.native-multistage} | 0 5 files changed, 1 insertion(+), 151 deletions(-) delete mode 100644 src/main/docker/Dockerfile.legacy-jar delete mode 100644 src/main/docker/Dockerfile.native delete mode 100644 src/main/docker/Dockerfile.native-micro rename src/main/docker/{Dockerfile.native-micro-multistage => Dockerfile.native-multistage} (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d29f345..21f7fce 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ variables: GIT_AUTHOR_NAME: ${GL_USER} GIT_COMMITTER_EMAIL: ${GL_USER}@noreply.gitlab.gwdg.de GIT_COMMITTER_NAME: ${GL_USER} - DOCKERFILE: $CI_PROJECT_DIR/src/main/docker/Dockerfile.native-micro-multistage + DOCKERFILE: $CI_PROJECT_DIR/src/main/docker/Dockerfile.native-multistage # Include Java settings from Gitlab templates repo. include: diff --git a/src/main/docker/Dockerfile.legacy-jar b/src/main/docker/Dockerfile.legacy-jar deleted file mode 100644 index 0f1fede..0000000 --- a/src/main/docker/Dockerfile.legacy-jar +++ /dev/null @@ -1,93 +0,0 @@ -#### -# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode -# -# Before building the container image run: -# -# ./mvnw package -Dquarkus.package.type=legacy-jar -# -# Then, build the image with: -# -# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/message-beans-legacy-jar . -# -# Then run the container using: -# -# docker run -i --rm -p 8080:8080 quarkus/message-beans-legacy-jar -# -# If you want to include the debug port into your docker image -# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005. -# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005 -# when running the container -# -# Then run the container using : -# -# docker run -i --rm -p 8080:8080 quarkus/message-beans-legacy-jar -# -# This image uses the `run-java.sh` script to run the application. -# This scripts computes the command line to execute your Java application, and -# includes memory/GC tuning. -# You can configure the behavior using the following environment properties: -# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") -# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options -# in JAVA_OPTS (example: "-Dsome.property=foo") -# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is -# used to calculate a default maximal heap memory based on a containers restriction. -# If used in a container without any memory constraints for the container then this -# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio -# of the container available memory as set here. The default is `50` which means 50% -# of the available memory is used as an upper boundary. You can skip this mechanism by -# setting this value to `0` in which case no `-Xmx` option is added. -# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This -# is used to calculate a default initial heap memory based on the maximum heap memory. -# If used in a container without any memory constraints for the container then this -# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio -# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` -# is used as the initial heap size. You can skip this mechanism by setting this value -# to `0` in which case no `-Xms` option is added (example: "25") -# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. -# This is used to calculate the maximum value of the initial heap memory. If used in -# a container without any memory constraints for the container then this option has -# no effect. If there is a memory constraint then `-Xms` is limited to the value set -# here. The default is 4096MB which means the calculated value of `-Xms` never will -# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") -# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output -# when things are happening. This option, if set to true, will set -# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). -# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: -# true"). -# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). -# - CONTAINER_CORE_LIMIT: A calculated core limit as described in -# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") -# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). -# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. -# (example: "20") -# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. -# (example: "40") -# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. -# (example: "4") -# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus -# previous GC times. (example: "90") -# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") -# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") -# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should -# contain the necessary JRE command-line options to specify the required GC, which -# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). -# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") -# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") -# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be -# accessed directly. (example: "foo.example.com,bar.example.com") -# -### -FROM registry.access.redhat.com/ubi8/openjdk-17:1.18 - -ENV LANGUAGE='en_US:en' - - -COPY target/lib/* /deployments/lib/ -COPY target/*-runner.jar /deployments/quarkus-run.jar - -EXPOSE 8080 -USER 185 -ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" -ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" - -ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] diff --git a/src/main/docker/Dockerfile.native b/src/main/docker/Dockerfile.native deleted file mode 100644 index f022069..0000000 --- a/src/main/docker/Dockerfile.native +++ /dev/null @@ -1,27 +0,0 @@ -#### -# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. -# -# Before building the container image run: -# -# ./mvnw package -Dnative -# -# Then, build the image with: -# -# docker build -f src/main/docker/Dockerfile.native -t quarkus/message-beans . -# -# Then run the container using: -# -# docker run -i --rm -p 8080:8080 quarkus/message-beans -# -### -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9 -WORKDIR /work/ -RUN chown 1001 /work \ - && chmod "g+rwX" /work \ - && chown 1001:root /work -COPY --chown=1001:root target/*-runner /work/application - -EXPOSE 8080 -USER 1001 - -ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/src/main/docker/Dockerfile.native-micro b/src/main/docker/Dockerfile.native-micro deleted file mode 100644 index e63c20e..0000000 --- a/src/main/docker/Dockerfile.native-micro +++ /dev/null @@ -1,30 +0,0 @@ -#### -# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. -# It uses a micro base image, tuned for Quarkus native executables. -# It reduces the size of the resulting container image. -# Check https://quarkus.io/guides/quarkus-runtime-base-image for further information about this image. -# -# Before building the container image run: -# -# ./mvnw package -Dnative -# -# Then, build the image with: -# -# docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/message-beans . -# -# Then run the container using: -# -# docker run -i --rm -p 8080:8080 quarkus/message-beans -# -### -FROM quay.io/quarkus/quarkus-micro-image:2.0 -WORKDIR /work/ -RUN chown 1001 /work \ - && chmod "g+rwX" /work \ - && chown 1001:root /work -COPY --chown=1001:root target/*-runner /work/application - -EXPOSE 8080 -USER 1001 - -ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/src/main/docker/Dockerfile.native-micro-multistage b/src/main/docker/Dockerfile.native-multistage similarity index 100% rename from src/main/docker/Dockerfile.native-micro-multistage rename to src/main/docker/Dockerfile.native-multistage -- GitLab From d92718c06f683e61d0772017c58e8609c2a2ec5d Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Tue, 30 Jan 2024 13:15:52 +0100 Subject: [PATCH 17/58] fix: fix some ubbo-comments --- .../info/textgrid/middleware/ejb/Connect.java | 33 ------- .../textgrid/middleware/ejb/ConnectAbs.java | 46 ---------- .../textgrid/middleware/ejb/DHConnectEJB.java | 85 ------------------ ...MDB.java => DHLoggingMessageConsumer.java} | 2 +- ...DB.java => DHPrescaleMessageConsumer.java} | 6 +- ...geBeanAbs.java => MessageConsumerAbs.java} | 4 +- ...MDB.java => TGLoggingMessageConsumer.java} | 2 +- ...BeanAbs.java => TGMessageConsumerAbs.java} | 16 ++-- ...DB.java => TGPrescaleMessageConsumer.java} | 2 +- .../middleware/services/DHConnect.java | 90 +++++++++++++++++++ .../messagebeans/TestMessageBeanAbs.java | 42 ++++----- 11 files changed, 126 insertions(+), 202 deletions(-) delete mode 100644 src/main/java/info/textgrid/middleware/ejb/Connect.java delete mode 100644 src/main/java/info/textgrid/middleware/ejb/ConnectAbs.java delete mode 100644 src/main/java/info/textgrid/middleware/ejb/DHConnectEJB.java rename src/main/java/info/textgrid/middleware/messagebeans/{DHAllMDB.java => DHLoggingMessageConsumer.java} (90%) rename src/main/java/info/textgrid/middleware/messagebeans/{DHDigilibPrescalerMDB.java => DHPrescaleMessageConsumer.java} (97%) rename src/main/java/info/textgrid/middleware/messagebeans/{MessageBeanAbs.java => MessageConsumerAbs.java} (99%) rename src/main/java/info/textgrid/middleware/messagebeans/{TGAllMDB.java => TGLoggingMessageConsumer.java} (89%) rename src/main/java/info/textgrid/middleware/messagebeans/{TGMessageBeanAbs.java => TGMessageConsumerAbs.java} (50%) rename src/main/java/info/textgrid/middleware/messagebeans/{TGDigilibPrescalerMDB.java => TGPrescaleMessageConsumer.java} (98%) create mode 100644 src/main/java/info/textgrid/middleware/services/DHConnect.java diff --git a/src/main/java/info/textgrid/middleware/ejb/Connect.java b/src/main/java/info/textgrid/middleware/ejb/Connect.java deleted file mode 100644 index 813d80e..0000000 --- a/src/main/java/info/textgrid/middleware/ejb/Connect.java +++ /dev/null @@ -1,33 +0,0 @@ -package info.textgrid.middleware.ejb; - -import java.io.InputStream; - - -/** - * - */ -public interface Connect { - - /** - * - */ - public void init(); - - /** - * @param theUri - * @return - */ - public InputStream getObjectData(String theUri); - - /** - * @param key - * @return - */ - public String getProperty(String key); - - /** - * @return - */ - public String getAuth(); - -} diff --git a/src/main/java/info/textgrid/middleware/ejb/ConnectAbs.java b/src/main/java/info/textgrid/middleware/ejb/ConnectAbs.java deleted file mode 100644 index 55dc1b3..0000000 --- a/src/main/java/info/textgrid/middleware/ejb/ConnectAbs.java +++ /dev/null @@ -1,46 +0,0 @@ -package info.textgrid.middleware.ejb; - -import java.io.BufferedInputStream; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.net.URL; -import java.util.Properties; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * - */ -public abstract class ConnectAbs implements Connect { - - protected final static Logger LOGGER = Logger.getLogger(Connect.class.getName()); - - protected String propertiesLocation; - protected Properties properties; - protected URL crudUrl; - - /** - * - */ - @Override - public void init() { - - this.properties = new Properties(); - BufferedInputStream stream; - - try { - stream = new BufferedInputStream(new FileInputStream(this.propertiesLocation)); - this.properties.load(stream); - stream.close(); - - this.crudUrl = new URL(this.properties.getProperty("crudUrl")); - - } catch (FileNotFoundException e) { - LOGGER.log(Level.SEVERE, "Properties file not found!", e); - } catch (IOException e) { - LOGGER.log(Level.SEVERE, "Unable to get CRUD URL from properties file!", e); - } - } - -} diff --git a/src/main/java/info/textgrid/middleware/ejb/DHConnectEJB.java b/src/main/java/info/textgrid/middleware/ejb/DHConnectEJB.java deleted file mode 100644 index b3027a0..0000000 --- a/src/main/java/info/textgrid/middleware/ejb/DHConnectEJB.java +++ /dev/null @@ -1,85 +0,0 @@ -package info.textgrid.middleware.ejb; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; -import org.eclipse.microprofile.rest.client.RestClientBuilder; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.DHCrudService; -import jakarta.inject.Singleton; -import jakarta.ws.rs.core.Response; - -/** - * - */ -// TODO: is @Singleton OK?, was @Stateful before -@Singleton -public class DHConnectEJB extends ConnectAbs { - - private static final String CLASS_NAME = "{DHConnectEJB} "; - - // private RestClient rclient = new RestClientBuilder().connectionPoolSize(100).build(); - - /** - * @param thePropertiesLocation - */ - public DHConnectEJB() { - - this.propertiesLocation = "/etc/dhrep/messagebeans/dhmb.properties"; - - init(); - - LOGGER.info(CLASS_NAME + "Called init()"); - } - - /** - * @param theUri - * @param theTempFile - * @throws IOException - * @throws URISyntaxException - * @throws NullPointerException - */ - public void getObjectData(String theUri, File theTempFile) - throws IOException, NullPointerException, URISyntaxException { - - // TODO: better initialize only once, and not on every operation - DHCrudService dhclient = - RestClientBuilder.newBuilder().baseUri(this.crudUrl.toURI()).build(DHCrudService.class); - - Response response = dhclient.read(URI.create(theUri), 0l, "MB" + System.currentTimeMillis()); - - LOGGER.info(CLASS_NAME + "Retrieving data from " + theUri + ", storing to " + theTempFile); - - // TODO! - // IOUtils.transferTo(response.readEntity(InputStream.class), theTempFile); - - response.close(); - } - - /** - * - */ - @Override - public String getProperty(String key) { - return this.properties.getProperty(key); - } - - /** - * - */ - @Override - public String getAuth() { - return ""; - } - - /** - * - */ - @Override - public InputStream getObjectData(String theUri) { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/DHLoggingMessageConsumer.java similarity index 90% rename from src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java rename to src/main/java/info/textgrid/middleware/messagebeans/DHLoggingMessageConsumer.java index 1b57f9a..50f3dd7 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHAllMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHLoggingMessageConsumer.java @@ -9,7 +9,7 @@ import io.smallrye.reactive.messaging.annotations.Blocking; /** * */ -public class DHAllMDB extends MessageBeanAbs { +public class DHLoggingMessageConsumer extends MessageConsumerAbs { /** * @param message diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java similarity index 97% rename from src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java rename to src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java index fdd1409..020951d 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHDigilibPrescalerMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java @@ -15,18 +15,18 @@ import org.eclipse.microprofile.reactive.messaging.Incoming; import org.eclipse.microprofile.reactive.messaging.Message; import info.textgrid.middleware.common.CrudOperations; import info.textgrid.middleware.common.TextGridMimetypes; -import info.textgrid.middleware.ejb.DHConnectEJB; import info.textgrid.middleware.model.CrudMessage; +import info.textgrid.middleware.services.DHConnect; import io.smallrye.reactive.messaging.annotations.Blocking; import jakarta.inject.Inject; /** * */ -public class DHDigilibPrescalerMDB extends MessageBeanAbs { +public class DHPrescaleMessageConsumer extends MessageConsumerAbs { @Inject - DHConnectEJB dhconnect; + DHConnect dhconnect; private static final String CLASS_NAME = "{DHDigilibPrescalerMDB} "; diff --git a/src/main/java/info/textgrid/middleware/messagebeans/MessageBeanAbs.java b/src/main/java/info/textgrid/middleware/messagebeans/MessageConsumerAbs.java similarity index 99% rename from src/main/java/info/textgrid/middleware/messagebeans/MessageBeanAbs.java rename to src/main/java/info/textgrid/middleware/messagebeans/MessageConsumerAbs.java index 0c2cf49..5c006ad 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/MessageBeanAbs.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/MessageConsumerAbs.java @@ -22,7 +22,7 @@ import info.textgrid.middleware.model.CrudMessage; /** * */ -public abstract class MessageBeanAbs { +public abstract class MessageConsumerAbs { private static final String CLASS_NAME = "{MessageBeanAbs} "; protected static final String PRESCALE_PATH = "/var/dhrep/digilib/prescale/"; @@ -31,7 +31,7 @@ public abstract class MessageBeanAbs { protected static final int TILESIZE = 512; protected static final int MAX_FRACTION = 16; - protected final static Logger LOGGER = Logger.getLogger(MessageBeanAbs.class.toString()); + protected final static Logger LOGGER = Logger.getLogger(MessageConsumerAbs.class.toString()); protected final static String OPERATION_KEY = "operation"; protected final static String FORMAT_KEY = "format"; protected final static String PUBLIC_KEY = "public"; diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/TGLoggingMessageConsumer.java similarity index 89% rename from src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java rename to src/main/java/info/textgrid/middleware/messagebeans/TGLoggingMessageConsumer.java index f2c40b6..16374c1 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGAllMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGLoggingMessageConsumer.java @@ -9,7 +9,7 @@ import io.smallrye.reactive.messaging.annotations.Blocking; /** * */ -public class TGAllMDB extends TGMessageBeanAbs { +public class TGLoggingMessageConsumer extends TGMessageConsumerAbs { /** * @param message diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGMessageBeanAbs.java b/src/main/java/info/textgrid/middleware/messagebeans/TGMessageConsumerAbs.java similarity index 50% rename from src/main/java/info/textgrid/middleware/messagebeans/TGMessageBeanAbs.java rename to src/main/java/info/textgrid/middleware/messagebeans/TGMessageConsumerAbs.java index 23cbacb..5b1791a 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGMessageBeanAbs.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGMessageConsumerAbs.java @@ -3,22 +3,20 @@ package info.textgrid.middleware.messagebeans; /** * */ -public abstract class TGMessageBeanAbs extends MessageBeanAbs { +public abstract class TGMessageConsumerAbs extends MessageConsumerAbs { - /* - * (non-Javadoc) - * - * @see info.textgrid.middleware.messagebeans.MessageBeanAbs#getPrescaleHash(java.lang.String) + /** + * @param theURI + * @return */ protected String getPrescaleHash(String theURI) { // Take the first three chars. return getPrescaleID(theURI).substring(0, 2); } - /* - * (non-Javadoc) - * - * @see info.textgrid.middleware.messagebeans.MessageBeanAbs#getPrescaleID(java.lang.String) + /** + * @param theURI + * @return */ protected String getPrescaleID(String theURI) { // Cut "textgrid:". diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java b/src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java similarity index 98% rename from src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java rename to src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java index eb74bfb..c16718f 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGDigilibPrescalerMDB.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java @@ -21,7 +21,7 @@ import io.smallrye.reactive.messaging.annotations.Blocking; /** * */ -public class TGDigilibPrescalerMDB extends TGMessageBeanAbs { +public class TGPrescaleMessageConsumer extends TGMessageConsumerAbs { private static final String PUBLIC_STORAGE_PATH = "/data/public/productive/"; private static final String NONPUBLIC_STORAGE_PATH = "/data/nonpublic/productive/"; diff --git a/src/main/java/info/textgrid/middleware/services/DHConnect.java b/src/main/java/info/textgrid/middleware/services/DHConnect.java new file mode 100644 index 0000000..b2487f7 --- /dev/null +++ b/src/main/java/info/textgrid/middleware/services/DHConnect.java @@ -0,0 +1,90 @@ +package info.textgrid.middleware.services; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.apache.cxf.helpers.IOUtils; +import org.eclipse.microprofile.rest.client.RestClientBuilder; +import org.eclipse.microprofile.rest.client.RestClientDefinitionException; +import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.DHCrudService; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.ws.rs.core.Response; + +/** + * + */ +@ApplicationScoped +public class DHConnect { + + private final String CLASS_NAME = "{DHConnectEJB} "; + private final Logger LOGGER = Logger.getLogger(DHConnect.class.getName()); + + private String propertiesLocation; + private Properties properties; + private URL crudUrl; + private DHCrudService dhclient; + + /** + * @throws IllegalStateException + * @throws RestClientDefinitionException + * @throws URISyntaxException + */ + public DHConnect() + throws IllegalStateException, RestClientDefinitionException, URISyntaxException { + + this.propertiesLocation = "/etc/dhrep/messagebeans/dhmb.properties"; + + this.properties = new Properties(); + BufferedInputStream stream; + + try { + stream = new BufferedInputStream(new FileInputStream(this.propertiesLocation)); + this.properties.load(stream); + stream.close(); + + this.crudUrl = new URL(this.properties.getProperty("crudUrl")); + + } catch (FileNotFoundException e) { + this.LOGGER.log(Level.SEVERE, "Properties file not found!", e); + } catch (IOException e) { + this.LOGGER.log(Level.SEVERE, "Unable to get CRUD URL from properties file!", e); + } + + if (this.dhclient == null) { + this.dhclient = + RestClientBuilder.newBuilder().baseUri(this.crudUrl.toURI()).build(DHCrudService.class); + } + } + + /** + * @param theUri + * @param theTempFile + * @throws IOException + * @throws NullPointerException + * @throws URISyntaxException + */ + public void getObjectData(String theUri, File theTempFile) + throws IOException, NullPointerException, URISyntaxException { + + try (Response response = + this.dhclient.read(URI.create(theUri), 0l, "MB" + System.currentTimeMillis())) { + + this.LOGGER + .info(this.CLASS_NAME + "Retrieving data from " + theUri + ", storing to " + theTempFile); + + IOUtils.transferTo(response.readEntity(InputStream.class), theTempFile); + + response.close(); + } + } + +} diff --git a/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java b/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java index 8919274..44dcbde 100644 --- a/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java +++ b/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java @@ -22,7 +22,7 @@ public class TestMessageBeanAbs { String expectedFilename = "21.T11991-0000-0013-281B-1"; // Test filename. - String filename = MessageBeanAbs.getPrescaleFilenameOnly(uri); + String filename = MessageConsumerAbs.getPrescaleFilenameOnly(uri); if (!filename.equals(expectedFilename)) { System.out.println(filename + " != " + expectedFilename); } @@ -42,29 +42,29 @@ public class TestMessageBeanAbs { System.out.println(id); List<Path> expectedPathList = new ArrayList<Path>(); - expectedPathList - .add(fs.getPath(MessageBeanAbs.PRESCALE_PATH + "jpeg-sf1/21.T11991-0000-0013-281B-1.jpeg")); - expectedPathList - .add(fs.getPath(MessageBeanAbs.PRESCALE_PATH + "jpeg-sf2/21.T11991-0000-0013-281B-1.jpeg")); - expectedPathList - .add(fs.getPath(MessageBeanAbs.PRESCALE_PATH + "jpeg-sf4/21.T11991-0000-0013-281B-1.jpeg")); - expectedPathList - .add(fs.getPath(MessageBeanAbs.PRESCALE_PATH + "jpeg-sf8/21.T11991-0000-0013-281B-1.jpeg")); expectedPathList.add( - fs.getPath(MessageBeanAbs.PRESCALE_PATH + "jpeg-sf16/21.T11991-0000-0013-281B-1.jpeg")); - expectedPathList - .add(fs.getPath(MessageBeanAbs.PRESCALE_PATH + "tile-sf1/21.T11991-0000-0013-281B-1.tiff")); - expectedPathList - .add(fs.getPath(MessageBeanAbs.PRESCALE_PATH + "tile-sf2/21.T11991-0000-0013-281B-1.tiff")); - expectedPathList - .add(fs.getPath(MessageBeanAbs.PRESCALE_PATH + "tile-sf4/21.T11991-0000-0013-281B-1.tiff")); - expectedPathList - .add(fs.getPath(MessageBeanAbs.PRESCALE_PATH + "tile-sf8/21.T11991-0000-0013-281B-1.tiff")); + fs.getPath(MessageConsumerAbs.PRESCALE_PATH + "jpeg-sf1/21.T11991-0000-0013-281B-1.jpeg")); expectedPathList.add( - fs.getPath(MessageBeanAbs.PRESCALE_PATH + "tile-sf16/21.T11991-0000-0013-281B-1.tiff")); + fs.getPath(MessageConsumerAbs.PRESCALE_PATH + "jpeg-sf2/21.T11991-0000-0013-281B-1.jpeg")); + expectedPathList.add( + fs.getPath(MessageConsumerAbs.PRESCALE_PATH + "jpeg-sf4/21.T11991-0000-0013-281B-1.jpeg")); + expectedPathList.add( + fs.getPath(MessageConsumerAbs.PRESCALE_PATH + "jpeg-sf8/21.T11991-0000-0013-281B-1.jpeg")); + expectedPathList.add( + fs.getPath(MessageConsumerAbs.PRESCALE_PATH + "jpeg-sf16/21.T11991-0000-0013-281B-1.jpeg")); + expectedPathList.add( + fs.getPath(MessageConsumerAbs.PRESCALE_PATH + "tile-sf1/21.T11991-0000-0013-281B-1.tiff")); + expectedPathList.add( + fs.getPath(MessageConsumerAbs.PRESCALE_PATH + "tile-sf2/21.T11991-0000-0013-281B-1.tiff")); + expectedPathList.add( + fs.getPath(MessageConsumerAbs.PRESCALE_PATH + "tile-sf4/21.T11991-0000-0013-281B-1.tiff")); + expectedPathList.add( + fs.getPath(MessageConsumerAbs.PRESCALE_PATH + "tile-sf8/21.T11991-0000-0013-281B-1.tiff")); + expectedPathList.add( + fs.getPath(MessageConsumerAbs.PRESCALE_PATH + "tile-sf16/21.T11991-0000-0013-281B-1.tiff")); - String prescaleFilename = MessageBeanAbs.getPrescaleFilenameOnly(uri); - List<Path> pathList = MessageBeanAbs.getPrescaleProcessingList(fs, prescaleFilename); + String prescaleFilename = MessageConsumerAbs.getPrescaleFilenameOnly(uri); + List<Path> pathList = MessageConsumerAbs.getPrescaleProcessingList(fs, prescaleFilename); // We need to test, if all list elements are existing in each list, the order of elements is not // important. -- GitLab From 8c9f0476b2ff639e4b5fe48f74a246aa8805af62 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Tue, 30 Jan 2024 16:16:27 +0100 Subject: [PATCH 18/58] fix: remove cxf io utils, using commons.fileutils now --- .../middleware/messagebeans/DHPrescaleMessageConsumer.java | 2 +- .../middleware/messagebeans/MessageConsumerAbs.java | 3 ++- .../middleware/messagebeans/TGPrescaleMessageConsumer.java | 2 +- .../java/info/textgrid/middleware/services/DHConnect.java | 7 +++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java index 020951d..3548073 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java @@ -28,7 +28,7 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { @Inject DHConnect dhconnect; - private static final String CLASS_NAME = "{DHDigilibPrescalerMDB} "; + private static final String CLASS_NAME = DHPrescaleMessageConsumer.class.getName() + " "; /** * @param message diff --git a/src/main/java/info/textgrid/middleware/messagebeans/MessageConsumerAbs.java b/src/main/java/info/textgrid/middleware/messagebeans/MessageConsumerAbs.java index 5c006ad..681965f 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/MessageConsumerAbs.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/MessageConsumerAbs.java @@ -24,7 +24,8 @@ import info.textgrid.middleware.model.CrudMessage; */ public abstract class MessageConsumerAbs { - private static final String CLASS_NAME = "{MessageBeanAbs} "; + private static final String CLASS_NAME = MessageConsumerAbs.class.getName() + " "; + protected static final String PRESCALE_PATH = "/var/dhrep/digilib/prescale/"; protected static final int JPEG_QUALITY = 90; diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java b/src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java index c16718f..3ef876f 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java @@ -23,9 +23,9 @@ import io.smallrye.reactive.messaging.annotations.Blocking; */ public class TGPrescaleMessageConsumer extends TGMessageConsumerAbs { + private static final String CLASS_NAME = TGPrescaleMessageConsumer.class.getName() + " "; private static final String PUBLIC_STORAGE_PATH = "/data/public/productive/"; private static final String NONPUBLIC_STORAGE_PATH = "/data/nonpublic/productive/"; - private static final String CLASS_NAME = "{TGDigilibPrescalerMDB} "; /** * @param message diff --git a/src/main/java/info/textgrid/middleware/services/DHConnect.java b/src/main/java/info/textgrid/middleware/services/DHConnect.java index b2487f7..7979a58 100644 --- a/src/main/java/info/textgrid/middleware/services/DHConnect.java +++ b/src/main/java/info/textgrid/middleware/services/DHConnect.java @@ -12,7 +12,7 @@ import java.net.URL; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; -import org.apache.cxf.helpers.IOUtils; +import org.apache.commons.io.FileUtils; import org.eclipse.microprofile.rest.client.RestClientBuilder; import org.eclipse.microprofile.rest.client.RestClientDefinitionException; import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.DHCrudService; @@ -25,7 +25,6 @@ import jakarta.ws.rs.core.Response; @ApplicationScoped public class DHConnect { - private final String CLASS_NAME = "{DHConnectEJB} "; private final Logger LOGGER = Logger.getLogger(DHConnect.class.getName()); private String propertiesLocation; @@ -79,9 +78,9 @@ public class DHConnect { this.dhclient.read(URI.create(theUri), 0l, "MB" + System.currentTimeMillis())) { this.LOGGER - .info(this.CLASS_NAME + "Retrieving data from " + theUri + ", storing to " + theTempFile); + .info(DHConnect.class.getName() + "Storing data from " + theUri + " to " + theTempFile); - IOUtils.transferTo(response.readEntity(InputStream.class), theTempFile); + FileUtils.copyInputStreamToFile(response.readEntity(InputStream.class), theTempFile); response.close(); } -- GitLab From c37554ea904f5cc6056cb16ff69b2517812e7ee0 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Tue, 30 Jan 2024 16:18:54 +0100 Subject: [PATCH 19/58] fix: set dhclient null with init --- src/main/java/info/textgrid/middleware/services/DHConnect.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/info/textgrid/middleware/services/DHConnect.java b/src/main/java/info/textgrid/middleware/services/DHConnect.java index 7979a58..98d6a8d 100644 --- a/src/main/java/info/textgrid/middleware/services/DHConnect.java +++ b/src/main/java/info/textgrid/middleware/services/DHConnect.java @@ -30,7 +30,7 @@ public class DHConnect { private String propertiesLocation; private Properties properties; private URL crudUrl; - private DHCrudService dhclient; + private DHCrudService dhclient = null; /** * @throws IllegalStateException -- GitLab From 8e2adf2399fd9b93314da3d7e3a2192a721cda0e Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Tue, 30 Jan 2024 16:27:14 +0100 Subject: [PATCH 20/58] fix: use commons io now for file utils --- pom.xml | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index 8c36aab..519a88a 100644 --- a/pom.xml +++ b/pom.xml @@ -11,6 +11,7 @@ <compiler-plugin.version>3.11.0</compiler-plugin.version> <common.version>5.0.1-SNAPSHOT</common.version> <commons-imaging.version>1.0-alpha3</commons-imaging.version> + <commons-io.version>2.15.1</commons-io.version> <crud.version>11.9.5-SNAPSHOT</crud.version> <maven.compiler.release>17</maven.compiler.release> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> @@ -67,22 +68,6 @@ <groupId>info.textgrid.middleware</groupId> <artifactId>dhcrud-api</artifactId> <version>${crud.version}</version> - <!-- <exclusions> --> - <!-- Exclude frontend-jaxrs due to Wildfly deployment dependency problems - in JBoss. --> - <!-- <exclusion> --> - <!-- <groupId>org.apache.cxf</groupId> --> - <!-- <artifactId>cxf-rt-frontend-jaxrs</artifactId> --> - <!-- </exclusion> --> - <!-- <exclusion> --> - <!-- <groupId>org.apache.cxf</groupId> --> - <!-- <artifactId>cxf-rt-transports-http</artifactId> --> - <!-- </exclusion> --> - <!-- <exclusion> --> - <!-- <groupId>org.apache.cxf</groupId> --> - <!-- <artifactId>cxf-rt-rs-client</artifactId> --> - <!-- </exclusion> --> - <!-- </exclusions> --> </dependency> <dependency> <groupId>info.textgrid.middleware</groupId> @@ -94,6 +79,11 @@ <artifactId>commons-imaging</artifactId> <version>${commons-imaging.version}</version> </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>${commons-io.version}</version> + </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-junit5</artifactId> -- GitLab From 125ec3979324f4abe5dab2736e26c888d8e5c4bb Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Tue, 30 Jan 2024 16:37:10 +0100 Subject: [PATCH 21/58] fix: add jandex plugin --- pom.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pom.xml b/pom.xml index 519a88a..0ef387a 100644 --- a/pom.xml +++ b/pom.xml @@ -13,6 +13,7 @@ <commons-imaging.version>1.0-alpha3</commons-imaging.version> <commons-io.version>2.15.1</commons-io.version> <crud.version>11.9.5-SNAPSHOT</crud.version> + <jandex-maven-plugin.version>1.1.0</jandex-maven-plugin.version> <maven.compiler.release>17</maven.compiler.release> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> @@ -145,6 +146,19 @@ </systemPropertyVariables> </configuration> </plugin> + <plugin> + <groupId>org.jboss.jandex</groupId> + <artifactId>jandex-maven-plugin</artifactId> + <version>${jandex-maven-plugin.version}</version> + <executions> + <execution> + <id>make-index</id> + <goals> + <goal>jandex</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> <profiles> -- GitLab From 34c6925ffd0604beede337d5aa31c80ac18ce790 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Tue, 30 Jan 2024 17:44:47 +0100 Subject: [PATCH 22/58] fix: add quarkus jandex and config --- pom.xml | 10 +++++----- src/main/resources/application.properties | 21 +++++++++++++++++---- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 0ef387a..766a7b9 100644 --- a/pom.xml +++ b/pom.xml @@ -80,16 +80,16 @@ <artifactId>commons-imaging</artifactId> <version>${commons-imaging.version}</version> </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>${commons-io.version}</version> - </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-junit5</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>${commons-io.version}</version> + </dependency> </dependencies> <build> <plugins> diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 0a9685d..c950629 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,18 +1,31 @@ +### +# AMQP related +### + # Set the AMQP address for the `tgcrud` and 'tgcrud' channels, as it's not the # channel name # Set to "dhcrud-events" for dhcrud messages, and to "tgcrud-events" for tgcrud messages! -# See in docker-compose file env param: MP_MESSAGING_INCOMING_CRUD_ADDRESS +# See in docker-compose file env param: MP_MESSAGING_INCOMING_CRUD_ADDRESS mp.messaging.incoming.tgcrud.address=tgcrud-events mp.messaging.incoming.dhcrud.address=dhcrud-events # TooManyDownstreamCandidatesException: -# 'IncomingConnector{channel:'crud', attribute:'mp.messaging.incoming.crud'}' +# 'IncomingConnector{channel:'crud', attribute:'mp.messaging.incoming.crud'}' # supports a single downstream consumer, but found 4: # [SubscriberMethod{method:'onMessage', incoming:'crud'}, # SubscriberMethod{method:'onMessage', incoming:'crud'}, -# SubscriberMethod{method:'onMessage', incoming:'crud'}, -# SubscriberMethod{method:'onMessage', incoming:'crud'}]. +# SubscriberMethod{method:'onMessage', incoming:'crud'}, +# SubscriberMethod{method:'onMessage', incoming:'crud'}]. # You may want to enable broadcast using 'mp.messaging.incoming.crud.broadcast=true' # to allow multiple downstreams. mp.messaging.incoming.tgcrud.broadcast=true mp.messaging.incoming.dhcrud.broadcast=true + +### +# quarkus related +### + +# jandex maven plugin did not really work on this dependecies, but manually +# adding here helps...? +quarkus.index-dependency.info.textgrid.middleware.group-id=info.textgrid.middleware +quarkus.index-dependency.info.textgrid.middleware.artifact-id=dhcrud-api -- GitLab From 76aba08b9a16e6fb5f5aad2a8da1adf779dcec4a Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Wed, 31 Jan 2024 11:55:21 +0100 Subject: [PATCH 23/58] fix: fix jandex name in config --- src/main/resources/application.properties | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c950629..3024526 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,5 +1,5 @@ ### -# AMQP related +# amqp related ### # Set the AMQP address for the `tgcrud` and 'tgcrud' channels, as it's not the @@ -25,7 +25,7 @@ mp.messaging.incoming.dhcrud.broadcast=true # quarkus related ### -# jandex maven plugin did not really work on this dependecies, but manually +# jandex maven plugin did not really work on this dependencies, but manually # adding here helps...? -quarkus.index-dependency.info.textgrid.middleware.group-id=info.textgrid.middleware -quarkus.index-dependency.info.textgrid.middleware.artifact-id=dhcrud-api +quarkus.index-dependency.info-textgrid-middleware.group-id=info.textgrid.middleware +quarkus.index-dependency.info-textgrid-middleware.artifact-id=dhcrud-api -- GitLab From 02e442a90eb2a4b74fde3cad0ce21f8f519fb015 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Wed, 31 Jan 2024 13:48:34 +0100 Subject: [PATCH 24/58] fix: change jandex dep name --- src/main/resources/application.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 3024526..c8f5d6d 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -27,5 +27,5 @@ mp.messaging.incoming.dhcrud.broadcast=true # jandex maven plugin did not really work on this dependencies, but manually # adding here helps...? -quarkus.index-dependency.info-textgrid-middleware.group-id=info.textgrid.middleware -quarkus.index-dependency.info-textgrid-middleware.artifact-id=dhcrud-api +quarkus.index-dependency.dhcrud-api.group-id=info.textgrid.middleware +quarkus.index-dependency.dhcrud-api.artifact-id=dhcrud-api -- GitLab From ff1ce618aef82919a02c8ab4a77ea03054dde438 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Wed, 31 Jan 2024 17:14:46 +0100 Subject: [PATCH 25/58] fix: remove jandex due to dhcrud api issues, using client directly now --- pom.xml | 14 ------------ .../middleware/services/DHConnect.java | 22 ++++++++++--------- src/main/resources/application.properties | 9 -------- 3 files changed, 12 insertions(+), 33 deletions(-) diff --git a/pom.xml b/pom.xml index 766a7b9..279aff7 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,6 @@ <commons-imaging.version>1.0-alpha3</commons-imaging.version> <commons-io.version>2.15.1</commons-io.version> <crud.version>11.9.5-SNAPSHOT</crud.version> - <jandex-maven-plugin.version>1.1.0</jandex-maven-plugin.version> <maven.compiler.release>17</maven.compiler.release> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> @@ -146,19 +145,6 @@ </systemPropertyVariables> </configuration> </plugin> - <plugin> - <groupId>org.jboss.jandex</groupId> - <artifactId>jandex-maven-plugin</artifactId> - <version>${jandex-maven-plugin.version}</version> - <executions> - <execution> - <id>make-index</id> - <goals> - <goal>jandex</goal> - </goals> - </execution> - </executions> - </plugin> </plugins> </build> <profiles> diff --git a/src/main/java/info/textgrid/middleware/services/DHConnect.java b/src/main/java/info/textgrid/middleware/services/DHConnect.java index 98d6a8d..bd3471f 100644 --- a/src/main/java/info/textgrid/middleware/services/DHConnect.java +++ b/src/main/java/info/textgrid/middleware/services/DHConnect.java @@ -6,17 +6,17 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; import org.apache.commons.io.FileUtils; -import org.eclipse.microprofile.rest.client.RestClientBuilder; import org.eclipse.microprofile.rest.client.RestClientDefinitionException; -import info.textgrid.namespaces.middleware.tgcrud.services.tgcrudservice.DHCrudService; import jakarta.enterprise.context.ApplicationScoped; +import jakarta.ws.rs.client.Client; +import jakarta.ws.rs.client.ClientBuilder; +import jakarta.ws.rs.client.WebTarget; import jakarta.ws.rs.core.Response; /** @@ -26,11 +26,12 @@ import jakarta.ws.rs.core.Response; public class DHConnect { private final Logger LOGGER = Logger.getLogger(DHConnect.class.getName()); + private final String CLASS_NAME = DHConnect.class.getName(); private String propertiesLocation; private Properties properties; private URL crudUrl; - private DHCrudService dhclient = null; + private Client dhclient; /** * @throws IllegalStateException @@ -59,8 +60,7 @@ public class DHConnect { } if (this.dhclient == null) { - this.dhclient = - RestClientBuilder.newBuilder().baseUri(this.crudUrl.toURI()).build(DHCrudService.class); + this.dhclient = ClientBuilder.newClient().property("thread.safe.client", "true"); } } @@ -74,11 +74,13 @@ public class DHConnect { public void getObjectData(String theUri, File theTempFile) throws IOException, NullPointerException, URISyntaxException { - try (Response response = - this.dhclient.read(URI.create(theUri), 0l, "MB" + System.currentTimeMillis())) { + WebTarget target = this.dhclient.target(this.crudUrl.toString()).path(theUri + "/data"); - this.LOGGER - .info(DHConnect.class.getName() + "Storing data from " + theUri + " to " + theTempFile); + this.LOGGER.info(this.CLASS_NAME + " Reading DH-crud data file from: " + target.getUri()); + + try (Response response = target.request().get()) { + + this.LOGGER.info(this.CLASS_NAME + " Storing data from " + theUri + " to " + theTempFile); FileUtils.copyInputStreamToFile(response.readEntity(InputStream.class), theTempFile); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c8f5d6d..72cabe0 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -20,12 +20,3 @@ mp.messaging.incoming.dhcrud.address=dhcrud-events # to allow multiple downstreams. mp.messaging.incoming.tgcrud.broadcast=true mp.messaging.incoming.dhcrud.broadcast=true - -### -# quarkus related -### - -# jandex maven plugin did not really work on this dependencies, but manually -# adding here helps...? -quarkus.index-dependency.dhcrud-api.group-id=info.textgrid.middleware -quarkus.index-dependency.dhcrud-api.artifact-id=dhcrud-api -- GitLab From b5a28988de614c8cb84ac02016449534dfd14af4 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Wed, 31 Jan 2024 18:29:55 +0100 Subject: [PATCH 26/58] test: add more logging --- .../messagebeans/DHPrescaleMessageConsumer.java | 9 ++++++--- .../info/textgrid/middleware/services/DHConnect.java | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java index 3548073..709389a 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java @@ -25,11 +25,11 @@ import jakarta.inject.Inject; */ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { + private static final String CLASS_NAME = DHPrescaleMessageConsumer.class.getName() + " "; + @Inject DHConnect dhconnect; - private static final String CLASS_NAME = DHPrescaleMessageConsumer.class.getName() + " "; - /** * @param message * @return @@ -40,8 +40,11 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { CrudMessage msg = fromMessage(message); + logMoreInfo(this.getClass().getSimpleName(), msg); + // Select image mimetypes via TextGrid mimetypes from dariah-de-common. if (TextGridMimetypes.IMAGE_SET.contains(msg.getFormat())) { + int operation = msg.getOperation(); String uri = msg.getObjectId().toASCIIString(); boolean isPublic = msg.isPublic(); @@ -52,7 +55,7 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { prescale(uri, isPublic); break; case CrudOperations.UPDATE: - LOGGER.info(CLASS_NAME + "UPDATE: Re-prescaling " + uri); + LOGGER.info(CLASS_NAME + "UPDATE: Rescaling " + uri); prescale(uri, isPublic); break; case CrudOperations.DELETE: diff --git a/src/main/java/info/textgrid/middleware/services/DHConnect.java b/src/main/java/info/textgrid/middleware/services/DHConnect.java index bd3471f..d2852b0 100644 --- a/src/main/java/info/textgrid/middleware/services/DHConnect.java +++ b/src/main/java/info/textgrid/middleware/services/DHConnect.java @@ -26,7 +26,7 @@ import jakarta.ws.rs.core.Response; public class DHConnect { private final Logger LOGGER = Logger.getLogger(DHConnect.class.getName()); - private final String CLASS_NAME = DHConnect.class.getName(); + private final String CLASS_NAME = DHConnect.class.getName() + " "; private String propertiesLocation; private Properties properties; @@ -76,11 +76,11 @@ public class DHConnect { WebTarget target = this.dhclient.target(this.crudUrl.toString()).path(theUri + "/data"); - this.LOGGER.info(this.CLASS_NAME + " Reading DH-crud data file from: " + target.getUri()); + this.LOGGER.info(this.CLASS_NAME + "Reading DH-crud data file from: " + target.getUri()); try (Response response = target.request().get()) { - this.LOGGER.info(this.CLASS_NAME + " Storing data from " + theUri + " to " + theTempFile); + this.LOGGER.info(this.CLASS_NAME + "Storing data from " + theUri + " to " + theTempFile); FileUtils.copyInputStreamToFile(response.readEntity(InputStream.class), theTempFile); -- GitLab From 1017238cda06c599646c20168ba08fed62205e30 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Thu, 1 Feb 2024 13:54:36 +0100 Subject: [PATCH 27/58] fix: add logging to fix HTTP issue --- .../textgrid/middleware/services/DHConnect.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/info/textgrid/middleware/services/DHConnect.java b/src/main/java/info/textgrid/middleware/services/DHConnect.java index d2852b0..73fdacf 100644 --- a/src/main/java/info/textgrid/middleware/services/DHConnect.java +++ b/src/main/java/info/textgrid/middleware/services/DHConnect.java @@ -12,6 +12,7 @@ import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; import org.apache.commons.io.FileUtils; +import org.eclipse.aether.util.FileUtils.TempFile; import org.eclipse.microprofile.rest.client.RestClientDefinitionException; import jakarta.enterprise.context.ApplicationScoped; import jakarta.ws.rs.client.Client; @@ -68,11 +69,8 @@ public class DHConnect { * @param theUri * @param theTempFile * @throws IOException - * @throws NullPointerException - * @throws URISyntaxException */ - public void getObjectData(String theUri, File theTempFile) - throws IOException, NullPointerException, URISyntaxException { + public void getObjectData(String theUri, File theTempFile) throws IOException { WebTarget target = this.dhclient.target(this.crudUrl.toString()).path(theUri + "/data"); @@ -80,10 +78,18 @@ public class DHConnect { try (Response response = target.request().get()) { + int status = response.getStatus(); + String reasonPhrase = response.getStatusInfo().getReasonPhrase(); + + this.LOGGER.info(this.CLASS_NAME + "Status: " + status + " " + reasonPhrase); + this.LOGGER.info(this.CLASS_NAME + "Storing data from " + theUri + " to " + theTempFile); FileUtils.copyInputStreamToFile(response.readEntity(InputStream.class), theTempFile); + this.LOGGER + .info(this.CLASS_NAME + "Copied data to temp file: " + theTempFile.getCanonicalPath()); + response.close(); } } -- GitLab From 31fca05896d6fd449af771c3ea87bd8c8badf336 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Thu, 1 Feb 2024 13:59:00 +0100 Subject: [PATCH 28/58] fix: fixing the issue fix :-D --- .../middleware/messagebeans/DHPrescaleMessageConsumer.java | 2 +- src/main/java/info/textgrid/middleware/services/DHConnect.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java index 709389a..d35001d 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java @@ -162,7 +162,7 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { LOGGER.info(CLASS_NAME + "Scaling COMPLETE for " + prescaleFilename); - } catch (NullPointerException | IOException | URISyntaxException e) { + } catch (NullPointerException | IOException e) { LOGGER.log(Level.SEVERE, CLASS_NAME + "Could not store data file from DH-crud to " + tempFile.getAbsolutePath() + "!", e); } catch (ImageReadException e) { diff --git a/src/main/java/info/textgrid/middleware/services/DHConnect.java b/src/main/java/info/textgrid/middleware/services/DHConnect.java index 73fdacf..b3122b2 100644 --- a/src/main/java/info/textgrid/middleware/services/DHConnect.java +++ b/src/main/java/info/textgrid/middleware/services/DHConnect.java @@ -12,7 +12,6 @@ import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; import org.apache.commons.io.FileUtils; -import org.eclipse.aether.util.FileUtils.TempFile; import org.eclipse.microprofile.rest.client.RestClientDefinitionException; import jakarta.enterprise.context.ApplicationScoped; import jakarta.ws.rs.client.Client; -- GitLab From 60f45d3efb10056b7dea1e38d2487298cf62dca5 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Thu, 1 Feb 2024 14:40:57 +0100 Subject: [PATCH 29/58] chore: mc --- .../DHPrescaleMessageConsumer.java | 46 +++++++++---------- .../TGPrescaleMessageConsumer.java | 37 ++++++--------- 2 files changed, 36 insertions(+), 47 deletions(-) diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java index d35001d..2175808 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java @@ -2,7 +2,6 @@ package info.textgrid.middleware.messagebeans; import java.io.File; import java.io.IOException; -import java.net.URISyntaxException; import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.Path; @@ -25,8 +24,6 @@ import jakarta.inject.Inject; */ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { - private static final String CLASS_NAME = DHPrescaleMessageConsumer.class.getName() + " "; - @Inject DHConnect dhconnect; @@ -38,9 +35,9 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { @Blocking CompletionStage<Void> onMessage(Message<CrudMessage> message) { - CrudMessage msg = fromMessage(message); + LOGGER.log(Level.INFO, "START METHOD!"); - logMoreInfo(this.getClass().getSimpleName(), msg); + CrudMessage msg = fromMessage(message); // Select image mimetypes via TextGrid mimetypes from dariah-de-common. if (TextGridMimetypes.IMAGE_SET.contains(msg.getFormat())) { @@ -51,20 +48,19 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { switch (operation) { case CrudOperations.CREATE: - LOGGER.info(CLASS_NAME + "CREATE: Prescaling " + uri); + LOGGER.info("CREATE: Prescaling " + uri); prescale(uri, isPublic); break; case CrudOperations.UPDATE: - LOGGER.info(CLASS_NAME + "UPDATE: Rescaling " + uri); + LOGGER.info("UPDATE: Rescaling " + uri); prescale(uri, isPublic); break; case CrudOperations.DELETE: - LOGGER.info(CLASS_NAME + "DELETE: Deleting " + uri); + LOGGER.info("DELETE: Deleting " + uri); removePrescales(uri); break; default: - LOGGER.info(CLASS_NAME + "UNKNOWN OPERATION: " + CrudOperations.getName(operation) - + " on " + uri); + LOGGER.info("UNKNOWN OPERATION: " + CrudOperations.getName(operation) + " on " + uri); break; } } @@ -116,10 +112,10 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { if (!tempFolder.exists()) { boolean tempFolderCreated = tempFolder.mkdirs(); if (tempFolderCreated) { - LOGGER.info(CLASS_NAME + "Temp folder not yet existing! Created new folder: " - + tempFolder.getAbsolutePath()); + LOGGER.info( + "Temp folder not yet existing! Created new folder: " + tempFolder.getAbsolutePath()); } else { - LOGGER.fine(CLASS_NAME + "Temp folder already existing: " + tempFolder.getAbsolutePath()); + LOGGER.fine("Temp folder already existing: " + tempFolder.getAbsolutePath()); } } @@ -134,10 +130,10 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { if (!pFolder.exists()) { boolean cacheFolderCreated = pFolder.mkdirs(); if (cacheFolderCreated) { - LOGGER.info(CLASS_NAME + "Cache folder not yet existing! Created new folder: " - + pFolder.getAbsolutePath()); + LOGGER.info( + "Cache folder not yet existing! Created new folder: " + pFolder.getAbsolutePath()); } else { - LOGGER.fine(CLASS_NAME + "Cache folder already existing: " + pFolder.getAbsolutePath()); + LOGGER.fine("Cache folder already existing: " + pFolder.getAbsolutePath()); } } } @@ -148,8 +144,8 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { // Retrieve image from DH-crud and store image to original path. this.dhconnect.getObjectData(theURI, tempFile); - LOGGER.info(CLASS_NAME + "Data file temporarily stored to " + tempFile.getAbsolutePath() - + " (" + tempFile.length() + " bytes)"); + LOGGER.info("Data file temporarily stored to " + tempFile.getAbsolutePath() + " (" + + tempFile.length() + " bytes)"); // Original size JPEG is in jpeg-sf1 (scale factor 1). String origFile = @@ -160,22 +156,22 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { // Create all the other tiles. fractionalScale(prescaleFilename, origFile); - LOGGER.info(CLASS_NAME + "Scaling COMPLETE for " + prescaleFilename); + LOGGER.info("Scaling COMPLETE for " + prescaleFilename); } catch (NullPointerException | IOException e) { - LOGGER.log(Level.SEVERE, CLASS_NAME + "Could not store data file from DH-crud to " + LOGGER.log(Level.SEVERE, "Could not store data file from DH-crud to " + tempFile.getAbsolutePath() + "!", e); } catch (ImageReadException e) { - LOGGER.log(Level.WARNING, - CLASS_NAME + "Error identifying image properties: " + tempFile.getAbsolutePath(), e); + LOGGER.log(Level.WARNING, "Error identifying image properties: " + tempFile.getAbsolutePath(), + e); } finally { // Remove original data file from temp. boolean deleted = tempFile.delete(); if (!deleted) { - LOGGER.log(Level.WARNING, CLASS_NAME + "Could not delete orig data file from temp: " - + tempFile.getAbsolutePath() + "!"); + LOGGER.log(Level.WARNING, + "Could not delete orig data file from temp: " + tempFile.getAbsolutePath() + "!"); } else { - LOGGER.info(CLASS_NAME + "Temp file deletion complete: " + tempFile.getAbsolutePath()); + LOGGER.info("Temp file deletion complete: " + tempFile.getAbsolutePath()); } } } diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java b/src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java index 3ef876f..812758b 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java @@ -23,7 +23,6 @@ import io.smallrye.reactive.messaging.annotations.Blocking; */ public class TGPrescaleMessageConsumer extends TGMessageConsumerAbs { - private static final String CLASS_NAME = TGPrescaleMessageConsumer.class.getName() + " "; private static final String PUBLIC_STORAGE_PATH = "/data/public/productive/"; private static final String NONPUBLIC_STORAGE_PATH = "/data/nonpublic/productive/"; @@ -46,22 +45,22 @@ public class TGPrescaleMessageConsumer extends TGMessageConsumerAbs { switch (operation) { case CrudOperations.CREATE: - LOGGER.info(CLASS_NAME + "CREATE: prescaling " + uri); + LOGGER.info("CREATE: prescaling " + uri); prescale(uri, isPublic); break; case CrudOperations.UPDATE: - LOGGER.info(CLASS_NAME + "UPDATE: prescaling " + uri); + LOGGER.info("UPDATE: prescaling " + uri); prescale(uri, isPublic); break; case CrudOperations.DELETE: - LOGGER.info(CLASS_NAME + "DELETE " + uri); + LOGGER.info("DELETE " + uri); removePrescales(uri); break; case CrudOperations.UPDATEMETADATA: touchPrescales(uri); break; default: - LOGGER.info(CLASS_NAME + "UNKNOWN OPERATION: " + CrudOperations.getName(operation) + LOGGER.info("UNKNOWN OPERATION: " + CrudOperations.getName(operation) + " on " + uri); break; } @@ -82,18 +81,15 @@ public class TGPrescaleMessageConsumer extends TGMessageConsumerAbs { FileSystem fs = FileSystems.getDefault(); for (int i = 1; i <= MAX_FRACTION; i = i * 2) { - Path scaleJpegFile = - fs.getPath(PRESCALE_PATH + "jpeg-sf" + i + "/" + id + ".jpeg"); - Path tileTiffFile = - fs.getPath(PRESCALE_PATH + "tile-sf" + i + "/" + id + ".tiff"); + Path scaleJpegFile = fs.getPath(PRESCALE_PATH + "jpeg-sf" + i + "/" + id + ".jpeg"); + Path tileTiffFile = fs.getPath(PRESCALE_PATH + "tile-sf" + i + "/" + id + ".tiff"); try { Files.setLastModifiedTime(scaleJpegFile, modificationTime); Files.setLastModifiedTime(tileTiffFile, modificationTime); } catch (IOException e) { - LOGGER.log(Level.SEVERE, CLASS_NAME + "Error touching " + textgridUri, e); + LOGGER.log(Level.SEVERE, "Error touching " + textgridUri, e); } } - } /** @@ -106,15 +102,13 @@ public class TGPrescaleMessageConsumer extends TGMessageConsumerAbs { FileSystem fs = FileSystems.getDefault(); for (int i = 1; i <= MAX_FRACTION; i = i * 2) { - Path scaleJpegFile = - fs.getPath(PRESCALE_PATH + "jpeg-sf" + i + "/" + id + ".jpeg"); - Path tileTiffFile = - fs.getPath(PRESCALE_PATH + "tile-sf" + i + "/" + id + ".tiff"); + Path scaleJpegFile = fs.getPath(PRESCALE_PATH + "jpeg-sf" + i + "/" + id + ".jpeg"); + Path tileTiffFile = fs.getPath(PRESCALE_PATH + "tile-sf" + i + "/" + id + ".tiff"); try { Files.delete(scaleJpegFile); Files.delete(tileTiffFile); } catch (IOException e) { - LOGGER.log(Level.SEVERE, CLASS_NAME + "Error deleting " + textgridUri, e); + LOGGER.log(Level.SEVERE, "Error deleting " + textgridUri, e); } } } @@ -148,7 +142,7 @@ public class TGPrescaleMessageConsumer extends TGMessageConsumerAbs { pairtree = new JPairtree(textgridUri); String sourceFile = storagePath + pairtree.getPtreePathString() + pairtree.getPtreeEncodedId(); - LOGGER.info(CLASS_NAME + "Image source: " + sourceFile); + LOGGER.info("Image source: " + sourceFile); // original size jpeg is in jpeg-sf1 (scalefactor 1) String origFile = PRESCALE_PATH + "jpeg-sf1" + "/" + id + ".jpeg"; @@ -164,19 +158,18 @@ public class TGPrescaleMessageConsumer extends TGMessageConsumerAbs { fractionalScale(id, origFile); } catch (IOException e) { - LOGGER.log(Level.SEVERE, CLASS_NAME + "Error prescaling image: " + textgridUri, e); + LOGGER.log(Level.SEVERE, "Error prescaling image: " + textgridUri, e); } catch (ImageReadException e) { - LOGGER.log(Level.WARNING, CLASS_NAME + "Error identifying image properties: " + textgridUri, + LOGGER.log(Level.WARNING, "Error identifying image properties: " + textgridUri, e); } finally { // Remove link to original data file from temp. boolean deleted = tempLinkFile.delete(); if (!deleted) { - LOGGER.log(Level.WARNING, CLASS_NAME + "Could not delete link to orig data file from temp: " + LOGGER.log(Level.WARNING, "Could not delete link to orig data file from temp: " + tempLinkFile.getAbsolutePath() + "!"); } else { - LOGGER.info( - CLASS_NAME + "Temp link file deletion complete: " + tempLinkFile.getAbsolutePath()); + LOGGER.info("Temp link file deletion complete: " + tempLinkFile.getAbsolutePath()); } } } -- GitLab From a94c24199fbf5236820f6c8418ef550f1983a51c Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Thu, 1 Feb 2024 14:58:03 +0100 Subject: [PATCH 30/58] chore: add more logging --- .../messagebeans/DHPrescaleMessageConsumer.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java index 2175808..30c4a31 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java @@ -35,7 +35,7 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { @Blocking CompletionStage<Void> onMessage(Message<CrudMessage> message) { - LOGGER.log(Level.INFO, "START METHOD!"); + LOGGER.log(Level.INFO, "START METHOD DHPrescaleMessageConsumer()"); CrudMessage msg = fromMessage(message); @@ -107,8 +107,13 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { */ private void prescale(String theURI, boolean isPublic) { + LOGGER.info("START METHOD prescale()"); + // Create temp folder, if not yet existing. File tempFolder = new File(TEMP_PATH); + + LOGGER.info("temp folder: " + tempFolder.getAbsolutePath()); + if (!tempFolder.exists()) { boolean tempFolderCreated = tempFolder.mkdirs(); if (tempFolderCreated) { @@ -119,8 +124,12 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { } } + LOGGER.info("temp folder existing? " + tempFolder.exists()); + String prescaleFilename = getPrescaleFilenameOnly(theURI); + LOGGER.info("prescale filename: " + prescaleFilename); + // Get prescale pathes. FileSystem fs = FileSystems.getDefault(); List<Path> pathList = getPrescaleProcessingList(fs, prescaleFilename); -- GitLab From aa154072671ee85b5badedcf27cd5e88f1192684 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Thu, 1 Feb 2024 15:14:44 +0100 Subject: [PATCH 31/58] chore: more testing --- .../middleware/messagebeans/DHPrescaleMessageConsumer.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java index 30c4a31..ced5074 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java @@ -133,9 +133,15 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { // Get prescale pathes. FileSystem fs = FileSystems.getDefault(); List<Path> pathList = getPrescaleProcessingList(fs, prescaleFilename); + + LOGGER.info("pathList: " + pathList); + // Create cache folders here, if not yet existing. for (Path p : pathList) { File pFolder = p.toFile().getParentFile(); + + LOGGER.info("p folder: " + pFolder.getAbsolutePath()); + if (!pFolder.exists()) { boolean cacheFolderCreated = pFolder.mkdirs(); if (cacheFolderCreated) { -- GitLab From 07805e904339cc7981d0bbf1942256544a406b55 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Thu, 1 Feb 2024 15:38:07 +0100 Subject: [PATCH 32/58] chore: more loggggginggggggg --- .../DHLoggingMessageConsumer.java | 2 +- .../DHPrescaleMessageConsumer.java | 62 +++++++++++-------- .../messagebeans/MessageConsumerAbs.java | 12 +--- .../TGLoggingMessageConsumer.java | 2 +- .../TGPrescaleMessageConsumer.java | 27 ++++---- .../middleware/services/DHConnect.java | 31 +++++----- 6 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHLoggingMessageConsumer.java b/src/main/java/info/textgrid/middleware/messagebeans/DHLoggingMessageConsumer.java index 50f3dd7..7e3b9bc 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHLoggingMessageConsumer.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHLoggingMessageConsumer.java @@ -20,7 +20,7 @@ public class DHLoggingMessageConsumer extends MessageConsumerAbs { CompletionStage<Void> onMessage(Message<CrudMessage> message) { CrudMessage msg = fromMessage(message); - logMoreInfo(this.getClass().getSimpleName(), msg); + logInfo(this.getClass().getSimpleName(), msg); return message.ack(); } diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java index ced5074..d00e48f 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java @@ -8,7 +8,6 @@ import java.nio.file.Path; import java.nio.file.attribute.FileTime; import java.util.List; import java.util.concurrent.CompletionStage; -import java.util.logging.Level; import org.apache.commons.imaging.ImageReadException; import org.eclipse.microprofile.reactive.messaging.Incoming; import org.eclipse.microprofile.reactive.messaging.Message; @@ -24,6 +23,8 @@ import jakarta.inject.Inject; */ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { + private static final String CLASS_NAME = "{" + DHPrescaleMessageConsumer.class.getName() + "} "; + @Inject DHConnect dhconnect; @@ -35,7 +36,7 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { @Blocking CompletionStage<Void> onMessage(Message<CrudMessage> message) { - LOGGER.log(Level.INFO, "START METHOD DHPrescaleMessageConsumer()"); + LOGGER.info(CLASS_NAME + "START METHOD DHPrescaleMessageConsumer()"); CrudMessage msg = fromMessage(message); @@ -48,19 +49,20 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { switch (operation) { case CrudOperations.CREATE: - LOGGER.info("CREATE: Prescaling " + uri); + LOGGER.info(CLASS_NAME + "CREATE: Prescaling " + uri); prescale(uri, isPublic); break; case CrudOperations.UPDATE: - LOGGER.info("UPDATE: Rescaling " + uri); + LOGGER.info(CLASS_NAME + "UPDATE: Rescaling " + uri); prescale(uri, isPublic); break; case CrudOperations.DELETE: - LOGGER.info("DELETE: Deleting " + uri); + LOGGER.info(CLASS_NAME + "DELETE: Deleting " + uri); removePrescales(uri); break; default: - LOGGER.info("UNKNOWN OPERATION: " + CrudOperations.getName(operation) + " on " + uri); + LOGGER.warning(CLASS_NAME + "UNKNOWN OPERATION: " + CrudOperations.getName(operation) + + " on " + uri); break; } } @@ -107,60 +109,68 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { */ private void prescale(String theURI, boolean isPublic) { - LOGGER.info("START METHOD prescale()"); + LOGGER.info(CLASS_NAME + "START METHOD prescale()"); // Create temp folder, if not yet existing. File tempFolder = new File(TEMP_PATH); - LOGGER.info("temp folder: " + tempFolder.getAbsolutePath()); + LOGGER.info(CLASS_NAME + "temp folder: " + tempFolder.getAbsolutePath()); if (!tempFolder.exists()) { boolean tempFolderCreated = tempFolder.mkdirs(); if (tempFolderCreated) { - LOGGER.info( + LOGGER.info(CLASS_NAME + "Temp folder not yet existing! Created new folder: " + tempFolder.getAbsolutePath()); } else { - LOGGER.fine("Temp folder already existing: " + tempFolder.getAbsolutePath()); + LOGGER.fine(CLASS_NAME + "Temp folder already existing: " + tempFolder.getAbsolutePath()); } } - LOGGER.info("temp folder existing? " + tempFolder.exists()); + LOGGER.info(CLASS_NAME + "temp folder existing? " + tempFolder.exists()); String prescaleFilename = getPrescaleFilenameOnly(theURI); - LOGGER.info("prescale filename: " + prescaleFilename); + LOGGER.info(CLASS_NAME + "prescale filename: " + prescaleFilename); // Get prescale pathes. FileSystem fs = FileSystems.getDefault(); List<Path> pathList = getPrescaleProcessingList(fs, prescaleFilename); - LOGGER.info("pathList: " + pathList); + LOGGER.info(CLASS_NAME + "pathList: " + pathList); // Create cache folders here, if not yet existing. for (Path p : pathList) { File pFolder = p.toFile().getParentFile(); - LOGGER.info("p folder: " + pFolder.getAbsolutePath()); + LOGGER.info(CLASS_NAME + "p folder: " + pFolder.getAbsolutePath()); if (!pFolder.exists()) { boolean cacheFolderCreated = pFolder.mkdirs(); if (cacheFolderCreated) { - LOGGER.info( - "Cache folder not yet existing! Created new folder: " + pFolder.getAbsolutePath()); + LOGGER.info(CLASS_NAME + "Cache folder not yet existing! Created new folder: " + + pFolder.getAbsolutePath()); } else { - LOGGER.fine("Cache folder already existing: " + pFolder.getAbsolutePath()); + LOGGER.fine(CLASS_NAME + "Cache folder already existing: " + pFolder.getAbsolutePath()); } } + + LOGGER.info("p folder exists: " + pFolder.exists()); } // Get image path and create file. File tempFile = new File(tempFolder, prescaleFilename); + + LOGGER.info(CLASS_NAME + "temp file: " + tempFile.getAbsolutePath()); + try { // Retrieve image from DH-crud and store image to original path. this.dhconnect.getObjectData(theURI, tempFile); - LOGGER.info("Data file temporarily stored to " + tempFile.getAbsolutePath() + " (" - + tempFile.length() + " bytes)"); + + + LOGGER + .info(CLASS_NAME + "Data file temporarily stored to " + tempFile.getAbsolutePath() + " (" + + tempFile.length() + " bytes)"); // Original size JPEG is in jpeg-sf1 (scale factor 1). String origFile = @@ -174,19 +184,19 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { LOGGER.info("Scaling COMPLETE for " + prescaleFilename); } catch (NullPointerException | IOException e) { - LOGGER.log(Level.SEVERE, "Could not store data file from DH-crud to " - + tempFile.getAbsolutePath() + "!", e); + LOGGER.severe(CLASS_NAME + "Could not store data file from DH-crud to " + + tempFile.getAbsolutePath() + "!"); } catch (ImageReadException e) { - LOGGER.log(Level.WARNING, "Error identifying image properties: " + tempFile.getAbsolutePath(), - e); + LOGGER.warning( + CLASS_NAME + "Error identifying image properties: " + tempFile.getAbsolutePath()); } finally { // Remove original data file from temp. boolean deleted = tempFile.delete(); if (!deleted) { - LOGGER.log(Level.WARNING, - "Could not delete orig data file from temp: " + tempFile.getAbsolutePath() + "!"); + LOGGER.warning(CLASS_NAME + "Could not delete orig data file from temp: " + + tempFile.getAbsolutePath() + "!"); } else { - LOGGER.info("Temp file deletion complete: " + tempFile.getAbsolutePath()); + LOGGER.info(CLASS_NAME + "Temp file deletion complete: " + tempFile.getAbsolutePath()); } } } diff --git a/src/main/java/info/textgrid/middleware/messagebeans/MessageConsumerAbs.java b/src/main/java/info/textgrid/middleware/messagebeans/MessageConsumerAbs.java index 681965f..d8ebe76 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/MessageConsumerAbs.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/MessageConsumerAbs.java @@ -24,7 +24,7 @@ import info.textgrid.middleware.model.CrudMessage; */ public abstract class MessageConsumerAbs { - private static final String CLASS_NAME = MessageConsumerAbs.class.getName() + " "; + private static final String CLASS_NAME = "{" + MessageConsumerAbs.class.getName() + "} "; protected static final String PRESCALE_PATH = "/var/dhrep/digilib/prescale/"; @@ -71,15 +71,7 @@ public abstract class MessageConsumerAbs { * @param theClassName * @param theMessage */ - protected void logGeneralInfo(String theClassName, CrudMessage theMessage) { - LOGGER.info("{" + theClassName + "} " + RECEIVED + theMessage); - } - - /** - * @param theClassName - * @param theMessage - */ - protected void logMoreInfo(String theClassName, CrudMessage theMessage) { + protected void logInfo(String theClassName, CrudMessage theMessage) { LOGGER.info("{" + theClassName + "} " + RECEIVED + theMessage); } diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGLoggingMessageConsumer.java b/src/main/java/info/textgrid/middleware/messagebeans/TGLoggingMessageConsumer.java index 16374c1..1cbe6a3 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGLoggingMessageConsumer.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGLoggingMessageConsumer.java @@ -20,7 +20,7 @@ public class TGLoggingMessageConsumer extends TGMessageConsumerAbs { CompletionStage<Void> onMessage(Message<CrudMessage> message) { CrudMessage msg = fromMessage(message); - logMoreInfo(this.getClass().getSimpleName(), msg); + logInfo(this.getClass().getSimpleName(), msg); return message.ack(); } diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java b/src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java index 812758b..096ef7b 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java @@ -8,7 +8,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.attribute.FileTime; import java.util.concurrent.CompletionStage; -import java.util.logging.Level; import org.apache.commons.imaging.ImageReadException; import org.eclipse.microprofile.reactive.messaging.Incoming; import org.eclipse.microprofile.reactive.messaging.Message; @@ -23,6 +22,7 @@ import io.smallrye.reactive.messaging.annotations.Blocking; */ public class TGPrescaleMessageConsumer extends TGMessageConsumerAbs { + private static final String CLASS_NAME = "{" + TGPrescaleMessageConsumer.class.getName() + "} "; private static final String PUBLIC_STORAGE_PATH = "/data/public/productive/"; private static final String NONPUBLIC_STORAGE_PATH = "/data/nonpublic/productive/"; @@ -45,22 +45,23 @@ public class TGPrescaleMessageConsumer extends TGMessageConsumerAbs { switch (operation) { case CrudOperations.CREATE: - LOGGER.info("CREATE: prescaling " + uri); + LOGGER.info(CLASS_NAME + "CREATE: prescaling " + uri); prescale(uri, isPublic); break; case CrudOperations.UPDATE: - LOGGER.info("UPDATE: prescaling " + uri); + LOGGER.info(CLASS_NAME + "UPDATE: prescaling " + uri); prescale(uri, isPublic); break; case CrudOperations.DELETE: - LOGGER.info("DELETE " + uri); + LOGGER.info(CLASS_NAME + "DELETE " + uri); removePrescales(uri); break; case CrudOperations.UPDATEMETADATA: + LOGGER.fine(CLASS_NAME + "UPDATEMETADATA " + uri); touchPrescales(uri); break; default: - LOGGER.info("UNKNOWN OPERATION: " + CrudOperations.getName(operation) + LOGGER.warning(CLASS_NAME + "UNKNOWN OPERATION: " + CrudOperations.getName(operation) + " on " + uri); break; } @@ -87,7 +88,7 @@ public class TGPrescaleMessageConsumer extends TGMessageConsumerAbs { Files.setLastModifiedTime(scaleJpegFile, modificationTime); Files.setLastModifiedTime(tileTiffFile, modificationTime); } catch (IOException e) { - LOGGER.log(Level.SEVERE, "Error touching " + textgridUri, e); + LOGGER.severe(CLASS_NAME + "Error touching " + textgridUri); } } } @@ -108,7 +109,7 @@ public class TGPrescaleMessageConsumer extends TGMessageConsumerAbs { Files.delete(scaleJpegFile); Files.delete(tileTiffFile); } catch (IOException e) { - LOGGER.log(Level.SEVERE, "Error deleting " + textgridUri, e); + LOGGER.severe(CLASS_NAME + "Error deleting " + textgridUri); } } } @@ -142,7 +143,7 @@ public class TGPrescaleMessageConsumer extends TGMessageConsumerAbs { pairtree = new JPairtree(textgridUri); String sourceFile = storagePath + pairtree.getPtreePathString() + pairtree.getPtreeEncodedId(); - LOGGER.info("Image source: " + sourceFile); + LOGGER.info(CLASS_NAME + "Image source: " + sourceFile); // original size jpeg is in jpeg-sf1 (scalefactor 1) String origFile = PRESCALE_PATH + "jpeg-sf1" + "/" + id + ".jpeg"; @@ -158,18 +159,18 @@ public class TGPrescaleMessageConsumer extends TGMessageConsumerAbs { fractionalScale(id, origFile); } catch (IOException e) { - LOGGER.log(Level.SEVERE, "Error prescaling image: " + textgridUri, e); + LOGGER.severe(CLASS_NAME + "Error prescaling image: " + textgridUri); } catch (ImageReadException e) { - LOGGER.log(Level.WARNING, "Error identifying image properties: " + textgridUri, - e); + LOGGER.warning(CLASS_NAME + "Error identifying image properties: " + textgridUri); } finally { // Remove link to original data file from temp. boolean deleted = tempLinkFile.delete(); if (!deleted) { - LOGGER.log(Level.WARNING, "Could not delete link to orig data file from temp: " + LOGGER.warning(CLASS_NAME + "Could not delete link to orig data file from temp: " + tempLinkFile.getAbsolutePath() + "!"); } else { - LOGGER.info("Temp link file deletion complete: " + tempLinkFile.getAbsolutePath()); + LOGGER.info( + CLASS_NAME + "Temp link file deletion complete: " + tempLinkFile.getAbsolutePath()); } } } diff --git a/src/main/java/info/textgrid/middleware/services/DHConnect.java b/src/main/java/info/textgrid/middleware/services/DHConnect.java index b3122b2..4d909f1 100644 --- a/src/main/java/info/textgrid/middleware/services/DHConnect.java +++ b/src/main/java/info/textgrid/middleware/services/DHConnect.java @@ -6,13 +6,10 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.net.URISyntaxException; import java.net.URL; import java.util.Properties; -import java.util.logging.Level; import java.util.logging.Logger; import org.apache.commons.io.FileUtils; -import org.eclipse.microprofile.rest.client.RestClientDefinitionException; import jakarta.enterprise.context.ApplicationScoped; import jakarta.ws.rs.client.Client; import jakarta.ws.rs.client.ClientBuilder; @@ -25,8 +22,8 @@ import jakarta.ws.rs.core.Response; @ApplicationScoped public class DHConnect { - private final Logger LOGGER = Logger.getLogger(DHConnect.class.getName()); - private final String CLASS_NAME = DHConnect.class.getName() + " "; + private static final Logger LOGGER = Logger.getLogger(DHConnect.class.getName()); + private static final String CLASS_NAME = DHConnect.class.getName() + " "; private String propertiesLocation; private Properties properties; @@ -34,12 +31,9 @@ public class DHConnect { private Client dhclient; /** - * @throws IllegalStateException - * @throws RestClientDefinitionException - * @throws URISyntaxException + * */ - public DHConnect() - throws IllegalStateException, RestClientDefinitionException, URISyntaxException { + public DHConnect() { this.propertiesLocation = "/etc/dhrep/messagebeans/dhmb.properties"; @@ -54,9 +48,9 @@ public class DHConnect { this.crudUrl = new URL(this.properties.getProperty("crudUrl")); } catch (FileNotFoundException e) { - this.LOGGER.log(Level.SEVERE, "Properties file not found!", e); + LOGGER.severe(CLASS_NAME + "Properties file not found!"); } catch (IOException e) { - this.LOGGER.log(Level.SEVERE, "Unable to get CRUD URL from properties file!", e); + LOGGER.severe(CLASS_NAME + "Unable to get CRUD URL from properties file!"); } if (this.dhclient == null) { @@ -73,21 +67,24 @@ public class DHConnect { WebTarget target = this.dhclient.target(this.crudUrl.toString()).path(theUri + "/data"); - this.LOGGER.info(this.CLASS_NAME + "Reading DH-crud data file from: " + target.getUri()); + LOGGER.info(CLASS_NAME + "crud url: " + this.crudUrl); + LOGGER.info(CLASS_NAME + "uri: " + theUri); + LOGGER.info(CLASS_NAME + "temp file: " + theTempFile); + + LOGGER.info(CLASS_NAME + "Reading DH-crud data file from: " + target.getUri()); try (Response response = target.request().get()) { int status = response.getStatus(); String reasonPhrase = response.getStatusInfo().getReasonPhrase(); - this.LOGGER.info(this.CLASS_NAME + "Status: " + status + " " + reasonPhrase); + LOGGER.info(CLASS_NAME + "Status: " + status + " " + reasonPhrase); - this.LOGGER.info(this.CLASS_NAME + "Storing data from " + theUri + " to " + theTempFile); + LOGGER.info(CLASS_NAME + "Storing data from " + theUri + " to " + theTempFile); FileUtils.copyInputStreamToFile(response.readEntity(InputStream.class), theTempFile); - this.LOGGER - .info(this.CLASS_NAME + "Copied data to temp file: " + theTempFile.getCanonicalPath()); + LOGGER.info(CLASS_NAME + "Copied data to temp file: " + theTempFile.getCanonicalPath()); response.close(); } -- GitLab From cdc9888cc28e0edd5976036ea978a4eee792f516 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Thu, 1 Feb 2024 15:49:27 +0100 Subject: [PATCH 33/58] chore: aaaaaaaaahhhh!!!!!!! --- .../info/textgrid/middleware/services/DHConnect.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/info/textgrid/middleware/services/DHConnect.java b/src/main/java/info/textgrid/middleware/services/DHConnect.java index 4d909f1..c109901 100644 --- a/src/main/java/info/textgrid/middleware/services/DHConnect.java +++ b/src/main/java/info/textgrid/middleware/services/DHConnect.java @@ -63,7 +63,7 @@ public class DHConnect { * @param theTempFile * @throws IOException */ - public void getObjectData(String theUri, File theTempFile) throws IOException { + public void getObjectData(String theUri, File theTempFile) { WebTarget target = this.dhclient.target(this.crudUrl.toString()).path(theUri + "/data"); @@ -84,9 +84,15 @@ public class DHConnect { FileUtils.copyInputStreamToFile(response.readEntity(InputStream.class), theTempFile); - LOGGER.info(CLASS_NAME + "Copied data to temp file: " + theTempFile.getCanonicalPath()); + LOGGER.info(CLASS_NAME + "Copied data to temp file: " + theTempFile.getAbsolutePath()); response.close(); + + } catch (IOException e) { + + LOGGER.severe(CLASS_NAME + "ERROR: " + e.getMessage()); + + e.printStackTrace(); } } -- GitLab From 57e1e9a2c803dd307799324643ad8c5f782d6647 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Thu, 1 Feb 2024 16:12:28 +0100 Subject: [PATCH 34/58] chore: argargargargarg --- .../messagebeans/DHPrescaleMessageConsumer.java | 13 ++++++++----- .../messagebeans/TGPrescaleMessageConsumer.java | 3 ++- .../textgrid/middleware/services/DHConnect.java | 6 ++++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java index d00e48f..e3d5328 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java @@ -163,19 +163,22 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { LOGGER.info(CLASS_NAME + "temp file: " + tempFile.getAbsolutePath()); try { + LOGGER.info(CLASS_NAME + "calling getObjectData(" + theURI + ")!"); + // Retrieve image from DH-crud and store image to original path. this.dhconnect.getObjectData(theURI, tempFile); + LOGGER.info(CLASS_NAME + "temp file exists? " + tempFile.exists()); - - LOGGER - .info(CLASS_NAME + "Data file temporarily stored to " + tempFile.getAbsolutePath() + " (" - + tempFile.length() + " bytes)"); + LOGGER.info(CLASS_NAME + "Data file temporarily stored to " + tempFile.getAbsolutePath() + + " (" + tempFile.length() + " bytes)"); // Original size JPEG is in jpeg-sf1 (scale factor 1). String origFile = PRESCALE_PATH + "jpeg-sf1" + File.separatorChar + prescaleFilename + JPEG_SUFFIX; + LOGGER.info(CLASS_NAME + "origFile: " + origFile); + // Create JPEG in original size. execVipsJpegsave(tempFile.getAbsolutePath(), origFile); // Create all the other tiles. @@ -183,7 +186,7 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { LOGGER.info("Scaling COMPLETE for " + prescaleFilename); - } catch (NullPointerException | IOException e) { + } catch (IOException e) { LOGGER.severe(CLASS_NAME + "Could not store data file from DH-crud to " + tempFile.getAbsolutePath() + "!"); } catch (ImageReadException e) { diff --git a/src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java b/src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java index 096ef7b..bf7097d 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/TGPrescaleMessageConsumer.java @@ -22,7 +22,8 @@ import io.smallrye.reactive.messaging.annotations.Blocking; */ public class TGPrescaleMessageConsumer extends TGMessageConsumerAbs { - private static final String CLASS_NAME = "{" + TGPrescaleMessageConsumer.class.getName() + "} "; + private static final String CLASS_NAME = + "{" + TGPrescaleMessageConsumer.class.getSimpleName() + "} "; private static final String PUBLIC_STORAGE_PATH = "/data/public/productive/"; private static final String NONPUBLIC_STORAGE_PATH = "/data/nonpublic/productive/"; diff --git a/src/main/java/info/textgrid/middleware/services/DHConnect.java b/src/main/java/info/textgrid/middleware/services/DHConnect.java index c109901..5d8f1a2 100644 --- a/src/main/java/info/textgrid/middleware/services/DHConnect.java +++ b/src/main/java/info/textgrid/middleware/services/DHConnect.java @@ -22,8 +22,8 @@ import jakarta.ws.rs.core.Response; @ApplicationScoped public class DHConnect { - private static final Logger LOGGER = Logger.getLogger(DHConnect.class.getName()); - private static final String CLASS_NAME = DHConnect.class.getName() + " "; + private static final Logger LOGGER = Logger.getLogger(DHConnect.class.getSimpleName()); + private static final String CLASS_NAME = DHConnect.class.getSimpleName() + " "; private String propertiesLocation; private Properties properties; @@ -56,6 +56,8 @@ public class DHConnect { if (this.dhclient == null) { this.dhclient = ClientBuilder.newClient().property("thread.safe.client", "true"); } + + LOGGER.info(CLASS_NAME + "dhclient: " + this.dhclient.getConfiguration().getProperties()); } /** -- GitLab From 7a50176e2cfc6e40ed16e26bea44a1e8e14d4264 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Thu, 1 Feb 2024 16:25:53 +0100 Subject: [PATCH 35/58] chore: hmpf --- .../middleware/messagebeans/DHPrescaleMessageConsumer.java | 7 +++++-- .../java/info/textgrid/middleware/services/DHConnect.java | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java index e3d5328..0451629 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java @@ -23,7 +23,8 @@ import jakarta.inject.Inject; */ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { - private static final String CLASS_NAME = "{" + DHPrescaleMessageConsumer.class.getName() + "} "; + private static final String CLASS_NAME = + "{" + DHPrescaleMessageConsumer.class.getSimpleName() + "} "; @Inject DHConnect dhconnect; @@ -36,7 +37,7 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { @Blocking CompletionStage<Void> onMessage(Message<CrudMessage> message) { - LOGGER.info(CLASS_NAME + "START METHOD DHPrescaleMessageConsumer()"); + LOGGER.info(CLASS_NAME + "---------- START METHOD onMessage() ----------"); CrudMessage msg = fromMessage(message); @@ -65,6 +66,8 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { + " on " + uri); break; } + + LOGGER.info(CLASS_NAME + "---------- END METHOD onMessage() ----------"); } return message.ack(); diff --git a/src/main/java/info/textgrid/middleware/services/DHConnect.java b/src/main/java/info/textgrid/middleware/services/DHConnect.java index 5d8f1a2..b61159a 100644 --- a/src/main/java/info/textgrid/middleware/services/DHConnect.java +++ b/src/main/java/info/textgrid/middleware/services/DHConnect.java @@ -22,8 +22,8 @@ import jakarta.ws.rs.core.Response; @ApplicationScoped public class DHConnect { - private static final Logger LOGGER = Logger.getLogger(DHConnect.class.getSimpleName()); - private static final String CLASS_NAME = DHConnect.class.getSimpleName() + " "; + private static final Logger LOGGER = Logger.getLogger(DHConnect.class.getName()); + private static final String CLASS_NAME = "{" + DHConnect.class.getSimpleName() + "} "; private String propertiesLocation; private Properties properties; -- GitLab From 720adc2a92809d1ee89010616a79aff5efb127cc Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Thu, 1 Feb 2024 16:34:33 +0100 Subject: [PATCH 36/58] chore: mc --- .../middleware/messagebeans/DHPrescaleMessageConsumer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java index 0451629..29e6b4d 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java @@ -66,10 +66,10 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { + " on " + uri); break; } - - LOGGER.info(CLASS_NAME + "---------- END METHOD onMessage() ----------"); } + LOGGER.info(CLASS_NAME + "---------- END METHOD onMessage() ----------"); + return message.ack(); } -- GitLab From fb9c0eadee4e3dd9a8403283e60b625dcef9b117 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 2 Feb 2024 11:48:22 +0100 Subject: [PATCH 37/58] fix: update jvm-multistage image --- src/main/docker/Dockerfile.jvm-multistage | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/docker/Dockerfile.jvm-multistage b/src/main/docker/Dockerfile.jvm-multistage index af9efce..c3714c4 100644 --- a/src/main/docker/Dockerfile.jvm-multistage +++ b/src/main/docker/Dockerfile.jvm-multistage @@ -6,10 +6,18 @@ RUN --mount=type=cache,target=/root/.m2 mvn clean package ## Stage 2 : create the docker final image -FROM registry.access.redhat.com/ubi8/openjdk-17:1.18 +#FROM registry.access.redhat.com/ubi8/openjdk-17:1.18 +FROM debian:bookworm-slim ENV LANGUAGE='en_US:en' +WORKDIR /work/ +COPY --from=build /code/target/*-runner /work/application +RUN chmod 775 /work +RUN apt-get update -y && apt-get upgrade -y && apt-get install --no-install-recommends -y \ + openjdk-17-jdk \ + # save some space + && rm -rf /var/lib/apt/lists/* # We make four distinct layers so if there are application changes the library layers can be re-used COPY --from=build --chown=185 /code/target/quarkus-app/lib/ /deployments/lib/ @@ -22,5 +30,5 @@ USER 185 ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" -ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] - +#ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] +ENTRYPOINT ["java -jar", "/deployments/quarkus-run.jar", "-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"] -- GitLab From 17a5825fa53885acedf8b367688bb66fbd40305b Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 2 Feb 2024 12:13:50 +0100 Subject: [PATCH 38/58] fix: activate jvm-multistage image --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 21f7fce..a9fc001 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ variables: GIT_AUTHOR_NAME: ${GL_USER} GIT_COMMITTER_EMAIL: ${GL_USER}@noreply.gitlab.gwdg.de GIT_COMMITTER_NAME: ${GL_USER} - DOCKERFILE: $CI_PROJECT_DIR/src/main/docker/Dockerfile.native-multistage + DOCKERFILE: $CI_PROJECT_DIR/src/main/docker/Dockerfile.jvm-multistage # Include Java settings from Gitlab templates repo. include: -- GitLab From 5809635e26a13299f592ce373604a4d77ce5437e Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 2 Feb 2024 12:51:04 +0100 Subject: [PATCH 39/58] fix: remove unwanted line --- src/main/docker/Dockerfile.jvm-multistage | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/docker/Dockerfile.jvm-multistage b/src/main/docker/Dockerfile.jvm-multistage index c3714c4..1705d2f 100644 --- a/src/main/docker/Dockerfile.jvm-multistage +++ b/src/main/docker/Dockerfile.jvm-multistage @@ -12,7 +12,6 @@ FROM debian:bookworm-slim ENV LANGUAGE='en_US:en' WORKDIR /work/ -COPY --from=build /code/target/*-runner /work/application RUN chmod 775 /work RUN apt-get update -y && apt-get upgrade -y && apt-get install --no-install-recommends -y \ openjdk-17-jdk \ -- GitLab From bc372f7cdf1c835c6c4c5889260b1fd98af25267 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 2 Feb 2024 17:40:19 +0100 Subject: [PATCH 40/58] fix: add vips to jvm dockerfile --- src/main/docker/Dockerfile.jvm-multistage | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/docker/Dockerfile.jvm-multistage b/src/main/docker/Dockerfile.jvm-multistage index 1705d2f..00140dd 100644 --- a/src/main/docker/Dockerfile.jvm-multistage +++ b/src/main/docker/Dockerfile.jvm-multistage @@ -4,30 +4,27 @@ COPY . /code/ WORKDIR /code RUN --mount=type=cache,target=/root/.m2 mvn clean package - ## Stage 2 : create the docker final image #FROM registry.access.redhat.com/ubi8/openjdk-17:1.18 FROM debian:bookworm-slim - ENV LANGUAGE='en_US:en' - WORKDIR /work/ RUN chmod 775 /work -RUN apt-get update -y && apt-get upgrade -y && apt-get install --no-install-recommends -y \ +RUN apt-get update -y && \ + apt-get upgrade -y && \ + apt-get install --no-install-recommends -y \ openjdk-17-jdk \ + libvips-tools \ # save some space && rm -rf /var/lib/apt/lists/* - # We make four distinct layers so if there are application changes the library layers can be re-used COPY --from=build --chown=185 /code/target/quarkus-app/lib/ /deployments/lib/ COPY --from=build --chown=185 /code/target/quarkus-app/*.jar /deployments/ COPY --from=build --chown=185 /code/target/quarkus-app/app/ /deployments/app/ COPY --from=build --chown=185 /code/target/quarkus-app/quarkus/ /deployments/quarkus/ - EXPOSE 8080 USER 185 ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" - #ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] ENTRYPOINT ["java -jar", "/deployments/quarkus-run.jar", "-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"] -- GitLab From a177344530dd9223f23d51096d2548940a7775bc Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 2 Feb 2024 17:50:52 +0100 Subject: [PATCH 41/58] test: add echos for testing container start --- src/main/docker/Dockerfile.jvm-multistage | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/docker/Dockerfile.jvm-multistage b/src/main/docker/Dockerfile.jvm-multistage index 00140dd..f0793cf 100644 --- a/src/main/docker/Dockerfile.jvm-multistage +++ b/src/main/docker/Dockerfile.jvm-multistage @@ -27,4 +27,8 @@ USER 185 ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" #ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] + +RUN echo $PATH +RUN which java + ENTRYPOINT ["java -jar", "/deployments/quarkus-run.jar", "-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"] -- GitLab From 71fc4a0f9f2a4c4595251fe15bea128a7f971517 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 2 Feb 2024 18:01:41 +0100 Subject: [PATCH 42/58] fix: fix entrypoint --- src/main/docker/Dockerfile.jvm-multistage | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/docker/Dockerfile.jvm-multistage b/src/main/docker/Dockerfile.jvm-multistage index f0793cf..c8b8bc4 100644 --- a/src/main/docker/Dockerfile.jvm-multistage +++ b/src/main/docker/Dockerfile.jvm-multistage @@ -27,8 +27,4 @@ USER 185 ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" #ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] - -RUN echo $PATH -RUN which java - -ENTRYPOINT ["java -jar", "/deployments/quarkus-run.jar", "-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"] +ENTRYPOINT ["java", "-jar", $JAVA_APP_JAR, $JAVA_OPTS] -- GitLab From f3f8bdb0eae0756e51583ae6fe27bceb0a18017b Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 2 Feb 2024 18:05:26 +0100 Subject: [PATCH 43/58] fix: remove more things --- src/main/docker/Dockerfile.jvm-multistage | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main/docker/Dockerfile.jvm-multistage b/src/main/docker/Dockerfile.jvm-multistage index c8b8bc4..2404f57 100644 --- a/src/main/docker/Dockerfile.jvm-multistage +++ b/src/main/docker/Dockerfile.jvm-multistage @@ -17,14 +17,7 @@ RUN apt-get update -y && \ libvips-tools \ # save some space && rm -rf /var/lib/apt/lists/* -# We make four distinct layers so if there are application changes the library layers can be re-used -COPY --from=build --chown=185 /code/target/quarkus-app/lib/ /deployments/lib/ -COPY --from=build --chown=185 /code/target/quarkus-app/*.jar /deployments/ -COPY --from=build --chown=185 /code/target/quarkus-app/app/ /deployments/app/ -COPY --from=build --chown=185 /code/target/quarkus-app/quarkus/ /deployments/quarkus/ EXPOSE 8080 -USER 185 ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" -#ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] ENTRYPOINT ["java", "-jar", $JAVA_APP_JAR, $JAVA_OPTS] -- GitLab From c734f9f5e7a274f9e1de1ba52768a865dbb543be Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 2 Feb 2024 18:06:13 +0100 Subject: [PATCH 44/58] fix: ...and still more corrections --- src/main/docker/Dockerfile.jvm-multistage | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/docker/Dockerfile.jvm-multistage b/src/main/docker/Dockerfile.jvm-multistage index 2404f57..1c04b7e 100644 --- a/src/main/docker/Dockerfile.jvm-multistage +++ b/src/main/docker/Dockerfile.jvm-multistage @@ -17,7 +17,13 @@ RUN apt-get update -y && \ libvips-tools \ # save some space && rm -rf /var/lib/apt/lists/* +# We make four distinct layers so if there are application changes the library layers can be re-used +COPY --from=build /code/target/quarkus-app/lib/ /deployments/lib/ +COPY --from=build /code/target/quarkus-app/*.jar /deployments/ +COPY --from=build /code/target/quarkus-app/app/ /deployments/app/ +COPY --from=build /code/target/quarkus-app/quarkus/ /deployments/quarkus/ EXPOSE 8080 ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" +#ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] ENTRYPOINT ["java", "-jar", $JAVA_APP_JAR, $JAVA_OPTS] -- GitLab From c2a65bdca8ea1af3455acc0793f165cd67c29f39 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 2 Feb 2024 18:12:34 +0100 Subject: [PATCH 45/58] fix: more fixxxxes --- src/main/docker/Dockerfile.jvm-multistage | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/docker/Dockerfile.jvm-multistage b/src/main/docker/Dockerfile.jvm-multistage index 1c04b7e..4236320 100644 --- a/src/main/docker/Dockerfile.jvm-multistage +++ b/src/main/docker/Dockerfile.jvm-multistage @@ -25,5 +25,4 @@ COPY --from=build /code/target/quarkus-app/quarkus/ /deployments/quarkus/ EXPOSE 8080 ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" -#ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] -ENTRYPOINT ["java", "-jar", $JAVA_APP_JAR, $JAVA_OPTS] +ENTRYPOINT ["/usr/lib/jvm/java-17-openjdk-amd64/bin/java", "-jar", "/deployments/quarkus-run.jar", "-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"] -- GitLab From ad89980dd0e42953c253ce9d4ad37947c4590846 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 2 Feb 2024 18:13:16 +0100 Subject: [PATCH 46/58] fix(da ist noch ein leerzeichen!!!): da ist noch ein leerzeichen! --- src/main/docker/Dockerfile.jvm-multistage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/docker/Dockerfile.jvm-multistage b/src/main/docker/Dockerfile.jvm-multistage index 4236320..9e8db18 100644 --- a/src/main/docker/Dockerfile.jvm-multistage +++ b/src/main/docker/Dockerfile.jvm-multistage @@ -25,4 +25,4 @@ COPY --from=build /code/target/quarkus-app/quarkus/ /deployments/quarkus/ EXPOSE 8080 ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" -ENTRYPOINT ["/usr/lib/jvm/java-17-openjdk-amd64/bin/java", "-jar", "/deployments/quarkus-run.jar", "-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"] +ENTRYPOINT ["/usr/lib/jvm/java-17-openjdk-amd64/bin/java", "-jar", "/deployments/quarkus-run.jar", "-Dquarkus.http.host=0.0.0.0", "-Djava.util.logging.manager=org.jboss.logmanager.LogManager"] -- GitLab From 5661ad8e13ce330e985f101bc8b0d687a1133750 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 9 Feb 2024 15:06:06 +0100 Subject: [PATCH 47/58] fix: add more logging --- .../java/info/textgrid/middleware/services/DHConnect.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/info/textgrid/middleware/services/DHConnect.java b/src/main/java/info/textgrid/middleware/services/DHConnect.java index b61159a..5292a3f 100644 --- a/src/main/java/info/textgrid/middleware/services/DHConnect.java +++ b/src/main/java/info/textgrid/middleware/services/DHConnect.java @@ -69,10 +69,14 @@ public class DHConnect { WebTarget target = this.dhclient.target(this.crudUrl.toString()).path(theUri + "/data"); + LOGGER.info("client config: " + this.dhclient.getConfiguration().getProperties()); + LOGGER.info("target config: " + target.getConfiguration().getProperties()); + LOGGER.info(CLASS_NAME + "crud url: " + this.crudUrl); LOGGER.info(CLASS_NAME + "uri: " + theUri); LOGGER.info(CLASS_NAME + "temp file: " + theTempFile); + LOGGER.info(CLASS_NAME + "Reading DH-crud data file from: " + target.getUri()); try (Response response = target.request().get()) { -- GitLab From 7d25394394e1f68b51fb1fdca63f8b6057514a58 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 9 Feb 2024 15:17:51 +0100 Subject: [PATCH 48/58] fix: more logging --- .../info/textgrid/middleware/services/DHConnect.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/info/textgrid/middleware/services/DHConnect.java b/src/main/java/info/textgrid/middleware/services/DHConnect.java index 5292a3f..9807c21 100644 --- a/src/main/java/info/textgrid/middleware/services/DHConnect.java +++ b/src/main/java/info/textgrid/middleware/services/DHConnect.java @@ -54,7 +54,14 @@ public class DHConnect { } if (this.dhclient == null) { + + LOGGER.info("CREATING NEW DHCLIENT"); + LOGGER.info("crud url: " + this.crudUrl); + this.dhclient = ClientBuilder.newClient().property("thread.safe.client", "true"); + + LOGGER.info("hostname verifyer: " + this.dhclient.getHostnameVerifier()); + LOGGER.info("YEAH!"); } LOGGER.info(CLASS_NAME + "dhclient: " + this.dhclient.getConfiguration().getProperties()); @@ -69,10 +76,7 @@ public class DHConnect { WebTarget target = this.dhclient.target(this.crudUrl.toString()).path(theUri + "/data"); - LOGGER.info("client config: " + this.dhclient.getConfiguration().getProperties()); - LOGGER.info("target config: " + target.getConfiguration().getProperties()); - - LOGGER.info(CLASS_NAME + "crud url: " + this.crudUrl); + LOGGER.info("target uri: " + target.getUri()); LOGGER.info(CLASS_NAME + "uri: " + theUri); LOGGER.info(CLASS_NAME + "temp file: " + theTempFile); -- GitLab From f8dfd519dbab915c4235f13be46f5851a96782dd Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 9 Feb 2024 16:12:33 +0100 Subject: [PATCH 49/58] fix: cleared some logs --- .../DHPrescaleMessageConsumer.java | 28 +------------ .../middleware/services/DHConnect.java | 22 ----------- .../messagebeans/TestMessageBeanAbs.java | 39 +++++++++++++++++++ 3 files changed, 40 insertions(+), 49 deletions(-) diff --git a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java index 29e6b4d..304d8b7 100644 --- a/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java +++ b/src/main/java/info/textgrid/middleware/messagebeans/DHPrescaleMessageConsumer.java @@ -37,8 +37,6 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { @Blocking CompletionStage<Void> onMessage(Message<CrudMessage> message) { - LOGGER.info(CLASS_NAME + "---------- START METHOD onMessage() ----------"); - CrudMessage msg = fromMessage(message); // Select image mimetypes via TextGrid mimetypes from dariah-de-common. @@ -68,8 +66,6 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { } } - LOGGER.info(CLASS_NAME + "---------- END METHOD onMessage() ----------"); - return message.ack(); } @@ -112,13 +108,9 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { */ private void prescale(String theURI, boolean isPublic) { - LOGGER.info(CLASS_NAME + "START METHOD prescale()"); - // Create temp folder, if not yet existing. File tempFolder = new File(TEMP_PATH); - LOGGER.info(CLASS_NAME + "temp folder: " + tempFolder.getAbsolutePath()); - if (!tempFolder.exists()) { boolean tempFolderCreated = tempFolder.mkdirs(); if (tempFolderCreated) { @@ -129,24 +121,16 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { } } - LOGGER.info(CLASS_NAME + "temp folder existing? " + tempFolder.exists()); - String prescaleFilename = getPrescaleFilenameOnly(theURI); - LOGGER.info(CLASS_NAME + "prescale filename: " + prescaleFilename); - // Get prescale pathes. FileSystem fs = FileSystems.getDefault(); List<Path> pathList = getPrescaleProcessingList(fs, prescaleFilename); - LOGGER.info(CLASS_NAME + "pathList: " + pathList); - // Create cache folders here, if not yet existing. for (Path p : pathList) { File pFolder = p.toFile().getParentFile(); - LOGGER.info(CLASS_NAME + "p folder: " + pFolder.getAbsolutePath()); - if (!pFolder.exists()) { boolean cacheFolderCreated = pFolder.mkdirs(); if (cacheFolderCreated) { @@ -156,23 +140,15 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { LOGGER.fine(CLASS_NAME + "Cache folder already existing: " + pFolder.getAbsolutePath()); } } - - LOGGER.info("p folder exists: " + pFolder.exists()); } // Get image path and create file. File tempFile = new File(tempFolder, prescaleFilename); - LOGGER.info(CLASS_NAME + "temp file: " + tempFile.getAbsolutePath()); - try { - LOGGER.info(CLASS_NAME + "calling getObjectData(" + theURI + ")!"); - // Retrieve image from DH-crud and store image to original path. this.dhconnect.getObjectData(theURI, tempFile); - LOGGER.info(CLASS_NAME + "temp file exists? " + tempFile.exists()); - LOGGER.info(CLASS_NAME + "Data file temporarily stored to " + tempFile.getAbsolutePath() + " (" + tempFile.length() + " bytes)"); @@ -180,14 +156,12 @@ public class DHPrescaleMessageConsumer extends MessageConsumerAbs { String origFile = PRESCALE_PATH + "jpeg-sf1" + File.separatorChar + prescaleFilename + JPEG_SUFFIX; - LOGGER.info(CLASS_NAME + "origFile: " + origFile); - // Create JPEG in original size. execVipsJpegsave(tempFile.getAbsolutePath(), origFile); // Create all the other tiles. fractionalScale(prescaleFilename, origFile); - LOGGER.info("Scaling COMPLETE for " + prescaleFilename); + LOGGER.info(CLASS_NAME + "Scaling COMPLETE for " + prescaleFilename); } catch (IOException e) { LOGGER.severe(CLASS_NAME + "Could not store data file from DH-crud to " diff --git a/src/main/java/info/textgrid/middleware/services/DHConnect.java b/src/main/java/info/textgrid/middleware/services/DHConnect.java index 9807c21..59a083f 100644 --- a/src/main/java/info/textgrid/middleware/services/DHConnect.java +++ b/src/main/java/info/textgrid/middleware/services/DHConnect.java @@ -54,14 +54,7 @@ public class DHConnect { } if (this.dhclient == null) { - - LOGGER.info("CREATING NEW DHCLIENT"); - LOGGER.info("crud url: " + this.crudUrl); - this.dhclient = ClientBuilder.newClient().property("thread.safe.client", "true"); - - LOGGER.info("hostname verifyer: " + this.dhclient.getHostnameVerifier()); - LOGGER.info("YEAH!"); } LOGGER.info(CLASS_NAME + "dhclient: " + this.dhclient.getConfiguration().getProperties()); @@ -76,22 +69,9 @@ public class DHConnect { WebTarget target = this.dhclient.target(this.crudUrl.toString()).path(theUri + "/data"); - LOGGER.info("target uri: " + target.getUri()); - LOGGER.info(CLASS_NAME + "uri: " + theUri); - LOGGER.info(CLASS_NAME + "temp file: " + theTempFile); - - LOGGER.info(CLASS_NAME + "Reading DH-crud data file from: " + target.getUri()); try (Response response = target.request().get()) { - - int status = response.getStatus(); - String reasonPhrase = response.getStatusInfo().getReasonPhrase(); - - LOGGER.info(CLASS_NAME + "Status: " + status + " " + reasonPhrase); - - LOGGER.info(CLASS_NAME + "Storing data from " + theUri + " to " + theTempFile); - FileUtils.copyInputStreamToFile(response.readEntity(InputStream.class), theTempFile); LOGGER.info(CLASS_NAME + "Copied data to temp file: " + theTempFile.getAbsolutePath()); @@ -101,8 +81,6 @@ public class DHConnect { } catch (IOException e) { LOGGER.severe(CLASS_NAME + "ERROR: " + e.getMessage()); - - e.printStackTrace(); } } diff --git a/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java b/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java index 44dcbde..86c1b29 100644 --- a/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java +++ b/src/test/java/info/textgrid/middleware/messagebeans/TestMessageBeanAbs.java @@ -1,11 +1,19 @@ package info.textgrid.middleware.messagebeans; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.Test; +import jakarta.ws.rs.client.Client; +import jakarta.ws.rs.client.ClientBuilder; +import jakarta.ws.rs.client.WebTarget; +import jakarta.ws.rs.core.Response; /** * @@ -75,4 +83,35 @@ public class TestMessageBeanAbs { } } + /** + * Testing online: dhcrud read access. + * + * @throws IOException + */ + // @Test + public void testGetFromDHCrudOnline() throws IOException { + + String host = "https://trep.de.dariah.eu/1.0/dhcrud/"; + String path = "hdl:21.T11991/0000-001D-8BF4-1/data"; + File tempFile = File.createTempFile("kakki-", "-fakki"); + + Client client = ClientBuilder.newClient().property("thread.safe.client", "true"); + WebTarget target = client.target(host).path(path); + + try (Response response = target.request().get()) { + + int status = response.getStatus(); + String reasonPhrase = response.getStatusInfo().getReasonPhrase(); + + System.out.println(status + " " + reasonPhrase); + + FileUtils.copyInputStreamToFile(response.readEntity(InputStream.class), tempFile); + + response.close(); + + } + + System.out.println(tempFile.getCanonicalPath() + " --> " + tempFile.length()); + } + } -- GitLab From f07fa2ebdc747e0bc9ed9eaf86171440ae7d611d Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 9 Feb 2024 16:33:10 +0100 Subject: [PATCH 50/58] fix: remove sbom from gitlab ci --> quarkus? --- .gitlab-ci.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a9fc001..f289eb1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -82,8 +82,7 @@ validate-java: junit: - "**/target/*-reports/TEST-*.xml" -# Build and deploy all the JARs to GWDG Nexus, and build all the DEBs and store DEBs to artifacts. -# NOTE: "deploy" also triggers BOM creation! +# Build and deploy all the JARs to GWDG Nexus. build-and-deploy-jars: stage: test-build-deploy-maven image: $MAVEN_IMAGE @@ -91,14 +90,10 @@ build-and-deploy-jars: - develop - tags script: - - mvn $MAVEN_OPTS $MAVEN_CLI_OPTS $MAVEN_DEPLOY_OPTS -U clean deploy -Psbom - - cp target/bom.json . + - mvn $MAVEN_OPTS $MAVEN_CLI_OPTS $MAVEN_DEPLOY_OPTS -U clean deploy artifacts: name: WEBAPP_DEB_PACKAGES - paths: - - ./bom.json reports: # Declare the JUnit reports (recursive pattern for multi-module projects) junit: - "**/target/*-reports/TEST-*.xml" - -- GitLab From b70e31f11956540c3b4d0be4ffaf51f9e6a52dbd Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 9 Feb 2024 16:50:48 +0100 Subject: [PATCH 51/58] fix: add sbom again to pom (?) --- .gitlab-ci.yml | 4 ++++ pom.xml | 54 +++++++++++++++++++++++++++++++++++++------------- 2 files changed, 44 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f289eb1..a899b74 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -91,9 +91,13 @@ build-and-deploy-jars: - tags script: - mvn $MAVEN_OPTS $MAVEN_CLI_OPTS $MAVEN_DEPLOY_OPTS -U clean deploy + - cp target/bom.json . artifacts: name: WEBAPP_DEB_PACKAGES + paths: + - ./bom.json reports: # Declare the JUnit reports (recursive pattern for multi-module projects) junit: - "**/target/*-reports/TEST-*.xml" + diff --git a/pom.xml b/pom.xml index 279aff7..7138a3e 100644 --- a/pom.xml +++ b/pom.xml @@ -7,12 +7,15 @@ <groupId>info.textgrid.middleware</groupId> <artifactId>message-beans</artifactId> <version>4.0.0-SNAPSHOT</version> + <name>DARIAHDE :: Repository :: Message Driven Beans</name> + <description>Message driven beans for the TextGrid and DARIAH-DE Repository</description> <properties> <compiler-plugin.version>3.11.0</compiler-plugin.version> <common.version>5.0.1-SNAPSHOT</common.version> <commons-imaging.version>1.0-alpha3</commons-imaging.version> <commons-io.version>2.15.1</commons-io.version> <crud.version>11.9.5-SNAPSHOT</crud.version> + <cyclonedx-maven-plugin.version>2.7.0</cyclonedx-maven-plugin.version> <maven.compiler.release>17</maven.compiler.release> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> @@ -90,6 +93,43 @@ <version>${commons-io.version}</version> </dependency> </dependencies> + <profiles> + <profile> + <id>sbom</id> + <build> + <plugins> + <plugin> + <groupId>org.cyclonedx</groupId> + <artifactId>cyclonedx-maven-plugin</artifactId> + <version>${cyclonedx-maven-plugin.version}</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>makeAggregateBom</goal> + </goals> + </execution> + </executions> + <configuration> + <outputFormat>JSON</outputFormat> + </configuration> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <properties> + <skipITs>false</skipITs> + <quarkus.package.type>native</quarkus.package.type> + </properties> + </profile> + </profiles> <build> <plugins> <plugin> @@ -147,18 +187,4 @@ </plugin> </plugins> </build> - <profiles> - <profile> - <id>native</id> - <activation> - <property> - <name>native</name> - </property> - </activation> - <properties> - <skipITs>false</skipITs> - <quarkus.package.type>native</quarkus.package.type> - </properties> - </profile> - </profiles> </project> -- GitLab From 923e185a041ddb251d12e643277b7bf12855a4a5 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 9 Feb 2024 17:01:32 +0100 Subject: [PATCH 52/58] fix: add distibution repository (?) --- pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pom.xml b/pom.xml index 7138a3e..2342f44 100644 --- a/pom.xml +++ b/pom.xml @@ -32,6 +32,13 @@ <url>https://nexus.gwdg.de/repository/maven-dariah-public/</url> </repository> </repositories> + <distributionManagement> + <repository> + <id>maven-dariah-public</id> + <name>GWDG Nexus DARIAH-DE Repository</name> + <url>https://nexus.gwdg.de/repository/maven-dariah-public/</url> + </repository> + </distributionManagement> <dependencyManagement> <dependencies> <dependency> -- GitLab From 1c7856d70f25b25ea2b1d504d8bb731863454959 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Fri, 9 Feb 2024 17:03:31 +0100 Subject: [PATCH 53/58] fix: add distribution repo (?) --- pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pom.xml b/pom.xml index 7138a3e..2342f44 100644 --- a/pom.xml +++ b/pom.xml @@ -32,6 +32,13 @@ <url>https://nexus.gwdg.de/repository/maven-dariah-public/</url> </repository> </repositories> + <distributionManagement> + <repository> + <id>maven-dariah-public</id> + <name>GWDG Nexus DARIAH-DE Repository</name> + <url>https://nexus.gwdg.de/repository/maven-dariah-public/</url> + </repository> + </distributionManagement> <dependencyManagement> <dependencies> <dependency> -- GitLab From 5eda6d30ca8fc4bfcbf658711fb28a808779b5c9 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Mon, 12 Feb 2024 09:58:39 +0100 Subject: [PATCH 54/58] fix: add distribution management --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index 2342f44..0c473ed 100644 --- a/pom.xml +++ b/pom.xml @@ -33,6 +33,11 @@ </repository> </repositories> <distributionManagement> + <snapshotRepository> + <id>maven-dariah-public</id> + <name>GWDG Nexus DARIAH-DE Repository</name> + <url>https://nexus.gwdg.de/repository/maven-dariah-public/</url> + </snapshotRepository> <repository> <id>maven-dariah-public</id> <name>GWDG Nexus DARIAH-DE Repository</name> -- GitLab From c2b5c06dea151554da855b67175a04a9a3f00e9c Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Mon, 12 Feb 2024 10:11:58 +0100 Subject: [PATCH 55/58] fix: add sbom to mvn build params again --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a899b74..a9fc001 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -82,7 +82,8 @@ validate-java: junit: - "**/target/*-reports/TEST-*.xml" -# Build and deploy all the JARs to GWDG Nexus. +# Build and deploy all the JARs to GWDG Nexus, and build all the DEBs and store DEBs to artifacts. +# NOTE: "deploy" also triggers BOM creation! build-and-deploy-jars: stage: test-build-deploy-maven image: $MAVEN_IMAGE @@ -90,7 +91,7 @@ build-and-deploy-jars: - develop - tags script: - - mvn $MAVEN_OPTS $MAVEN_CLI_OPTS $MAVEN_DEPLOY_OPTS -U clean deploy + - mvn $MAVEN_OPTS $MAVEN_CLI_OPTS $MAVEN_DEPLOY_OPTS -U clean deploy -Psbom - cp target/bom.json . artifacts: name: WEBAPP_DEB_PACKAGES -- GitLab From 6914693abe72d04a792787fe23d79891b6f2f7a6 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Mon, 12 Feb 2024 14:15:17 +0100 Subject: [PATCH 56/58] fix: add metrics and json output --- pom.xml | 4 ++++ src/main/resources/application.properties | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/pom.xml b/pom.xml index 0c473ed..65a6003 100644 --- a/pom.xml +++ b/pom.xml @@ -69,6 +69,10 @@ <groupId>io.quarkus</groupId> <artifactId>quarkus-rest-client-reactive-jaxb</artifactId> </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-micrometer-registry-prometheus</artifactId> + </dependency> <dependency> <groupId>info.textgrid.middleware</groupId> <artifactId>cacheutils</artifactId> diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 72cabe0..b5d0e57 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -20,3 +20,8 @@ mp.messaging.incoming.dhcrud.address=dhcrud-events # to allow multiple downstreams. mp.messaging.incoming.tgcrud.broadcast=true mp.messaging.incoming.dhcrud.broadcast=true + +# Enable json metrics +quarkus.micrometer.export.json.enabled=true +quarkus.micrometer.export.json.path=metrics/json +quarkus.micrometer.export.prometheus.path=metrics/prometheus -- GitLab From 3133f8cc76cc7c3dfa3bff795ace65cc0d6668f3 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Mon, 12 Feb 2024 16:05:27 +0100 Subject: [PATCH 57/58] fix: tabs to spaces! go! go! go! --- pom.xml | 400 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 200 insertions(+), 200 deletions(-) diff --git a/pom.xml b/pom.xml index 65a6003..9a29ff1 100644 --- a/pom.xml +++ b/pom.xml @@ -1,206 +1,206 @@ <?xml version="1.0"?> <project - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" - xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <modelVersion>4.0.0</modelVersion> - <groupId>info.textgrid.middleware</groupId> - <artifactId>message-beans</artifactId> - <version>4.0.0-SNAPSHOT</version> - <name>DARIAHDE :: Repository :: Message Driven Beans</name> - <description>Message driven beans for the TextGrid and DARIAH-DE Repository</description> - <properties> - <compiler-plugin.version>3.11.0</compiler-plugin.version> - <common.version>5.0.1-SNAPSHOT</common.version> - <commons-imaging.version>1.0-alpha3</commons-imaging.version> - <commons-io.version>2.15.1</commons-io.version> - <crud.version>11.9.5-SNAPSHOT</crud.version> - <cyclonedx-maven-plugin.version>2.7.0</cyclonedx-maven-plugin.version> - <maven.compiler.release>17</maven.compiler.release> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id> - <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id> - <quarkus.platform.version>3.6.3</quarkus.platform.version> - <skipITs>true</skipITs> - <surefire-plugin.version>3.1.2</surefire-plugin.version> - </properties> - <repositories> - <repository> - <id>maven-dariah-public</id> - <name>GWDG Nexus DARIAH-DE Repository</name> - <url>https://nexus.gwdg.de/repository/maven-dariah-public/</url> - </repository> - </repositories> - <distributionManagement> - <snapshotRepository> - <id>maven-dariah-public</id> - <name>GWDG Nexus DARIAH-DE Repository</name> - <url>https://nexus.gwdg.de/repository/maven-dariah-public/</url> - </snapshotRepository> - <repository> - <id>maven-dariah-public</id> - <name>GWDG Nexus DARIAH-DE Repository</name> - <url>https://nexus.gwdg.de/repository/maven-dariah-public/</url> - </repository> - </distributionManagement> - <dependencyManagement> - <dependencies> - <dependency> - <groupId>${quarkus.platform.group-id}</groupId> - <artifactId>${quarkus.platform.artifact-id}</artifactId> - <version>${quarkus.platform.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> - <dependencies> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-smallrye-reactive-messaging-amqp</artifactId> - <!--<artifactId>quarkus-smallrye-reactive-messaging-rabbitmq</artifactId> --> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-arc</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-rest-client-reactive-jaxb</artifactId> - </dependency> - <dependency> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <groupId>info.textgrid.middleware</groupId> + <artifactId>message-beans</artifactId> + <version>4.0.0-SNAPSHOT</version> + <name>DARIAHDE :: Repository :: Message Driven Beans</name> + <description>Message driven beans for the TextGrid and DARIAH-DE Repository</description> + <properties> + <compiler-plugin.version>3.11.0</compiler-plugin.version> + <common.version>5.0.1-SNAPSHOT</common.version> + <commons-imaging.version>1.0-alpha3</commons-imaging.version> + <commons-io.version>2.15.1</commons-io.version> + <crud.version>11.9.5-SNAPSHOT</crud.version> + <cyclonedx-maven-plugin.version>2.7.0</cyclonedx-maven-plugin.version> + <maven.compiler.release>17</maven.compiler.release> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id> + <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id> + <quarkus.platform.version>3.6.3</quarkus.platform.version> + <skipITs>true</skipITs> + <surefire-plugin.version>3.1.2</surefire-plugin.version> + </properties> + <repositories> + <repository> + <id>maven-dariah-public</id> + <name>GWDG Nexus DARIAH-DE Repository</name> + <url>https://nexus.gwdg.de/repository/maven-dariah-public/</url> + </repository> + </repositories> + <distributionManagement> + <snapshotRepository> + <id>maven-dariah-public</id> + <name>GWDG Nexus DARIAH-DE Repository</name> + <url>https://nexus.gwdg.de/repository/maven-dariah-public/</url> + </snapshotRepository> + <repository> + <id>maven-dariah-public</id> + <name>GWDG Nexus DARIAH-DE Repository</name> + <url>https://nexus.gwdg.de/repository/maven-dariah-public/</url> + </repository> + </distributionManagement> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>${quarkus.platform.group-id}</groupId> + <artifactId>${quarkus.platform.artifact-id}</artifactId> + <version>${quarkus.platform.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + <dependencies> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-smallrye-reactive-messaging-amqp</artifactId> + <!--<artifactId>quarkus-smallrye-reactive-messaging-rabbitmq</artifactId> --> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-arc</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-rest-client-reactive-jaxb</artifactId> + </dependency> + <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-micrometer-registry-prometheus</artifactId> </dependency> - <dependency> - <groupId>info.textgrid.middleware</groupId> - <artifactId>cacheutils</artifactId> - <version>${common.version}</version> - </dependency> - <dependency> - <groupId>info.textgrid.middleware</groupId> - <artifactId>const</artifactId> - <version>${common.version}</version> - </dependency> - <dependency> - <groupId>info.textgrid.middleware</groupId> - <artifactId>dhcrud-api</artifactId> - <version>${crud.version}</version> - </dependency> - <dependency> - <groupId>info.textgrid.middleware</groupId> - <artifactId>jpairtree</artifactId> - <version>${common.version}</version> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-imaging</artifactId> - <version>${commons-imaging.version}</version> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-junit5</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>${commons-io.version}</version> - </dependency> - </dependencies> - <profiles> - <profile> - <id>sbom</id> - <build> - <plugins> - <plugin> - <groupId>org.cyclonedx</groupId> - <artifactId>cyclonedx-maven-plugin</artifactId> - <version>${cyclonedx-maven-plugin.version}</version> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>makeAggregateBom</goal> - </goals> - </execution> - </executions> - <configuration> - <outputFormat>JSON</outputFormat> - </configuration> - </plugin> - </plugins> - </build> - </profile> - <profile> - <id>native</id> - <activation> - <property> - <name>native</name> - </property> - </activation> - <properties> - <skipITs>false</skipITs> - <quarkus.package.type>native</quarkus.package.type> - </properties> - </profile> - </profiles> - <build> - <plugins> - <plugin> - <groupId>${quarkus.platform.group-id}</groupId> - <artifactId>quarkus-maven-plugin</artifactId> - <version>${quarkus.platform.version}</version> - <extensions>true</extensions> - <executions> - <execution> - <goals> - <goal>build</goal> - <goal>generate-code</goal> - <goal>generate-code-tests</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <version>${compiler-plugin.version}</version> - <configuration> - <compilerArgs> - <arg>-parameters</arg> - </compilerArgs> - </configuration> - </plugin> - <plugin> - <artifactId>maven-surefire-plugin</artifactId> - <version>${surefire-plugin.version}</version> - <configuration> - <systemPropertyVariables> - <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> - <maven.home>${maven.home}</maven.home> - </systemPropertyVariables> - </configuration> - </plugin> - <plugin> - <artifactId>maven-failsafe-plugin</artifactId> - <version>${surefire-plugin.version}</version> - <executions> - <execution> - <goals> - <goal>integration-test</goal> - <goal>verify</goal> - </goals> - </execution> - </executions> - <configuration> - <systemPropertyVariables> - <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> - <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> - <maven.home>${maven.home}</maven.home> - </systemPropertyVariables> - </configuration> - </plugin> - </plugins> - </build> + <dependency> + <groupId>info.textgrid.middleware</groupId> + <artifactId>cacheutils</artifactId> + <version>${common.version}</version> + </dependency> + <dependency> + <groupId>info.textgrid.middleware</groupId> + <artifactId>const</artifactId> + <version>${common.version}</version> + </dependency> + <dependency> + <groupId>info.textgrid.middleware</groupId> + <artifactId>dhcrud-api</artifactId> + <version>${crud.version}</version> + </dependency> + <dependency> + <groupId>info.textgrid.middleware</groupId> + <artifactId>jpairtree</artifactId> + <version>${common.version}</version> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-imaging</artifactId> + <version>${commons-imaging.version}</version> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>${commons-io.version}</version> + </dependency> + </dependencies> + <profiles> + <profile> + <id>sbom</id> + <build> + <plugins> + <plugin> + <groupId>org.cyclonedx</groupId> + <artifactId>cyclonedx-maven-plugin</artifactId> + <version>${cyclonedx-maven-plugin.version}</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>makeAggregateBom</goal> + </goals> + </execution> + </executions> + <configuration> + <outputFormat>JSON</outputFormat> + </configuration> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <properties> + <skipITs>false</skipITs> + <quarkus.package.type>native</quarkus.package.type> + </properties> + </profile> + </profiles> + <build> + <plugins> + <plugin> + <groupId>${quarkus.platform.group-id}</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <version>${quarkus.platform.version}</version> + <extensions>true</extensions> + <executions> + <execution> + <goals> + <goal>build</goal> + <goal>generate-code</goal> + <goal>generate-code-tests</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>${compiler-plugin.version}</version> + <configuration> + <compilerArgs> + <arg>-parameters</arg> + </compilerArgs> + </configuration> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire-plugin.version}</version> + <configuration> + <systemPropertyVariables> + <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> + <maven.home>${maven.home}</maven.home> + </systemPropertyVariables> + </configuration> + </plugin> + <plugin> + <artifactId>maven-failsafe-plugin</artifactId> + <version>${surefire-plugin.version}</version> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + <configuration> + <systemPropertyVariables> + <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> + <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> + <maven.home>${maven.home}</maven.home> + </systemPropertyVariables> + </configuration> + </plugin> + </plugins> + </build> </project> -- GitLab From 2de33202a1f507835c8aa074ca73c71ea5ec09ae Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Thu, 23 May 2024 16:37:31 +0200 Subject: [PATCH 58/58] feat: using ampq instead of wildfly now! BREAKING CHANGE: NO WILDFLY anymore...! --- pom.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 9a29ff1..3ce0e3c 100644 --- a/pom.xml +++ b/pom.xml @@ -11,10 +11,10 @@ <description>Message driven beans for the TextGrid and DARIAH-DE Repository</description> <properties> <compiler-plugin.version>3.11.0</compiler-plugin.version> - <common.version>5.0.1-SNAPSHOT</common.version> + <common.version>6.1.0</common.version> <commons-imaging.version>1.0-alpha3</commons-imaging.version> <commons-io.version>2.15.1</commons-io.version> - <crud.version>11.9.5-SNAPSHOT</crud.version> + <crud.version>12.0.1</crud.version> <cyclonedx-maven-plugin.version>2.7.0</cyclonedx-maven-plugin.version> <maven.compiler.release>17</maven.compiler.release> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> @@ -59,7 +59,6 @@ <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-smallrye-reactive-messaging-amqp</artifactId> - <!--<artifactId>quarkus-smallrye-reactive-messaging-rabbitmq</artifactId> --> </dependency> <dependency> <groupId>io.quarkus</groupId> -- GitLab