static boolean hasFederatedOperations(final OperationChain<?> operationChain) { for (final Operation operation : operationChain.getOperations()) { if (operation instanceof FederatedOperation) { return true; } } return false; } }
/** * Injects the input of the NamedOperation into the first operation in the OperationChain. This is used when * chaining NamedOperations together. * * @param opChain the resolved operation chain * @param input the input of the NamedOperation */ private void updateOperationInput(final OperationChain<?> opChain, final Object input) { final Operation firstOp = opChain.getOperations().get(0); if (null != input && (firstOp instanceof Input) && null == ((Input) firstOp).getInput()) { ((Input) firstOp).setInput(input); } } }
/** * Checks the {@link Operation}s in the provided {@link OperationChain} * are allowed to be executed by the user. * This is done by checking the user's auths against the operation auths. * If an operation cannot be executed then an {@link IllegalAccessError} is thrown. * * @param context the user to authorise. * @param opChain the operation chain. */ @Override public void preExecute(final OperationChain<?> opChain, final Context context) { if (null != opChain) { for (final Operation operation : opChain.getOperations()) { authorise(operation, context.getUser()); } authorise(opChain, context.getUser()); } }
private List<Operation> resolveNamedOperation(final NamedOperation namedOp, final User user) { final NamedOperationDetail namedOpDetail; try { namedOpDetail = cache.getNamedOperation(namedOp.getOperationName(), user); } catch (final CacheOperationFailedException e) { // Unable to find named operation - just return the original named operation return Collections.singletonList(namedOp); } final OperationChain<?> namedOperationChain = namedOpDetail.getOperationChain(namedOp.getParameters()); updateOperationInput(namedOperationChain, namedOp.getInput()); // Call resolveNamedOperations again to check there are no nested named operations resolveNamedOperations(namedOperationChain, user); return namedOperationChain.getOperations(); }