@Override public void onSuccess(final VdcOperation<?, ?> operation, final Object result) { // Do nothing more than call original callback. VdcOperation<?, ?> originalOperation = getOriginalOperation(operation); originalOperation.getCallback().onSuccess(originalOperation, result); removePending(operation); // Finished, check for more operations. processOperation(manager); }
@Override public void onFailure(Throwable exception) { operation.getCallback().onFailure(operation, exception); } });
@Override public void onSuccess(XsrfToken token) { xsrfRequestBuilder.setXsrfToken(token); callback.serviceFound(service); }
@Override public void onFailure(final VdcOperation<?, ?> operation, final Throwable exception) { // Remove pending, so it won't accidentally stop the re-add if possible. removePending(operation); // If the failure is recoverable, then add the request back into the queue. if (!operation.allowDuplicates() && operation.getCopyCount() < RETRY_THRESHOLD) { manager.addOperation(operation); } else { VdcOperation<?, ?> originalOperation = getOriginalOperation(operation); originalOperation.getCallback().onFailure(originalOperation, exception); } // Finished, check for more operations. processOperation(manager); } };
@Override public void onSuccess(final List<VdcOperation<?, ?>> operationList, final Object result) { if (!operationList.isEmpty()) { // All the call-backs in the list are the same, just have to call one. VdcOperation<?, ?> originalOperation = getOriginalOperation(operationList.get(0)); VdcOperationCallback<List<VdcOperation<?, ?>>, Object> originalCallback = originalOperation.getCallback(); originalCallback.onSuccess(operationList, result); removePending(operationList); // Finished, check for more operations. processOperation(manager); } }
/** * Add operation to the queue. Fire event when operation is successfully added if fireEvent is true. * If the operation determined by equals is already in the queue, do not add it again. * @param operation The {@code VdcOperation} to add. */ private void addOperationImpl(final VdcOperation<?, ?> operation) { // If the operation is not already in the queue || the operation is an action (allows duplicates). // Then add this operation to the queue, and process the queue immediately. final boolean operationCanBeAdded = !operationQueue.contains(operation) || operation.allowDuplicates(); if (operationCanBeAdded && operationQueue.add(operation)) { processor.processOperation(this); if (engineSessionRefreshed(operation)) { EngineSessionRefreshedEvent.fire(eventBus); } } }
/** * Copy constructor that allows for a different callback. * @param sourceOperation The source {@code VdcOperation} object. * @param callback The new callback method. */ public VdcOperation(final VdcOperation<T, P> sourceOperation, final VdcOperationCallback<?, ?> callback) { this(sourceOperation.getOperation(), sourceOperation.getParameter(), callback, sourceOperation, sourceOperation.isPublic(), sourceOperation.isFromList, sourceOperation.isRunOnlyIfAllValidationPass()); }
/** * Log out the user. * @param callback The callback to call when the operation is completed. */ public void logoutUser(final UserCallback<?> callback) { communicationProvider.logout(callback); } }
/** * Returns the number of times this operation has been copied using the copy constructor. * If this is the original returns 1. * @return The copy count. */ public int getCopyCount() { int result = 1; if (source != null) { result += source.getCopyCount(); } return result; }
@Override public void onFailure(Throwable caught) { callback.onFailure(caught); } });
/** * Log out the user. * @param callback The callback to call when the operation is completed. */ public void logoutUser(final UserCallback<?> callback) { processor.logoutUser(callback); }
/** * Check if duplicates of this are allowed. If the operation wraps an action * duplicates are allowed. * @return True if duplicates are allowed, false otherwise. */ public boolean allowDuplicates() { return isAction(); }
/** * Add operation to the queue. * @param operation The {@code VdcOperation} to add. */ public void addOperation(final VdcOperation<?, ?> operation) { addOperationImpl(operation); }
/** * Traverse the source operation tree to find the original one. * @param operation The operation to use to traverse. * @return The original operation. */ private VdcOperation<?, ?> getOriginalOperation(final VdcOperation<?, ?> operation) { // Get the original operation. VdcOperation<?, ?> originalOperation = operation; while (originalOperation.getSource() != null) { originalOperation = originalOperation.getSource(); } return originalOperation; }
@Override protected void dispatch(AsyncOperationCompleteHandler handler) { handler.onAsyncOperationComplete(this); }
@Override protected void dispatch(RefreshActiveModelHandler handler) { handler.onRefreshActiveModel(this); }
@Override protected void dispatch(AsyncOperationStartedHandler handler) { handler.onAsyncOperationStarted(this); }
private void fireAsyncQueryFailedEvent(Object target) { AsyncOperationCompleteEvent.fire(this, target, false, false); }
@Override public void onFailure(Throwable exception) { operation.getCallback().onFailure(operation, exception); } });
@Override public void onFailure(Throwable exception) { operation.getCallback().onFailure(operation, exception); } });