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);
}
}
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;
}
Aggregations