use of net.geoprism.registry.model.ServerGeoObjectType 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 net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.
the class Organization method getGeoObjectTypes.
/**
* Return a map of {@link GeoObjectType} codes and labels for this
* {@link Organization}.
*
* @return a map of {@link GeoObjectType} codes and labels for this
* {@link Organization}.
*/
public Map<String, ServerGeoObjectType> getGeoObjectTypes() {
// For performance, get all of the universals defined
List<? extends EntityDAOIF> universalList = ObjectCache.getCachedEntityDAOs(Universal.CLASS);
Map<String, ServerGeoObjectType> typeCodeMap = new HashMap<String, ServerGeoObjectType>();
for (EntityDAOIF entityDAOIF : universalList) {
Universal universal = (Universal) BusinessFacade.get(entityDAOIF);
// Check to see if the universal is owned by the organization role.
String ownerId = universal.getOwnerOid();
Roles organizationRole = this.getRole();
if (ownerId.equals(organizationRole.getOid())) {
ServerGeoObjectType type = ServerGeoObjectType.get(universal);
typeCodeMap.put(type.getCode(), type);
}
}
return typeCodeMap;
}
use of net.geoprism.registry.model.ServerGeoObjectType 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 net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.
the class CreateGeoObjectAction method apply.
@Override
public void apply() {
String sJson = this.getGeoObjectJson();
GeoObjectOverTime geoObject = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), sJson);
ServerGeoObjectType type = ServerGeoObjectType.get(geoObject.getType());
geoObjectPermissionService.enforceCanCreateCR(type.getOrganization().getCode(), type);
super.apply();
}
use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.
the class SetParentAction method apply.
@Override
public void apply() {
// Important to remember that the child may or may not exist at this point (so we can't fetch it from the DB here)
ServerGeoObjectType type = ServiceFactory.getMetadataCache().getGeoObjectType(this.getChildTypeCode()).get();
ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(type, this.getJson());
ptnOt.enforceUserHasPermissionSetParents(this.getChildTypeCode(), true);
super.apply();
}
Aggregations