Search in sources :

Example 6 with Roles

use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.

the class ServerGeoObjectTypeConverter method create_RM_GeoObjectTypeRole.

private void create_RM_GeoObjectTypeRole(MdGeoVertexDAO mdGeoVertexDAO, String organizationCode, String geoObjectTypeCode) {
    if (organizationCode != null && !organizationCode.trim().equals("")) {
        String rmRoleName = RegistryRole.Type.getRM_RoleName(organizationCode, geoObjectTypeCode);
        Locale locale = Session.getCurrentLocale();
        String defaultDisplayLabel = mdGeoVertexDAO.getLocalValue(MdGeoVertexInfo.DISPLAY_LABEL, locale) + " Registry Maintainer";
        Roles rmOrgRole = new Roles();
        rmOrgRole.setRoleName(rmRoleName);
        rmOrgRole.getDisplayLabel().setDefaultValue(defaultDisplayLabel);
        rmOrgRole.apply();
        String orgRoleName = RegistryRole.Type.getRootOrgRoleName(organizationCode);
        Roles orgRole = Roles.findRoleByName(orgRoleName);
        RoleDAO orgRoleDAO = (RoleDAO) BusinessFacade.getEntityDAO(orgRole);
        RoleDAO rmOrgRoleDAO = (RoleDAO) BusinessFacade.getEntityDAO(rmOrgRole);
        orgRoleDAO.addInheritance(rmOrgRoleDAO);
        // Inherit the permissions from the root RM role
        RoleDAO rootRM_DAO = (RoleDAO) BusinessFacade.getEntityDAO(Roles.findRoleByName(RegistryConstants.REGISTRY_MAINTAINER_ROLE));
        rootRM_DAO.addInheritance(rmOrgRoleDAO);
    }
}
Also used : Locale(java.util.Locale) RoleDAO(com.runwaysdk.business.rbac.RoleDAO) Roles(com.runwaysdk.system.Roles)

Example 7 with Roles

use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.

the class ServerGeoObjectTypeConverter method assign_RM_GeoObjectTypeRole.

private void assign_RM_GeoObjectTypeRole(MdGeoVertexDAO mdGeoVertexDAO, MdBusiness mdBusiness, String organizationCode, String geoObjectTypeCode) {
    if (organizationCode != null && !organizationCode.trim().equals("")) {
        String rmRoleName = RegistryRole.Type.getRM_RoleName(organizationCode, geoObjectTypeCode);
        Roles rmRole = Roles.findRoleByName(rmRoleName);
        this.assignAllPermissions(mdBusiness, rmRole);
        this.assignAllPermissions(mdGeoVertexDAO, rmRole);
    }
}
Also used : Roles(com.runwaysdk.system.Roles)

Example 8 with Roles

use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.

the class ServerGeoObjectTypeConverter method assignAll_RA_Permissions.

/**
 * Assigns all permissions to the Organization's RA
 *
 * @param mdGeoVertexDAO
 * @param mdBusiness
 * @param organizationCode
 */
private void assignAll_RA_Permissions(MdGeoVertexDAO mdGeoVertexDAO, MdBusiness mdBusiness, String organizationCode) {
    if (organizationCode != null && !organizationCode.trim().equals("")) {
        Organization organization = Organization.getByKey(organizationCode);
        Roles raRole = organization.getRegistryAdminiRole();
        this.assignAllPermissions(mdBusiness, raRole);
        this.assignAllPermissions(mdGeoVertexDAO, raRole);
    }
}
Also used : Organization(net.geoprism.registry.Organization) Roles(com.runwaysdk.system.Roles)

Example 9 with Roles

use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.

the class AccountService method addRolesForOrganization.

