diff --git a/afs/afs-mapdb-storage/src/main/java/com/powsybl/afs/mapdb/storage/NodeInfoSerializer.java b/afs/afs-mapdb-storage/src/main/java/com/powsybl/afs/mapdb/storage/NodeInfoSerializer.java index e4e742a5f86..a0c9e4f85cb 100644 --- a/afs/afs-mapdb-storage/src/main/java/com/powsybl/afs/mapdb/storage/NodeInfoSerializer.java +++ b/afs/afs-mapdb-storage/src/main/java/com/powsybl/afs/mapdb/storage/NodeInfoSerializer.java @@ -55,18 +55,18 @@ public void serialize(DataOutput2 out, NodeInfo nodeInfo) throws IOException { out.writeBoolean(e.getValue()); } out.writeInt(nodeInfo.getAccessRights().getUsersRights().size()); - for (Map.Entry e : nodeInfo.getAccessRights().getUsersRights().entrySet()) { + for (Map.Entry e : nodeInfo.getAccessRights().getUsersRights().entrySet()) { out.writeUTF(e.getKey()); - out.writeShort(e.getValue()); + out.writeInt(e.getValue()); } out.writeInt(nodeInfo.getAccessRights().getGroupsRights().size()); - for (Map.Entry e : nodeInfo.getAccessRights().getGroupsRights().entrySet()) { + for (Map.Entry e : nodeInfo.getAccessRights().getGroupsRights().entrySet()) { out.writeUTF(e.getKey()); - out.writeShort(e.getValue()); + out.writeInt(e.getValue()); } out.writeInt(Objects.isNull(nodeInfo.getAccessRights().getOthersRights()) ? 0 : 1); if (!Objects.isNull(nodeInfo.getAccessRights().getOthersRights())) { - out.writeShort(nodeInfo.getAccessRights().getOthersRights()); + out.writeInt(nodeInfo.getAccessRights().getOthersRights()); } } @@ -99,15 +99,15 @@ public NodeInfo deserialize(DataInput2 input, int available) throws IOException NodeAccessRights accessRights = new NodeAccessRights(); int usersRightsSize = input.readInt(); for (int i = 0; i < usersRightsSize; i++) { - accessRights.setUserRights(input.readUTF(), input.readShort()); + accessRights.setUserRights(input.readUTF(), input.readInt()); } int groupsRightsSize = input.readInt(); for (int i = 0; i < groupsRightsSize; i++) { - accessRights.setGroupRights(input.readUTF(), input.readShort()); + accessRights.setGroupRights(input.readUTF(), input.readInt()); } int othersRightsSize = input.readInt(); for (int i = 0; i < othersRightsSize; i++) { - accessRights.setOthersRights(input.readShort()); + accessRights.setOthersRights(input.readInt()); } return new NodeInfo(nodeId, name, pseudoClass, description, creationTime, modificationTime, version, metadata, accessRights); diff --git a/afs/afs-storage-api/src/main/java/com/powsybl/afs/storage/NodeAccessRights.java b/afs/afs-storage-api/src/main/java/com/powsybl/afs/storage/NodeAccessRights.java index fb5166ce122..a0f639514a8 100644 --- a/afs/afs-storage-api/src/main/java/com/powsybl/afs/storage/NodeAccessRights.java +++ b/afs/afs-storage-api/src/main/java/com/powsybl/afs/storage/NodeAccessRights.java @@ -12,47 +12,47 @@ public class NodeAccessRights { - private final Map usersRights; + private final Map usersRights; - private final Map groupsRights; + private final Map groupsRights; - private Short othersRights; + private Integer othersRights; public NodeAccessRights() { this(new HashMap<>(), new HashMap<>(), null); } - public NodeAccessRights(Map usersRights, Map groupsRights, Short othersRights) { + public NodeAccessRights(Map usersRights, Map groupsRights, Integer othersRights) { this.usersRights = Objects.requireNonNull(usersRights); this.groupsRights = Objects.requireNonNull(groupsRights); this.othersRights = othersRights; } - public Map getUsersRights() { + public Map getUsersRights() { return usersRights; } - public NodeAccessRights setUserRights(String user, Short rights) { + public NodeAccessRights setUserRights(String user, Integer rights) { Objects.requireNonNull(user); usersRights.put(user, rights); return this; } - public Map getGroupsRights() { + public Map getGroupsRights() { return groupsRights; } - public NodeAccessRights setGroupRights(String group, Short rights) { + public NodeAccessRights setGroupRights(String group, Integer rights) { Objects.requireNonNull(group); groupsRights.put(group, rights); return this; } - public Short getOthersRights() { + public Integer getOthersRights() { return othersRights; } - public NodeAccessRights setOthersRights(Short rights) { + public NodeAccessRights setOthersRights(Integer rights) { othersRights = rights; return this; } diff --git a/afs/afs-storage-api/src/main/java/com/powsybl/afs/storage/json/NodeAccessRightsJsonDeserializer.java b/afs/afs-storage-api/src/main/java/com/powsybl/afs/storage/json/NodeAccessRightsJsonDeserializer.java index 6e6ef684748..4ae1db61d95 100644 --- a/afs/afs-storage-api/src/main/java/com/powsybl/afs/storage/json/NodeAccessRightsJsonDeserializer.java +++ b/afs/afs-storage-api/src/main/java/com/powsybl/afs/storage/json/NodeAccessRightsJsonDeserializer.java @@ -39,13 +39,13 @@ private static void parseFieldName(JsonParser jsonParser, NodeAccessRightsJsonDe jsonParser.nextToken(); switch (parsingContext.type) { case NodeAccessRightsJsonSerializer.USER: - parsingContext.accessRights.setUserRights(parsingContext.name, (short) jsonParser.getValueAsInt()); + parsingContext.accessRights.setUserRights(parsingContext.name, jsonParser.getValueAsInt()); break; case NodeAccessRightsJsonSerializer.GROUP: - parsingContext.accessRights.setGroupRights(parsingContext.name, (short) jsonParser.getValueAsInt()); + parsingContext.accessRights.setGroupRights(parsingContext.name, jsonParser.getValueAsInt()); break; case NodeAccessRightsJsonSerializer.OTHERS: - parsingContext.accessRights.setOthersRights((short) jsonParser.getValueAsInt()); + parsingContext.accessRights.setOthersRights(jsonParser.getValueAsInt()); break; default: throw new AssertionError("Unexpected access right type " + parsingContext.type); diff --git a/afs/afs-storage-api/src/main/java/com/powsybl/afs/storage/json/NodeAccessRightsJsonSerializer.java b/afs/afs-storage-api/src/main/java/com/powsybl/afs/storage/json/NodeAccessRightsJsonSerializer.java index 87482acd3ea..178f555b6e9 100644 --- a/afs/afs-storage-api/src/main/java/com/powsybl/afs/storage/json/NodeAccessRightsJsonSerializer.java +++ b/afs/afs-storage-api/src/main/java/com/powsybl/afs/storage/json/NodeAccessRightsJsonSerializer.java @@ -24,14 +24,14 @@ public NodeAccessRightsJsonSerializer() { @Override public void serialize(NodeAccessRights nodeAccessRights, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartArray(); - for (Map.Entry e : nodeAccessRights.getUsersRights().entrySet()) { + for (Map.Entry e : nodeAccessRights.getUsersRights().entrySet()) { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField(TYPE, USER); jsonGenerator.writeStringField(NAME, e.getKey()); jsonGenerator.writeNumberField(VALUE, e.getValue()); jsonGenerator.writeEndObject(); } - for (Map.Entry e : nodeAccessRights.getGroupsRights().entrySet()) { + for (Map.Entry e : nodeAccessRights.getGroupsRights().entrySet()) { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField(TYPE, GROUP); jsonGenerator.writeStringField(NAME, e.getKey()); diff --git a/afs/afs-storage-api/src/test/java/com/powsybl/afs/storage/AbstractAppStorageArchiveTest.java b/afs/afs-storage-api/src/test/java/com/powsybl/afs/storage/AbstractAppStorageArchiveTest.java index 751b1f5f040..7488d6ddb00 100644 --- a/afs/afs-storage-api/src/test/java/com/powsybl/afs/storage/AbstractAppStorageArchiveTest.java +++ b/afs/afs-storage-api/src/test/java/com/powsybl/afs/storage/AbstractAppStorageArchiveTest.java @@ -66,7 +66,7 @@ public void archive() throws IOException { NodeInfo folder1Info = storage.createNode(rootFolderInfo.getId(), "folder1", AbstractAppStorageTest.FOLDER_PSEUDO_CLASS, "", 0, new NodeGenericMetadata(), new NodeAccessRights()); storage.setConsistent(folder1Info.getId()); - NodeInfo file1Info = storage.createNode(folder1Info.getId(), "file1", AbstractAppStorageTest.DATA_FILE_CLASS, "", 0, new NodeGenericMetadata().setInt("i1", 1), new NodeAccessRights().setUserRights("user1", (short) 7)); + NodeInfo file1Info = storage.createNode(folder1Info.getId(), "file1", AbstractAppStorageTest.DATA_FILE_CLASS, "", 0, new NodeGenericMetadata().setInt("i1", 1), new NodeAccessRights().setUserRights("user1", 7)); storage.setConsistent(file1Info.getId()); try (OutputStream os = storage.writeBinaryData(file1Info.getId(), "data1")) { @@ -86,7 +86,7 @@ public void archive() throws IOException { NodeInfo folder2Info = storage.createNode(rootFolderInfo.getId(), "folder2", AbstractAppStorageTest.FOLDER_PSEUDO_CLASS, "", 0, new NodeGenericMetadata(), new NodeAccessRights()); storage.setConsistent(folder2Info.getId()); NodeInfo file2Info = storage.createNode(folder2Info.getId(), "file2", AbstractAppStorageTest.DATA_FILE_CLASS, "", 0, new NodeGenericMetadata() - .setString("s1", "a"), new NodeAccessRights().setGroupRights("group1", (short) 5)); + .setString("s1", "a"), new NodeAccessRights().setGroupRights("group1", 5)); storage.setConsistent(file2Info.getId()); storage.addDependency(file1Info.getId(), "dependency1", file2Info.getId()); diff --git a/afs/afs-storage-api/src/test/java/com/powsybl/afs/storage/AbstractAppStorageTest.java b/afs/afs-storage-api/src/test/java/com/powsybl/afs/storage/AbstractAppStorageTest.java index 6cb0e95333c..9d4feddb108 100644 --- a/afs/afs-storage-api/src/test/java/com/powsybl/afs/storage/AbstractAppStorageTest.java +++ b/afs/afs-storage-api/src/test/java/com/powsybl/afs/storage/AbstractAppStorageTest.java @@ -109,7 +109,7 @@ public void test() throws IOException, InterruptedException { // 2) create a test folder NodeInfo testFolderInfo = storage.createNode(rootFolderInfo.getId(), "test", FOLDER_PSEUDO_CLASS, "", 0, - new NodeGenericMetadata().setString("k", "v"), new NodeAccessRights().setUserRights("user1", (short) 6)); + new NodeGenericMetadata().setString("k", "v"), new NodeAccessRights().setUserRights("user1", 6)); storage.flush(); assertFalse(storage.isConsistent(testFolderInfo.getId())); @@ -176,7 +176,7 @@ public void test() throws IOException, InterruptedException { .setDouble("d1", 1d) .setInt("i1", 2) .setBoolean("b1", false), - new NodeAccessRights().setUserRights("user1", (short) 2).setUserRights("user2", (short) 4).setGroupRights("group1", (short) 6)); + new NodeAccessRights().setUserRights("user1", 2).setUserRights("user2", 4).setGroupRights("group1", 6)); NodeInfo testData3Info = storage.createNode(testFolderInfo.getId(), "data3", DATA_FILE_CLASS, "", 0, new NodeGenericMetadata(), new NodeAccessRights()); storage.setConsistent(testDataInfo.getId()); storage.setConsistent(testData2Info.getId()); diff --git a/afs/afs-storage-api/src/test/java/com/powsybl/afs/storage/NodeInfoTest.java b/afs/afs-storage-api/src/test/java/com/powsybl/afs/storage/NodeInfoTest.java index e203648ceb2..191b6d9e265 100644 --- a/afs/afs-storage-api/src/test/java/com/powsybl/afs/storage/NodeInfoTest.java +++ b/afs/afs-storage-api/src/test/java/com/powsybl/afs/storage/NodeInfoTest.java @@ -36,7 +36,7 @@ public void nodeInfoTest() throws IOException { .setDouble("d1", 1d) .setInt("i1", 2) .setBoolean("b1", true), - new NodeAccessRights().setGroupRights("group1", (short) 2).setGroupRights("group2", (short) 4).setUserRights("user1", (short) 6)); + new NodeAccessRights().setGroupRights("group1", 2).setGroupRights("group2", 4).setUserRights("user1", 6)); NodeInfo info2 = objectMapper.readValue(objectMapper.writeValueAsString(info), NodeInfo.class); assertEquals(info, info2); info.setVersion(1);