Search in sources :

Example 1 with AzureStorageQueueProperties

use of org.talend.components.azurestorage.queue.AzureStorageQueueProperties in project components by Talend.

the class AzureStorageQueueSourceOrSink method validate.

@Override
public ValidationResult validate(RuntimeContainer container) {
    ValidationResult vr = super.validate(container);
    if (vr != ValidationResult.OK)
        return vr;
    if (properties instanceof TAzureStorageQueueListProperties) {
        // no validation needed...
        return ValidationResult.OK;
    }
    if (properties instanceof AzureStorageQueueProperties) {
        String q = ((AzureStorageQueueProperties) properties).queueName.getValue();
        if (q.isEmpty()) {
            return new ValidationResult(ValidationResult.Result.ERROR, i18nMessages.getMessage("error.NameEmpty"));
        }
        if (q.length() < 3 || q.length() > 63) {
            return new ValidationResult(ValidationResult.Result.ERROR, i18nMessages.getMessage("error.LengthError"));
        }
        if (q.indexOf("--") > -1) {
            return new ValidationResult(ValidationResult.Result.ERROR, i18nMessages.getMessage("error.TwoDashError"));
        }
        if (!queueCheckNamePattern.matcher(q.replaceAll("-", "")).matches()) {
            return new ValidationResult(ValidationResult.Result.ERROR, i18nMessages.getMessage("error.QueueNameError"));
        }
    }
    if (properties instanceof TAzureStorageQueueInputProperties) {
        int nom = ((TAzureStorageQueueInputProperties) properties).numberOfMessages.getValue();
        if (nom < 1 || nom > 32) {
            return new ValidationResult(ValidationResult.Result.ERROR, i18nMessages.getMessage("error.ParameterLengthError"));
        }
        int vtimeout = ((TAzureStorageQueueInputProperties) properties).visibilityTimeoutInSeconds.getValue();
        if (vtimeout < 0) {
            return new ValidationResult(ValidationResult.Result.ERROR, i18nMessages.getMessage("error.ParameterValueError"));
        }
    }
    return ValidationResult.OK;
}
Also used : TAzureStorageQueueListProperties(org.talend.components.azurestorage.queue.tazurestoragequeuelist.TAzureStorageQueueListProperties) TAzureStorageQueueInputProperties(org.talend.components.azurestorage.queue.tazurestoragequeueinput.TAzureStorageQueueInputProperties) ValidationResult(org.talend.daikon.properties.ValidationResult) AzureStorageQueueProperties(org.talend.components.azurestorage.queue.AzureStorageQueueProperties)

Example 2 with AzureStorageQueueProperties

use of org.talend.components.azurestorage.queue.AzureStorageQueueProperties in project components by Talend.

the class AzureStorageQueueRuntime method initialize.

@Override
public ValidationResult initialize(RuntimeContainer runtimeContainer, ComponentProperties properties) {
    // init
    AzureStorageQueueProperties componentProperties = (AzureStorageQueueProperties) properties;
    this.queueName = componentProperties.queueName.getValue();
    // validate
    ValidationResult validationResult = super.initialize(runtimeContainer, properties);
    if (validationResult.getStatus() == ValidationResult.Result.ERROR) {
        return validationResult;
    }
    String errorMessage = "";
    if (queueName.isEmpty()) {
        errorMessage = messages.getMessage("error.NameEmpty");
        return new ValidationResult(ValidationResult.Result.ERROR, errorMessage);
    }
    if (queueName.length() < 3 || queueName.length() > 63) {
        errorMessage = messages.getMessage("error.LengthError");
        return new ValidationResult(ValidationResult.Result.ERROR, errorMessage);
    }
    if (queueName.indexOf("--") > -1) {
        errorMessage = messages.getMessage("error.TwoDashError");
        return new ValidationResult(ValidationResult.Result.ERROR, errorMessage);
    }
    if (!queueCheckNamePattern.matcher(queueName.replaceAll("-", "")).matches()) {
        errorMessage = messages.getMessage("error.QueueNameError");
        return new ValidationResult(ValidationResult.Result.ERROR, errorMessage);
    }
    return ValidationResult.OK;
}
Also used : AzureStorageQueueProperties(org.talend.components.azurestorage.queue.AzureStorageQueueProperties) ValidationResult(org.talend.daikon.properties.ValidationResult)

