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