use of net.geoprism.registry.permission.RolePermissionService in project geoprism-registry by terraframe.
the class CurationService method getListCurationInfo.
public JsonObject getListCurationInfo(ListTypeVersion version) {
final ListType listType = version.getListType();
final ServerGeoObjectType serverGOT = listType.getGeoObjectType();
final String orgCode = listType.getOrganization().getCode();
this.checkPermissions(orgCode, serverGOT);
JsonObject json = new JsonObject();
ListCurationHistory history = ListCurationJob.getMostRecent(version.getOid());
boolean isRunning = false;
if (history != null) {
if (history.getStatus().contains(AllJobStatus.RUNNING)) {
isRunning = true;
}
json.addProperty("lastRun", GeoRegistryUtil.formatDate(history.getCreateDate(), false));
json.addProperty("curationId", history.getOid());
}
final RolePermissionService perms = ServiceFactory.getRolePermissionService();
boolean hasRunPermission = perms.isSRA() || perms.isRA(orgCode) || perms.isRM(orgCode, serverGOT);
json.addProperty("canRun", !isRunning && hasRunPermission);
return json;
}
use of net.geoprism.registry.permission.RolePermissionService in project geoprism-registry by terraframe.
the class ServerGeoObjectService method updateGeoObjectInTrans.
@Transaction
public JsonObject updateGeoObjectInTrans(String geoObjectCode, String geoObjectTypeCode, String actions, String masterListId, String notes) {
final RolePermissionService perms = ServiceFactory.getRolePermissionService();
final ServerGeoObjectType type = ServerGeoObjectType.get(geoObjectTypeCode);
final String orgCode = type.getOrganization().getCode();
final VertexServerGeoObject go = (VertexServerGeoObject) new ServerGeoObjectService().getGeoObjectByCode(geoObjectCode, geoObjectTypeCode);
final JsonArray jaActions = JsonParser.parseString(actions).getAsJsonArray();
if (perms.isSRA() || perms.isRA(orgCode) || perms.isRM(orgCode, type)) {
this.executeActions(type, go, jaActions);
if (masterListId != null) {
ListTypeVersion.get(masterListId).updateRecord(go);
}
JsonObject resp = new JsonObject();
resp.addProperty("isChangeRequest", false);
resp.add("geoObject", go.toGeoObjectOverTime().toJSON(ServiceFactory.getRegistryService().serializer(Session.getCurrentSession().getOid())));
return resp;
} else if (ServiceFactory.getRolePermissionService().isRC(orgCode, type)) {
ChangeRequest request = createChangeRequest(geoObjectCode, geoObjectTypeCode, notes, orgCode, jaActions);
JsonObject resp = new JsonObject();
resp.addProperty("isChangeRequest", true);
resp.addProperty("changeRequestId", request.getOid());
return resp;
} else {
throw new CGRPermissionException();
}
}
use of net.geoprism.registry.permission.RolePermissionService in project geoprism-registry by terraframe.
the class SearchService method search.
public List<ServerGeoObjectIF> search(String text, Date date, Long limit) {
String suffix = this.getSuffix();
RolePermissionService service = new RolePermissionService();
MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(PACKAGE + "." + VERTEX_PREFIX + suffix);
MdAttributeDAOIF code = mdVertex.definesAttribute(CODE);
MdAttributeDAOIF startDate = mdVertex.definesAttribute(START_DATE);
MdAttributeDAOIF endDate = mdVertex.definesAttribute(END_DATE);
MdAttributeDAOIF label = mdVertex.definesAttribute(LABEL);
MdAttributeDAOIF vertexType = mdVertex.definesAttribute(VERTEX_TYPE);
MdEdgeDAOIF mdEdge = MdEdgeDAO.getMdEdgeDAO(PACKAGE + "." + EDGE_PREFIX + suffix);
String attributeName = label.getValue(MdAttributeTextInfo.NAME);
String className = mdVertex.getDBClassName();
String indexName = className + "." + attributeName;
StringBuilder statement = new StringBuilder();
statement.append("SELECT EXPAND(out('" + mdEdge.getDBClassName() + "'))");
statement.append(" FROM " + mdVertex.getDBClassName());
if (text != null) {
String regex = "([+\\-!\\(\\){}\\[\\]^\"~*?:\\\\]|[&\\|]{2})";
String escapedText = text.replaceAll(regex, "\\\\\\\\$1").trim();
statement.append(" WHERE (SEARCH_INDEX(\"" + indexName + "\", \"+" + label.getColumnName() + ":" + escapedText + "*\") = true");
statement.append(" OR :code = " + code.getColumnName() + ")");
} else {
statement.append(" WHERE " + code.getColumnName() + " IS NOT NULL");
}
if (date != null) {
statement.append(" AND :date BETWEEN " + startDate.getColumnName() + " AND " + endDate.getColumnName());
}
if (!service.isSRA() && service.hasSessionUser()) {
statement.append(" AND " + vertexType.getColumnName() + " IN ( :vertexTypes )");
}
statement.append(" ORDER BY " + label.getColumnName() + " DESC");
if (limit != null) {
statement.append(" LIMIT " + limit);
}
List<ServerGeoObjectIF> list = new LinkedList<ServerGeoObjectIF>();
GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
if (text != null) {
query.setParameter("code", text);
}
if (date != null) {
query.setParameter("date", date);
}
if (!service.isSRA() && service.hasSessionUser()) {
List<String> vertexTypes = new GeoObjectPermissionService().getMandateTypes(service.getOrganization());
query.setParameter("vertexTypes", vertexTypes);
}
List<VertexObject> results = query.getResults();
for (VertexObject result : results) {
MdVertexDAOIF mdVertexType = (MdVertexDAOIF) result.getMdClass();
ServerGeoObjectType type = ServerGeoObjectType.get(mdVertexType);
list.add(new VertexServerGeoObject(type, result, date));
}
return list;
}
use of net.geoprism.registry.permission.RolePermissionService in project geoprism-registry by terraframe.
the class ServiceFactory method initialize.
private void initialize() {
this.registryService = new RegistryService();
this.cs = new ConversionService();
this.idService = new RegistryIdService();
this.adapter = new RegistryAdapterServer(this.idService);
this.accountService = new AccountService();
this.goPermissionServ = new GeoObjectPermissionService();
this.serverGoService = new ServerGeoObjectService(goPermissionServ);
this.hierarchyService = new HierarchyService();
this.orgServ = new OrganizationPermissionService();
this.hierarchyPermServ = new HierarchyTypePermissionService();
this.goRelPermissionServ = new GeoObjectRelationshipPermissionService();
this.goTypeRelPermissionServ = new GeoObjectTypeRelationshipPermissionService();
this.goTypePermissionServ = new GeoObjectTypePermissionService();
this.rolePermissionServ = new RolePermissionService();
this.metadataCache = new ServerMetadataCache(this.adapter);
this.metadataCache.rebuild();
this.registryService.initialize(this.adapter);
}
use of net.geoprism.registry.permission.RolePermissionService in project geoprism-registry by terraframe.
the class TransitionPermissionService method getPermissions.
public Set<CGRPermissionAction> getPermissions(TransitionEvent event) {
final RolePermissionService perms = ServiceFactory.getRolePermissionService();
final String beforeOrgCode = event.getBeforeTypeOrgCode();
final String beforeGotCode = event.getBeforeTypeCode();
final String afterOrgCode = event.getAfterTypeOrgCode();
final String afterGotCode = event.getAfterTypeCode();
HashSet<CGRPermissionAction> actions = new HashSet<CGRPermissionAction>();
if (beforeOrgCode == null || beforeGotCode == null) {
return actions;
}
ServerGeoObjectType beforeType = ServerGeoObjectType.get(beforeGotCode, true);
ServerGeoObjectType afterType = ServerGeoObjectType.get(afterGotCode, true);
if (perms.isSRA()) {
actions.addAll(Arrays.asList(CGRPermissionAction.values()));
} else if (perms.isRA(beforeOrgCode)) {
actions.addAll(Arrays.asList(CGRPermissionAction.values()));
} else if (perms.isRM(beforeOrgCode, beforeType)) {
actions.addAll(Arrays.asList(CGRPermissionAction.values()));
} else if ((!beforeType.getIsPrivate() && !afterType.getIsPrivate()) || perms.isRA(afterOrgCode) || perms.isRM(afterOrgCode, afterType)) {
actions.add(CGRPermissionAction.READ);
}
return actions;
}
Aggregations