Skip to content

Commit 0d03567

Browse files
author
Jagrut Kosti
committed
List permissions for stream or asset
1 parent a8c3bda commit 0d03567

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/main/java/multichain/command/GrantCommand.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import multichain.object.Permission;
1313
import multichain.object.formatters.GrantFormatter;
1414

15+
import java.util.List;
16+
1517
/**
1618
* @author Ub - H. MARTEAU
1719
* @version 1.0
@@ -322,6 +324,18 @@ public static Permission listPermissions() throws MultichainException {
322324
return GrantFormatter.formatPermission(stringPermission);
323325
}
324326

327+
/**
328+
* Returns list of all permissions for a given address in the stream
329+
* @param streamPermission the stream permission query. E.g. streamName.write,admin or streamName.* for all
330+
* @param address the address for which to fetch the permission
331+
* @return List of permissions for the mentioned address in the stream
332+
* @throws MultichainException
333+
*/
334+
public static List<Permission> listPermissionForStreamAndAddress(String streamPermission, String address) throws MultichainException {
335+
String permissions = executeListPermissions(streamPermission, address, true);
336+
return GrantFormatter.formatPermissionList(permissions);
337+
}
338+
325339
/**
326340
* Revoke permissions to addresses
327341
*

src/main/java/multichain/command/builders/QueryBuilderGrant.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,18 @@ protected static String executeListPermissions(int permissions, String address,
206206
return listPermissions;
207207
}
208208

209+
/**
210+
* Returns list of permissions for specified addresses in the mentioned stream
211+
* @param streamPermission in the form of streamName.admin,write or streamName.*
212+
* @param address the list of address for which to fetch permission. * for all
213+
* @param verbose true - for detailed info, otherwise false
214+
* @return String containing the output of listpermissions command
215+
* @throws MultichainException
216+
*/
217+
protected static String executeListPermissions(String streamPermission, String address, boolean verbose) throws MultichainException {
218+
return execute(CommandEnum.LISTPERMISSIONS, streamPermission, address, formatJson(verbose));
219+
}
220+
209221
/**
210222
* Revoke permissions to addresses
211223
*

0 commit comments

Comments
 (0)