use of net.geoprism.registry.permission.GeoObjectPermissionServiceIF in project geoprism-registry by terraframe.
the class ServerChildTreeNode method toNode.
public ChildTreeNode toNode(boolean enforcePermissions) {
final GeoObjectRelationshipPermissionServiceIF relPermServ = ServiceFactory.getGeoObjectRelationshipPermissionService();
final GeoObjectPermissionServiceIF goPermServ = ServiceFactory.getGeoObjectPermissionService();
GeoObject go = this.getGeoObject().toGeoObject(this.getStartDate());
HierarchyType ht = this.getHierarchyType() != null ? this.getHierarchyType().toHierarchyType() : null;
ChildTreeNode node = new ChildTreeNode(go, ht);
String orgCode = go.getType().getOrganizationCode();
ServerGeoObjectType type = ServerGeoObjectType.get(go.getType());
for (ServerChildTreeNode child : this.children) {
if (!enforcePermissions || (relPermServ.canViewChild(orgCode, type, child.getGeoObject().getType()) && goPermServ.canRead(orgCode, type))) {
node.addChild(child.toNode(enforcePermissions));
}
}
return node;
}
use of net.geoprism.registry.permission.GeoObjectPermissionServiceIF in project geoprism-registry by terraframe.
the class RegistryService method getGeoObject.
@Request(RequestType.SESSION)
public GeoObject getGeoObject(String sessionId, String uid, String geoObjectTypeCode, Date date) {
ServerGeoObjectIF object = this.service.getGeoObject(uid, geoObjectTypeCode);
if (object == null) {
net.geoprism.registry.DataNotFoundException ex = new net.geoprism.registry.DataNotFoundException();
ex.setTypeLabel(GeoObjectMetadata.get().getClassDisplayLabel());
ex.setDataIdentifier(uid);
ex.setAttributeLabel(GeoObjectMetadata.get().getAttributeDisplayLabel(DefaultAttribute.UID.getName()));
throw ex;
}
final GeoObjectPermissionServiceIF pService = ServiceFactory.getGeoObjectPermissionService();
pService.enforceCanRead(object.getType().getOrganization().getCode(), object.getType());
ServerGeoObjectType type = object.getType();
GeoObject geoObject = object.toGeoObject(date);
geoObject.setWritable(pService.canCreateCR(type.getOrganization().getCode(), type));
return geoObject;
}
Aggregations