Java 类org.apache.camel.component.salesforce.SalesforceEndpointConfig 实例源码

项目:syndesis    文件:SalesforceStreamingConnector.java   
@Override
public final String createEndpointUri(final String scheme, final Map<String, String> options) throws URISyntaxException {
    final String sObjectName = options.get(SalesforceEndpointConfig.SOBJECT_NAME);

    final String query = "SELECT Id FROM " + sObjectName;
    final String topicName = topicNameFor(options);
    options.put("topicName", topicName);
    options.put(SalesforceEndpointConfig.SOBJECT_QUERY, query);
    options.remove(SalesforceEndpointConfig.SOBJECT_NAME);

    final String salesforceComponent = getComponentScheme();

    if (!topicName.endsWith("_delete")) {
        final Enricher enricher = new Enricher(
            new ConstantExpression(salesforceComponent + ":getSObject?rawPayload=true&sObjectName=" + sObjectName));
        enricher.setCamelContext(getCamelContext());

        setBeforeConsumer(enricher);
    }

    return super.createEndpointUri(scheme, options);
}
项目:syndesis    文件:SalesforceStreamingConnector.java   
private static String topicNameFor(final Map<String, String> options) {
    final String sObjectName = options.get(SalesforceEndpointConfig.SOBJECT_NAME);

    final String topicSuffix;
    if (Boolean.valueOf(options.get("notifyForOperationCreate"))) {
        topicSuffix = "_create";
    } else if (Boolean.valueOf(options.get("notifyForOperationUpdate"))) {
        topicSuffix = "_update";
    } else if (Boolean.valueOf(options.get("notifyForOperationDelete"))) {
        topicSuffix = "_delete";
    } else if (Boolean.valueOf(options.get("notifyForOperationUndelete"))) {
        topicSuffix = "_undelete";
    } else {
        topicSuffix = "_all";
    }

    return TOPIC_PREFIX + sObjectName + topicSuffix;
}
项目:connectors    文件:SalesforceUpdateSObjectComponent.java   
public SalesforceUpdateSObjectComponent() {
    super("salesforce-update-sobject", SalesforceUpdateSObjectComponent.class.getName());

    // set sObjectId header
    setBeforeProducer(exchange -> {

        // parse input json and extract Id field
        final ObjectMapper mapper = JsonUtils.createObjectMapper();
        final JsonNode node = mapper.readTree(exchange.getIn().getBody(String.class));

        final JsonNode sObjectId = node.get("Id");
        if (sObjectId == null) {
            exchange.setException(new SalesforceException("Missing field Id", 404));
        } else {
            exchange.getIn().setHeader(SalesforceEndpointConfig.SOBJECT_ID, sObjectId.asText());
        }

        clearBaseFields((ObjectNode) node);

        // update input json
        exchange.getIn().setBody(mapper.writeValueAsString(node));
    });
}
项目:connectors    文件:AbstractSalesforceStreamingConnector.java   
@Override
public String createEndpointUri(final String scheme, final Map<String, String> options) throws URISyntaxException {
    final String sObjectName = options.get(SalesforceEndpointConfig.SOBJECT_NAME);

    final String query = "SELECT Id FROM " + sObjectName;
    options.put("topicName", topicNameFor(options));
    options.put(SalesforceEndpointConfig.SOBJECT_QUERY, query);
    options.remove(SalesforceEndpointConfig.SOBJECT_NAME);

    final String salesforceComponent = getComponentName() + "-component";

    final Enricher enricher = new Enricher(
        new ConstantExpression(salesforceComponent + ":getSObject?rawPayload=true&sObjectName=" + sObjectName));
    enricher.setCamelContext(getCamelContext());

    setBeforeConsumer(enricher);

    return super.createEndpointUri(scheme, options);
}
项目:Camel    文件:PushTopicHelper.java   
public PushTopicHelper(SalesforceEndpointConfig config, String topicName, RestClient restClient) {
    this.config = config;
    this.topicName = topicName;
    this.restClient = restClient;
    this.preApi29 = Double.valueOf(config.getApiVersion()) < 29.0;

    // validate notify fields right away
    if (preApi29 && (config.getNotifyForOperationCreate() != null
            || config.getNotifyForOperationDelete() != null
            || config.getNotifyForOperationUndelete() != null
            || config.getNotifyForOperationUpdate() != null)) {
        throw new IllegalArgumentException("NotifyForOperationCreate, NotifyForOperationDelete"
            + ", NotifyForOperationUndelete, and NotifyForOperationUpdate"
            + " are only supported since API version 29.0"
            + ", instead use NotifyForOperations");
    } else if (!preApi29 && config.getNotifyForOperations() != null) {
        throw new IllegalArgumentException("NotifyForOperations is readonly since API version 29.0"
            + ", instead use NotifyForOperationCreate, NotifyForOperationDelete"
            + ", NotifyForOperationUndelete, and NotifyForOperationUpdate");
    }
}
项目:syndesis-verifier    文件:SalesforceMetadataAdapter.java   
@Override
public SyndesisMetadata<ObjectSchema> adapt(final Map<String, Object> properties, final MetaData metadata) {

    final ObjectSchema schema = schemaPayload(metadata);

    Set<ObjectSchema> schemasToConsider;
    if (isPresentAndNonNull(properties, SalesforceEndpointConfig.SOBJECT_NAME)) {
        schemasToConsider = Collections.singleton(objectSchemaFrom(schema));
    } else {
        schemasToConsider = schema.getOneOf().stream().filter(SalesforceMetadataAdapter::isObjectSchema)
            .map(ObjectSchema.class::cast).collect(Collectors.toSet());
    }

    final Map<String, List<PropertyPair>> enrichedProperties = new HashMap<>();
    enrichedProperties.put(SalesforceEndpointConfig.SOBJECT_NAME, schemasToConsider.stream()
        .map(SalesforceMetadataAdapter::nameAndTitlePropertyPairOf).collect(Collectors.toList()));

    if (isPresent(properties, SalesforceEndpointConfig.SOBJECT_EXT_ID_NAME)) {
        enrichedProperties.put(SalesforceEndpointConfig.SOBJECT_EXT_ID_NAME, schemasToConsider.stream()
            .flatMap(s -> s.getProperties().entrySet().stream()).filter(e -> isIdLookup(e.getValue()))
            .map(SalesforceMetadataAdapter::createFieldPairPropertyFromSchemaEntry).collect(Collectors.toList()));
    }

    if (isPresentAndNonNull(properties, SalesforceEndpointConfig.SOBJECT_NAME)) {
        final String objectName = (String) properties.get(SalesforceEndpointConfig.SOBJECT_NAME);
        final ObjectSchema inputOutputSchema = inputOutputSchemaFor(schemasToConsider, objectName);

        return new SyndesisMetadata<>(enrichedProperties, inputOutputSchema, inputOutputSchema);
    }

    return new SyndesisMetadata<>(enrichedProperties, null, null);
}
项目:syndesis    文件:SalesforceMetadataAdapter.java   
@Override
public SyndesisMetadata<ObjectSchema> adapt(String actionId, final Map<String, Object> properties, final MetaData metadata) {

    final ObjectSchema schema = schemaPayload(metadata);

    Set<ObjectSchema> schemasToConsider;
    if (isPresentAndNonNull(properties, SalesforceEndpointConfig.SOBJECT_NAME)) {
        schemasToConsider = Collections.singleton(objectSchemaFrom(schema));
    } else {
        schemasToConsider = schema.getOneOf().stream().filter(SalesforceMetadataAdapter::isObjectSchema)
            .map(ObjectSchema.class::cast).collect(Collectors.toSet());
    }

    final Map<String, List<PropertyPair>> enrichedProperties = new HashMap<>();
    enrichedProperties.put(SalesforceEndpointConfig.SOBJECT_NAME, schemasToConsider.stream()
        .map(SalesforceMetadataAdapter::nameAndTitlePropertyPairOf).collect(Collectors.toList()));

    if (isPresent(properties, SalesforceEndpointConfig.SOBJECT_EXT_ID_NAME)) {
        enrichedProperties.put(SalesforceEndpointConfig.SOBJECT_EXT_ID_NAME, schemasToConsider.stream()
            .flatMap(s -> s.getProperties().entrySet().stream()).filter(e -> isIdLookup(e.getValue()))
            .map(SalesforceMetadataAdapter::createFieldPairPropertyFromSchemaEntry).collect(Collectors.toList()));
    }

    if (isPresentAndNonNull(properties, SalesforceEndpointConfig.SOBJECT_NAME)) {
        final String objectName = (String) properties.get(SalesforceEndpointConfig.SOBJECT_NAME);
        final ObjectSchema inputOutputSchema = inputOutputSchemaFor(schemasToConsider, objectName);

        return new SyndesisMetadata<>(enrichedProperties, inputOutputSchema, inputOutputSchema);
    }

    return new SyndesisMetadata<>(enrichedProperties, null, null);
}
项目:syndesis    文件:AdaptObjectForUpdateProcessor.java   
@Override
public void process(final Exchange exchange) throws Exception {
    // parse input json and extract Id field
    final Message in = exchange.getIn();
    final String body = in.getBody(String.class);

    if (body == null) {
        return;
    }

    final ObjectNode node = (ObjectNode) MAPPER.readTree(body);

    final String idPropertyName = determineIdProperty(exchange);

    final JsonNode idProperty = node.remove(idPropertyName);
    if (idProperty == null) {
        exchange.setException(
            new SalesforceException("Missing option value for Id or " + SalesforceEndpointConfig.SOBJECT_EXT_ID_NAME, 404));

        return;
    }

    final String idValue = idProperty.textValue();
    if ("Id".equals(idPropertyName)) {
        in.setHeader(SalesforceEndpointConfig.SOBJECT_ID, idValue);
    } else {
        in.setHeader(SalesforceEndpointConfig.SOBJECT_EXT_ID_VALUE, idValue);
    }

    // base fields are not allowed to be updated
    clearBaseFields(node);

    // update input json
    in.setBody(MAPPER.writeValueAsString(node));
}
项目:connectors    文件:SalesforceOnDeleteComponent.java   
@Override
public String createEndpointUri(final String scheme, final Map<String, String> options) throws URISyntaxException {
    final String sObjectName = options.get(SalesforceEndpointConfig.SOBJECT_NAME);

    final String query = "SELECT Id FROM " + sObjectName;
    options.put("topicName", topicNameFor(options));
    options.put(SalesforceEndpointConfig.SOBJECT_QUERY, query);
    options.remove(SalesforceEndpointConfig.SOBJECT_NAME);

    return super.createEndpointUri(scheme, options);
}
项目:Camel    文件:CamelSalesforceMojoIntegrationTest.java   
protected CamelSalesforceMojo createMojo() throws IOException {
    CamelSalesforceMojo mojo = new CamelSalesforceMojo();

    mojo.setLog(new SystemStreamLog());

    // set login properties
    setLoginProperties(mojo);

    // set defaults
    mojo.version = System.getProperty("apiVersion", SalesforceEndpointConfig.DEFAULT_VERSION);
    mojo.loginUrl = System.getProperty("loginUrl", SalesforceLoginConfig.DEFAULT_LOGIN_URL);
    mojo.outputDirectory = new File("target/generated-sources/camel-salesforce");
    mojo.packageName = "org.apache.camel.salesforce.dto";

    // set code generation properties
    mojo.includePattern = "(.*__c)|(PushTopic)|(Document)|(Account)";

    // remove generated code directory
    if (mojo.outputDirectory.exists()) {
        // remove old files
        for (File file : mojo.outputDirectory.listFiles()) {
            file.delete();
        }
        mojo.outputDirectory.delete();
    }
    return mojo;
}
项目:Camel    文件:AnalyticsApiProcessor.java   
public AnalyticsApiProcessor(SalesforceEndpoint endpoint) throws SalesforceException {
    super(endpoint);

    this.analyticsClient = new DefaultAnalyticsApiClient(
        (String) endpointConfigMap.get(SalesforceEndpointConfig.API_VERSION), session,
        httpClient);
}
项目:connectors    文件:SalesforceOnDeleteComponent.java   
private static String topicNameFor(final Map<String, String> options) {
    final String sObjectName = options.get(SalesforceEndpointConfig.SOBJECT_NAME);

    return "syndesis_" + sObjectName + "_delete";
}
项目:connectors    文件:AbstractSalesforceStreamingConnector.java   
protected String topicNameFor(final Map<String, String> options) {
    final String sObjectName = options.get(SalesforceEndpointConfig.SOBJECT_NAME);

    return topicPrefix + sObjectName + topicSufix;
}
项目:Camel    文件:BulkApiProcessor.java   
public BulkApiProcessor(SalesforceEndpoint endpoint) throws SalesforceException {
    super(endpoint);

    this.bulkClient = new DefaultBulkApiClient(
        (String) endpointConfigMap.get(SalesforceEndpointConfig.API_VERSION), session, httpClient);
}
项目:Camel    文件:SalesforceComponentConfiguration.java   
public SalesforceEndpointConfig getConfig() {
    return config;
}
项目:Camel    文件:SalesforceComponentConfiguration.java   
public void setConfig(SalesforceEndpointConfig config) {
    this.config = config;
}
项目:syndesis    文件:AdaptObjectForUpdateProcessor.java   
private String determineIdProperty(final Exchange exchange) throws URISyntaxException {
    final String uri = exchange.getProperty(Exchange.TO_ENDPOINT, String.class);

    final Map<String, Object> endpointParameters = URISupport.parseParameters(URI.create(uri));

    return (String) endpointParameters.getOrDefault(SalesforceEndpointConfig.SOBJECT_EXT_ID_NAME, "Id");
}