Skip to content

Commit

Permalink
Modification of the request to create a new node on a remote storage …
Browse files Browse the repository at this point in the history
…to take access rights of the node into account (#827)

Signed-off-by: NOIR Nicolas ext <[email protected]>
  • Loading branch information
niconoir committed Oct 9, 2019
1 parent 84407fc commit e883e48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,9 @@ public Response getInconsistentChildrenNodes(@ApiParam(value = "File system name
public Response createNode(@ApiParam(value = "File system name") @PathParam("fileSystemName") String fileSystemName,
@ApiParam(value = "Node ID") @PathParam("nodeId") String nodeId,
@ApiParam(value = "Child Name") @PathParam("childName") String childName,
@ApiParam(value = "Description") @QueryParam("description") String description,
@ApiParam(value = "Node Pseudo Class") @QueryParam("nodePseudoClass") String nodePseudoClass,
@ApiParam(value = "Version") @QueryParam("version") int version,
@ApiParam(value = "Node Meta Data") NodeGenericMetadata nodeMetadata) {
@ApiParam(value = "Node Meta Data") NodeInfo nodeInfo) {
AppStorage storage = appDataBean.getStorage(fileSystemName);
NodeInfo newNodeInfo = storage.createNode(nodeId, childName, nodePseudoClass, description, version, nodeMetadata, new NodeAccessRights());
NodeInfo newNodeInfo = storage.createNode(nodeId, childName, nodeInfo.getPseudoClass(), nodeInfo.getDescription(), nodeInfo.getVersion(), nodeInfo.getGenericMetadata(), nodeInfo.getAccessRights());
return Response.ok().entity(newNodeInfo).build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@

import com.google.common.io.ByteStreams;
import com.google.common.util.concurrent.UncheckedExecutionException;
import com.powsybl.afs.storage.AppStorage;
import com.powsybl.afs.storage.NodeDependency;
import com.powsybl.afs.storage.NodeGenericMetadata;
import com.powsybl.afs.storage.NodeAccessRights;
import com.powsybl.afs.storage.NodeInfo;
import com.powsybl.afs.storage.*;
import com.powsybl.afs.storage.buffer.StorageChangeBuffer;
import com.powsybl.afs.ws.client.utils.ClientUtils;
import com.powsybl.afs.ws.utils.AfsRestApi;
Expand All @@ -36,6 +32,7 @@
import javax.ws.rs.core.*;
import java.io.*;
import java.net.URI;
import java.time.ZonedDateTime;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
Expand Down Expand Up @@ -321,14 +318,12 @@ public NodeInfo createNode(String parentNodeId, String name, String nodePseudoCl
.resolveTemplate(FILE_SYSTEM_NAME, fileSystemName)
.resolveTemplate(NODE_ID, parentNodeId)
.resolveTemplate("childName", name)
.queryParam("nodePseudoClass", nodePseudoClass)
.queryParam("description", description)
.queryParam(VERSION, version)
.request(MediaType.APPLICATION_JSON)
.header(HttpHeaders.AUTHORIZATION, token)
.header(HttpHeaders.CONTENT_ENCODING, "gzip")
.acceptEncoding("gzip")
.post(Entity.json(genericMetadata));
.post(Entity.json(new NodeInfo(parentNodeId, name, nodePseudoClass, description, ZonedDateTime.now().toInstant().toEpochMilli(),
ZonedDateTime.now().toInstant().toEpochMilli(), version, genericMetadata, accessRights)));
try {
return readEntityIfOk(response, NodeInfo.class);
} finally {
Expand Down

0 comments on commit e883e48

Please sign in to comment.