Difference between revisions of "GeoFence library"

From Gcube Wiki
Jump to: navigation, search
 
(73 intermediate revisions by the same user not shown)
Line 1: Line 1:
  
 +
This section aims to describe the Geofence library in order to help developers to manage users, groups, rules and instances in Geofence server.
  
=User section=
+
First of all, you need to configure Geofence with GeoServer using a probe. Download the geofence-plugin at this link https://github.com/geoserver/geofence according to your GeoServer version. The plugin contains three JAR files that you must insert in the WEB-INF/lib in geoserver.
*getUserById(String id)
+
<pre>
+
Parameters:
+
    id - It's the userId of user you are looking for.
+
Returns:
+
    GSUser object.
+
</pre>
+
  
*getUserByUsername(String userName)
+
After configuring between Geofence server with GeoServer, for instance, it's possible create an user in Geofence and automatically it's possible to login (with this user) in GeoServer.
<pre>
+
Parameters:
+
    userName - It's the name of user you are looking for.
+
Returns:
+
    GSUser object.
+
</pre>
+
  
==Group section==
+
Following is a list of methods (divided in sections), with all details to uderstand how invoke them.
 +
 
 +
 
 +
====Constructor====
 +
Parameters List :
 +
*"geofenceRestUrl" : [String value] The URL of Geofence instance;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
GeoFence gf = new GeoFence("http://geofenceRestUrl/");
 +
</source>
 +
 
 +
==User section==
 +
 
 +
===getUserById(String id)===
 +
 
 +
Parameters List :
 +
*"id" : [String value] It's the userId of user you are looking for;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String id = ...;
 +
GSUser user = gf.getUserById(id);
 +
String userName = user.getName();
 +
</source>
 +
 
 +
===getUserByUsername(String userName)===
 +
 
 +
Parameters List :
 +
*"userName" : [String value] It's the name of user you are looking for;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String userName = ...;
 +
GSUser user = gf.getUserByUsername(userName);
 +
String id = user.getId();
 +
</source>
 +
 
 +
===createUser(User user)===
 +
 
 +
Parameters List :
 +
*"user" : [User value] It's the org.gcube.data.access.bean.User object you are creating;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
User user = new User();
 +
user.setExtId("id_1");
 +
user.setName("test_1");
 +
user.setPassword("test");
 +
...
 +
HttpStatus status = gf.createUser(user);
 +
</source>
 +
 
 +
===updateUser(User user)===
 +
 
 +
Parameters List :
 +
*"user" : [User value] It's the org.gcube.data.access.bean.User object you are updating;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
User user = new User();
 +
user.setExtId("id_1");
 +
user.setName("test_1");
 +
user.setPassword("test_1");
 +
user.setEmailAddress("test@email.com");
 +
...
 +
HttpStatus status = gf.updateUser(user);
 +
</source>
 +
 
 +
===updateUserById(String id, String password, String email, boolean admin, boolean enabled)===
 +
 
 +
Parameters List :
 +
*"id" : [String value] It's the id of user;
 +
*"password" : [String value] It's the password of user.
 +
*"email" : [String value] It's the email of user.
 +
*"admin" : [boolean value] It's the boolean flag to define if user is administrator or not.
 +
*"enabled" : [boolean value] It's the boolean flag to define if user is enabled or not.
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String id = ...;
 +
HttpStatus status = gf.updateUserById(id, "new_pass", "test@email.com", false, false);
 +
</source>
 +
 
 +
===updateUserByUsername(String userName, String password, String email, boolean admin, boolean enabled)===
 +
 
 +
Parameters List :
 +
*"userName" : [String value] It's the userName of user;
 +
*"password" : [String value] It's the password of user.
 +
*"email" : [String value] It's the email of user.
 +
*"admin" : [boolean value] It's the boolean flag to define if user is administrator or not.
 +
*"enabled" : [boolean value] It's the boolean flag to define if user is enabled or not.
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String userName= ...;
 +
HttpStatus status = gf.updateUserByUsername(userName, "new_pass", "test@email.com", true, true);
 +
