Search in sources :

Example 31 with ValidationResultMutable

use of org.talend.daikon.properties.ValidationResultMutable in project components by Talend.

the class TMarketoListOperationProperties method validateMultipleOperation.

public ValidationResult validateMultipleOperation() {
    ValidationResultMutable vr = new ValidationResultMutable();
    if (listOperation.getValue().equals(ListOperation.isMemberOf) && multipleOperation.getValue()) {
        vr.setStatus(Result.ERROR);
        vr.setMessage("multipleOperation flag cannot be set with operation=isMemberOf!");
        return vr;
    }
    return ValidationResult.OK;
}
Also used : ValidationResultMutable(org.talend.daikon.properties.ValidationResultMutable)

Example 32 with ValidationResultMutable

use of org.talend.daikon.properties.ValidationResultMutable in project components by Talend.

the class MarketoSourceOrSink method validate.

@Override
public ValidationResult validate(RuntimeContainer container) {
    TMarketoConnectionProperties conn = getEffectiveConnection(container);
    String endpoint = conn.endpoint.getValue();
    String clientAccess = conn.clientAccessId.getValue();
    String secretKey = conn.secretKey.getValue();
    ValidationResultMutable vr = new ValidationResultMutable();
    if (endpoint == null || endpoint.isEmpty()) {
        vr.setMessage(messages.getMessage("error.validation.connection.endpoint"));
        vr.setStatus(ValidationResult.Result.ERROR);
        return vr;
    }
    if (clientAccess == null || clientAccess.isEmpty()) {
        vr.setMessage(messages.getMessage("error.validation.connection.clientaccess"));
        vr.setStatus(ValidationResult.Result.ERROR);
        return vr;
    }
    if (secretKey == null || secretKey.isEmpty()) {
        vr.setMessage(messages.getMessage("error.validation.connection.secretkey"));
        vr.setStatus(ValidationResult.Result.ERROR);
        return vr;
    }
    // bug/TDI-38439_MarketoWizardConnection
    return validateConnection(conn);
}
Also used : ValidationResultMutable(org.talend.daikon.properties.ValidationResultMutable) TMarketoConnectionProperties(org.talend.components.marketo.tmarketoconnection.TMarketoConnectionProperties)

Example 33 with ValidationResultMutable

use of org.talend.daikon.properties.ValidationResultMutable in project components by Talend.

the class MarketoSink method validate.

@Override
public ValidationResult validate(RuntimeContainer container) {
    ValidationResultMutable vr = new ValidationResultMutable(super.validate(container));
    if (vr.getStatus().equals(Result.ERROR)) {
        return vr;
    }
    // output
    if (properties instanceof TMarketoOutputProperties) {
        switch(((TMarketoOutputProperties) properties).outputOperation.getValue()) {
            case syncLead:
                break;
            case syncMultipleLeads:
                break;
            case deleteLeads:
                break;
            case syncCustomObjects:
                if (StringUtils.isEmpty(((TMarketoOutputProperties) properties).customObjectName.getValue())) {
                    vr.setStatus(Result.ERROR);
                    vr.setMessage(messages.getMessage("error.validation.customobject.customobjectname"));
                    return vr;
                }
                if (StringUtils.isEmpty(((TMarketoOutputProperties) properties).customObjectDedupeBy.getValue())) {
                // TODO check API if required. Not sure...
                }
                break;
            case deleteCustomObjects:
                if (StringUtils.isEmpty(((TMarketoOutputProperties) properties).customObjectName.getValue())) {
                    vr.setStatus(Result.ERROR);
                    vr.setMessage(messages.getMessage("error.validation.customobject.customobjectname"));
                    return vr;
                }
                break;
        }
    }
    // check list operations
    if (properties instanceof TMarketoListOperationProperties) {
    // nothing to check for now.
    }
    // check getMultipleLeads with an input
    if (properties instanceof TMarketoInputProperties) {
        // operation must be getMultipleLeads
        if (!((TMarketoInputProperties) properties).inputOperation.getValue().equals(InputOperation.getMultipleLeads)) {
            vr.setStatus(Result.ERROR);
            vr.setMessage(messages.getMessage("error.validation.sink.getmultipleleads.only"));
            return vr;
        }
        // lead selector must be LeadKeySelector
        LeadSelector selector;
        if (APIMode.SOAP.equals(properties.getConnectionProperties().apiMode.getValue())) {
            selector = ((TMarketoInputProperties) properties).leadSelectorSOAP.getValue();
        } else {
            selector = ((TMarketoInputProperties) properties).leadSelectorREST.getValue();
        }
        if (!selector.equals(LeadSelector.LeadKeySelector)) {
            vr.setStatus(Result.ERROR);
            vr.setMessage(messages.getMessage("error.validation.sink.leadkeyselector.only"));
            return vr;
        }
        // lead key values must be defined
        if (StringUtils.isEmpty(((TMarketoInputProperties) properties).leadKeyValues.getValue())) {
            vr.setStatus(Result.ERROR);
            vr.setMessage(messages.getMessage("error.validation.leadkeyvalues"));
            return vr;
        }
    }
    return ValidationResult.OK;
}
Also used : TMarketoOutputProperties(org.talend.components.marketo.tmarketooutput.TMarketoOutputProperties) ValidationResultMutable(org.talend.daikon.properties.ValidationResultMutable) TMarketoListOperationProperties(org.talend.components.marketo.tmarketolistoperation.TMarketoListOperationProperties) TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) LeadSelector(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties.LeadSelector)

