diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index d734a6748b..1462b4c9ca 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -8,10 +8,10 @@ import javax.servlet.http.HttpServletResponse; import org.baeldung.persistence.model.Foo; import org.baeldung.persistence.service.IFooService; import org.baeldung.web.exception.MyResourceNotFoundException; -import org.baeldung.web.hateoas.PaginatedResultsRetrievedEvent; -import org.baeldung.web.util.ResourceCreated; +import org.baeldung.web.hateoas.event.PaginatedResultsRetrievedEvent; +import org.baeldung.web.hateoas.event.ResourceCreatedEvent; +import org.baeldung.web.hateoas.event.SingleResourceRetrievedEvent; import org.baeldung.web.util.RestPreconditions; -import org.baeldung.web.util.SingleResourceRetrieved; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.data.domain.Page; @@ -51,7 +51,7 @@ public class FooController { public Foo findById(@PathVariable("id") final Long id, final HttpServletRequest request, final HttpServletResponse response) { final Foo resourceById = RestPreconditions.checkFound(service.findOne(id)); - eventPublisher.publishEvent(new SingleResourceRetrieved(this, request, response)); + eventPublisher.publishEvent(new SingleResourceRetrievedEvent(this, request, response)); return resourceById; } @@ -83,7 +83,7 @@ public class FooController { Preconditions.checkNotNull(resource); final Long idOfCreatedResource = service.create(resource).getId(); - eventPublisher.publishEvent(new ResourceCreated(this, response, idOfCreatedResource)); + eventPublisher.publishEvent(new ResourceCreatedEvent(this, response, idOfCreatedResource)); } } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/ResourceCreated.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/ResourceCreated.java deleted file mode 100644 index 3a2c8d3187..0000000000 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/ResourceCreated.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.baeldung.web.hateoas; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.context.ApplicationEvent; - -public class ResourceCreated extends ApplicationEvent { - private final HttpServletResponse response; - private final HttpServletRequest request; - private final long idOfNewResource; - - public ResourceCreated(final Object source, final HttpServletRequest request, final HttpServletResponse response, final long idOfNewResource) { - super(source); - - this.request = request; - this.response = response; - this.idOfNewResource = idOfNewResource; - } - - public HttpServletResponse getResponse() { - return response; - } - - public HttpServletRequest getRequest() { - return request; - } - - public long getIdOfNewResource() { - return idOfNewResource; - } - -} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/SingleResourceRetrieved.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/SingleResourceRetrieved.java deleted file mode 100644 index 8a115a1ff6..0000000000 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/SingleResourceRetrieved.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.baeldung.web.hateoas; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.context.ApplicationEvent; - -public class SingleResourceRetrieved extends ApplicationEvent { - private final HttpServletResponse response; - private final HttpServletRequest request; - - public SingleResourceRetrieved(final Object source, final HttpServletRequest request, final HttpServletResponse response) { - super(source); - - this.request = request; - this.response = response; - } - - public HttpServletResponse getResponse() { - return response; - } - - public HttpServletRequest getRequest() { - return request; - } -} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedEvent.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/PaginatedResultsRetrievedEvent.java similarity index 97% rename from spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedEvent.java rename to spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/PaginatedResultsRetrievedEvent.java index a9fe55ed3f..01f7e658f1 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedEvent.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/PaginatedResultsRetrievedEvent.java @@ -1,4 +1,4 @@ -package org.baeldung.web.hateoas; +package org.baeldung.web.hateoas.event; import java.io.Serializable; diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreated.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/ResourceCreatedEvent.java similarity index 68% rename from spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreated.java rename to spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/ResourceCreatedEvent.java index 8f0e85b5bc..efc04299bc 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreated.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/ResourceCreatedEvent.java @@ -1,14 +1,14 @@ -package org.baeldung.web.util; +package org.baeldung.web.hateoas.event; import javax.servlet.http.HttpServletResponse; import org.springframework.context.ApplicationEvent; -public class ResourceCreated extends ApplicationEvent { +public class ResourceCreatedEvent extends ApplicationEvent { private final HttpServletResponse response; private final long idOfNewResource; - public ResourceCreated(final Object source, final HttpServletResponse response, final long idOfNewResource) { + public ResourceCreatedEvent(final Object source, final HttpServletResponse response, final long idOfNewResource) { super(source); this.response = response; diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrieved.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/SingleResourceRetrievedEvent.java similarity index 67% rename from spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrieved.java rename to spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/SingleResourceRetrievedEvent.java index 143a73da65..e71fde51e2 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrieved.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/event/SingleResourceRetrievedEvent.java @@ -1,15 +1,15 @@ -package org.baeldung.web.util; +package org.baeldung.web.hateoas.event; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.context.ApplicationEvent; -public class SingleResourceRetrieved extends ApplicationEvent { +public class SingleResourceRetrievedEvent extends ApplicationEvent { private final HttpServletResponse response; private final HttpServletRequest request; - public SingleResourceRetrieved(final Object source, final HttpServletRequest request, final HttpServletResponse response) { + public SingleResourceRetrievedEvent(final Object source, final HttpServletRequest request, final HttpServletResponse response) { super(source); this.request = request; @@ -26,4 +26,4 @@ public class SingleResourceRetrieved extends ApplicationEvent { return request; } -} +} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedDiscoverabilityListener.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/PaginatedResultsRetrievedDiscoverabilityListener.java similarity index 97% rename from spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedDiscoverabilityListener.java rename to spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/PaginatedResultsRetrievedDiscoverabilityListener.java index dc65c754c6..312ead0ab0 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/PaginatedResultsRetrievedDiscoverabilityListener.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/PaginatedResultsRetrievedDiscoverabilityListener.java @@ -1,7 +1,8 @@ -package org.baeldung.web.hateoas; +package org.baeldung.web.hateoas.listener; import javax.servlet.http.HttpServletResponse; +import org.baeldung.web.hateoas.event.PaginatedResultsRetrievedEvent; import org.baeldung.web.util.LinkUtil; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreatedDiscoverabilityListener.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/ResourceCreatedDiscoverabilityListener.java similarity index 84% rename from spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreatedDiscoverabilityListener.java rename to spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/ResourceCreatedDiscoverabilityListener.java index aaceac0737..0b308712cb 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/util/ResourceCreatedDiscoverabilityListener.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/ResourceCreatedDiscoverabilityListener.java @@ -1,10 +1,11 @@ -package org.baeldung.web.util; +package org.baeldung.web.hateoas.listener; import java.net.URI; import javax.servlet.http.HttpServletResponse; import org.apache.http.HttpHeaders; +import org.baeldung.web.hateoas.event.ResourceCreatedEvent; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; import org.springframework.web.servlet.support.ServletUriComponentsBuilder; @@ -12,10 +13,10 @@ import org.springframework.web.servlet.support.ServletUriComponentsBuilder; import com.google.common.base.Preconditions; @Component -class ResourceCreatedDiscoverabilityListener implements ApplicationListener { +class ResourceCreatedDiscoverabilityListener implements ApplicationListener { @Override - public void onApplicationEvent(final ResourceCreated resourceCreatedEvent) { + public void onApplicationEvent(final ResourceCreatedEvent resourceCreatedEvent) { Preconditions.checkNotNull(resourceCreatedEvent); final HttpServletResponse response = resourceCreatedEvent.getResponse(); diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrievedDiscoverabilityListener.java b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/SingleResourceRetrievedDiscoverabilityListener.java similarity index 84% rename from spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrievedDiscoverabilityListener.java rename to spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/SingleResourceRetrievedDiscoverabilityListener.java index 6be6c08df9..3dd57cb78d 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/util/SingleResourceRetrievedDiscoverabilityListener.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/hateoas/listener/SingleResourceRetrievedDiscoverabilityListener.java @@ -1,8 +1,10 @@ -package org.baeldung.web.util; +package org.baeldung.web.hateoas.listener; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.baeldung.web.hateoas.event.SingleResourceRetrievedEvent; +import org.baeldung.web.util.LinkUtil; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; @@ -10,10 +12,10 @@ import com.google.common.base.Preconditions; import com.google.common.net.HttpHeaders; @Component -class SingleResourceRetrievedDiscoverabilityListener implements ApplicationListener { +class SingleResourceRetrievedDiscoverabilityListener implements ApplicationListener { @Override - public void onApplicationEvent(final SingleResourceRetrieved resourceRetrievedEvent) { + public void onApplicationEvent(final SingleResourceRetrievedEvent resourceRetrievedEvent) { Preconditions.checkNotNull(resourceRetrievedEvent); final HttpServletRequest request = resourceRetrievedEvent.getRequest();