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 });
}
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());
}
Aggregations