use of ddf.security.permission.Permissions in project ddf by codice.
the class ResourceUriPolicy method processPreUpdate.
@Override
public PolicyResponse processPreUpdate(Metacard input, Map<String, Serializable> properties) throws StopProcessingException {
if (!Requests.isLocal(properties)) {
return new PolicyResponseImpl();
}
PolicyResponseImpl policyResponse = new PolicyResponseImpl(null, Permissions.parsePermissionsFromString(getUpdatePermissions()));
List<Metacard> previousStateMetacards = ((OperationTransaction) properties.get(OPERATION_TRANSACTION_KEY)).getPreviousStateMetacards();
Metacard previous;
try {
previous = previousStateMetacards.stream().filter((x) -> x.getId().equals(input.getId())).findFirst().get();
} catch (NoSuchElementException e) {
LOGGER.debug("Cannot locate metacard {} for update. Applying permissions to the item", input.getId());
return policyResponse;
}
return requiresPermission(input.getResourceURI(), previous.getResourceURI()) ? policyResponse : new PolicyResponseImpl();
}
Aggregations