use of org.pentaho.platform.api.repository.datasource.NonExistingDatasourceException in project pentaho-platform by pentaho.
the class JcrBackedDatasourceMgmtService method updateDatasource.
private String updateDatasource(RepositoryFile file, IDatabaseConnection databaseConnection) throws NonExistingDatasourceException, DatasourceMgmtServiceException {
try {
if (file != null) {
file = new RepositoryFile.Builder(file).versionId(file.getVersionId()).id(file.getId()).title(RepositoryFile.DEFAULT_LOCALE, databaseConnection.getName()).build();
file = repository.updateFile(file, new NodeRepositoryFileData(databaseHelper.databaseConnectionToDataNode(databaseConnection)), null);
renameIfNecessary(databaseConnection, file);
return file.getId().toString();
} else {
throw new NonExistingDatasourceException(Messages.getInstance().getErrorString("DatasourceMgmtService.ERROR_0006_DATASOURCE_DOES_NOT_EXIST", // $NON-NLS-1$
databaseConnection.getName()));
}
// } catch(PasswordServiceException pse) {
// throw new DatasourceMgmtServiceException(Messages.getInstance()
// .getErrorString("DatasourceMgmtService.ERROR_0007_UNABLE_TO_ENCRYPT_PASSWORD"), pse ); //$NON-NLS-1$
} catch (UnifiedRepositoryException ure) {
throw new DatasourceMgmtServiceException(Messages.getInstance().getErrorString("DatasourceMgmtService.ERROR_0003_UNABLE_TO_UPDATE_DATASOURCE", databaseConnection.getName(), ure.getLocalizedMessage()), // $NON-NLS-1$
ure);
}
}
use of org.pentaho.platform.api.repository.datasource.NonExistingDatasourceException in project data-access by pentaho.
the class ConnectionServiceImpl method deleteConnection.
public boolean deleteConnection(String name) throws ConnectionServiceException {
ensureDataAccessPermission();
name = sanitizer.safeEscapeHtml(name);
try {
datasourceMgmtSvc.deleteDatasourceByName(name);
clearDatasource(name);
return true;
} catch (NonExistingDatasourceException nonExistingDatasourceException) {
String message = // $NON-NLS-1$
Messages.getErrorString(// $NON-NLS-1$
"ConnectionServiceImpl.ERROR_0006_UNABLE_TO_DELETE_CONNECTION", name, nonExistingDatasourceException.getLocalizedMessage());
throw new ConnectionServiceException(Response.SC_NOT_FOUND, message, nonExistingDatasourceException);
} catch (Exception e) {
String message = // $NON-NLS-1$
Messages.getErrorString(// $NON-NLS-1$
"ConnectionServiceImpl.ERROR_0006_UNABLE_TO_DELETE_CONNECTION", name, e.getLocalizedMessage());
logger.error(message);
throw new ConnectionServiceException(message, e);
}
}
use of org.pentaho.platform.api.repository.datasource.NonExistingDatasourceException in project data-access by pentaho.
the class ConnectionServiceImpl method updateConnection.
public boolean updateConnection(IDatabaseConnection connection) throws ConnectionServiceException {
ensureDataAccessPermission();
try {
connection.setPassword(getConnectionPassword(connection.getName(), connection.getPassword()));
datasourceMgmtSvc.updateDatasourceByName(connection.getName(), connection);
clearDatasource(connection.getName());
return true;
} catch (NonExistingDatasourceException nonExistingDatasourceException) {
String message = Messages.getErrorString(// $NON-NLS-1$
"ConnectionServiceImpl.ERROR_0005_UNABLE_TO_UPDATE_CONNECTION", connection.getName(), nonExistingDatasourceException.getLocalizedMessage());
throw new ConnectionServiceException(Response.SC_NOT_FOUND, message, nonExistingDatasourceException);
} catch (Exception e) {
String message = Messages.getErrorString(// $NON-NLS-1$
"ConnectionServiceImpl.ERROR_0005_UNABLE_TO_UPDATE_CONNECTION", connection.getName(), e.getLocalizedMessage());
logger.error(message);
throw new ConnectionServiceException(message, e);
}
}
use of org.pentaho.platform.api.repository.datasource.NonExistingDatasourceException in project data-access by pentaho.
the class ConnectionServiceImpl method deleteConnection.
public boolean deleteConnection(IDatabaseConnection connection) throws ConnectionServiceException {
ensureDataAccessPermission();
sanitizer.sanitizeConnectionParameters(connection);
try {
datasourceMgmtSvc.deleteDatasourceByName(connection.getName());
clearDatasource(connection.getName());
return true;
} catch (NonExistingDatasourceException nonExistingDatasourceException) {
String message = // $NON-NLS-1$
Messages.getErrorString(// $NON-NLS-1$
"ConnectionServiceImpl.ERROR_0006_UNABLE_TO_DELETE_CONNECTION", connection.getName(), nonExistingDatasourceException.getLocalizedMessage());
throw new ConnectionServiceException(Response.SC_NOT_FOUND, message, nonExistingDatasourceException);
} catch (Exception e) {
String message = // $NON-NLS-1$
Messages.getErrorString(// $NON-NLS-1$
"ConnectionServiceImpl.ERROR_0006_UNABLE_TO_DELETE_CONNECTION", connection.getName(), e.getLocalizedMessage());
logger.error(message);
throw new ConnectionServiceException(message, e);
}
}
Aggregations