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

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


                    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 CougarFrameworkException(sfc, "Credentials supplied were invalid", e);
                    }
                    throw new CougarFrameworkException(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 CougarFrameworkException(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 CougarFrameworkException(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 CougarFrameworkException(ServerFaultCode.Timeout, "Executable did not complete in time")));
            }
        }
View Full Code Here

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

        private void validateConnectedObjectLogExtension(ExecutionResult executionResult) {
            // need to validate the connected object extension, even though the logging's not done here but in the transport. a bit yucky
            if (connectedObjectLogExtension == null) {
                if (manager.getConnectedObjectLogExtensionClass() != null) {
                    if (executionResult.getResult() instanceof ConnectedResponse) {
                        throw new CougarFrameworkException("Connected object log extension expected but not found for " + key);
                    }
                }
            }
            else {
                if (manager.getNumConnectedObjectLogExtensionFields() != connectedObjectLogExtension.getFieldsToLog().length) {
                    throw new CougarFrameworkException("Connected object log extension class defined "+
                            connectedObjectLogExtension.getFieldsToLog().length+" fields. Expected" + manager.getNumConnectedObjectLogExtensionFields());
                }
            }
        }
View Full Code Here

          if (executionResult.isFault()) {
                        // As it was a fault, the service cannot have guaranteed to add the extension
                        // record, so we dummy one up with the correct number of fields
            fieldsToLog = new Object[manager.getNumLogExtensionFields()];
          } else {
            throw new CougarFrameworkException("Log extension expected but not found for " + key);
          }
        }
      } else {
        if (manager.getNumLogExtensionFields() != logExtension.getFieldsToLog().length) {
          throw new CougarFrameworkException("Log extension class defined "+
              logExtension.getFieldsToLog().length+" fields. Expected" + manager.getNumLogExtensionFields());
        }
        fieldsToLog = logExtension.getFieldsToLog();
      }
      RequestLogEvent operationEvent = new RequestLogEvent(
View Full Code Here

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

            if (gzipEnabled) {
                try {
                    context.setHandler(new GzipHandler(gzipBufferSize,gzipMinSize,gzipExcludedAgents, jettyServiceHandler));
                }
                catch (ServletException e) {
                    throw new CougarFrameworkException("Failed to create GZIP handler: [" + jettyContextRoot + "]", e);
                }
            }
            else {
                context.setHandler(jettyServiceHandler);
            }
            handlerCollection.addHandler(context);
            try {
                //If the server is already running, start this context up!
                //If it isn't running, then it will be started when Jetty starts
                if (server.isRunning()) {
                    context.start();
                }
            } catch (Exception ex) {
                throw new CougarFrameworkException("Failed to register serviceBindingDescriptor: [" + jettyContextRoot + "]", ex);
            }
        }
    }
View Full Code Here

                public List<IdentityToken> resolve(CougarObjectInput input, X509Certificate[] certificateChain) {
                    List<IdentityToken> tokens = new ArrayList<IdentityToken>();
                    try {
                        attachCertInfo(tokens, certificateChain);
                    } catch (NamingException e) {
                        throw new CougarFrameworkException("Unable to resolve cert info", e);
                    }
                    try {
                        int size = input.readInt();
                        for (int i = 0; i < size; i++) {
                            tokens.add(new IdentityToken(input.readString(), input.readString()));
View Full Code Here

        private void validateConnectedObjectLogExtension(ExecutionResult executionResult) {
            // need to validate the connected object extension, even though the logging's not done here but in the transport. a bit yucky
            if (connectedObjectLogExtension == null) {
                if (manager.getConnectedObjectLogExtensionClass() != null) {
                    if (executionResult.getResult() instanceof ConnectedResponse) {
                        throw new CougarFrameworkException("Connected object log extension expected but not found for " + key);
                    }
                }
            }
            else {
                if (manager.getNumConnectedObjectLogExtensionFields() != connectedObjectLogExtension.getFieldsToLog().length) {
                    throw new CougarFrameworkException("Connected object log extension class defined "+
                            connectedObjectLogExtension.getFieldsToLog().length+" fields. Expected" + manager.getNumConnectedObjectLogExtensionFields());
                }
            }
        }
View Full Code Here

TOP

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

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.