Search in sources :

Example 1 with AzureStorageContainerProperties

use of org.talend.components.azurestorage.blob.AzureStorageContainerProperties in project components by Talend.

the class AzureStorageContainerRuntime method initialize.

@Override
public ValidationResult initialize(RuntimeContainer runtimeContainer, ComponentProperties properties) {
    // init
    AzureStorageContainerProperties componentProperties = (AzureStorageContainerProperties) properties;
    this.containerName = componentProperties.container.getValue();
    // validate
    ValidationResult validationResult = super.initialize(runtimeContainer, properties);
    if (validationResult.getStatus() == ValidationResult.Result.ERROR) {
        return validationResult;
    }
    String errorMessage = "";
    // not empty
    if (StringUtils.isEmpty(containerName)) {
        errorMessage = messages.getMessage("error.ContainerEmpty");
    } else // valid characters 0-9 a-z and -
    if (!StringUtils.isAlphanumeric(containerName.replaceAll("-", ""))) {
        errorMessage = messages.getMessage("error.IncorrectName");
    } else // all lowercase
    if (!StringUtils.isAllLowerCase(containerName.replaceAll("(-|\\d)", ""))) {
        errorMessage = messages.getMessage("error.UppercaseName");
    } else // length range : 3-63
    if ((containerName.length() < 3) || (containerName.length() > 63)) {
        errorMessage = messages.getMessage("error.LengthError");
    }
    if (errorMessage.isEmpty()) {
        return ValidationResult.OK;
    } else {
        return new ValidationResult(ValidationResult.Result.ERROR, errorMessage);
    }
}
Also used : AzureStorageContainerProperties(org.talend.components.azurestorage.blob.AzureStorageContainerProperties) ValidationResult(org.talend.daikon.properties.ValidationResult)

Example 2 with AzureStorageContainerProperties

use of org.talend.components.azurestorage.blob.AzureStorageContainerProperties 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

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