Java 类org.apache.camel.component.salesforce.api.dto.AbstractSObjectBase 实例源码

项目:Camel    文件:AbstractRestProcessor.java   
private void processCreateSobject(final Exchange exchange, final AsyncCallback callback) throws SalesforceException {
    String sObjectName;
    // determine parameters from input AbstractSObject
    AbstractSObjectBase sObjectBase = exchange.getIn().getBody(AbstractSObjectBase.class);
    if (sObjectBase != null) {
        sObjectName = sObjectBase.getClass().getSimpleName();
    } else {
        sObjectName = getParameter(SOBJECT_NAME, exchange, IGNORE_BODY, NOT_OPTIONAL);
    }

    restClient.createSObject(sObjectName, getRequestStream(exchange),
        new RestClient.ResponseCallback() {
            @Override
            public void onResponse(InputStream response, SalesforceException exception) {
                processResponse(exchange, response, exception, callback);
            }
        });
}
项目:Camel    文件:AbstractRestProcessor.java   
private void processUpdateSobject(final Exchange exchange, final AsyncCallback callback) throws SalesforceException {
    String sObjectName;
    // determine parameters from input AbstractSObject
    final AbstractSObjectBase sObjectBase = exchange.getIn().getBody(AbstractSObjectBase.class);
    String sObjectId;
    if (sObjectBase != null) {
        sObjectName = sObjectBase.getClass().getSimpleName();
        // remember the sObject Id
        sObjectId = sObjectBase.getId();
        // clear base object fields, which cannot be updated
        sObjectBase.clearBaseFields();
    } else {
        sObjectName = getParameter(SOBJECT_NAME, exchange, IGNORE_BODY, NOT_OPTIONAL);
        sObjectId = getParameter(SOBJECT_ID, exchange, IGNORE_BODY, NOT_OPTIONAL);
    }

    final String finalsObjectId = sObjectId;
    restClient.updateSObject(sObjectName, sObjectId, getRequestStream(exchange),
        new RestClient.ResponseCallback() {
            @Override
            public void onResponse(InputStream response, SalesforceException exception) {
                processResponse(exchange, response, exception, callback);
                restoreFields(exchange, sObjectBase, finalsObjectId, null, null);
            }
        });
}
项目:Camel    文件:AbstractRestProcessor.java   
private void processDeleteSobject(final Exchange exchange, final AsyncCallback callback) throws SalesforceException {
    String sObjectName;
    // determine parameters from input AbstractSObject
    final AbstractSObjectBase sObjectBase = exchange.getIn().getBody(AbstractSObjectBase.class);
    String sObjectIdValue;
    if (sObjectBase != null) {
        sObjectName = sObjectBase.getClass().getSimpleName();
        sObjectIdValue = sObjectBase.getId();
    } else {
        sObjectName = getParameter(SOBJECT_NAME, exchange, IGNORE_BODY, NOT_OPTIONAL);
        sObjectIdValue = getParameter(SOBJECT_ID, exchange, USE_BODY, NOT_OPTIONAL);
    }
    final String sObjectId = sObjectIdValue;

    restClient.deleteSObject(sObjectName, sObjectId, new RestClient.ResponseCallback() {
        @Override
        public void onResponse(InputStream response, SalesforceException exception) {
            processResponse(exchange, response, exception, callback);
            restoreFields(exchange, sObjectBase, sObjectId, null, null);
        }
    });
}
项目:Camel    文件:AbstractRestProcessor.java   
private void restoreFields(Exchange exchange, AbstractSObjectBase sObjectBase,
                           String sObjectId, String sObjectExtIdName, Object oldValue) {
    // restore fields
    if (sObjectBase != null) {
        // restore the Id if it was cleared
        if (sObjectId != null) {
            sObjectBase.setId(sObjectId);
        }
        // restore the external id if it was cleared
        if (sObjectExtIdName != null && oldValue != null) {
            try {
                setPropertyValue(sObjectBase, sObjectExtIdName, oldValue);
            } catch (SalesforceException e) {
                // YES, the exchange may fail if the property cannot be reset!!!
                exchange.setException(e);
            }
        }
    }
}
项目:Camel    文件:SalesforceComponent.java   
private Map<String, Class<?>> parsePackages() {
    Map<String, Class<?>> result = new HashMap<String, Class<?>>();
    Set<Class<?>> classes = getCamelContext().getPackageScanClassResolver().
            findImplementations(AbstractSObjectBase.class, packages);
    for (Class<?> aClass : classes) {
        // findImplementations also returns AbstractSObjectBase for some reason!!!
        if (AbstractSObjectBase.class != aClass) {
            result.put(aClass.getSimpleName(), aClass);
        }
    }

    return result;
}
项目:Camel    文件:AbstractRestProcessor.java   
private void processGetSobject(final Exchange exchange, final AsyncCallback callback) throws SalesforceException {
    String sObjectName;
    String sObjectIdValue;
    // determine parameters from input AbstractSObject
    final AbstractSObjectBase sObjectBase = exchange.getIn().getBody(AbstractSObjectBase.class);
    if (sObjectBase != null) {
        sObjectName = sObjectBase.getClass().getSimpleName();
        sObjectIdValue = sObjectBase.getId();
    } else {
        sObjectName = getParameter(SOBJECT_NAME, exchange, IGNORE_BODY, NOT_OPTIONAL);
        sObjectIdValue = getParameter(SOBJECT_ID, exchange, USE_BODY, NOT_OPTIONAL);
    }
    final String sObjectId = sObjectIdValue;

    // use sObject name to load class
    setResponseClass(exchange, sObjectName);

    // get optional field list
    String fieldsValue = getParameter(SOBJECT_FIELDS, exchange, IGNORE_BODY, IS_OPTIONAL);
    String[] fields = null;
    if (fieldsValue != null) {
        fields = fieldsValue.split(",");
    }

    restClient.getSObject(sObjectName, sObjectId, fields, new RestClient.ResponseCallback() {
        @Override
        public void onResponse(InputStream response, SalesforceException exception) {
            processResponse(exchange, response, exception, callback);
            restoreFields(exchange, sObjectBase, sObjectId, null, null);
        }
    });
}
项目:Camel    文件:AbstractRestProcessor.java   
private void processGetSobjectWithId(final Exchange exchange, final AsyncCallback callback) throws SalesforceException {
    String sObjectName;
    Object oldValue = null;
    String sObjectExtIdValue;
    final String sObjectExtIdName = getParameter(SOBJECT_EXT_ID_NAME,
            exchange, IGNORE_BODY, NOT_OPTIONAL);

    // determine parameters from input AbstractSObject
    final AbstractSObjectBase sObjectBase = exchange.getIn().getBody(AbstractSObjectBase.class);
    if (sObjectBase != null) {
        sObjectName = sObjectBase.getClass().getSimpleName();
        oldValue = getAndClearPropertyValue(sObjectBase, sObjectExtIdName);
        sObjectExtIdValue = oldValue.toString();
    } else {
        sObjectName = getParameter(SOBJECT_NAME, exchange, IGNORE_BODY, NOT_OPTIONAL);
        sObjectExtIdValue = getParameter(SOBJECT_EXT_ID_VALUE, exchange, USE_BODY, NOT_OPTIONAL);
    }

    // use sObject name to load class
    setResponseClass(exchange, sObjectName);

    final Object finalOldValue = oldValue;
    restClient.getSObjectWithId(sObjectName, sObjectExtIdName, sObjectExtIdValue,
        new RestClient.ResponseCallback() {
            @Override
            public void onResponse(InputStream response, SalesforceException exception) {
                processResponse(exchange, response, exception, callback);
                restoreFields(exchange, sObjectBase, null, sObjectExtIdName, finalOldValue);
            }
        });
}
项目:Camel    文件:AbstractRestProcessor.java   
private void processUpsertSobject(final Exchange exchange, final AsyncCallback callback) throws SalesforceException {
    String sObjectName;
    String sObjectExtIdValue;
    final String sObjectExtIdName = getParameter(SOBJECT_EXT_ID_NAME, exchange,
            IGNORE_BODY, NOT_OPTIONAL);

    // determine parameters from input AbstractSObject
    Object oldValue = null;
    final AbstractSObjectBase sObjectBase = exchange.getIn().getBody(AbstractSObjectBase.class);
    if (sObjectBase != null) {
        sObjectName = sObjectBase.getClass().getSimpleName();
        oldValue = getAndClearPropertyValue(sObjectBase, sObjectExtIdName);
        sObjectExtIdValue = oldValue.toString();
        // clear base object fields, which cannot be updated
        sObjectBase.clearBaseFields();
    } else {
        sObjectName = getParameter(SOBJECT_NAME, exchange, IGNORE_BODY, NOT_OPTIONAL);
        sObjectExtIdValue = getParameter(SOBJECT_EXT_ID_VALUE, exchange, IGNORE_BODY, NOT_OPTIONAL);
    }

    final Object finalOldValue = oldValue;
    restClient.upsertSObject(sObjectName, sObjectExtIdName, sObjectExtIdValue, getRequestStream(exchange),
        new RestClient.ResponseCallback() {
            @Override
            public void onResponse(InputStream response, SalesforceException exception) {
                processResponse(exchange, response, exception, callback);
                restoreFields(exchange, sObjectBase, null, sObjectExtIdName, finalOldValue);
            }
        });
}
项目:Camel    文件:AbstractRestProcessor.java   
private void processDeleteSobjectWithId(final Exchange exchange, final AsyncCallback callback) throws SalesforceException {
    String sObjectName;
    final String sObjectExtIdName = getParameter(SOBJECT_EXT_ID_NAME, exchange, IGNORE_BODY, NOT_OPTIONAL);

    // determine parameters from input AbstractSObject
    Object oldValue = null;
    final AbstractSObjectBase sObjectBase = exchange.getIn().getBody(AbstractSObjectBase.class);
    String sObjectExtIdValue;
    if (sObjectBase != null) {
        sObjectName = sObjectBase.getClass().getSimpleName();
        oldValue = getAndClearPropertyValue(sObjectBase, sObjectExtIdName);
        sObjectExtIdValue = oldValue.toString();
    } else {
        sObjectName = getParameter(SOBJECT_NAME, exchange, IGNORE_BODY, NOT_OPTIONAL);
        sObjectExtIdValue = getParameter(SOBJECT_EXT_ID_VALUE, exchange, USE_BODY, NOT_OPTIONAL);
    }

    final Object finalOldValue = oldValue;
    restClient.deleteSObjectWithId(sObjectName, sObjectExtIdName, sObjectExtIdValue,
        new RestClient.ResponseCallback() {
            @Override
            public void onResponse(InputStream response, SalesforceException exception) {
                processResponse(exchange, response, exception, callback);
                restoreFields(exchange, sObjectBase, null, sObjectExtIdName, finalOldValue);
            }
        });
}
项目:Camel    文件:AbstractRestProcessor.java   
private void processGetBlobField(final Exchange exchange, final AsyncCallback callback) throws SalesforceException {
    String sObjectName;
    // get blob field name
    final String sObjectBlobFieldName = getParameter(SOBJECT_BLOB_FIELD_NAME,
            exchange, IGNORE_BODY, NOT_OPTIONAL);

    // determine parameters from input AbstractSObject
    final AbstractSObjectBase sObjectBase = exchange.getIn().getBody(AbstractSObjectBase.class);
    String sObjectIdValue;
    if (sObjectBase != null) {
        sObjectName = sObjectBase.getClass().getSimpleName();
        sObjectIdValue = sObjectBase.getId();
    } else {
        sObjectName = getParameter(SOBJECT_NAME, exchange, IGNORE_BODY, NOT_OPTIONAL);
        sObjectIdValue = getParameter(SOBJECT_ID, exchange, USE_BODY, NOT_OPTIONAL);
    }
    final String sObjectId = sObjectIdValue;

    restClient.getBlobField(sObjectName, sObjectId, sObjectBlobFieldName,
        new RestClient.ResponseCallback() {
            @Override
            public void onResponse(InputStream response, SalesforceException exception) {
                processResponse(exchange, response, exception, callback);
                restoreFields(exchange, sObjectBase, sObjectId, null, null);
            }
        });
}