use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class MarkLogicConnectionProperties method validateTestConnection.
public ValidationResult validateTestConnection() {
ValidationResult vr;
try (SandboxedInstance sandbox = SandboxInstanceFactory.createSandboxedInstance(RuntimeInfoProvider.getCommonRuntimeInfo(MarkLogicDatastoreDefinition.DATASTORE_RUNTIME), MarkLogicConnectionProperties.class.getClassLoader(), false)) {
DatastoreRuntime<MarkLogicConnectionProperties> datastoreRuntime = (DatastoreRuntime<MarkLogicConnectionProperties>) sandbox.getInstance();
datastoreRuntime.initialize(null, this);
ValidationResultMutable vrm = new ValidationResultMutable(datastoreRuntime.doHealthChecks(null).iterator().next());
if (vrm.getStatus() == ValidationResult.Result.OK) {
vrm.setMessage(getI18nMessage("messages.connectionSuccessful"));
getForm(WIZARD).setAllowFinish(true);
} else {
getForm(WIZARD).setAllowFinish(false);
}
vr = vrm;
} catch (Exception e) {
vr = new ValidationResult(Result.ERROR, e.getMessage());
}
return vr;
}
use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class PubSubDatasetProperties method beforeTopic.
public ValidationResult beforeTopic() {
PubSubDatasetDefinition definition = new PubSubDatasetDefinition();
RuntimeInfo runtimeInfo = definition.getRuntimeInfo(this);
try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, getClass().getClassLoader())) {
IPubSubDatasetRuntime runtime = (IPubSubDatasetRuntime) sandboxedInstance.getInstance();
runtime.initialize(null, this);
List<NamedThing> topics = new ArrayList<>();
for (String topicName : runtime.listTopics()) {
topics.add(new SimpleNamedThing(topicName, topicName));
}
topic.setPossibleValues(topics);
return ValidationResult.OK;
} catch (Exception e) {
return new ValidationResult(new ComponentException(e));
}
}
use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class SalesforceModuleListProperties method beforeFormPresentMain.
public void beforeFormPresentMain() throws Exception {
try (SandboxedInstance sandboxedInstance = getSandboxedInstance(SOURCE_OR_SINK_CLASS, USE_CURRENT_JVM_PROPS)) {
SalesforceRuntimeSourceOrSink ss = (SalesforceRuntimeSourceOrSink) sandboxedInstance.getInstance();
ss.initialize(null, this);
ValidationResult vr = ss.validate(null);
if (vr.getStatus() == ValidationResult.Result.OK) {
try {
moduleNames = ss.getSchemaNames(null);
} catch (Exception ex) {
throw new ComponentException(ExceptionUtil.exceptionToValidationResult(ex));
}
selectedModuleNames.setPossibleValues(moduleNames);
getForm(Form.MAIN).setAllowBack(true);
getForm(Form.MAIN).setAllowFinish(true);
} else {
throw new ComponentException(vr);
}
}
}
use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class TSalesforceInputProperties method validateGuessSchema.
public ValidationResult validateGuessSchema() {
ValidationResultMutable validationResult = new ValidationResultMutable();
try (SandboxedInstance sandboxedInstance = getSandboxedInstance(SOURCE_OR_SINK_CLASS)) {
SalesforceRuntimeSourceOrSink salesforceSourceOrSink = (SalesforceRuntimeSourceOrSink) sandboxedInstance.getInstance();
salesforceSourceOrSink.initialize(null, this);
Schema schema = ((SalesforceSchemaHelper<Schema>) salesforceSourceOrSink).guessSchema(query.getValue());
module.main.schema.setValue(schema);
validationResult.setStatus(ValidationResult.Result.OK);
} catch (TalendRuntimeException tre) {
String errorMessage = getI18nMessage("errorMessage.validateGuessSchemaSoqlError", tre.getMessage());
validationResult.setStatus(ValidationResult.Result.ERROR).setMessage(errorMessage);
} catch (RuntimeException e1) {
String errorMessage = getI18nMessage("errorMessage.validateGuessSchemaRuntimeError", e1.getMessage());
validationResult.setStatus(ValidationResult.Result.ERROR).setMessage(errorMessage);
} catch (IOException e2) {
String errorMessage = getI18nMessage("errorMessage.validateGuessSchemaConnectionError", e2.getMessage());
validationResult.setStatus(ValidationResult.Result.ERROR).setMessage(errorMessage);
}
return validationResult;
}
use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class SalesforceSourceOrSink method getSchemaNames.
public static List<NamedThing> getSchemaNames(RuntimeContainer container, SalesforceProvideConnectionProperties properties) throws IOException {
ClassLoader classLoader = SalesforceSourceOrSink.class.getClassLoader();
// org.talend.components.salesforce.runtime.common.SalesforceRuntimeCommon.enableTLSv11AndTLSv12ForJava7()
try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClassWithCurrentJVMProperties(getStaticRuntimeInfo(), classLoader)) {
SalesforceSourceOrSink ss = (SalesforceSourceOrSink) sandboxedInstance.getInstance();
ss.initialize(null, (ComponentProperties) properties);
try {
ss.connect(container);
return ss.getSchemaNames(container);
} catch (Exception ex) {
throw new ComponentException(SalesforceRuntimeCommon.exceptionToValidationResult(ex));
}
}
}
Aggregations