use of org.talend.components.azurestorage.tazurestorageconnection.TAzureStorageConnectionProperties in project components by Talend.
the class AzureStorageTableWriterTest method setUp.
@Before
public void setUp() throws Exception {
container = new RuntimeContainerMock();
sink = new AzureStorageTableSink();
properties = new TAzureStorageOutputTableProperties(PROP_ + "InputTable");
properties.setupProperties();
// valid fake connection
properties.connection = new TAzureStorageConnectionProperties(PROP_ + "Connection");
properties.connection.protocol.setValue(Protocol.HTTP);
properties.connection.accountName.setValue("fakeAccountName");
properties.connection.accountKey.setValue("fakeAccountKey=ANBHFYRJJFHRIKKJFU");
properties.dieOnError.setValue(false);
properties.tableName.setValue(TableHelper.generateRandomTableName());
properties.actionOnTable.setValue(ActionOnTable.Create_table_if_does_not_exist);
properties.actionOnData.setValue(ActionOnData.Insert);
properties.schema.schema.setValue(TableHelper.getWriteSchema());
properties.schemaReject.schema.setValue(TableHelper.getRejectSchema());
properties.partitionKey.setStoredValue("PartitionKey");
properties.rowKey.setStoredValue("RowKey");
}
use of org.talend.components.azurestorage.tazurestorageconnection.TAzureStorageConnectionProperties in project components by Talend.
the class AzureStorageComponentListPropertiesTest method testSetConnection.
/**
* @see org.talend.components.azurestorage.wizard.AzureStorageComponentListProperties#setConnection(TAzureStorageConnectionProperties)
*/
@Test
public void testSetConnection() {
TAzureStorageConnectionProperties connection = new TAzureStorageConnectionProperties(null);
AzureStorageComponentListProperties result = properties.setConnection(connection);
assertNotNull("result cannot be null", result.getConnectionProperties());
}
use of org.talend.components.azurestorage.tazurestorageconnection.TAzureStorageConnectionProperties in project components by Talend.
the class AzureStorageRuntime method getAzureConnection.
public AzureConnection getAzureConnection(RuntimeContainer runtimeContainer) {
TAzureStorageConnectionProperties conn = getUsedConnection(runtimeContainer);
if (conn.useSharedAccessSignature.getValue()) {
// extract account name and sas token from sas url
Matcher m = Pattern.compile(SAS_PATTERN).matcher(conn.sharedAccessSignature.getValue());
m.matches();
return //
AzureConnectionWithSasService.builder().accountName(//
m.group(2)).sasToken(//
m.group(4)).build();
} else {
return //
AzureConnectionWithKeyService.builder().protocol(//
conn.protocol.getValue().toString().toLowerCase()).accountName(//
conn.accountName.getValue()).accountKey(conn.accountKey.getValue()).build();
}
}
use of org.talend.components.azurestorage.tazurestorageconnection.TAzureStorageConnectionProperties in project components by Talend.
the class AzureStorageRuntime method initialize.
@Override
public ValidationResult initialize(RuntimeContainer runtimeContainer, ComponentProperties properties) {
// init
this.properties = (AzureStorageProvideConnectionProperties) properties;
TAzureStorageConnectionProperties conn = getUsedConnection(runtimeContainer);
// Validate connection properties
String errorMessage = "";
if (conn == null) {
// check connection failure
// $NON-NLS-1$
errorMessage = messages.getMessage("error.VacantConnection");
} else if (conn.useSharedAccessSignature.getValue()) {
// checks
if (StringUtils.isEmpty(conn.sharedAccessSignature.getStringValue())) {
// $NON-NLS-1$
errorMessage = messages.getMessage("error.EmptySAS");
} else {
Matcher m = Pattern.compile(SAS_PATTERN).matcher(conn.sharedAccessSignature.getValue());
if (!m.matches()) {
errorMessage = messages.getMessage("error.InvalidSAS");
}
}
} else if (!conn.useSharedAccessSignature.getValue() && (StringUtils.isEmpty(conn.accountName.getStringValue()) || StringUtils.isEmpty(conn.accountKey.getStringValue()))) {
// checks connection's account and key
// $NON-NLS-1$
errorMessage = messages.getMessage("error.EmptyKey");
}
// Return result
if (errorMessage.isEmpty()) {
return ValidationResult.OK;
} else {
return new ValidationResult(ValidationResult.Result.ERROR, errorMessage);
}
}
use of org.talend.components.azurestorage.tazurestorageconnection.TAzureStorageConnectionProperties in project components by Talend.
the class AzureStorageRuntime method getUsedConnection.
public TAzureStorageConnectionProperties getUsedConnection(RuntimeContainer runtimeContainer) {
TAzureStorageConnectionProperties connectionProperties = ((AzureStorageProvideConnectionProperties) properties).getConnectionProperties();
String refComponentId = connectionProperties.getReferencedComponentId();
// Using another component's connection
if (refComponentId != null) {
// In a runtime container
if (runtimeContainer != null) {
TAzureStorageConnectionProperties sharedConn = (TAzureStorageConnectionProperties) runtimeContainer.getComponentData(refComponentId, KEY_CONNECTION_PROPERTIES);
if (sharedConn != null) {
return sharedConn;
}
}
// Design time
connectionProperties = connectionProperties.getReferencedConnectionProperties();
}
if (runtimeContainer != null) {
runtimeContainer.setComponentData(runtimeContainer.getCurrentComponentId(), KEY_CONNECTION_PROPERTIES, connectionProperties);
}
return connectionProperties;
}
Aggregations