use of org.structr.core.entity.AbstractNode in project structr by structr.
the class SecurityContext method removeForbiddenNodes.
public void removeForbiddenNodes(List<? extends GraphObject> nodes, final boolean includeDeletedAndHidden, final boolean publicOnly) {
boolean readableByUser = false;
for (Iterator<? extends GraphObject> it = nodes.iterator(); it.hasNext(); ) {
GraphObject obj = it.next();
if (obj instanceof AbstractNode) {
AbstractNode n = (AbstractNode) obj;
readableByUser = n.isGranted(Permission.read, this);
if (!(readableByUser && (includeDeletedAndHidden || !n.isDeleted()) && (n.isVisibleToPublicUsers() || !publicOnly))) {
it.remove();
}
}
}
}
use of org.structr.core.entity.AbstractNode in project structr by structr.
the class EntityNotionProperty method getSearchAttribute.
@Override
public SearchAttribute getSearchAttribute(SecurityContext securityContext, Occurrence occur, T searchValue, boolean exactMatch, final Query query) {
final Predicate<GraphObject> predicate = query != null ? query.toPredicate() : null;
final SourceSearchAttribute attr = new SourceSearchAttribute(occur);
final Set<GraphObject> intersectionResult = new LinkedHashSet<>();
boolean alreadyAdded = false;
try {
if (searchValue != null && !StringUtils.isBlank(searchValue.toString())) {
final App app = StructrApp.getInstance(securityContext);
final PropertyKey key = notion.getPrimaryPropertyKey();
final PropertyConverter inputConverter = key != null ? key.inputConverter(securityContext) : null;
// transform search values using input convert of notion property
final Object transformedValue = inputConverter != null ? inputConverter.convert(searchValue) : searchValue;
if (exactMatch) {
Result<AbstractNode> result = app.nodeQuery(entityProperty.relatedType()).and(key, transformedValue).getResult();
for (AbstractNode node : result.getResults()) {
switch(occur) {
case REQUIRED:
if (!alreadyAdded) {
// the first result is the basis of all subsequent intersections
intersectionResult.addAll(entityProperty.getRelatedNodesReverse(securityContext, node, declaringClass, predicate));
// the next additions are intersected with this one
alreadyAdded = true;
} else {
intersectionResult.retainAll(entityProperty.getRelatedNodesReverse(securityContext, node, declaringClass, predicate));
}
break;
case OPTIONAL:
intersectionResult.addAll(entityProperty.getRelatedNodesReverse(securityContext, node, declaringClass, predicate));
break;
case FORBIDDEN:
break;
}
}
} else {
Result<AbstractNode> result = app.nodeQuery(entityProperty.relatedType()).and(key, transformedValue, false).getResult();
// loose search behaves differently, all results must be combined
for (AbstractNode node : result.getResults()) {
intersectionResult.addAll(entityProperty.getRelatedNodesReverse(securityContext, node, declaringClass, predicate));
}
}
attr.setResult(intersectionResult);
} else {
// value in the given field
return new EmptySearchAttribute(this, null);
}
} catch (FrameworkException fex) {
logger.warn("", fex);
}
return attr;
}
use of org.structr.core.entity.AbstractNode in project structr by structr.
the class CypherQueryProperty method getProperty.
@Override
public List<GraphObject> getProperty(SecurityContext securityContext, GraphObject obj, boolean applyConverter, Predicate<GraphObject> predicate) {
if (obj instanceof AbstractNode) {
try {
final String query = Scripting.replaceVariables(new ActionContext(securityContext), obj, this.format);
final Map<String, Object> parameters = new LinkedHashMap<>();
parameters.put("id", obj.getUuid());
parameters.put("type", obj.getType());
return StructrApp.getInstance(securityContext).command(CypherQueryCommand.class).execute(query, parameters);
} catch (Throwable t) {
logger.warn("", t);
}
}
return null;
}
use of org.structr.core.entity.AbstractNode in project structr by structr.
the class CMISAclService method getAcl.
@Override
public Acl getAcl(final String repositoryId, final String objectId, final Boolean onlyBasicPermissions, final ExtensionsData extension) {
final App app = StructrApp.getInstance(securityContext);
try (final Tx tx = app.tx()) {
final AbstractNode node = app.get(AbstractNode.class, objectId);
if (node != null) {
return CMISObjectWrapper.wrap(node, null, false);
}
tx.success();
} catch (FrameworkException fex) {
logger.warn("", fex);
}
throw new CmisObjectNotFoundException("Object with ID " + objectId + " does not exist");
}
use of org.structr.core.entity.AbstractNode in project structr by structr.
the class CMISObjectService method getObject.
@Override
public ObjectData getObject(final String repositoryId, final String objectId, final String propertyFilter, final Boolean includeAllowableActions, final IncludeRelationships includeRelationships, final String renditionFilter, final Boolean includePolicyIds, final Boolean includeAcl, final ExtensionsData extension) {
final App app = StructrApp.getInstance();
try (final Tx tx = app.tx()) {
final AbstractNode obj = app.get(AbstractNode.class, objectId);
if (obj != null) {
final ObjectData data = CMISObjectWrapper.wrap(obj, propertyFilter, includeAllowableActions);
tx.success();
return data;
}
} catch (Throwable t) {
logger.warn("", t);
}
throw new CmisObjectNotFoundException("Object with ID " + objectId + " does not exist");
}
Aggregations