use of org.commongeoregistry.adapter.metadata.RegistryRole in project geoprism-registry by terraframe.
the class RegistryAccountController method getRolesForUser.
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON)
public ResponseIF getRolesForUser(ClientRequestIF request, @RequestParamter(name = "userOID", required = true) String userOID) throws JSONException {
RegistryRole[] roles = this.accountService.getRolesForUser(request.getSessionId(), userOID);
JsonArray rolesJSONArray = this.createRoleMap(roles);
return new RestBodyResponse(rolesJSONArray);
}
use of org.commongeoregistry.adapter.metadata.RegistryRole in project geoprism-registry by terraframe.
the class RegistryAccountController method newInstance.
/**
* Returns all roles associated with the given {@link OrganizationDTO} codes.
* If no codes are provided then return all roles defined in the registry.
*
* @param request
* @param organizationCodes
* comma separated list of {@link OrganizationDTO} codes.
* @return
* @throws JSONException
*/
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON)
public ResponseIF newInstance(ClientRequestIF request, @RequestParamter(name = "organizationCodes") String organizationCodes) throws JSONException {
String[] orgCodeArray = null;
if (organizationCodes != null) {
JSONArray arr = new JSONArray(organizationCodes);
orgCodeArray = new String[arr.length()];
for (int i = 0; i < arr.length(); i++) {
orgCodeArray[i] = arr.getString(i);
}
} else {
orgCodeArray = new String[0];
}
GeoprismUserDTO user = UserInviteDTO.newUserInst(request);
RegistryRole[] registryRoles = this.accountService.getRolesForOrganization(request.getSessionId(), orgCodeArray);
JsonArray rolesJSONArray = this.createRoleMap(registryRoles);
RestResponse response = new RestResponse();
response.set("user", user);
response.set("roles", new JSONArray(rolesJSONArray.toString()));
return response;
}
use of org.commongeoregistry.adapter.metadata.RegistryRole in project geoprism-registry by terraframe.
the class OrganizationAndRoleTest method rm_RoleToRegistryRoleRequest.
@Request
public void rm_RoleToRegistryRoleRequest() {
String rmRoleName = RegistryRole.Type.getRM_RoleName(FastTestDataset.ORG_CGOV.getCode(), FastTestDataset.PROVINCE.getCode());
Roles rmRole = Roles.findRoleByName(rmRoleName);
RegistryRole registryRole = new RegistryRoleConverter().build(rmRole);
Assert.assertEquals(rmRoleName, registryRole.getName());
Assert.assertEquals(FastTestDataset.ORG_CGOV.getCode(), registryRole.getOrganizationCode());
Assert.assertEquals(FastTestDataset.PROVINCE.getCode(), registryRole.getGeoObjectTypeCode());
}
Aggregations