Example 3 with AzureStorageQueueProperties

use of org.talend.components.azurestorage.queue.AzureStorageQueueProperties in project components by Talend.

the class AzureStorageComponentListProperties method afterFormFinishTable.

public ValidationResult afterFormFinishTable(Repository<Properties> repo) throws Exception {
    connection.BlobSchema = selectedContainerNames.getValue();
    connection.QueueSchema = selectedQueueNames.getValue();
    connection.TableSchema = selectedTableNames.getValue();
    String repoLoc = repo.storeProperties(connection, connection.name.getValue(), repositoryLocation, null);
    String storeId;
    if (selectedContainerNames.getValue() != null) {
        for (NamedThing nl : selectedContainerNames.getValue()) {
            String containerId = nl.getName();
            AzureStorageContainerProperties containerProps = new AzureStorageContainerProperties(containerId);
            containerProps.init();
            containerProps.connection = connection;
            containerProps.container.setValue(containerId);
            containerProps.schema.schema.setValue(getContainerSchema());
            repo.storeProperties(containerProps, formatSchemaName(containerId), repoLoc, "schema.schema");
        }
    }
    if (selectedQueueNames.getValue() != null) {
        for (NamedThing nl : selectedQueueNames.getValue()) {
            String queueId = nl.getName();
            AzureStorageQueueProperties queueProps = new AzureStorageQueueProperties(queueId);
            queueProps.init();
            queueProps.connection = connection;
            queueProps.queueName.setValue(queueId);
            queueProps.schema.schema.setValue(getQueueSchema());
            repo.storeProperties(queueProps, formatSchemaName(queueId), repoLoc, "schema.schema");
        }
    }
    if (selectedTableNames.getValue() != null) {
        for (NamedThing nl : selectedTableNames.getValue()) {
            String tableId = nl.getName();
            AzureStorageTableProperties tableProps = new AzureStorageTableProperties(tableId);
            tableProps.init();
            tableProps.connection = connection;
            tableProps.tableName.setValue(tableId);
            try {
                Schema schema = AzureStorageTableSourceOrSink.getSchema(null, connection, tableId);
                tableProps.schema.schema.setValue(schema);
                repo.storeProperties(tableProps, formatSchemaName(tableId), repoLoc, "schema.schema");
            } catch (IOException e) {
                LOGGER.error(e.getLocalizedMessage());
            }
        }
    }
    return ValidationResult.OK;
}
Also used : AzureStorageContainerProperties(org.talend.components.azurestorage.blob.AzureStorageContainerProperties) Schema(org.apache.avro.Schema) IOException(java.io.IOException) NamedThing(org.talend.daikon.NamedThing) AzureStorageQueueProperties(org.talend.components.azurestorage.queue.AzureStorageQueueProperties) AzureStorageTableProperties(org.talend.components.azurestorage.table.AzureStorageTableProperties)

Aggregations

AzureStorageQueueProperties (org.talend.components.azurestorage.queue.AzureStorageQueueProperties)3 ValidationResult (org.talend.daikon.properties.ValidationResult)2 IOException (java.io.IOException)1 Schema (org.apache.avro.Schema)1 AzureStorageContainerProperties (org.talend.components.azurestorage.blob.AzureStorageContainerProperties)1 TAzureStorageQueueInputProperties (org.talend.components.azurestorage.queue.tazurestoragequeueinput.TAzureStorageQueueInputProperties)1 TAzureStorageQueueListProperties (org.talend.components.azurestorage.queue.tazurestoragequeuelist.TAzureStorageQueueListProperties)1 AzureStorageTableProperties (org.talend.components.azurestorage.table.AzureStorageTableProperties)1 NamedThing (org.talend.daikon.NamedThing)1