Search in sources :

Example 11 with RegistryRole

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);
}
Also used : JsonArray(com.google.gson.JsonArray) RegistryRole(org.commongeoregistry.adapter.metadata.RegistryRole) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 12 with RegistryRole

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;
}
Also used : JsonArray(com.google.gson.JsonArray) RegistryRole(org.commongeoregistry.adapter.metadata.RegistryRole) RestResponse(com.runwaysdk.mvc.RestResponse) JSONArray(org.json.JSONArray) Endpoint(com.runwaysdk.mvc.Endpoint) GeoprismUserDTO(net.geoprism.GeoprismUserDTO) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 13 with RegistryRole

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());
}
Also used : RegistryRole(org.commongeoregistry.adapter.metadata.RegistryRole) RegistryRoleConverter(net.geoprism.registry.conversion.RegistryRoleConverter) Roles(com.runwaysdk.system.Roles) Request(com.runwaysdk.session.Request)

Aggregations

RegistryRole (org.commongeoregistry.adapter.metadata.RegistryRole)13 Roles (com.runwaysdk.system.Roles)7 RegistryRoleConverter (net.geoprism.registry.conversion.RegistryRoleConverter)7 JsonArray (com.google.gson.JsonArray)6 Endpoint (com.runwaysdk.mvc.Endpoint)5 RestResponse (com.runwaysdk.mvc.RestResponse)4 JSONArray (org.json.JSONArray)4 JSONObject (org.json.JSONObject)4 Request (com.runwaysdk.session.Request)3 HashSet (java.util.HashSet)3 LinkedList (java.util.LinkedList)3 GeoprismUser (net.geoprism.GeoprismUser)2 Organization (net.geoprism.registry.Organization)2 Business (com.runwaysdk.business.Business)1 RoleDAO (com.runwaysdk.business.rbac.RoleDAO)1 RoleDAOIF (com.runwaysdk.business.rbac.RoleDAOIF)1 UserDAOIF (com.runwaysdk.business.rbac.UserDAOIF)1 AttributeValueException (com.runwaysdk.dataaccess.attributes.AttributeValueException)1 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1 RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)1