Search in sources :

Example 6 with RegistryRoleConverter

use of net.geoprism.registry.conversion.RegistryRoleConverter in project geoprism-registry by terraframe.

the class RegistryAccountUtil method sendEmail.

public static void sendEmail(UserInvite invite, String roleIds) {
    final String serverExternalUrl = GeoregistryProperties.getRemoteServerUrl();
    String address = invite.getEmail();
    String link = serverExternalUrl + "cgr/manage#/admin/invite-complete/" + invite.getToken();
    String subject = LocalizationFacade.localize("user.invite.email.subject");
    String body = LocalizationFacade.localize("user.invite.email.body");
    body = body.replaceAll("\\\\n", "\n");
    body = body.replace("${link}", link);
    body = body.replace("${expireTime}", getLocalizedExpireTime());
    JsonArray roleNameArray = JsonParser.parseString(roleIds).getAsJsonArray();
    String orgLabel = "??";
    Set<String> roleLabels = new HashSet<String>();
    for (int i = 0; i < roleNameArray.size(); ++i) {
        String roleName = roleNameArray.get(i).getAsString();
        Roles role = Roles.findRoleByName(roleName);
        RegistryRole registryRole = new RegistryRoleConverter().build(role);
        if (orgLabel.equals("??")) {
            String orgCode = registryRole.getOrganizationCode();
            if (orgCode != null && orgCode.length() > 0) {
                orgLabel = Organization.getByCode(orgCode).getDisplayLabel().getValue().trim();
            }
        }
        String roleLabel;
        if (RegistryRole.Type.isRA_Role(roleName)) {
            roleLabel = Roles.findRoleByName("cgr.RegistryAdministrator").getDisplayLabel().getValue().trim();
        } else {
            roleLabel = role.getDisplayLabel().getValue().trim();
        }
        roleLabels.add(roleLabel);
    }
    body = body.replace("${roles}", StringUtils.join(roleLabels, ", "));
    body = body.replace("${organization}", orgLabel);
    EmailSetting.sendEmail(subject, body, new String[] { address });
}
Also used : JsonArray(com.google.gson.JsonArray) RegistryRole(org.commongeoregistry.adapter.metadata.RegistryRole) RegistryRoleConverter(net.geoprism.registry.conversion.RegistryRoleConverter) Roles(com.runwaysdk.system.Roles) HashSet(java.util.HashSet)

Example 7 with RegistryRoleConverter

use of net.geoprism.registry.conversion.RegistryRoleConverter 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

Roles (com.runwaysdk.system.Roles)7 RegistryRoleConverter (net.geoprism.registry.conversion.RegistryRoleConverter)7 RegistryRole (org.commongeoregistry.adapter.metadata.RegistryRole)7 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 JsonArray (com.google.gson.JsonArray)1 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 QueryFactory (com.runwaysdk.query.QueryFactory)1 ConfigurationIF (net.geoprism.ConfigurationIF)1 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)1 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)1 Test (org.junit.Test)1