use of org.pentaho.platform.api.repository2.unified.data.node.DataNode in project pentaho-platform by pentaho.
the class MondrianCatalogHelper method appendCatalogsSection.
@VisibleForTesting
protected void appendCatalogsSection(IUnifiedRepository unifiedRepository, String etcMondrian, RepositoryFile etcMondrianFolder, StringBuffer datasourcesXML) {
// $NON-NLS-1$
datasourcesXML.append("<Catalogs>\n");
// Creates <Catalogs> from the "/etc/mondrian/<catalog>/metadata" nodes.
/*
* IPentahoSession pentahoSession = PentahoSessionHolder.getSession(); String tenantEtcFolder = null;
* if(pentahoSession != null) { String tenantId = (String)
* pentahoSession.getAttribute(IPentahoSession.TENANT_ID_KEY); tenantEtcFolder =
* ServerRepositoryPaths.getTenantEtcFolderPath(tenantId); } else { tenantEtcFolder =
* ServerRepositoryPaths.getTenantEtcFolderPath(); }
*/
List<RepositoryFile> mondrianCatalogs = unifiedRepository.getChildren(etcMondrianFolder.getId());
for (RepositoryFile catalog : mondrianCatalogs) {
String catalogName = catalog.getName();
RepositoryFile metadata = unifiedRepository.getFile(etcMondrian + RepositoryFile.SEPARATOR + catalogName + RepositoryFile.SEPARATOR + // $NON-NLS-1$
"metadata");
if (metadata != null) {
DataNode metadataNode = unifiedRepository.getDataForRead(metadata.getId(), NodeRepositoryFileData.class).getNode();
// $NON-NLS-1$
String datasourceInfo = metadataNode.getProperty("datasourceInfo").getString();
// $NON-NLS-1$
String definition = metadataNode.getProperty("definition").getString();
datasourcesXML.append(// $NON-NLS-1$ //$NON-NLS-2$
"<Catalog name=\"" + Encode.forXml(catalogName) + "\">\n");
datasourcesXML.append("<DataSourceInfo>" + Encode.forXml(datasourceInfo) + // $NON-NLS-1$
"</DataSourceInfo>\n");
datasourcesXML.append(// $NON-NLS-1$ //$NON-NLS-2$
"<Definition>" + Encode.forXml(definition) + "</Definition>\n");
// $NON-NLS-1$
datasourcesXML.append("</Catalog>\n");
} else {
logger.warn(// $NON-NLS-1$
Messages.getInstance().getString("MondrianCatalogHelper.WARN_META_DATA_IS_NULL"));
}
}
// $NON-NLS-1$
datasourcesXML.append("</Catalogs>\n");
}
Aggregations