</source>
 +
 
 +
===deleteUserById(String id, boolean removeAllRules)===
 +
 
 +
Parameters List :
 +
*"id" : [String value] It's the userId of user you are looking for;
 +
*"removeAllRules" : [boolean value] It's a flag to remove all rules together to the user;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String id = ...;
 +
HttpStatus status = gf.deleteUserById(id, true);
 +
</source>
 +
 
 +
===deleteUserByUsername(String userName, boolean removeAllRules)===
 +
 
 +
Parameters List :
 +
*"userName" : [String value] It's the userName of user you are looking for;
 +
*"removeAllRules" : [boolean value] It's a flag to remove all rules together to the user;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String userName = ...;
 +
HttpStatus status = gf.deleteUserById(userName, false);
 +
</source>
 +
 
 +
===getUserList()===
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
UserList userList = gf.getUserList();
 +
List<Users> users = userList.getUsers();
 +
int size = users.size();
 +
</source>
 +
 
 +
==UserGroup section==
 +
 
 +
===createUserGroup(UserGroup userGroup)===
 +
 
 +
Parameters List :
 +
*"userGroup " : [UserGroup value] - It's the org.gcube.data.access.bean.UserGroup object you are creating.
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
UserGroup group = new UserGroup();
 +
group.setExtId("ext_id_1");
 +
group.setName("My group");
 +
group.setDateCreation(new Date());
 +
group.setEnabled(false);
 +
HttpStatus status = gf.createUserGroup(group);
 +
</source>
 +
 
 +
===getUserGroupById(String id)===
 +
 
 +
Parameters List :
 +
*"id" : [String value] It's the id of group you are looking for;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String id = ...;
 +
Group g = gf.getUserGroupById(id);
 +
String name = g.getName();
 +
</source>
 +
 
 +
===getUserGroupByName(String userName)===
 +
 
 +
Parameters List :
 +
*"userName" : [String value] It's the userName of group you are looking for;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String userName = ...;
 +
Group g = gf.getUserGroupByName(userName);
 +
String id = g.getId();
 +
</source>
 +
 
 +
===updateUserGroup(Group group)===
 +
 
 +
Parameters List :
 +
*"group" : [Group value] It's the Group object you are updating;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
Group g =  ...
 +
g.setEnabled(false);
 +
HttpStatus status = gf.updateUserGroup(g);
 +
</source>
 +
 
 +
===updateUserGroupById(String id, boolean enabled)===
 +
 
 +
Parameters List :
 +
*"id" : [String value] It's the userId of user you are looking for;
 +
*"enabled" : [boolean value] It's the enabled flag of group;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String id =  ...
 +
HttpStatus status = gf.updateUserGroupById(id, true);
 +
</source>
 +
 
 +
===updateUserGroupByName(String name, boolean enabled)===
 +
 
 +
Parameters List :
 +
*"name" : [String value] It's the userId of user you are looking for;
 +
*"enabled" : [boolean value] It's the enabled flag of group;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String name =  ...
 +
HttpStatus status = gf.updateUserGroupByName(name, false);
 +
</source>
 +
 
 +
===deleteUserGroupById(String groupId)===
 +
 
 +
Parameters List :
 +
*"groupId" : [String value] It's the groupId of group;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String groupId = ...;
 +
HttpStatus status = gf.deleteUserGroupById(groupId);
 +
</source>
 +
 
 +
===deleteUserGroupByName(String groupName)===
 +
 
 +
Parameters List :
 +
*"groupName" : [String value] It's the groupName of group;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String groupName = ...;
 +
HttpStatus status = gf.deleteUserGroupByName(groupName);
 +
</source>
 +
 
 +
===getUserGroupList()===
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
UserGroupList ugl = gf.getUserGroupList();
 +
List<UserGroups> ugs = ugl.getUserGroups();
 +
int size = ugs.size();
 +
</source>
 +
 
 +
===assignToUserGroupByUserIdGroupId(String userId, String groupId)===
 +
 
 +
