Search in sources :

Example 1 with NonExistingDatasourceException

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);
    }
}
Also used : NonExistingDatasourceException(org.pentaho.platform.api.repository.datasource.NonExistingDatasourceException) NodeRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData) UnifiedRepositoryException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryException) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) DatasourceMgmtServiceException(org.pentaho.platform.api.repository.datasource.DatasourceMgmtServiceException)

Example 2 with NonExistingDatasourceException

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);
    }
}
Also used : NonExistingDatasourceException(org.pentaho.platform.api.repository.datasource.NonExistingDatasourceException) ConnectionServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException) DatabaseDialectException(org.pentaho.database.DatabaseDialectException) ConnectionServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException) DuplicateDatasourceException(org.pentaho.platform.api.repository.datasource.DuplicateDatasourceException) DatasourceMgmtServiceException(org.pentaho.platform.api.repository.datasource.DatasourceMgmtServiceException) NonExistingDatasourceException(org.pentaho.platform.api.repository.datasource.NonExistingDatasourceException)

Example 3 with NonExistingDatasourceException

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);
    }
}
Also used : NonExistingDatasourceException(org.pentaho.platform.api.repository.datasource.NonExistingDatasourceException) ConnectionServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException) DatabaseDialectException(org.pentaho.database.DatabaseDialectException) ConnectionServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException) DuplicateDatasourceException(org.pentaho.platform.api.repository.datasource.DuplicateDatasourceException) DatasourceMgmtServiceException(org.pentaho.platform.api.repository.datasource.DatasourceMgmtServiceException) NonExistingDatasourceException(org.pentaho.platform.api.repository.datasource.NonExistingDatasourceException)

Example 4 with NonExistingDatasourceException

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);
    }
}
Also used : NonExistingDatasourceException(org.pentaho.platform.api.repository.datasource.NonExistingDatasourceException) ConnectionServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException) DatabaseDialectException(org.pentaho.database.DatabaseDialectException) ConnectionServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException) DuplicateDatasourceException(org.pentaho.platform.api.repository.datasource.DuplicateDatasourceException) DatasourceMgmtServiceException(org.pentaho.platform.api.repository.datasource.DatasourceMgmtServiceException) NonExistingDatasourceException(org.pentaho.platform.api.repository.datasource.NonExistingDatasourceException)

Aggregations

DatasourceMgmtServiceException (org.pentaho.platform.api.repository.datasource.DatasourceMgmtServiceException)4 NonExistingDatasourceException (org.pentaho.platform.api.repository.datasource.NonExistingDatasourceException)4 DatabaseDialectException (org.pentaho.database.DatabaseDialectException)3 DuplicateDatasourceException (org.pentaho.platform.api.repository.datasource.DuplicateDatasourceException)3 ConnectionServiceException (org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException)3 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)1 UnifiedRepositoryException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryException)1 NodeRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData)1