public List<String> getDatasourceIds() throws DatasourceMgmtServiceException { final List<IDatabaseConnection> datasources = getDatasources(); final List<String> list = new ArrayList<String>(); for ( int i = 0; i < datasources.size(); i++ ) { final IDatabaseConnection connection = datasources.get( i ); list.add( connection.getId() ); } return list; }
public List<IDatabaseConnection> getDatasources() throws DatasourceMgmtServiceException { final ArrayList<IDatabaseConnection> connection = new ArrayList<IDatabaseConnection>( parent.getDatasources() ); final Iterator<IDatabaseConnection> it = connection.iterator(); while ( it.hasNext() ) { final IDatabaseConnection databaseConnection = it.next(); if ( deletedMembersById.contains( databaseConnection.getId() ) ) { it.remove(); } } return connection; }
public List<String> getDatasourceIds() throws DatasourceMgmtServiceException { load(); final ArrayList<String> connections = new ArrayList<String>(); final Collection<SerializedConnection> values = connectionsById.values(); for ( final SerializedConnection co : values ) { connections.add( co.getConnection().getId() ); } return connections; }
public IDatabaseConnection getDatasourceByName( final String name ) throws DatasourceMgmtServiceException { final IDatabaseConnection dataSource = parent.getDatasourceByName( name ); if ( deletedMembersById.contains( dataSource.getId() ) ) { throw new NonExistingDatasourceException(); } return dataSource; }
public void commit() { for ( final String id : deletedMembersById ) { parent.deleteDatasourceById( id ); } final Set<String> datasourceIds = new HashSet<String>( parent.getDatasourceIds() ); for ( final SerializedConnection c : editedMembers.values() ) { final IDatabaseConnection connection = c.getConnection(); if ( datasourceIds.contains( connection.getId() ) ) { parent.updateDatasourceById( connection.getId(), connection ); } else { parent.createDatasource( connection ); } } deletedMembersById.clear(); editedMembers.clear(); } }
public String updateDatasourceById( final String id, final IDatabaseConnection databaseConnection ) throws NonExistingDatasourceException, DatasourceMgmtServiceException { if ( StringUtils.isEmpty( id ) ) { throw new IllegalArgumentException(); } if ( ObjectUtilities.equal( id, databaseConnection.getId() ) == false ) { // the Hitachi Vantara-datasources API is ill defined and allows bad behaviour. throw new IllegalArgumentException(); } if ( deletedMembersById.contains( id ) ) { throw new NonExistingDatasourceException(); } editedMembers.put( id, new SerializedConnection( databaseConnection ) ); return id; }
/** * Returns a response with id of a database connection * * @param name * String representing the name of the database to search * @return Response based on the string value of the connection id * * @throws ConnectionServiceException */ @GET @Path( "/getid" ) @Produces( { APPLICATION_JSON } ) @Facet( name = "Unsupported" ) public Response getConnectionIdByNameWithResponse( @QueryParam( "name" ) String name ) throws ConnectionServiceException { IDatabaseConnection conn = null; Response response; try { conn = connectionService.getConnectionByName( name ); if ( conn != null ) { response = Response.ok().entity( conn.getId() ).build(); } else { response = Response.notModified().build(); } } catch ( Exception ex ) { response = Response.serverError().entity( ex.getMessage() ).build(); } return response; }
public synchronized void deleteDatasourceById( final String id ) throws NonExistingDatasourceException, DatasourceMgmtServiceException { load(); final SerializedConnection connection = connectionsById.get( id ); if ( connection == null ) { throw new NonExistingDatasourceException(); } final IDatabaseConnection databaseConnection = connection.getConnection(); connectionsByName.remove( databaseConnection.getName() ); connectionsById.remove( databaseConnection.getId() ); writeChanges(); }
/** * If password is empty, that means connection sent from UI and user didn't change password. Since we cleaned password * during sending to UI, we need to use stored password. */ private void applySavedPassword( IDatabaseConnection conn ) throws ConnectionServiceException { if ( StringUtils.isBlank( conn.getPassword() ) ) { IDatabaseConnection savedConn; if ( conn.getId() != null ) { savedConn = connectionService.getConnectionById( conn.getId() ); } else { try { savedConn = connectionService.getConnectionByName( conn.getName() ); } catch ( ConnectionServiceException e ) { logger.warn( e.getMessage() ); savedConn = null; } } // The connection might not be in the database because this may be a new // hive connection that doesn't require a password if ( savedConn != null ) { conn.setPassword( savedConn.getPassword() ); } } }
/** * If password is empty, that means client didn't change password. * Since we cleaned password during sending to client, we need to use stored password. * @throws ConnectionServiceException if unable to get connection */ private void applySavedPassword( IDatabaseConnection conn ) throws ConnectionServiceException { if ( StringUtils.isBlank( conn.getPassword() ) ) { IDatabaseConnection savedConn; if ( conn.getId() != null ) { savedConn = service.getConnectionById( conn.getId() ); } else { try { savedConn = service.getConnectionByName( conn.getName() ); } catch ( ConnectionServiceException e ) { logger.warn( e.getMessage() ); savedConn = null; } } // The connection might not be in the database because this may be a new // hive connection that doesn't require a password if ( savedConn != null ) { conn.setPassword( savedConn.getPassword() ); } } }
final DatabaseConnectionCollection collection = (DatabaseConnectionCollection) resource.getResource(); for ( final IDatabaseConnection connection : collection.getConnections() ) { final String id = connection.getId(); final String name = connection.getName(); if ( name == null ) {
public String updateDatasourceByName( String name, IDatabaseConnection databaseConnection ) throws NonExistingDatasourceException, DatasourceMgmtServiceException { RepositoryFile file = null; try { if ( databaseConnection.getId() != null ) { file = repository.getFileById( databaseConnection.getId() ); } else { file = repository.getFile( getPath( name ) ); } } catch ( UnifiedRepositoryException ure ) { throw new DatasourceMgmtServiceException( Messages .getInstance() .getErrorString( "DatasourceMgmtService.ERROR_0003_UNABLE_TO_UPDATE_DATASOURCE", databaseConnection.getName(), ure.getLocalizedMessage() ), ure ); //$NON-NLS-1$ } return updateDatasource( file, databaseConnection ); }
connection.setPassword( old.getPassword() ); connection.setId( old.getId() );
@Override public void startup() { try { String agileMartDatasourceName = PentahoSystem.getSystemSetting( SETTINGS_FILE, AGILE_MART_STAGING_DATASOURCE_NAME, null ); IDatabaseConnection agileMartDatasource = datasourceMgmtService.getDatasourceByName( agileMartDatasourceName ); IDatabaseConnection newAgileMartDatasource = agileMartDatasourceHelper.getAgileMartDatasource(); if ( agileMartDatasource != null ) { newAgileMartDatasource.setId( agileMartDatasource.getId() ); datasourceMgmtService.updateDatasourceByName( agileMartDatasource.getName(), newAgileMartDatasource ); } else { datasourceMgmtService.createDatasource( newAgileMartDatasource ); } } catch ( Throwable th ) { log.warn( "Error during the create/update of AgileMart Datasource", th ); } }
rootAttrs.setAttribute( ConnectionModule.NAMESPACE, "id", databaseConnection.getId() ); rootAttrs.setAttribute( ConnectionModule.NAMESPACE, PROP_CONTYPE, setNull( databaseConnection.getAccessType() .getName() ) );
protected void copyDatabaseConnectionProperties( IDatabaseConnection source, IDatabaseConnection target ) { target.setId( source.getId() ); target.setAccessType( source.getAccessType() ); target.setDatabaseType( source.getDatabaseType() );
protected void copyDatabaseConnectionProperties( IDatabaseConnection source, IDatabaseConnection target ) { target.setId( source.getId() ); target.setAccessType( source.getAccessType() ); target.setDatabaseType( source.getDatabaseType() );
connectionImpl.setForcingIdentifiersToUpperCase( connectionBean.isForcingIdentifiersToUpperCase() ); connectionImpl.setHostname( connectionBean.getHostname() ); connectionImpl.setId( connectionBean.getId() ); connectionImpl.setIndexTablespace( connectionBean.getIndexTablespace() ); connectionImpl.setInformixServername( connectionBean.getInformixServername() );