Parameters List :
 +
*"userId" : [String value] It's the id of user;
 +
*"groupId" : [String value] It's the id of group;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String userId = ...
 +
String groupId = ...
 +
HttpStatus status = gf.assignToUserGroupByUserIdGroupId(userId, groupId);
 +
</source>
 +
 
 +
===assignToUserGroupByUserIdGroupName(String userId, String groupName)===
 +
 
 +
Parameters List :
 +
*"userId" : [String value] It's the id of user;
 +
*"groupName" : [String value] It's the name of group;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String userId = ...
 +
String groupName = ...
 +
HttpStatus status = gf.assignToUserGroupByUserIdGroupId(userId, groupName);
 +
</source>
 +
 
 +
===assignToUserGroupByUserNameGroupId(String userName, String groupId)===
 +
 
 +
Parameters List :
 +
*"userName" : [String value] It's the username of use;
 +
*"groupId" : [String value] It's the id of group;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String userName = ...
 +
String groupId = ...
 +
HttpStatus status = gf.assignToUserGroupByUserNameGroupId(userName, groupId);
 +
</source>
 +
 
 +
===assignToUserGroupByUserNameGroupName(String userName, String groupName)===
 +
 
 +
Parameters List :
 +
*"userName" : [String value] It's the username of user;
 +
*"groupName" : [String value] It's the name of group;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String userName = ...
 +
String groupName = ...
 +
HttpStatus status = gf.assignToUserGroupByUserNameGroupName(userName, groupName);
 +
</source>
 +
 
 +
===removeUserGroupByUserIdGroupId(String userId, String groupId)===
 +
 
 +
Parameters List :
 +
*"userId" : [String value] It's the id of user;
 +
*"groupId" : [String value] It's the id of group;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String userId = ...;
 +
String groupId = ...;
 +
HttpStatus status = gf.removeUserGroupByUserIdGroupId(userId, groupId);
 +
</source>
 +
 
 +
===removeUserGroupByUserIdGroupName(String userId, String groupName)===
 +
 
 +
Parameters List :
 +
*"userId" : [String value] It's the id of user;
 +
*"groupName" : [String value] It's the name of group;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String userId = ...;
 +
String groupName = ...;
 +
HttpStatus status = gf.removeUserGroupByUserIdGroupName(userId, groupName);
 +
</source>
 +
 
 +
===removeUserGroupByUserNameGroupId(String userName, String groupId)===
 +
 
 +
Parameters List :
 +
*"userName" : [String value] It's the name of user;
 +
*"groupId" : [String value] It's the id of group;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String userName = ...;
 +
String groupId = ...;
 +
HttpStatus status = gf.removeUserGroupByUserNameGroupId(userName, groupId);
 +
</source>
 +
 
 +
===removeUserGroupByUserNameGroupName(String userName, String groupName)===
 +
 
 +
Parameters List :
 +
*"userName" : [String value] It's the name of user;
 +
*"groupName" : [String value] It's the name of group;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String userName = ...;
 +
String groupName = ...;
 +
HttpStatus status = gf.removeUserGroupByUserNameGroupName(userName, groupName);
 +
</source>
 +
 
 +
==Instance section==
 +
 
 +
===createInstance(Instance instance)===
 +
 
 +
Parameters List :
 +
*"instance" : [Instance value] - It's the org.gcube.data.access.bean.Instance object you are creating.
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
Instance instance = new Instance();
 +
instance.setBaseURL("https://geoserver.org/geoserver");
 +
instance.setName("geoserver");
 +
instance.setPassword("geoserver");
 +
instance.setUsername("admin");
 +
instance.setDescription("A geoserver test");
 +
instance.setDateCreation(new Date());
 +
HttpStatus status = gf.createInstance(instance);
 +
</source>
 +
 
 +
===getInstanceById(String instanceId)===
 +
 
 +
Parameters List :
 +
*"instanceId" : [String value] It's the id of Instance object;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String id = ...;
 +
