use of com.runwaysdk.session.SessionIF in project geoprism-registry by terraframe.
the class Organization method isRegistryMaintainer.
/**
* @param org
* @return If the current user is part of the registry admin role for the
* given organization
*/
public static boolean isRegistryMaintainer(Organization org) {
if (new RolePermissionService().isSRA()) {
return true;
}
final SessionIF session = Session.getCurrentSession();
if (session != null) {
Map<String, ServerGeoObjectType> types = org.getGeoObjectTypes();
Set<Entry<String, ServerGeoObjectType>> entries = types.entrySet();
for (Entry<String, ServerGeoObjectType> entry : entries) {
String roleName = RegistryRole.Type.getRM_RoleName(org.getCode(), entry.getKey());
boolean hasRole = session.userHasRole(roleName);
if (hasRole) {
return true;
}
}
return false;
}
return true;
}
use of com.runwaysdk.session.SessionIF in project geoprism-registry by terraframe.
the class SynchronizationConfig method apply.
@Override
@Transaction
public void apply() {
SessionIF session = Session.getCurrentSession();
Organization organization = this.getOrganization();
if (session != null && organization != null) {
ServiceFactory.getRolePermissionService().enforceRA(organization.getCode());
}
super.apply();
if (this.isNew()) {
DataExportJob job = new DataExportJob();
job.setConfig(this);
job.apply();
}
}
use of com.runwaysdk.session.SessionIF in project geoprism-registry by terraframe.
the class ChangeRequestPermissionService method getPermissions.
public Set<ChangeRequestPermissionAction> getPermissions(ChangeRequest cr) {
final RolePermissionService perms = ServiceFactory.getRolePermissionService();
final String orgCode = cr.getOrganizationCode();
final String gotCode = cr.getGeoObjectTypeCode();
ServerGeoObjectType type = null;
if (gotCode != null) {
type = ServerGeoObjectType.get(gotCode, true);
}
HashSet<ChangeRequestPermissionAction> actions = new HashSet<ChangeRequestPermissionAction>();
final AllGovernanceStatus status = cr.getGovernanceStatus();
if (perms.isSRA()) {
actions.addAll(Arrays.asList(ChangeRequestPermissionAction.values()));
actions.remove(ChangeRequestPermissionAction.DELETE);
actions.remove(ChangeRequestPermissionAction.WRITE_CONTRIBUTOR_NOTES);
actions.remove(ChangeRequestPermissionAction.WRITE_DETAILS);
if (status.equals(AllGovernanceStatus.ACCEPTED)) {
actions.remove(ChangeRequestPermissionAction.EXECUTE);
actions.remove(ChangeRequestPermissionAction.WRITE_MAINTAINER_NOTES);
}
} else if (perms.isRA(orgCode)) {
actions.addAll(Arrays.asList(ChangeRequestPermissionAction.values()));
actions.remove(ChangeRequestPermissionAction.DELETE);
actions.remove(ChangeRequestPermissionAction.WRITE_CONTRIBUTOR_NOTES);
actions.remove(ChangeRequestPermissionAction.WRITE_DETAILS);
if (status.equals(AllGovernanceStatus.ACCEPTED)) {
actions.remove(ChangeRequestPermissionAction.EXECUTE);
actions.remove(ChangeRequestPermissionAction.WRITE_MAINTAINER_NOTES);
}
} else if (perms.isRM(orgCode, type)) {
actions.addAll(Arrays.asList(ChangeRequestPermissionAction.values()));
actions.remove(ChangeRequestPermissionAction.DELETE);
actions.remove(ChangeRequestPermissionAction.WRITE_CONTRIBUTOR_NOTES);
actions.remove(ChangeRequestPermissionAction.WRITE_DETAILS);
if (status.equals(AllGovernanceStatus.ACCEPTED)) {
actions.remove(ChangeRequestPermissionAction.EXECUTE);
actions.remove(ChangeRequestPermissionAction.WRITE_MAINTAINER_NOTES);
}
} else if (perms.isRC(orgCode, type) || perms.isAC(orgCode, type)) {
actions.addAll(Arrays.asList(ChangeRequestPermissionAction.READ, ChangeRequestPermissionAction.WRITE, ChangeRequestPermissionAction.READ_APPROVAL_STATUS, ChangeRequestPermissionAction.READ_DETAILS, ChangeRequestPermissionAction.WRITE_DETAILS, ChangeRequestPermissionAction.READ_DOCUMENTS, ChangeRequestPermissionAction.WRITE_DOCUMENTS, ChangeRequestPermissionAction.READ_MAINTAINER_NOTES, ChangeRequestPermissionAction.READ_CONTRIBUTOR_NOTES, ChangeRequestPermissionAction.WRITE_CONTRIBUTOR_NOTES, ChangeRequestPermissionAction.SUBMIT, ChangeRequestPermissionAction.DELETE));
SessionIF session = Session.getCurrentSession();
if (session == null || session.getUser() == null || cr.getCreatedBy() == null || !cr.getCreatedBy().getOid().equals(session.getUser().getOid())) {
actions.remove(ChangeRequestPermissionAction.DELETE);
}
if (status.equals(AllGovernanceStatus.ACCEPTED) || status.equals(AllGovernanceStatus.REJECTED) || status.equals(AllGovernanceStatus.INVALID) || status.equals(AllGovernanceStatus.PARTIAL)) {
actions.remove(ChangeRequestPermissionAction.WRITE_CONTRIBUTOR_NOTES);
actions.remove(ChangeRequestPermissionAction.WRITE_DETAILS);
actions.remove(ChangeRequestPermissionAction.DELETE);
}
}
if (orgCode == null || gotCode == null) {
actions.removeAll(Arrays.asList(ChangeRequestPermissionAction.EXECUTE, ChangeRequestPermissionAction.WRITE_APPROVAL_STATUS, ChangeRequestPermissionAction.WRITE_DETAILS));
if (gotCode == null) {
actions.remove(ChangeRequestPermissionAction.READ_DETAILS);
}
if (perms.isSRA() || perms.isRA() || perms.isRM()) {
actions.add(ChangeRequestPermissionAction.DELETE);
}
}
return actions;
}
use of com.runwaysdk.session.SessionIF in project geoprism-registry by terraframe.
the class Organization method isRegistryAdmin.
/**
* @param org
* @return If the current user is part of the registry admin role for the
* given organization
*/
public static boolean isRegistryAdmin(Organization org) {
if (new RolePermissionService().isSRA()) {
return true;
}
String roleName = RegistryRole.Type.getRA_RoleName((org.getCode()));
final SessionIF session = Session.getCurrentSession();
if (session != null) {
return session.userHasRole(roleName);
}
return true;
}
use of com.runwaysdk.session.SessionIF in project geoprism-registry by terraframe.
the class ExternalSystem method apply.
@Override
@Transaction
public void apply() {
Organization organization = this.getOrganization();
if (organization != null) {
SessionIF session = Session.getCurrentSession();
if (session != null) {
ServiceFactory.getRolePermissionService().enforceRA(organization.getCode());
}
}
super.apply();
}
Aggregations