Example 34 with ValidationResultMutable

use of org.talend.daikon.properties.ValidationResultMutable in project components by Talend.

the class MarketoSource method validate.

@Override
public ValidationResult validate(RuntimeContainer container) {
    ValidationResultMutable vr = new ValidationResultMutable(super.validate(container));
    if (vr.getStatus().equals(Result.ERROR)) {
        return vr;
    }
    if (properties instanceof TMarketoInputProperties) {
        TMarketoInputProperties p = (TMarketoInputProperties) properties;
        boolean useSOAP = APIMode.SOAP.equals(properties.getConnectionProperties().apiMode.getValue());
        // Validate dynamic schema if needed
        Boolean isDynamic = AvroUtils.isIncludeAllFields(p.schemaInput.schema.getValue());
        if (useSOAP) {
            // no dynamic schema for SOAP !
            if (isDynamic) {
                vr.setStatus(Result.ERROR);
                vr.setMessage(messages.getMessage("error.validation.soap.dynamicschema"));
                return vr;
            }
        }
        // getLead
        if (p.inputOperation.getValue().equals(InputOperation.getLead)) {
            if (p.leadKeyValue.getValue().isEmpty()) {
                vr.setStatus(Result.ERROR);
                vr.setMessage(messages.getMessage("error.validation.leadkeyvalue"));
                return vr;
            }
        }
        // getMultipleLeads
        if (p.inputOperation.getValue().equals(InputOperation.getMultipleLeads)) {
            LeadSelector sel;
            if (useSOAP) {
                sel = p.leadSelectorSOAP.getValue();
            } else {
                sel = p.leadSelectorREST.getValue();
            }
            switch(sel) {
                case LeadKeySelector:
                    if (p.leadKeyValues.getValue().isEmpty()) {
                        vr.setStatus(Result.ERROR);
                        vr.setMessage(messages.getMessage("error.validation.leadkeyvalues"));
                        return vr;
                    }
                    break;
                case StaticListSelector:
                    if (ListParam.STATIC_LIST_NAME.equals(p.listParam.getValue())) {
                        if (p.listParamListName.getValue().isEmpty()) {
                            vr.setStatus(Result.ERROR);
                            vr.setMessage(messages.getMessage("error.validation.listparamvalue"));
                            return vr;
                        }
                    } else {
                        if (p.listParamListId.getValue() == null) {
                            vr.setStatus(Result.ERROR);
                            vr.setMessage(messages.getMessage("error.validation.listparamvalue"));
                            return vr;
                        }
                    }
                    break;
                case LastUpdateAtSelector:
                    if (p.oldestUpdateDate.getValue().isEmpty() || p.latestUpdateDate.getValue().isEmpty() || isInvalidDate(p.oldestUpdateDate.getValue()) || isInvalidDate(p.latestUpdateDate.getValue())) {
                        vr.setStatus(Result.ERROR);
                        vr.setMessage(messages.getMessage("error.validation.updatedates"));
                        return vr;
                    }
                    break;
            }
        }
        // getLeadActivity
        if (p.inputOperation.getValue().equals(InputOperation.getLeadActivity)) {
            if (isDynamic) {
                vr.setStatus(Result.ERROR);
                vr.setMessage(messages.getMessage("error.validation.operation.dynamicschema"));
                return vr;
            }
            if (useSOAP) {
                if (p.leadKeyValue.getValue().isEmpty()) {
                    vr.setStatus(Result.ERROR);
                    vr.setMessage(messages.getMessage("error.validation.leadkeyvalue"));
                    return vr;
                }
            } else {
                if (p.sinceDateTime.getValue().isEmpty() || isInvalidDate(p.sinceDateTime.getValue())) {
                    vr.setStatus(Result.ERROR);
                    vr.setMessage(messages.getMessage("error.validation.sincedatetime"));
                    return vr;
                }
            }
        }
        // getLeadChanges
        if (p.inputOperation.getValue().equals(InputOperation.getLeadChanges)) {
            if (isDynamic) {
                vr.setStatus(Result.ERROR);
                vr.setMessage(messages.getMessage("error.validation.operation.dynamicschema"));
                return vr;
            }
            if (useSOAP) {
                if (p.oldestCreateDate.getValue().isEmpty() || p.latestCreateDate.getValue().isEmpty() || isInvalidDate(p.oldestCreateDate.getValue()) || isInvalidDate(p.latestCreateDate.getValue())) {
                    vr.setStatus(Result.ERROR);
                    vr.setMessage(messages.getMessage("error.validation.createdates"));
                    return vr;
                }
            } else {
                if (p.sinceDateTime.getValue().isEmpty() || isInvalidDate(p.sinceDateTime.getValue())) {
                    vr.setStatus(Result.ERROR);
                    vr.setMessage(messages.getMessage("error.validation.sincedatetime"));
                    return vr;
                }
                if (StringUtils.isEmpty(p.fieldList.getValue())) {
                    vr.setStatus(Result.ERROR);
                    vr.setMessage(messages.getMessage("error.validation.fieldlist"));
                    return vr;
                }
            }
        }
        // ///////////////////
        if (p.inputOperation.getValue().equals(InputOperation.CustomObject)) {
            // get Action
            if (p.customObjectAction.getValue().equals(CustomObjectAction.get)) {
                if (p.customObjectName.getValue().isEmpty()) {
                    vr.setStatus(Result.ERROR);
                    vr.setMessage(messages.getMessage("error.validation.customobject.customobjectname"));
                    return vr;
                }
                if (p.useCompoundKey.getValue()) {
                    if (p.compoundKey.size() == 0) {
                        vr.setStatus(Result.ERROR);
                        vr.setMessage(messages.getMessage("error.validation.customobject.compoundkey"));
                        return vr;
                    }
                } else {
                    // filterType & filterValue
                    if (p.customObjectFilterType.getValue().isEmpty()) {
                        vr.setStatus(Result.ERROR);
                        vr.setMessage(messages.getMessage("error.validation.customobject.filtertype"));
                        return vr;
                    }
                    if (p.customObjectFilterValues.getValue().isEmpty()) {
                        vr.setStatus(Result.ERROR);
                        vr.setMessage(messages.getMessage("error.validation.customobject.filtervalues"));
                        return vr;
                    }
                }
            }
            // list no checking...
            if (p.customObjectAction.getValue().equals(CustomObjectAction.list)) {
                if (isDynamic) {
                    vr.setStatus(Result.ERROR);
                    vr.setMessage(messages.getMessage("error.validation.operation.dynamicschema"));
                    return vr;
                }
            }
            // describe
            if (p.customObjectAction.getValue().equals(CustomObjectAction.describe)) {
                if (isDynamic) {
                    vr.setStatus(Result.ERROR);
                    vr.setMessage(messages.getMessage("error.validation.operation.dynamicschema"));
                    return vr;
                }
                if (p.customObjectName.getValue().isEmpty()) {
                    vr.setStatus(Result.ERROR);
                    vr.setMessage(messages.getMessage("error.validation.customobject.customobjectname"));
                    return vr;
                }
            }
        }
    }
    // BulkExec
    if (properties instanceof TMarketoBulkExecProperties) {
        TMarketoBulkExecProperties p = (TMarketoBulkExecProperties) properties;
        if (StringUtils.isEmpty(p.bulkFilePath.getValue())) {
            vr.setStatus(Result.ERROR);
            vr.setMessage(messages.getMessage("error.validation.sink.bulk.bulkfilepath"));
            return vr;
        }
        Path tmpPath = Paths.get(p.bulkFilePath.getValue());
        if (!Files.exists(tmpPath)) {
            vr.setStatus(Result.ERROR);
            vr.setMessage(messages.getMessage("error.validation.sink.bulk.bulkfilepath.notexists"));
            return vr;
        }
        if (StringUtils.isEmpty(p.logDownloadPath.getValue())) {
            vr.setStatus(Result.ERROR);
            vr.setMessage(messages.getMessage("error.validation.sink.bulk.logdownloadpath"));
            return vr;
        }
        tmpPath = Paths.get(p.logDownloadPath.getValue());
        if (!Files.isDirectory(tmpPath)) {
            vr.setStatus(Result.ERROR);
            vr.setMessage(messages.getMessage("error.validation.sink.bulk.logdownloadpath"));
            return vr;
        }
        if (p.bulkImportTo.getValue().equals(BulkImportTo.Leads)) {
            if (StringUtils.isEmpty(p.lookupField.getValue().name())) {
                vr.setStatus(Result.ERROR);
                vr.setMessage(messages.getMessage("error.validation.bulk.lookupfield"));
                return vr;
            }
        } else {
            if (StringUtils.isEmpty(p.customObjectName.getValue())) {
                vr.setStatus(Result.ERROR);
                vr.setMessage(messages.getMessage("error.validation.customobject.customobjectname"));
                return vr;
            }
        }
    }
    return vr;
}
Also used : Path(java.nio.file.Path) ValidationResultMutable(org.talend.daikon.properties.ValidationResultMutable) TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) TMarketoBulkExecProperties(org.talend.components.marketo.tmarketobulkexec.TMarketoBulkExecProperties) LeadSelector(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties.LeadSelector)