GSInstance ins = gf.getInstanceById(id);
 +
String name = ins.getName();
 +
</source>
 +
 
 +
===getInstanceByName(String instanceName)===
 +
 
 +
Parameters List :
 +
*"instanceName" : [String value] It's the name of Instance object;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String name = ...;
 +
GSUser user = gf.getInstanceByName(name);
 +
String id = user.getId();
 +
</source>
 +
 +
===updateInstance(Instance instance)===
 +
 
 +
Parameters List :
 +
*"instance" : [Instance value] It's the Instance object;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
Instance instance = new Instance();
 +
...
 +
instance.setDescription("My geoserver update");
 +
HttpStatus status = gf.updateInstance(instance);
 +
</source>
 +
 
 +
===updateInstanceById(String id, String username, String password, String baseURL, String description)===
 +
 
 +
Parameters List :
 +
*"id" : [String value] It's the id of Instance object, not editable;
 +
*"username" : [String value] It's the username of Instance object;
 +
*"password" : [String value] It's the password of Instance object;
 +
*"baseURL" : [String value] It's the baseURL of Instance object;
 +
*"description" : [String value] It's the description of Instance object;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String id = ...;
 +
HttpStatus status = gf.updateInstanceById(id, "admin", "geoserver", "https://geoserver.org/geoserver", "geoserver");
 +
</source>
 +
 
 +
===updateInstanceByName(String instanceName, String username, String password, String baseURL, String description)===
 +
 
 +
Parameters List :
 +
*"instanceName" : [String value] It's the name of Instance object, not editable;
 +
*"username" : [String value] It's the username of Instance object;
 +
*"password" : [String value] It's the password of Instance object;
 +
*"baseURL" : [String value] It's the baseURL of Instance object;
 +
*"description" : [String value] It's the description of Instance object;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String id = ...;
 +
HttpStatus status = gf.updateInstanceById(id, "admin", "geoserver", "https://geoserver.org/geoserver", "geoserver");
 +
</source>
 +
 
 +
===deleteInstanceById(String instanceId)===
 +
 
 +
Parameters List :
 +
*"instanceId" : [String value] It's the id of Instance object;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String id = ...;
 +
HttpStatus status = gf.deleteInstanceById(id);
 +
</source>
 +
 
 +
===deleteInstanceByName(String instanceName, boolean removeAllRules)===
 +
 
 +
Parameters List :
 +
*"instanceName" : [String value] It's the name of Instance object;
 +
*"removeAllRules" : [boolean value] It's a parameter to removes all rules together the Instance object;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String name = ...;
 +
HttpStatus status = gf.deleteInstanceByName(name, false);
 +
</source>
 +
 
 +
===getInstanceList()===
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
GSInstanceList g =  gf.getInstanceList();
 +
int size = g.getInstances().size();
 +
</source>
 +
 
 +
==Rule section==
 +
 
 +
===createRule(Rule rule)===
 +
 
 +
Parameters List :
 +
*"rule" : [Rule value] - It's the org.gcube.data.access.bean.Rule object.
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
Rule rule = new Rule();
 +
rule.setPosition(PositionType.FIXED_PRIORITY.toString(), "1");
 +
rule.setGrant(GrantType.DENY);
 +
String id = ...;
 +
String name = ...;
 +
rule.setUser(id, name);
 +
...
 +
rule.setLayer("*");
 +
rule.setPriority("1");
 +
rule.setRequest("*");
 +
rule.setService("*");
 +
rule.setWorkspace("test");
 +
HttpStatus status = gf.createRule(rule);
 +
</source>
 +
 
 +
===getRulesById(String id)===
 +
 
 +
Parameters List :
 +
*"id" : [String value] It's the id of rule;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String id = ...;
 +
Rules rule = gf.getRulesById(id);
 +
String user = rule.getUser().getName();
 +
</source>
 +
 
 +
 
 +
===updateRule(Rule rule)===
 +
 
 +
Parameters List :
 +
*"rule" : [Rule value] It's the rule object;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
Rule rule = new Rule();
 +
