use of org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException in project teiid by teiid.
the class FakeServer method deployVDB.
public void deployVDB(String vdbName, MetadataStore metadata, DeployVDBParameter parameterObject) {
VDBMetaData vdbMetaData = null;
try {
if (parameterObject.vdbResources != null && parameterObject.useVdbXml) {
VDBResource resource = parameterObject.vdbResources.get("/META-INF/vdb.xml");
if (resource != null) {
vdbMetaData = VDBMetadataParser.unmarshell(resource.openStream());
}
}
if (vdbMetaData == null) {
vdbMetaData = new VDBMetaData();
vdbMetaData.setName(vdbName);
for (Schema schema : metadata.getSchemas().values()) {
ModelMetaData model = addModel(vdbMetaData, schema);
if (parameterObject.metadataRepo != null) {
model.addAttchment(MetadataRepository.class, parameterObject.metadataRepo);
// fakeserver does not load through the repository framework, so call load after the fact here.
MetadataFactory mf = createMetadataFactory(vdbMetaData, metadata, model, parameterObject.vdbResources);
mf.setSchema(schema);
try {
parameterObject.metadataRepo.loadMetadata(mf, null, null);
} catch (TranslatorException e) {
throw new TeiidRuntimeException(e);
}
}
}
} else {
if (!parameterObject.useDataRoles) {
vdbMetaData.setDataPolicies(Collections.EMPTY_LIST);
}
cmr.createConnectorManagers(vdbMetaData, this);
}
UDFMetaData udfMetaData = null;
if (parameterObject.udfs != null) {
udfMetaData = new UDFMetaData();
for (Map.Entry<String, Collection<FunctionMethod>> entry : parameterObject.udfs.entrySet()) {
udfMetaData.addFunctions(entry.getKey(), entry.getValue());
}
}
if (parameterObject.vdbImports != null) {
for (VDBImportMetadata vdbImport : parameterObject.vdbImports) {
vdbMetaData.getVDBImports().add(vdbImport);
}
}
vdbMetaData.setStatus(VDB.Status.ACTIVE);
this.repo.addVDB(vdbMetaData, metadata, parameterObject.vdbResources, udfMetaData, cmr);
this.repo.finishDeployment(vdbMetaData.getName(), vdbMetaData.getVersion());
this.repo.getLiveVDB(vdbMetaData.getName(), vdbMetaData.getVersion()).setStatus(VDB.Status.ACTIVE);
} catch (VirtualDatabaseException e) {
throw new RuntimeException(e);
} catch (ConnectorManagerException e) {
throw new RuntimeException(e);
} catch (XMLStreamException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations