Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<groupId>uk.gov.moj.cpp.sjp</groupId>
<artifactId>sjp-parent</artifactId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
Expand Down Expand Up @@ -40,9 +40,9 @@

<assignment.version>6.0.0</assignment.version>
<access-control-sjp-providers.version>4.1.4-ATCM</access-control-sjp-providers.version>
<material.version>17.0.57</material.version>
<material.version>17.0.85</material.version>
<notification.notify.version>17.0.1</notification.notify.version>
<referencedata.version>17.104.137</referencedata.version>
<referencedata.version>17.104.140</referencedata.version>
<referencedata.offences.version>17.104.52</referencedata.offences.version>
<scheduling.version>17.0.11</scheduling.version>
<authorisation.service.version>0.1.49</authorisation.service.version>
Expand Down
2 changes: 1 addition & 1 deletion sjp-command/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sjp-parent</artifactId>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sjp-command/sjp-command-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sjp-command</artifactId>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sjp-command/sjp-command-controller/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sjp-command</artifactId>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sjp-command/sjp-command-handler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sjp-command</artifactId>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sjp-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<artifactId>sjp-parent</artifactId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>

<artifactId>sjp-domain</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion sjp-domain/sjp-domain-aggregate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<artifactId>sjp-domain</artifactId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>

<artifactId>sjp-domain-aggregate</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion sjp-domain/sjp-domain-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<artifactId>sjp-domain</artifactId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion sjp-domain/sjp-domain-event-processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sjp-domain</artifactId>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sjp-domain/sjp-domain-event/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<artifactId>sjp-domain</artifactId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>

<artifactId>sjp-domain-event</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion sjp-domain/sjp-domain-prosecution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>sjp-domain</artifactId>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>

<artifactId>sjp-domain-prosecution</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion sjp-domain/sjp-domain-transformation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sjp-domain</artifactId>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sjp-domain-transformation</artifactId>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sjp-domain-transformation</artifactId>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sjp-event-sources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sjp-parent</artifactId>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sjp-event/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sjp-parent</artifactId>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sjp-event/sjp-event-indexer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sjp-event</artifactId>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sjp-event/sjp-event-listener/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sjp-event</artifactId>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sjp-event/sjp-event-processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sjp-event</artifactId>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sjp-healthchecks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sjp-parent</artifactId>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sjp-integration-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<artifactId>sjp-parent</artifactId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sjp-json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<parent>
<artifactId>sjp-parent</artifactId>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sjp-query/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sjp-parent</artifactId>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
13 changes: 1 addition & 12 deletions sjp-query/sjp-query-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sjp-query</artifactId>
<groupId>uk.gov.moj.cpp.sjp</groupId>
<version>17.104.194-SNAPSHOT</version>
<version>17.104.194-CHD-2845-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -89,17 +89,6 @@
<artifactId>sjp-json</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>uk.gov.moj.cpp.material</groupId>
<artifactId>material-client</artifactId>
<version>${material.version}</version>
<exclusions>
<exclusion>
<groupId>uk.gov.justice.services</groupId>
<artifactId>test-utils-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import uk.gov.justice.services.core.annotation.Component;
import uk.gov.justice.services.core.interceptor.InterceptorChainProcessor;
import uk.gov.justice.services.messaging.JsonEnvelope;
import uk.gov.moj.cpp.material.client.MaterialClient;
import uk.gov.moj.cpp.sjp.material.client.MaterialClient;
import uk.gov.moj.cpp.systemusers.ServiceContextSystemUserProvider;

import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package uk.gov.moj.cpp.sjp.material.client;

import static javax.ws.rs.client.ClientBuilder.newClient;
import static uk.gov.justice.services.common.http.HeaderConstants.USER_ID;

import java.util.UUID;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.core.Response;

import org.slf4j.Logger;

/**
* SJP-owned copy of material's HTTP adapter (decouples sjp from the material-client JAR - PEG-3447).
* Trimmed to the single method sjp uses; runtime behaviour is unchanged - sjp still calls material
* over HTTP exactly as before.
*/
@ApplicationScoped
public class MaterialClient {

public static final String REQUEST_PARAM_ADD_INLINE_CONTENT_DISPOSITION_HEADER = "addInlineContentDispositionHeader";

@Inject
Logger logger;

private static final String BASE_URI = "http://localhost:8080/material-query-api/query/api/rest/material";
private static final String MATERIAL_REQUEST_PATH = "/material/";
private static final String GET_MATERIAL_AS_PDF = "application/vnd.material.query.material+json";
private static final String REQUEST_PARAM_STREAM = "stream";
private static final String REQUEST_PARAM_REQUEST_PDF = "requestPdf";

public Response getMaterialWithHeader(final UUID materialId, final UUID userId) {
return getMaterial(materialId.toString(), userId.toString(), true, false, true);
}

private Response getMaterial(final String materialId, final String userId, final boolean asStream, final boolean asPdf, final boolean addInlineContentDispositionHeader) {

final Invocation.Builder builder = getClient()
.target(BASE_URI)
.path(MATERIAL_REQUEST_PATH + materialId)
.queryParam(REQUEST_PARAM_STREAM, asStream)
.queryParam(REQUEST_PARAM_REQUEST_PDF, asPdf)
.queryParam(REQUEST_PARAM_ADD_INLINE_CONTENT_DISPOSITION_HEADER, addInlineContentDispositionHeader)
.request()
.header(USER_ID, userId)
.accept(GET_MATERIAL_AS_PDF);

logger.info("Invoking call to material context");
return builder.get();
}

/**
* Returns the JAX-RS client. Extracted so the client can be mocked in unit tests, since the
* static {@code newClient()} call is otherwise hard to stub.
*/
Client getClient() {
return newClient();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import uk.gov.justice.services.core.interceptor.InterceptorChainProcessor;
import uk.gov.justice.services.core.interceptor.InterceptorContext;
import uk.gov.justice.services.messaging.JsonEnvelope;
import uk.gov.moj.cpp.material.client.MaterialClient;
import uk.gov.moj.cpp.sjp.material.client.MaterialClient;
import uk.gov.moj.cpp.systemusers.ServiceContextSystemUserProvider;

import java.util.Optional;
Expand Down Expand Up @@ -116,7 +116,7 @@ public void shouldRunNotFoundStatusWhenDocumentNotFound() {

verifyInterceptorChainExecution();

verify(materialClient, never()).getMaterial(argThat(any(UUID.class)), argThat(any(UUID.class)));
verify(materialClient, never()).getMaterialWithHeader(argThat(any(UUID.class)), argThat(any(UUID.class)));
}

@Test
Expand Down Expand Up @@ -150,7 +150,7 @@ public void shouldRethrowAnyInterceptorException() {
}

verifyInterceptorChainExecution();
verify(materialClient, never()).getMaterial(argThat(any(UUID.class)), argThat(any(UUID.class)));
verify(materialClient, never()).getMaterialWithHeader(argThat(any(UUID.class)), argThat(any(UUID.class)));
}

@Test
Expand Down
Loading
Loading