rule.setGroup("5", "My group");
 +
rule.setId("11");
 +
rule.setInstance("2","default-gs");
 +
rule.setPriority("2");
 +
rule.setUser("12","test");
 +
...
 +
HttpStatus status = gf.updateRule(rule);
 +
</source>
 +
 
 +
===updateRuleById(String id, String priority, String service, String request, String workspace, String layer, String userId, String groupId, String instanceId)===
 +
 
 +
Parameters List :
 +
*"id" : [String value] It's the id of Instance object, not editable;
 +
*"priority" : [String value] It's the priority of Instance object;
 +
*"service" : [String value] It's the service of Instance object;
 +
*"request" : [String value] It's the request of Instance object;
 +
*"workspace" : [String value] It's the workspace of Instance object;
 +
*"layer" : [String value] It's the layer of Instance object;
 +
*"userId" : [String value] It's the userId of Instance object;
 +
*"groupId" : [String value] It's the groupId of Instance object;
 +
*"instanceId" : [String value] It's the instanceId of Instance object;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String id = ...;
 +
String priority = ...;
 +
String service = ...;
 +
String request = ...;
 +
String workspace = ...;
 +
String layer = ...;
 +
String userId = ...;
 +
String groupId = ...;
 +
String instanceId = ...;
 +
HttpStatus status = gf.updateRuleById(id, priority, service, request, workspace, layer, userId, groupId, instanceId);
 +
</source>
 +
 
 +
===deleteRule(String ruleId)===
 +
 
 +
Parameters List :
 +
*"ruleId" : [String value] It's the id of Rule object;
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String ruleId = ...;
 +
HttpStatus status = gf.deleteRule(ruleId);
 +
</source>
 +
 
 +
===getRulesList())===
 +
 
 +
'''Invocation example'''
 +
<source lang="java5">
 +
RuleList rl = gf.getRulesList();
 +
int size = rl.getRules().size();
 +
</source>

Latest revision as of 16:00, 22 November 2017

This section aims to describe the Geofence library in order to help developers to manage users, groups, rules and instances in Geofence server.

First of all, you need to configure Geofence with GeoServer using a probe. Download the geofence-plugin at this link https://github.com/geoserver/geofence according to your GeoServer version. The plugin contains three JAR files that you must insert in the WEB-INF/lib in geoserver.

After configuring between Geofence server with GeoServer, for instance, it's possible create an user in Geofence and automatically it's possible to login (with this user) in GeoServer.

Following is a list of methods (divided in sections), with all details to uderstand how invoke them.


Contents

Constructor

Parameters List :

  • "geofenceRestUrl" : [String value] The URL of Geofence instance;

Invocation example

GeoFence gf = new GeoFence("http://geofenceRestUrl/");

User section

getUserById(String id)

Parameters List :

  • "id" : [String value] It's the userId of user you are looking for;

Invocation example

String id = ...;
GSUser user = gf.getUserById(id);
String userName = user.getName();

getUserByUsername(String userName)

Parameters List :

  • "userName" : [String value] It's the name of user you are looking for;

Invocation example

String userName = ...;
GSUser user = gf.getUserByUsername(userName);
String id = user.getId();

createUser(User user)

Parameters List :

  • "user" : [User value] It's the org.gcube.data.access.bean.User object you are creating;

Invocation example

User user = new User();
user.setExtId("id_1");
user.setName("test_1");
user.setPassword("test");
...
HttpStatus status = gf.createUser(user);

updateUser(User user)

Parameters List :

  • "user" : [User value] It's the org.gcube.data.access.bean.User object you are updating;

Invocation example

User user = new User();
user.setExtId("id_1");
user.setName("test_1");
user.setPassword("test_1");
user.setEmailAddress("test@email.com");
...
HttpStatus status = gf.updateUser(user);

updateUserById(String id, String password, String email, boolean admin, boolean enabled)

Parameters List :

  • "id" : [String value] It's the id of user;
  • "password" : [String value] It's the password of user.
  • "email" : [String value] It's the email of user.
  • "admin" : [boolean value] It's the boolean flag to define if user is administrator or not.
  • "enabled" : [boolean value] It's the boolean flag to define if user is enabled or not.

Invocation example

String id = ...;
HttpStatus status = gf.updateUserById(id, "new_pass", "test@email.com", false, false);

updateUserByUsername(String userName, String password, String email, boolean admin, boolean enabled)

Parameters List :

  • "userName" : [String value] It's the userName of user;
  • "password" : [String value] It's the password of user.
  • "email" : [String value] It's the email of user.
  • "admin" : [boolean value] It's the boolean flag to define if user is administrator or not.
  • "enabled" : [boolean value] It's the boolean flag to define if user is enabled or not.

Invocation example

String userName= ...;
HttpStatus status = gf.updateUserByUsername(userName, "new_pass", "test@email.com", true, true);

deleteUserById(String id, boolean removeAllRules)

Parameters List :

  • "id" : [String value] It's the userId of user you are looking for;
  • "removeAllRules" : [boolean value] It's a flag to remove all rules together to the user;

Invocation example

String id = ...;
HttpStatus status = gf.deleteUserById(id, true);

deleteUserByUsername(String userName, boolean removeAllRules)

Parameters List :

  • "userName" : [String value] It's the userName of user you are looking for;
  • "removeAllRules" : [boolean value] It's a flag to remove all rules together to the user;

Invocation example

String userName = ...;
HttpStatus status = gf.deleteUserById(userName, false);

getUserList()

Invocation example

UserList userList = gf.getUserList();
List<Users> users = userList.getUsers();
int size = users.size();

UserGroup section

createUserGroup(UserGroup userGroup)

Parameters List :

  • "userGroup " : [UserGroup value] - It's the org.gcube.data.access.bean.UserGroup object you are creating.

Invocation example

UserGroup group = new UserGroup();
group.setExtId("ext_id_1");
group.setName("My group");
group.setDateCreation(new Date());
group.setEnabled(false);
HttpStatus status = gf.createUserGroup(group);

getUserGroupById(String id)

Parameters List :

  • "id" : [String value] It's the id of group you are looking for;

Invocation example

String id = ...;
Group g = gf.getUserGroupById(id);
String name = g.getName();

getUserGroupByName(String userName)

Parameters List :

  • "userName" : [String value] It's the userName of group you are looking for;

Invocation example

String userName = ...;
Group g = gf.getUserGroupByName(userName);
String id = g.getId();

updateUserGroup(Group group)

Parameters List :

  • "group" : [Group value] It's the Group object you are updating;

Invocation example

Group g =  ...
g.setEnabled(false);
HttpStatus status = gf.updateUserGroup(g);

updateUserGroupById(String id, boolean enabled)

Parameters List :

  • "id" : [String value] It's the userId of user you are looking for;
  • "enabled" : [boolean value] It's the enabled flag of group;

Invocation example

String id =  ...	
HttpStatus status = gf.updateUserGroupById(id, true);

updateUserGroupByName(String name, boolean enabled)

Parameters List :

  • "name" : [String value] It's the userId of user you are looking for;
  • "enabled" : [boolean value] It's the enabled flag of group;

Invocation example

String name =  ...	
HttpStatus status = gf.updateUserGroupByName(name, false);

deleteUserGroupById(String groupId)

Parameters List :

  • "groupId" : [String value] It's the groupId of group;

Invocation example

String groupId = ...;
HttpStatus status = gf.deleteUserGroupById(groupId);

deleteUserGroupByName(String groupName)

Parameters List :

  • "groupName" : [String value] It's the groupName of group;

Invocation example

String groupName = ...;
HttpStatus status = gf.deleteUserGroupByName(groupName);

getUserGroupList()

Invocation example

UserGroupList ugl = gf.getUserGroupList();
List<UserGroups> ugs = ugl.getUserGroups();
int size = ugs.size();

assignToUserGroupByUserIdGroupId(String userId, String groupId)