Example 35 with ValidationResultMutable

use of org.talend.daikon.properties.ValidationResultMutable in project components by Talend.

the class TMarketoOutputProperties method validateOutputOperation.

public ValidationResult validateOutputOperation() {
    if (isApiSOAP()) {
        switch(outputOperation.getValue()) {
            case syncLead:
            case syncMultipleLeads:
                return OK;
            case deleteLeads:
            case syncCustomObjects:
            case deleteCustomObjects:
                ValidationResultMutable vr = new ValidationResultMutable();
                vr.setStatus(Result.ERROR);
                vr.setMessage(messages.getMessage("validation.error.operation.soap"));
                return vr;
        }
    }
    return ValidationResult.OK;
}
Also used : ValidationResultMutable(org.talend.daikon.properties.ValidationResultMutable)

Aggregations

ValidationResultMutable (org.talend.daikon.properties.ValidationResultMutable)41 IOException (java.io.IOException)11 SandboxedInstance (org.talend.daikon.sandbox.SandboxedInstance)8 ValidationResult (org.talend.daikon.properties.ValidationResult)7 SQLException (java.sql.SQLException)5 Schema (org.apache.avro.Schema)5 MarketoComponentDefinition.getSandboxedInstance (org.talend.components.marketo.MarketoComponentDefinition.getSandboxedInstance)3 MarketoSourceOrSinkRuntime (org.talend.components.marketo.runtime.MarketoSourceOrSinkRuntime)3 SalesforceDefinition.getSandboxedInstance (org.talend.components.salesforce.SalesforceDefinition.getSandboxedInstance)3 SalesforceRuntimeSourceOrSink (org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink)3 User (com.google.api.services.drive.model.User)2 File (java.io.File)2 GeneralSecurityException (java.security.GeneralSecurityException)2 Connection (java.sql.Connection)2 MarketoSourceOrSinkSchemaProvider (org.talend.components.marketo.runtime.MarketoSourceOrSinkSchemaProvider)2 TMarketoInputProperties (org.talend.components.marketo.tmarketoinput.TMarketoInputProperties)2 LeadSelector (org.talend.components.marketo.tmarketoinput.TMarketoInputProperties.LeadSelector)2 SalesforceSchemaHelper (org.talend.components.salesforce.schema.SalesforceSchemaHelper)2 NamedThing (org.talend.daikon.NamedThing)2 TalendRuntimeException (org.talend.daikon.exception.TalendRuntimeException)2