use of org.pentaho.di.core.exception.KettleRepositoryNotSupportedException in project pentaho-kettle by pentaho.
the class RepositoriesMeta method parseRepositoriesDoc.
protected void parseRepositoriesDoc(Document doc) throws Exception {
// Get the <repositories> node:
Node repsnode = XMLHandler.getSubNode(doc, "repositories");
// Handle connections
int nrconn = XMLHandler.countNodes(repsnode, "connection");
if (log.isDebug()) {
log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Log.ConnectionNumber", nrconn));
}
for (int i = 0; i < nrconn; i++) {
if (log.isDebug()) {
log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Log.LookingConnection", i));
}
Node dbnode = XMLHandler.getSubNodeByNr(repsnode, "connection", i);
DatabaseMeta dbcon = null;
try {
dbcon = new DatabaseMeta(dbnode);
addDatabase(dbcon);
if (log.isDebug()) {
log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Log.ReadConnection", dbcon.getName()));
}
} catch (Exception kpe) {
log.logError(BaseMessages.getString(PKG, "RepositoryMeta.Error.CreatingDatabaseMeta", dbcon.getName()));
}
}
// Handle repositories...
int nrreps = XMLHandler.countNodes(repsnode, RepositoryMeta.XML_TAG);
if (log.isDebug()) {
log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Log.RepositoryNumber", nrreps));
}
StringBuilder unableToReadIds = new StringBuilder();
KettleException kettleException = null;
for (int i = 0; i < nrreps; i++) {
Node repnode = XMLHandler.getSubNodeByNr(repsnode, RepositoryMeta.XML_TAG, i);
if (log.isDebug()) {
log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Log.LookingRepository", i));
}
String id = XMLHandler.getTagValue(repnode, "id");
if (Utils.isEmpty(id)) {
// Backward compatibility : if the id is not defined, it's the database repository!
//
id = KettleDatabaseRepositoryMeta.REPOSITORY_TYPE_ID;
}
try {
RepositoryMeta repositoryMeta = PluginRegistry.getInstance().loadClass(RepositoryPluginType.class, id, RepositoryMeta.class);
if (repositoryMeta != null) {
repositoryMeta.loadXML(repnode, databases);
// repositories dialog
if (repositoryMeta.getDescription() == null || repositoryMeta.getDescription().equals("")) {
repositoryMeta.setDescription(repositoryMeta.getName());
}
addRepository(repositoryMeta);
if (log.isDebug()) {
log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Log.ReadRepository", repositoryMeta.getName()));
}
} else {
unableToReadIds.append(id);
unableToReadIds.append(",");
if (log.isDebug()) {
log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Error.ReadRepositoryId", id));
}
}
} catch (KettleException ex) {
// Get to the root cause
Throwable cause = ex;
kettleException = ex;
while (cause.getCause() != null) {
cause = cause.getCause();
}
if (cause instanceof KettleRepositoryNotSupportedException) {
// If the root cause is a KettleRepositoryNotSupportedException, do not fail
if (log.isDebug()) {
log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Error.UnrecognizedRepositoryType", id));
}
}
}
}
if (unableToReadIds != null && unableToReadIds.length() > 0) {
errorMessage = BaseMessages.getString(PKG, "RepositoryMeta.Error.ReadRepositoryIdNotAvailable", unableToReadIds.substring(0, unableToReadIds.lastIndexOf(",")));
}
if (kettleException != null) {
throw kettleException;
}
}
Aggregations