Parameters List :

  • "userId" : [String value] It's the id of user;
  • "groupId" : [String value] It's the id of group;

Invocation example

String userId = ...
String groupId = ...
HttpStatus status = gf.assignToUserGroupByUserIdGroupId(userId, groupId);

assignToUserGroupByUserIdGroupName(String userId, String groupName)

Parameters List :

  • "userId" : [String value] It's the id of user;
  • "groupName" : [String value] It's the name of group;

Invocation example

String userId = ...
String groupName = ...
HttpStatus status = gf.assignToUserGroupByUserIdGroupId(userId, groupName);

assignToUserGroupByUserNameGroupId(String userName, String groupId)

Parameters List :

  • "userName" : [String value] It's the username of use;
  • "groupId" : [String value] It's the id of group;

Invocation example

String userName = ...
String groupId = ...
HttpStatus status = gf.assignToUserGroupByUserNameGroupId(userName, groupId);

assignToUserGroupByUserNameGroupName(String userName, String groupName)

Parameters List :

  • "userName" : [String value] It's the username of user;
  • "groupName" : [String value] It's the name of group;

Invocation example

String userName = ...
String groupName = ...
HttpStatus status = gf.assignToUserGroupByUserNameGroupName(userName, groupName);

removeUserGroupByUserIdGroupId(String userId, String groupId)

Parameters List :

  • "userId" : [String value] It's the id of user;
  • "groupId" : [String value] It's the id of group;

Invocation example

String userId = ...;
String groupId = ...;
HttpStatus status = gf.removeUserGroupByUserIdGroupId(userId, groupId);

removeUserGroupByUserIdGroupName(String userId, String groupName)

Parameters List :

  • "userId" : [String value] It's the id of user;
  • "groupName" : [String value] It's the name of group;

Invocation example

String userId = ...;
String groupName = ...;
HttpStatus status = gf.removeUserGroupByUserIdGroupName(userId, groupName);

removeUserGroupByUserNameGroupId(String userName, String groupId)

Parameters List :

  • "userName" : [String value] It's the name of user;
  • "groupId" : [String value] It's the id of group;

Invocation example

String userName = ...;
String groupId = ...;
HttpStatus status = gf.removeUserGroupByUserNameGroupId(userName, groupId);

removeUserGroupByUserNameGroupName(String userName, String groupName)

Parameters List :

  • "userName" : [String value] It's the name of user;
  • "groupName" : [String value] It's the name of group;

Invocation example

String userName = ...;
String groupName = ...;
HttpStatus status = gf.removeUserGroupByUserNameGroupName(userName, groupName);

Instance section

createInstance(Instance instance)

Parameters List :

  • "instance" : [Instance value] - It's the org.gcube.data.access.bean.Instance object you are creating.

Invocation example

Instance instance = new Instance();
instance.setBaseURL("https://geoserver.org/geoserver");
instance.setName("geoserver");
instance.setPassword("geoserver");
instance.setUsername("admin");
instance.setDescription("A geoserver test");
instance.setDateCreation(new Date());
HttpStatus status = gf.createInstance(instance);

getInstanceById(String instanceId)

Parameters List :

  • "instanceId" : [String value] It's the id of Instance object;

Invocation example

String id = ...;
GSInstance ins = gf.getInstanceById(id);
String name = ins.getName();

getInstanceByName(String instanceName)

Parameters List :

  • "instanceName" : [String value] It's the name of Instance object;

Invocation example

String name = ...;
GSUser user = gf.getInstanceByName(name);
String id = user.getId();

updateInstance(Instance instance)

Parameters List :

  • "instance" : [Instance value] It's the Instance object;

Invocation example

Instance instance = new Instance();
...
instance.setDescription("My geoserver update");
HttpStatus status = gf.updateInstance(instance);

updateInstanceById(String id, String username, String password, String baseURL, String description)