private void addRolesForOrganization(List<RegistryRole> registryRoleList, Organization organization) {
    LocalizedValue orgDisplayLabel = LocalizedValueConverter.convert(organization.getDisplayLabel());
    // Add the RA role
    Roles adminRole = organization.getRegistryAdminiRole();
    RegistryRole adminRegistryRole = new RegistryRoleConverter().build(adminRole);
    adminRegistryRole.setOrganizationLabel(orgDisplayLabel);
    registryRoleList.add(adminRegistryRole);
    Map<String, ServerGeoObjectType> geoObjectTypeInfo = organization.getGeoObjectTypes();
    for (String typeCode : geoObjectTypeInfo.keySet()) {
        ServerGeoObjectType type = geoObjectTypeInfo.get(typeCode);
        // The cannot be assigned directly to the child type.
        if (type.getSuperType() == null) {
            // Add the RM role
            String rmRoleName = RegistryRole.Type.getRM_RoleName(organization.getCode(), typeCode);
            Roles rmRole = Roles.findRoleByName(rmRoleName);
            RegistryRole rmRegistryRole = new RegistryRoleConverter().build(rmRole);
            rmRegistryRole.setOrganizationLabel(orgDisplayLabel);
            LocalizedValue label = type.getLabel();
            rmRegistryRole.setGeoObjectTypeLabel(label);
            registryRoleList.add(rmRegistryRole);
            // Add the RC role
            String rcRoleName = RegistryRole.Type.getRC_RoleName(organization.getCode(), typeCode);
            Roles rcRole = Roles.findRoleByName(rcRoleName);
            RegistryRole rcRegistryRole = new RegistryRoleConverter().build(rcRole);
            rcRegistryRole.setOrganizationLabel(orgDisplayLabel);
            rcRegistryRole.setGeoObjectTypeLabel(label);
            registryRoleList.add(rcRegistryRole);
            // Add the AC role
            String acRoleName = RegistryRole.Type.getAC_RoleName(organization.getCode(), typeCode);
            Roles acRole = Roles.findRoleByName(acRoleName);
            RegistryRole acRegistryRole = new RegistryRoleConverter().build(acRole);
            acRegistryRole.setOrganizationLabel(orgDisplayLabel);
            acRegistryRole.setGeoObjectTypeLabel(label);
            registryRoleList.add(acRegistryRole);
        }
    }
}
Also used : RegistryRole(org.commongeoregistry.adapter.metadata.RegistryRole) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) RegistryRoleConverter(net.geoprism.registry.conversion.RegistryRoleConverter) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Roles(com.runwaysdk.system.Roles)

Example 10 with Roles

use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.

the class AccountService method getRolesForOrganization.

private List<RegistryRole> getRolesForOrganization(String... organizationCodes) {
    List<RegistryRole> registryRoleList = new LinkedList<RegistryRole>();
    List<String> orgCodesToProcess = new LinkedList<String>();
    for (String organizationCode : organizationCodes) {
        if (!organizationCode.trim().equals("")) {
            orgCodesToProcess.add(organizationCode.trim());
        }
    }
    List<Organization> organizationList;
    if (orgCodesToProcess.size() == 0) {
        // Add the SRA role
        String sraRoleName = RegistryRole.Type.getSRA_RoleName();
        Roles sraRole = Roles.findRoleByName(sraRoleName);
        registryRoleList.add(new RegistryRoleConverter().build(sraRole));
        organizationList = Organization.getOrganizationsFromCache();
    } else {
        organizationList = new LinkedList<Organization>();
        for (String organizationCode : organizationCodes) {
            organizationList.add(Organization.getByCode(organizationCode));
        }
    }
    for (Organization organization : organizationList) {
        this.addRolesForOrganization(registryRoleList, organization);
    }
    return registryRoleList;
}
Also used : RegistryRole(org.commongeoregistry.adapter.metadata.RegistryRole) Organization(net.geoprism.registry.Organization) RegistryRoleConverter(net.geoprism.registry.conversion.RegistryRoleConverter) Roles(com.runwaysdk.system.Roles) LinkedList(java.util.LinkedList)

Aggregations

Roles (com.runwaysdk.system.Roles)25 RegistryRoleConverter (net.geoprism.registry.conversion.RegistryRoleConverter)7 RegistryRole (org.commongeoregistry.adapter.metadata.RegistryRole)7 RoleDAO (com.runwaysdk.business.rbac.RoleDAO)6 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)4 Request (com.runwaysdk.session.Request)4 Locale (java.util.Locale)4 Organization (net.geoprism.registry.Organization)4 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)4 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)3 Actor (com.runwaysdk.system.Actor)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 LinkedList (java.util.LinkedList)3 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)3 MdVertexDAO (com.runwaysdk.dataaccess.metadata.graph.MdVertexDAO)2 LocalizedValueStore (com.runwaysdk.localization.LocalizedValueStore)2 GeoprismUser (net.geoprism.GeoprismUser)2 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)2 JsonArray (com.google.gson.JsonArray)1