@@ -36,23 +35,23 @@
*/
@Slf4j
@Component
-public class MessagePublisher {
+public class AsyncMessagePublisher {
private final JmsTemplate jmsTemplate;
private final Queue queue;
@Autowired
- public MessagePublisher(JmsTemplate jmsTemplate, Queue queue) {
+ public AsyncMessagePublisher(JmsTemplate jmsTemplate, Queue queue) {
this.jmsTemplate = jmsTemplate;
this.queue = queue;
}
@SuppressWarnings("unused")
- public void broadcastToAll(P payload);
+
+ void broadcastToSpecificBroadcaster(String broadcasterId, P payload);
+
+ void broadcastToSpecificResource(String resourceId, P payload);
+
+}
diff --git a/common-web-notification/src/main/java/io/herd/common/web/notification/NotificationService.java b/common-web-notification/src/main/java/io/herd/common/web/notification/service/NotificationServiceImpl.java
similarity index 80%
rename from common-web-notification/src/main/java/io/herd/common/web/notification/NotificationService.java
rename to common-web-notification/src/main/java/io/herd/common/web/notification/service/NotificationServiceImpl.java
index bcc7c96..f309808 100644
--- a/common-web-notification/src/main/java/io/herd/common/web/notification/NotificationService.java
+++ b/common-web-notification/src/main/java/io/herd/common/web/notification/service/NotificationServiceImpl.java
@@ -16,9 +16,10 @@
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-package io.herd.common.web.notification;
+package io.herd.common.web.notification.service;
import io.herd.common.web.UrlUtils;
+import io.herd.common.web.notification.domain.NotificationMessage;
import lombok.extern.slf4j.Slf4j;
import org.atmosphere.cpr.AtmosphereResource;
import org.atmosphere.cpr.AtmosphereResourceFactory;
@@ -31,7 +32,7 @@
@Slf4j
@Service
-public class NotificationService {
+public class NotificationServiceImpl implements NotificationService {
@Value("${spring.web.atmosphere.url.mapping:/atmosphere}")
private String atmosphereUrlMapping;
@@ -41,7 +42,7 @@ public class NotificationService {
private final AtmosphereResourceFactory atmosphereResourceFactory;
@Autowired
- public NotificationService(
+ public NotificationServiceImpl(
@Lazy BroadcasterFactory atmosphereBroadcasterFactory,
@Lazy AtmosphereResourceFactory atmosphereResourceFactory
) {
@@ -49,24 +50,26 @@ public NotificationService(
this.atmosphereResourceFactory = atmosphereResourceFactory;
}
- public void broadcastToAll(P payload) {
for (Broadcaster broadcaster : atmosphereBroadcasterFactory.lookupAll()) {
- broadcaster.broadcast(new Notification<>(message));
+ broadcaster.broadcast(new NotificationMessage<>(payload));
}
}
- public void broadcastToSpecificBroadcaster(String broadcasterId, P payload) {
String prefix = UrlUtils.appendSlash(atmosphereUrlMapping);
Broadcaster broadcaster = atmosphereBroadcasterFactory.lookup(prefix + broadcasterId);
if (broadcaster == null) {
log.warn("Atmosphere Broadcaster '{}' not found!", prefix + broadcasterId);
return;
}
-
- broadcaster.broadcast(new Notification<>(message));
+ broadcaster.broadcast(new NotificationMessage<>(payload));
}
- public void broadcastToSpecificResource(String resourceId, P payload) {
AtmosphereResource atmosphereResource = atmosphereResourceFactory.find(resourceId);
if (atmosphereResource == null) {
log.warn("Atmosphere Resource '{}' not found!", resourceId);
@@ -74,7 +77,7 @@ public
- *
* This way, when we annotate a class with {@link Validated}, Spring Boot will create a Proxy for this class
* and thus the validation will not work correctly if the validation annotations are not in the methods.
*/
diff --git a/common-web-security/src/main/java/io/herd/common/web/security/sign_request/authorization/SignRequestServletInputStream.java b/common-web-security/src/main/java/io/herd/common/web/security/sign_request/authorization/SignRequestServletInputStream.java
index df73dad..5051a61 100644
--- a/common-web-security/src/main/java/io/herd/common/web/security/sign_request/authorization/SignRequestServletInputStream.java
+++ b/common-web-security/src/main/java/io/herd/common/web/security/sign_request/authorization/SignRequestServletInputStream.java
@@ -20,6 +20,7 @@
import jakarta.servlet.ReadListener;
import jakarta.servlet.ServletInputStream;
+
import java.io.IOException;
import java.io.InputStream;
diff --git a/common-web-security/src/main/java/io/herd/common/web/security/sign_request/authorization/SignRequestSigner.java b/common-web-security/src/main/java/io/herd/common/web/security/sign_request/authorization/SignRequestSigner.java
index 5b8f7fa..f649d22 100644
--- a/common-web-security/src/main/java/io/herd/common/web/security/sign_request/authorization/SignRequestSigner.java
+++ b/common-web-security/src/main/java/io/herd/common/web/security/sign_request/authorization/SignRequestSigner.java
@@ -84,7 +84,9 @@ private String generateStringToSign(HttpServletRequest request) {
request.getHeader(HEADER_DATE);
}
- /** Instead of signing the whole request content directly, first we need to generate the hash. */
+ /**
+ * Instead of signing the whole request content directly, first we need to generate the hash.
+ */
@SneakyThrows({IOException.class, NoSuchAlgorithmException.class})
private String computeRequestBodyHash(InputStream fis) {
MessageDigest digest = MessageDigest.getInstance("MD5");
diff --git a/common-web-security/src/main/java/io/herd/common/web/security/sign_request/authorization/SignRequestWrapper.java b/common-web-security/src/main/java/io/herd/common/web/security/sign_request/authorization/SignRequestWrapper.java
index b25f3e3..40972cf 100644
--- a/common-web-security/src/main/java/io/herd/common/web/security/sign_request/authorization/SignRequestWrapper.java
+++ b/common-web-security/src/main/java/io/herd/common/web/security/sign_request/authorization/SignRequestWrapper.java
@@ -18,11 +18,11 @@
*/
package io.herd.common.web.security.sign_request.authorization;
-import org.apache.commons.io.IOUtils;
-
import jakarta.servlet.ServletInputStream;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequestWrapper;
+import org.apache.commons.io.IOUtils;
+
import java.io.*;
/**
diff --git a/common-web-security/src/test/java/io/herd/common/web/security/sign_request/authorization/SignRequestSignerTest.java b/common-web-security/src/test/java/io/herd/common/web/security/sign_request/authorization/SignRequestSignerTest.java
index c5bb47d..908dc9a 100644
--- a/common-web-security/src/test/java/io/herd/common/web/security/sign_request/authorization/SignRequestSignerTest.java
+++ b/common-web-security/src/test/java/io/herd/common/web/security/sign_request/authorization/SignRequestSignerTest.java
@@ -18,13 +18,13 @@
*/
package io.herd.common.web.security.sign_request.authorization;
+import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.mock.web.DelegatingServletInputStream;
-import jakarta.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -39,8 +39,8 @@ void shouldSignStringWithSuccess() throws IOException {
HttpServletRequest servletRequest = mock(HttpServletRequest.class);
when(servletRequest.getMethod()).thenReturn("POST");
doReturn(new DelegatingServletInputStream(
- IOUtils.toInputStream( "Testing Request Signature!", StandardCharsets.UTF_8)))
- .when(servletRequest).getInputStream();
+ IOUtils.toInputStream("Testing Request Signature!", StandardCharsets.UTF_8)
+ )).when(servletRequest).getInputStream();
when(servletRequest.getHeader(SignRequestSigner.HEADER_DATE)).thenReturn("Fri, 17 Jan 2020 18:30:00 GMT");
String secretKey = "!A%D*G-KaPdSgVkXp2s5v8y/B?E(H+MbQeThWmZq3t6w9z$C&F)J@NcRfUjXn2r5";
diff --git a/common-web/README.md b/common-web/README.md
index 8c42bd5..88b5fe1 100644
--- a/common-web/README.md
+++ b/common-web/README.md
@@ -1,7 +1,7 @@
SpringFox Support
---------------
-It will be necessary to copy the file `springdoc.properties` contained in the directory `/src/main/resources`
-of this project, to your application's `/src/main/resources` directory, changing the values
+It will be necessary to copy the file `springdoc.properties` contained in the directory `/src/main/resources`
+of this project, to your application's `/src/main/resources` directory, changing the values
of its properties according to the necessity.
Only copy this properties file, in case there is a change in the properties.
diff --git a/common-web/pom.xml b/common-web/pom.xml
index 286e671..543abd6 100644
--- a/common-web/pom.xml
+++ b/common-web/pom.xml
@@ -35,12 +35,15 @@