Parameters List :

  • "id" : [String value] It's the id of Instance object, not editable;
  • "username" : [String value] It's the username of Instance object;
  • "password" : [String value] It's the password of Instance object;
  • "baseURL" : [String value] It's the baseURL of Instance object;
  • "description" : [String value] It's the description of Instance object;

Invocation example

String id = ...;
HttpStatus status = gf.updateInstanceById(id, "admin", "geoserver", "https://geoserver.org/geoserver", "geoserver");

updateInstanceByName(String instanceName, String username, String password, String baseURL, String description)

Parameters List :

  • "instanceName" : [String value] It's the name of Instance object, not editable;
  • "username" : [String value] It's the username of Instance object;
  • "password" : [String value] It's the password of Instance object;
  • "baseURL" : [String value] It's the baseURL of Instance object;
  • "description" : [String value] It's the description of Instance object;

Invocation example

String id = ...;
HttpStatus status = gf.updateInstanceById(id, "admin", "geoserver", "https://geoserver.org/geoserver", "geoserver");

deleteInstanceById(String instanceId)

Parameters List :

  • "instanceId" : [String value] It's the id of Instance object;

Invocation example

String id = ...;
HttpStatus status = gf.deleteInstanceById(id);

deleteInstanceByName(String instanceName, boolean removeAllRules)

Parameters List :

  • "instanceName" : [String value] It's the name of Instance object;
  • "removeAllRules" : [boolean value] It's a parameter to removes all rules together the Instance object;

Invocation example

String name = ...;
HttpStatus status = gf.deleteInstanceByName(name, false);

getInstanceList()

Invocation example

GSInstanceList g =  gf.getInstanceList();
int size = g.getInstances().size();

Rule section

createRule(Rule rule)

Parameters List :

  • "rule" : [Rule value] - It's the org.gcube.data.access.bean.Rule object.

Invocation example

Rule rule = new Rule();
rule.setPosition(PositionType.FIXED_PRIORITY.toString(), "1");
rule.setGrant(GrantType.DENY);
String id = ...;
String name = ...;
rule.setUser(id, name);
...
rule.setLayer("*");
rule.setPriority("1");
rule.setRequest("*");
rule.setService("*");		
rule.setWorkspace("test");	
HttpStatus status = gf.createRule(rule);

getRulesById(String id)

Parameters List :

  • "id" : [String value] It's the id of rule;

Invocation example

String id = ...;
Rules rule = gf.getRulesById(id);
String user = rule.getUser().getName();


updateRule(Rule rule)

Parameters List :

  • "rule" : [Rule value] It's the rule object;

Invocation example

Rule rule = new Rule();
rule.setGroup("5", "My group");
rule.setId("11");
rule.setInstance("2","default-gs");
rule.setPriority("2");
rule.setUser("12","test");
...
HttpStatus status = gf.updateRule(rule);

updateRuleById(String id, String priority, String service, String request, String workspace, String layer, String userId, String groupId, String instanceId)

Parameters List :

  • "id" : [String value] It's the id of Instance object, not editable;
  • "priority" : [String value] It's the priority of Instance object;
  • "service" : [String value] It's the service of Instance object;
  • "request" : [String value] It's the request of Instance object;
  • "workspace" : [String value] It's the workspace of Instance object;
  • "layer" : [String value] It's the layer of Instance object;
  • "userId" : [String value] It's the userId of Instance object;
  • "groupId" : [String value] It's the groupId of Instance object;
  • "instanceId" : [String value] It's the instanceId of Instance object;

Invocation example

String id = ...;
String priority = ...;
String service = ...;
String request = ...;
String workspace = ...;
String layer = ...;
String userId = ...;
String groupId = ...;
String instanceId = ...;
HttpStatus status = gf.updateRuleById(id, priority, service, request, workspace, layer, userId, groupId, instanceId);

deleteRule(String ruleId)

Parameters List :

  • "ruleId" : [String value] It's the id of Rule object;

Invocation example

String ruleId = ...;
HttpStatus status = gf.deleteRule(ruleId);

getRulesList())

Invocation example

RuleList rl = gf.getRulesList();
int size = rl.getRules().size();