Skip to content

Commit

Permalink
[SELC-5247] Fix: change method to read json file (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
flaminiaScarciofolo authored Jul 24, 2024
1 parent ae30527 commit 6f880c8
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.nio.file.Files;
import java.nio.file.Paths;
import java.io.InputStream;
import java.util.List;
import java.util.Map;

Expand All @@ -21,15 +20,16 @@
public class ActionMapRetriever {

private Map<PartyRole, List<String>> userActionsMap;
private static final String ACTIONS_FILE_PATH = "src/main/resources/role_action_mapping.json";
private static final String ACTIONS_FILE_PATH = "role_action_mapping.json";

public ActionMapRetriever() {
this.userActionsMap = retrieveActionsMap();
}

private Map<PartyRole, List<String>> retrieveActionsMap() {
try {
byte[] jsonFile = Files.readAllBytes(Paths.get(ACTIONS_FILE_PATH));
try (InputStream actionsFile = getClass().getClassLoader().getResourceAsStream(ACTIONS_FILE_PATH)) {
assert actionsFile != null;
byte[] jsonFile = actionsFile.readAllBytes();
ObjectMapper objectMapper = new ObjectMapper();
log.info("retrieved file with actions map");
userActionsMap = objectMapper.readValue(jsonFile, new TypeReference<>() {});
Expand Down

0 comments on commit 6f880c8

Please sign in to comment.