Search in sources :

Example 1 with GeoObjectPermissionServiceIF

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;
}
Also used : GeoObjectRelationshipPermissionServiceIF(net.geoprism.registry.permission.GeoObjectRelationshipPermissionServiceIF) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) GeoObjectPermissionServiceIF(net.geoprism.registry.permission.GeoObjectPermissionServiceIF) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) ChildTreeNode(org.commongeoregistry.adapter.dataaccess.ChildTreeNode)

Example 2 with GeoObjectPermissionServiceIF

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;
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) GeoObjectPermissionServiceIF(net.geoprism.registry.permission.GeoObjectPermissionServiceIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Aggregations

GeoObjectPermissionServiceIF (net.geoprism.registry.permission.GeoObjectPermissionServiceIF)2 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)2 Request (com.runwaysdk.session.Request)1 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)1 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)1 GeoObjectRelationshipPermissionServiceIF (net.geoprism.registry.permission.GeoObjectRelationshipPermissionServiceIF)1 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)1 ChildTreeNode (org.commongeoregistry.adapter.dataaccess.ChildTreeNode)1 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)1