Package org.apache.camel.component.salesforce.api

Examples of org.apache.camel.component.salesforce.api.SalesforceException


        InputStream request;
        try {
            request = exchange.getIn().getMandatoryBody(InputStream.class);
        } catch (CamelException e) {
            String msg = "Error preparing batch request: " + e.getMessage();
            throw new SalesforceException(msg, e);
        }

        bulkClient.createBatch(request, jobId, contentType, new BulkApiClient.BatchInfoResponseCallback() {
            @Override
            public void onResponse(BatchInfo batchInfo, SalesforceException ex) {
View Full Code Here


                if (inputStream != null) {
                    try {
                        body = StreamCacheConverter.convertToStreamCache(inputStream, exchange);
                    } catch (IOException e) {
                        String msg = "Error retrieving batch request: " + e.getMessage();
                        ex = new SalesforceException(msg, e);
                    } finally {
                        // close the input stream to release the Http connection
                        try {
                            inputStream.close();
                        } catch (IOException ignore) {
View Full Code Here

                if (inputStream != null) {
                    try {
                        body = StreamCacheConverter.convertToStreamCache(inputStream, exchange);
                    } catch (IOException e) {
                        String msg = "Error retrieving batch results: " + e.getMessage();
                        ex = new SalesforceException(msg, e);
                    } finally {
                        // close the input stream to release the Http connection
                        try {
                            inputStream.close();
                        } catch (IOException ignore) {
View Full Code Here

                    // ensures the connection is read
                    try {
                        body = StreamCacheConverter.convertToStreamCache(inputStream, exchange);
                    } catch (IOException e) {
                        String msg = "Error retrieving query result: " + e.getMessage();
                        ex = new SalesforceException(msg, e);
                    } finally {
                        // close the input stream to release the Http connection
                        try {
                            inputStream.close();
                        } catch (IOException e) {
View Full Code Here

                    // if all else fails, get body as String
                    final String body = in.getBody(String.class);
                    if (null == body) {
                        String msg = "Unsupported request message body "
                            + (in.getBody() == null ? null : in.getBody().getClass());
                        throw new SalesforceException(msg, null);
                    } else {
                        request = new ByteArrayInputStream(body.getBytes(StringUtil.__UTF8_CHARSET));
                    }
                }
            }

            return request;

        } catch (IOException e) {
            String msg = "Error marshaling request: " + e.getMessage();
            throw new SalesforceException(msg, e);
        }
    }
View Full Code Here

            // copy headers and attachments
            exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());
            exchange.getOut().getAttachments().putAll(exchange.getIn().getAttachments());
        } catch (IOException e) {
            String msg = "Error parsing JSON response: " + e.getMessage();
            exchange.setException(new SalesforceException(msg, e));
        } finally {
            // cleanup temporary exchange headers
            exchange.removeProperty(RESPONSE_CLASS);
            exchange.removeProperty(RESPONSE_TYPE);
View Full Code Here

                    + "NotifyForFields, NotifyForOperations, Description "
                    + "FROM PushTopic WHERE Name = '" + topicName + "'",
                    callback);

            if (!callback.await(API_TIMEOUT, TimeUnit.SECONDS)) {
                throw new SalesforceException("API call timeout!", null);
            }
            if (callback.getException() != null) {
                throw callback.getException();
            }
            QueryRecordsPushTopic records = OBJECT_MAPPER.readValue(callback.getResponse(),
View Full Code Here

        try {
            restClient.createSObject(PUSH_TOPIC_OBJECT_NAME,
                    new ByteArrayInputStream(OBJECT_MAPPER.writeValueAsBytes(topic)), callback);

            if (!callback.await(API_TIMEOUT, TimeUnit.SECONDS)) {
                throw new SalesforceException("API call timeout!", null);
            }
            if (callback.getException() != null) {
                throw callback.getException();
            }

            CreateSObjectResult result = OBJECT_MAPPER.readValue(callback.getResponse(), CreateSObjectResult.class);
            if (!result.getSuccess()) {
                final SalesforceException salesforceException = new SalesforceException(
                        result.getErrors(), HttpStatus.BAD_REQUEST_400);
                throw new CamelException(
                        String.format("Error creating Topic %s: %s", topicName, result.getErrors()),
                        salesforceException);
            }
View Full Code Here

            restClient.updateSObject("PushTopic", topicId,
                    new ByteArrayInputStream(OBJECT_MAPPER.writeValueAsBytes(topic)),
                    callback);

            if (!callback.await(API_TIMEOUT, TimeUnit.SECONDS)) {
                throw new SalesforceException("API call timeout!", null);
            }
            if (callback.getException() != null) {
                throw callback.getException();
            }
View Full Code Here

                        final LoginError error = objectMapper.readValue(responseContent, LoginError.class);
                        final String msg = String.format("Login error code:[%s] description:[%s]",
                                error.getError(), error.getErrorDescription());
                        final List<RestError> errors = new ArrayList<RestError>();
                        errors.add(new RestError(msg, error.getErrorDescription()));
                        throw new SalesforceException(errors, HttpStatus.BAD_REQUEST_400);

                    default:
                        throw new SalesforceException(String.format("Login error status:[%s] reason:[%s]",
                            responseStatus, loginPost.getReason()), responseStatus);
                    }
                    break;

                case HttpExchange.STATUS_EXCEPTED:
                    final Throwable ex = loginPost.getException();
                    throw new SalesforceException(
                            String.format("Unexpected login exception: %s", ex.getMessage()), ex);

                case HttpExchange.STATUS_CANCELLED:
                    throw new SalesforceException("Login request CANCELLED!", null);

                case HttpExchange.STATUS_EXPIRED:
                    throw new SalesforceException("Login request TIMEOUT!", null);

                default:
                    throw new SalesforceException("Unknow status: " + exchangeState, null);
                }
            } catch (IOException e) {
                String msg = "Login error: unexpected exception " + e.getMessage();
                throw new SalesforceException(msg, e);
            } catch (InterruptedException e) {
                String msg = "Login error: unexpected exception " + e.getMessage();
                throw new SalesforceException(msg, e);
            }
        }

        return accessToken;
    }
View Full Code Here

TOP

Related Classes of org.apache.camel.component.salesforce.api.SalesforceException

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.