use of org.teiid.core.TeiidRuntimeException in project teiid by teiid.
the class FtpManagedConnectionFactory method setCertificate.
public void setCertificate(String certificate) {
this.certificate = certificate;
if (this.certificate != null && Files.exists(Paths.get(this.certificate))) {
try {
// $NON-NLS-1$
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
InputStream in = Files.newInputStream(Paths.get(this.certificate));
Certificate cert = certificateFactory.generateCertificate(in);
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null);
// $NON-NLS-1$
keyStore.setCertificateEntry("alias", cert);
trustManager = TrustManagerUtils.getDefaultTrustManager(keyStore);
} catch (IOException | GeneralSecurityException e) {
// $NON-NLS-1$
throw new TeiidRuntimeException(UTIL.getString("ftp_certificate_path", certificate, e));
}
}
}
use of org.teiid.core.TeiidRuntimeException in project teiid by teiid.
the class DataTierManagerImpl method getColumns.
private List<ElementSymbol> getColumns(TransformationMetadata tm, String name) {
GroupSymbol gs = new GroupSymbol(name);
try {
ResolverUtil.resolveGroup(gs, tm);
List<ElementSymbol> columns = ResolverUtil.resolveElementsInGroup(gs, tm);
return columns;
} catch (TeiidException e) {
throw new TeiidRuntimeException(e);
}
}
use of org.teiid.core.TeiidRuntimeException in project teiid by teiid.
the class LanguageBridgeFactory method translate.
/* Execute */
Call translate(StoredProcedure sp) {
Procedure proc = null;
if (sp.getProcedureID() != null) {
try {
proc = this.metadataFactory.getProcedure(sp.getGroup().getName());
} catch (TranslatorException e) {
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30486, e);
}
}
Class<?> returnType = null;
List<Argument> translatedParameters = new ArrayList<Argument>();
for (SPParameter param : sp.getParameters()) {
Direction direction = Direction.IN;
switch(param.getParameterType()) {
case ParameterInfo.IN:
direction = Direction.IN;
break;
case ParameterInfo.INOUT:
direction = Direction.INOUT;
break;
case ParameterInfo.OUT:
direction = Direction.OUT;
break;
case ParameterInfo.RESULT_SET:
// already part of the metadata
continue;
case ParameterInfo.RETURN_VALUE:
returnType = param.getClassType();
continue;
}
if (param.isUsingDefault() && BaseColumn.OMIT_DEFAULT.equalsIgnoreCase(metadataFactory.getMetadata().getExtensionProperty(param.getMetadataID(), BaseColumn.DEFAULT_HANDLING, false))) {
continue;
}
ProcedureParameter metadataParam = metadataFactory.getParameter(param);
// we can assume for now that all arguments will be literals, which may be multivalued
org.teiid.language.Expression value = null;
if (direction != Direction.OUT) {
if (param.isVarArg()) {
ArrayImpl av = (ArrayImpl) ((Constant) param.getExpression()).getValue();
if (av != null) {
for (Object obj : av.getValues()) {
Argument arg = new Argument(direction, new Literal(obj, param.getClassType().getComponentType()), param.getClassType().getComponentType(), metadataParam);
translatedParameters.add(arg);
}
}
break;
}
value = translate(param.getExpression());
}
Argument arg = new Argument(direction, value, param.getClassType(), metadataParam);
translatedParameters.add(arg);
}
Call call = new Call(removeSchemaName(sp.getProcedureName()), translatedParameters, proc);
call.setReturnType(returnType);
return call;
}
use of org.teiid.core.TeiidRuntimeException in project teiid by teiid.
the class LanguageBridgeFactory method translate.
public NamedTable translate(GroupSymbol symbol) {
String alias = null;
String fullGroup = symbol.getOutputName();
if (symbol.getOutputDefinition() != null) {
alias = symbol.getOutputName();
fullGroup = symbol.getOutputDefinition();
if (remappedGroups != null) {
GroupSymbol remappedGroup = remappedGroups.get(symbol.getMetadataID());
if (remappedGroup != null && remappedGroup != symbol) {
fullGroup = remappedGroup.getName();
}
}
}
fullGroup = removeSchemaName(fullGroup);
NamedTable group = new NamedTable(fullGroup, alias, null);
try {
group.setMetadataObject(metadataFactory.getGroup(symbol.getMetadataID()));
} catch (QueryMetadataException e) {
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30487, e);
} catch (TeiidComponentException e) {
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30488, e);
}
return group;
}
use of org.teiid.core.TeiidRuntimeException in project teiid by teiid.
the class CachedFinder method findCapabilities.
/**
* Find capabilities used the cache if possible, otherwise do the lookup.
*/
public SourceCapabilities findCapabilities(String modelName) throws TeiidComponentException {
SourceCapabilities caps = userCache.get(modelName);
if (caps != null) {
return caps;
}
ModelMetaData model = vdb.getModel(modelName);
List<String> sourceNames = model.getSourceNames();
if (sourceNames.isEmpty()) {
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30499, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30499, modelName));
}
TeiidException cause = null;
for (String sourceName : sourceNames) {
// TOOD: in multi-source mode it may be necessary to compute minimal capabilities across the sources
ConnectorManager mgr = this.connectorRepo.getConnectorManager(sourceName);
if (mgr == null) {
throw new TeiidComponentException(QueryPlugin.Event.TEIID30497, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30497, sourceName, modelName, sourceName));
}
try {
caps = mgr.getCapabilities();
break;
} catch (TeiidException e) {
cause = e;
// $NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_DQP, e, "Could not obtain capabilities for" + sourceName);
}
}
if (caps == null) {
InvalidCaps ic = new InvalidCaps();
ic.setSourceProperty(Capability.INVALID_EXCEPTION, cause);
caps = ic;
}
userCache.put(modelName, caps);
return caps;
}
Aggregations