Skip to content

Commit

Permalink
Merge branch 'master' into COT-552_sptribs_staff_update
Browse files Browse the repository at this point in the history
  • Loading branch information
abul-syed authored Oct 13, 2023
2 parents 58b4e18 + be72b0e commit ac85711
Show file tree
Hide file tree
Showing 24 changed files with 259 additions and 106 deletions.
4 changes: 2 additions & 2 deletions charts/am-org-role-mapping-service/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ appVersion: "1.0"
description: A Helm chart for AM Organisation Role Mapping Service
name: am-org-role-mapping-service
home: https://github.com/hmcts/am-org-role-mapping-service
version: 0.0.51
version: 0.0.52
maintainers:
- name: Access Management Team
dependencies:
- name: java
version: 4.2.0
version: 5.0.0
repository: 'https://hmctspublic.azurecr.io/helm/v1/repo/'
- name: servicebus
version: 1.0.4
Expand Down
4 changes: 4 additions & 0 deletions config/owasp/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@
<notes>https://tools.hmcts.net/jira/browse/AM-2952 plexus</notes>
<cve>CVE-2022-4245</cve>
</suppress>
<suppress>
<notes>https://tools.hmcts.net/jira/browse/AM-2968 netty</notes>
<cve>CVE-2023-4586</cve>
</suppress>
</suppressions>
2 changes: 1 addition & 1 deletion src/functionalTest/resources/features/F-004/S-031.td.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"primaryLocation" : "[[ANYTHING_PRESENT]]",
"jurisdiction" : "SSCS",
"region" : "[[ANYTHING_PRESENT]]",
"workTypes" : "pre_hearing_work,hearing_work,post_hearing_work,decision_making_work,routine_work,priority"
"workTypes" : "pre_hearing,hearing_work,post_hearing,decision_making_work,routine_work,priority"
},
"authorisations" : "[[ANYTHING_PRESENT]]"
}
Expand Down
4 changes: 2 additions & 2 deletions src/functionalTest/resources/features/F-004/S-032.td.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"primaryLocation" : "[[ANYTHING_PRESENT]]",
"jurisdiction" : "SSCS",
"region" : "[[ANYTHING_PRESENT]]",
"workTypes" : "pre_hearing_work,hearing_work,post_hearing_work,decision_making_work,routine_work,priority"
"workTypes" : "pre_hearing,hearing_work,post_hearing,decision_making_work,routine_work,priority"
},
"authorisations" : "[[ANYTHING_PRESENT]]"
},
Expand All @@ -66,7 +66,7 @@
"primaryLocation" : "[[ANYTHING_PRESENT]]",
"jurisdiction" : "SSCS",
"region" : "[[ANYTHING_PRESENT]]",
"workTypes" : "pre_hearing_work,hearing_work,post_hearing_work,decision_making_work,routine_work,priority"
"workTypes" : "pre_hearing,hearing_work,post_hearing,decision_making_work,routine_work,priority"
},
"authorisations" : "[[ANYTHING_PRESENT]]"
},
Expand Down
2 changes: 1 addition & 1 deletion src/functionalTest/resources/features/F-005/S-041.td.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"primaryLocation": "21153",
"jurisdiction": "SSCS",
"region" : "2",
"workTypes": "applications,hearing_work,routine_work,priority"
"workTypes": "applications,hearing_work,routine_work,priority,pre_hearing"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/functionalTest/resources/features/F-005/S-042.td.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"primaryLocation": "21153",
"jurisdiction": "SSCS",
"region" : "2",
"workTypes": "pre_hearing_work,post_hearing_work,decision_making_work,applications,hearing_work,routine_work,priority"
"workTypes": "pre_hearing,post_hearing,decision_making_work,applications,hearing_work,routine_work,priority"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/functionalTest/resources/features/F-005/S-043.td.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
"primaryLocation": "271588",
"jurisdiction": "SSCS",
"region" : "2",
"workTypes": "pre_hearing_work,post_hearing_work,decision_making_work,applications,hearing_work,routine_work,priority"
"workTypes": "pre_hearing,post_hearing,decision_making_work,applications,hearing_work,routine_work,priority"
}
},
{
Expand Down Expand Up @@ -209,7 +209,7 @@
"primaryLocation": "271588",
"jurisdiction": "SSCS",
"region" : "2",
"workTypes": "pre_hearing_work,post_hearing_work,applications,hearing_work,routine_work,priority,decision_making_work"
"workTypes": "pre_hearing,post_hearing,applications,hearing_work,routine_work,priority,decision_making_work"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/functionalTest/resources/features/F-005/S-044.td.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"primaryLocation" : "[[ANYTHING_PRESENT]]",
"jurisdiction" : "SSCS",
"region" : "[[ANYTHING_PRESENT]]",
"workTypes" : "pre_hearing_work,post_hearing_work,applications,hearing_work,routine_work,priority,decision_making_work"
"workTypes" : "pre_hearing,post_hearing,applications,hearing_work,routine_work,priority,decision_making_work"
}
}, {
"id" : "[[ANYTHING_PRESENT]]",
Expand All @@ -137,7 +137,7 @@
"primaryLocation" : "[[ANYTHING_PRESENT]]",
"jurisdiction" : "SSCS",
"region" :"[[ANYTHING_PRESENT]]",
"workTypes" : "pre_hearing_work,post_hearing_work,applications,hearing_work,routine_work,priority,decision_making_work"
"workTypes" : "pre_hearing,post_hearing,applications,hearing_work,routine_work,priority,decision_making_work"
}
} ]
}
Expand Down
4 changes: 2 additions & 2 deletions src/functionalTest/resources/features/F-006/S-051.td.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"primaryLocation": "[[ANYTHING_PRESENT]]",
"jurisdiction": "SSCS",
"region" : "2",
"workTypes": "pre_hearing_work,post_hearing_work,applications,hearing_work,routine_work,priority,decision_making_work",
"workTypes": "pre_hearing,post_hearing,applications,hearing_work,routine_work,priority,decision_making_work",
"substantive" : "Y"
}
},
Expand All @@ -52,7 +52,7 @@
"primaryLocation": "[[ANYTHING_PRESENT]]",
"jurisdiction": "SSCS",
"region" : "2",
"workTypes": "pre_hearing_work,post_hearing_work,applications,hearing_work,routine_work,priority,decision_making_work",
"workTypes": "pre_hearing,post_hearing,applications,hearing_work,routine_work,priority,decision_making_work",
"substantive" : "Y"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/functionalTest/resources/features/F-006/S-052.td.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"primaryLocation": "[[ANYTHING_PRESENT]]",
"jurisdiction": "SSCS",
"region" : "2",
"workTypes": "pre_hearing_work,post_hearing_work,decision_making_work,applications,hearing_work,routine_work,priority",
"workTypes": "pre_hearing,post_hearing,decision_making_work,applications,hearing_work,routine_work,priority",
"substantive" : "Y"
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/functionalTest/resources/features/F-006/S-053.td.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"primaryLocation": "[[ANYTHING_PRESENT]]",
"jurisdiction": "SSCS",
"region" : "2",
"workTypes": "applications,hearing_work,routine_work,priority",
"workTypes": "applications,hearing_work,routine_work,priority,pre_hearing",
"substantive" : "Y"
}
},
Expand All @@ -52,7 +52,7 @@
"primaryLocation": "[[ANYTHING_PRESENT]]",
"jurisdiction": "SSCS",
"region" : "2",
"workTypes": "applications,hearing_work,routine_work,priority",
"workTypes": "applications,hearing_work,routine_work,priority,pre_hearing",
"substantive" : "Y"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ public class InvalidRequest extends RuntimeException {
public InvalidRequest(String message) {
super(message);
}

public InvalidRequest(String message, Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ public class UnprocessableEntityException extends RuntimeException {

private static final long serialVersionUID = 7L;

public UnprocessableEntityException(String message) {
public UnprocessableEntityException(String message) {
super(message);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public ResponseEntity<Object> createBulkAssignmentsRequest(UserRequest userReque

//Extract and Validate received users List
parseRequestService.validateUserRequest(userRequest);
log.info("Validated {} userIds :: {}", userRequest.getUserIds().size(), userRequest.getUserIds());
log.info("Validated {} userIds of userType {} :: {}",
userRequest.getUserIds().size(), userType, userRequest.getUserIds());
long startTime = System.currentTimeMillis();
Map<String, Set<UserAccessProfile>> userAccessProfiles;
//Create userAccessProfiles based upon roleId and service codes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ public class CRDTopicConsumer extends CRDMessagingConfiguration {
private BulkAssignmentOrchestrator bulkAssignmentOrchestrator;
private OrmDeserializer deserializer;


public CRDTopicConsumer(BulkAssignmentOrchestrator bulkAssignmentOrchestrator,
OrmDeserializer deserializer) {
OrmDeserializer deserializer) {
this.bulkAssignmentOrchestrator = bulkAssignmentOrchestrator;
this.deserializer = deserializer;

}

@Bean
Expand Down Expand Up @@ -72,9 +70,24 @@ CompletableFuture<Void> registerCRDMessageHandlerOnClient(@Autowired @Qualifier(
SubscriptionClient receiveClient)
throws ServiceBusException, InterruptedException {

log.debug(" Calling registerMessageHandlerOnClient in CRD ");
ExecutorService executorService = Executors.newFixedThreadPool(1);
receiveClient.registerMessageHandler(
getMessageHandler(receiveClient),
new MessageHandlerOptions(
1,
false,
Duration.ofHours(1),
Duration.ofMinutes(5)
),
executorService
);
return null;

}

IMessageHandler messageHandler = new IMessageHandler() {
public IMessageHandler getMessageHandler(SubscriptionClient receiveClient) {
log.debug(" Calling registerMessageHandlerOnClient in CRD ");
return new IMessageHandler() {
// callback invoked when the message handler loop has obtained a message
@SneakyThrows
@WithSpan(value = "CRD Azure Service Bus Topic", kind = SpanKind.SERVER)
Expand All @@ -93,42 +106,31 @@ public CompletableFuture<Void> onMessageAsync(IMessage message) {
log.debug(" getLockToken......{}", message.getLockToken());

} catch (Exception e) { // java.lang.Throwable introduces the Sonar issues
throw new InvalidRequest("Some Network issue");
log.error("Error processing CRD message from service bus : {}", e.getMessage());
throw new InvalidRequest("Error processing message from service bus", e);
}
log.debug("Finally getLockedUntilUtc" + message.getLockedUntilUtc());
return null;
}

public void notifyException(Throwable throwable, ExceptionPhase exceptionPhase) {
log.error("Exception occurred.");
log.error(exceptionPhase + "-" + throwable.getMessage());
log.error(
"An error occurred when Calling onMessageAsync in CRD. Phase: {}",
exceptionPhase,
throwable
);
}
};

ExecutorService executorService = Executors.newFixedThreadPool(1);
receiveClient.registerMessageHandler(
messageHandler, new MessageHandlerOptions(1,
false, Duration.ofHours(1), Duration.ofMinutes(5)),
executorService);
return null;

}

private void processMessage(List<byte[]> body, AtomicBoolean result) {

log.info(" Parsing the message in CRD");
UserRequest request = deserializer.deserialize(body);
try {
ResponseEntity<Object> response = bulkAssignmentOrchestrator.createBulkAssignmentsRequest(request,
UserType.CASEWORKER);
log.info("----Role Assignment Service Response CRD {}", response.getStatusCode());
result.set(Boolean.TRUE);
} catch (Exception e) {
log.error("Exception from RAS service : {}", e.getMessage());
throw e;
}
}
log.debug("Parsing the message from CRD with size :: {}", request.getUserIds().size());

ResponseEntity<Object> response = bulkAssignmentOrchestrator.createBulkAssignmentsRequest(request,
UserType.CASEWORKER);

log.info("Role Assignment Service Response CRD: {}", response.getStatusCode());
result.set(Boolean.TRUE);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public JRDTopicConsumer(BulkAssignmentOrchestrator bulkAssignmentOrchestrator,
OrmDeserializer deserializer) {
this.bulkAssignmentOrchestrator = bulkAssignmentOrchestrator;
this.deserializer = deserializer;

}

@Bean
Expand Down Expand Up @@ -75,9 +74,24 @@ CompletableFuture<Void> registerJRDMessageHandlerOnClient(@Autowired @Qualifier(
SubscriptionClient receiveClient)
throws ServiceBusException, InterruptedException {

log.info(" Calling registerMessageHandlerOnClient in JRD ");
ExecutorService executorService = Executors.newFixedThreadPool(1);
receiveClient.registerMessageHandler(
getMessageHandler(receiveClient),
new MessageHandlerOptions(
1,
false,
Duration.ofHours(1),
Duration.ofMinutes(5)
),
executorService
);
return null;

IMessageHandler messageHandler = new IMessageHandler() {
}

public IMessageHandler getMessageHandler(SubscriptionClient receiveClient) {
log.info(" Calling registerMessageHandlerOnClient in JRD ");
return new IMessageHandler() {
// callback invoked when the message handler loop has obtained a message
@SneakyThrows
@WithSpan(value = "JRD Azure Service Bus Topic", kind = SpanKind.SERVER)
Expand All @@ -94,51 +108,39 @@ public CompletableFuture<Void> onMessageAsync(IMessage message) {
return receiveClient.completeAsync(message.getLockToken());
}


log.debug(" getLockToken......{}", message.getLockToken());
} else {
log.info("The JRD feature flag is currently disabled. This message would be suppressed");
return receiveClient.completeAsync(message.getLockToken());
}

} catch (Exception e) { // java.lang.Throwable introduces the Sonar issues
throw new InvalidRequest("Some Network issue");
log.error("Error processing JRD message from service bus : {}", e.getMessage());
throw new InvalidRequest("Error processing message from service bus", e);
}
log.debug("Finally getLockedUntilUtc" + message.getLockedUntilUtc());
return null;

}

public void notifyException(Throwable throwable, ExceptionPhase exceptionPhase) {
log.error("Exception occurred.");
log.error(exceptionPhase + "-" + throwable.getMessage());
log.error(
"An error occurred when Calling onMessageAsync in JRD. Phase: {}",
exceptionPhase,
throwable
);
}
};

ExecutorService executorService = Executors.newFixedThreadPool(1);
receiveClient.registerMessageHandler(
messageHandler, new MessageHandlerOptions(1,
false, Duration.ofHours(1), Duration.ofMinutes(5)),
executorService);
return null;

}

private void processMessage(List<byte[]> body, AtomicBoolean result) {


UserRequest request = deserializer.deserialize(body);
log.debug("Parsing the message from JRD with size :: {}", request.getUserIds().size());
try {
ResponseEntity<Object> response = bulkAssignmentOrchestrator.createBulkAssignmentsRequest(request,
UserType.JUDICIAL);
log.debug("Role Assignment Service Response JRD {}", response.getStatusCode());
result.set(Boolean.TRUE);
} catch (Exception e) {
log.error("Exception from RAS service : {}", e.getMessage());
throw e;
}
}

ResponseEntity<Object> response = bulkAssignmentOrchestrator.createBulkAssignmentsRequest(request,
UserType.JUDICIAL);

log.debug("Role Assignment Service Response JRD: {}", response.getStatusCode());
result.set(Boolean.TRUE);
}
}
Loading

0 comments on commit ac85711

Please sign in to comment.