Package com.betfair.cougar.core.api.exception

Examples of com.betfair.cougar.core.api.exception.CougarServiceException


                executable.execute(ctxAdapter, key, args, ctxAdapter, executionVenue, timeConstraints);
            } catch (CougarException e) {
                ctxAdapter.onResult(new ExecutionResult(e));
            } catch (Exception e) {
                ctxAdapter.onResult(new ExecutionResult(
                        new CougarServiceException(ServerFaultCode.ServiceRuntimeException,
                                "Exception thrown by service method",
                                e)));
            }
        }
View Full Code Here


  }

  @Override
  protected CommandResolver<HttpCommand> createCommandResolver(
      HttpCommand command) {
    throw new CougarServiceException(ServerFaultCode.NoSuchService, "Service does not exist");
  }
View Full Code Here

                } catch (CougarException e) {
                    newObserver.onResult(new ExecutionResult(e));
                }
                catch (Exception e) {
                    newObserver.onResult(new ExecutionResult(
                            new CougarServiceException(ServerFaultCode.ServiceRuntimeException,
                                    "Exception thrown by service method",
                                    e)));
                }
            }
        };
View Full Code Here

                    identityResolver.resolve(chain, contextWithTokens);
                }
                catch (InvalidCredentialsException e) {
                    if (e.getCredentialFaultCode() != null) { // Check if a custom error code should be used
                        ServerFaultCode sfc = ServerFaultCode.getByCredentialFaultCode(e.getCredentialFaultCode());
                        throw new CougarServiceException(sfc, "Credentials supplied were invalid", e);
                    }
                    throw new CougarServiceException(ServerFaultCode.SecurityException, "Credentials supplied were invalid", e);
                }
                // ensure the identity chain set in the context is immutable
                contextWithTokens.setIdentityChain(new IdentityChainImpl(chain.getIdentities()));
                contextWithTokens.getIdentityTokens().clear();
                List<IdentityToken> tokens = identityResolver.tokenise(contextWithTokens.getIdentity());
View Full Code Here

    @Override
    public void execute(final ExecutionContext ctx, final OperationKey key, final Object[] args, ExecutionObserver observer, TimeConstraints timeConstraints) {
        final DefinedExecutable de = registry.get(key);
        if (de == null) {
            logger.log(Level.FINE, "Not request logging request to URI: %s as no operation was found", key.toString());
            observer.onResult(new ExecutionResult(new CougarServiceException(ServerFaultCode.NoSuchOperation, "Operation not found: "+key.toString())));
        } else {
            long serverExpiryTime = de.maxExecutionTime == 0 ? Long.MAX_VALUE : System.currentTimeMillis() + de.maxExecutionTime;
            long clientExpiryTime = timeConstraints.getExpiryTime() == null ? Long.MAX_VALUE : timeConstraints.getExpiryTime();
            long expiryTime = Math.min(clientExpiryTime, serverExpiryTime);
            if (expiryTime == Long.MAX_VALUE) {
                expiryTime = 0;
            }
            if (!(observer instanceof ExpiringObserver)) {
                final ExpiringObserver expiringObserver = new ExpiringObserver(observer, expiryTime);
                if (expiringObserver.expires()) {
                    registerExpiringObserver(expiringObserver);
                }
                observer = expiringObserver;
            }
            observer = new ExecutionObserverWrapper(observer, de.recorder, key);

            try {
                ExecutionContext contextToUse = resolveIdentitiesIfRequired(ctx);
                de.exec.execute(contextToUse, key, args, observer, this, timeConstraints);
            } catch (CougarException e) {
                observer.onResult(new ExecutionResult(e));
            } catch (Exception e) {
                observer.onResult(new ExecutionResult(
                        new CougarServiceException(ServerFaultCode.ServiceRuntimeException,
                                "Exception thrown by service method",
                                e)));
            }
        }
        if (observer instanceof ExpiringObserver) {
View Full Code Here

            return compareTo((ExpiringObserver)o);
        }

        public void expire() {
            if (onResultCalled.compareAndSet(false, true)) {
                observer.onResult(new ExecutionResult(new CougarServiceException(ServerFaultCode.Timeout, "Executable did not complete in time")));
            }
        }
View Full Code Here

                    executionResult = new ExecutionResult((CougarException)interceptorResult);
                } else if (interceptorResult instanceof CougarApplicationException) {
                    executionResult = new ExecutionResult((CougarApplicationException)interceptorResult);
                } else if (result.getResult() instanceof Exception) {
                    executionResult = new ExecutionResult(
                            new CougarServiceException(ServerFaultCode.ServiceRuntimeException,
                                    "Interceptor forced exception", (Exception)result.getResult()));
                } else {
                    // onException forced, but result is not an exception
                    executionResult = new ExecutionResult(
                            new CougarServiceException(ServerFaultCode.ServiceRuntimeException,
                                    "Interceptor forced exception, but result was not an exception - I found a " +
                                            result.getResult()));
                }
                observer.onResult(executionResult);
View Full Code Here

                executable.execute(ctxAdapter, key, args, ctxAdapter, executionVenue, timeConstraints);
            } catch (CougarException e) {
                ctxAdapter.onResult(new ExecutionResult(e));
            } catch (Exception e) {
                ctxAdapter.onResult(new ExecutionResult(
                        new CougarServiceException(ServerFaultCode.ServiceRuntimeException,
                                "Exception thrown by service method",
                                e)));
            }
        }
View Full Code Here

      executionResult = new ExecutionResult((CougarException)interceptorResult);
        } else if (interceptorResult instanceof CougarApplicationException) {
            executionResult = new ExecutionResult((CougarApplicationException)interceptorResult);
    } else if (result.getResult() instanceof Exception) {
      executionResult = new ExecutionResult(
                    new CougarServiceException(ServerFaultCode.ServiceRuntimeException,
                            "Interceptor forced exception", (Exception)result.getResult()));
    } else {
      // onException forced, but result is not an exception
            executionResult = new ExecutionResult(
                    new CougarServiceException(ServerFaultCode.ServiceRuntimeException,
                            "Interceptor forced exception, but result was not an exception - I found a " +
                                    result.getResult()));
    }
    observer.onResult(executionResult);
  }
View Full Code Here

        if (addressClassifier.isPrivateAddress(gld.getRemoteAddr()) || addressClassifier.isLocalAddress(gld.getRemoteAddr())) {
            return new InterceptorResult(InterceptorState.CONTINUE);
        }

        return new InterceptorResult(InterceptorState.FORCE_ON_EXCEPTION, new CougarServiceException(ServerFaultCode.BannedLocation, "Access not being made from private network location"));
    }
View Full Code Here

TOP

Related Classes of com.betfair.cougar.core.api.exception.CougarServiceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.