Search in sources :

Example 11 with EEUserInfo

use of org.pentaho.di.repository.pur.model.EEUserInfo in project pentaho-kettle by pentaho.

the class PurRepository method connect.

@Override
public void connect(final String username, final String password) throws KettleException {
    connected = false;
    if (isTest()) {
        connected = true;
        purRepositoryServiceRegistry.registerService(IRevisionService.class, new UnifiedRepositoryRevisionService(pur, getRootRef()));
        purRepositoryServiceRegistry.registerService(ILockService.class, new UnifiedRepositoryLockService(pur));
        purRepositoryServiceRegistry.registerService(IAclService.class, new UnifiedRepositoryConnectionAclService(pur));
        metaStore = new PurRepositoryMetaStore(this);
        try {
            metaStore.createNamespace(PentahoDefaults.NAMESPACE);
        } catch (MetaStoreException e) {
            log.logError(BaseMessages.getString(PKG, "PurRepositoryMetastore.NamespaceCreateException.Message", PentahoDefaults.NAMESPACE), e);
        }
        this.user = new EEUserInfo(username, password, username, "test user", true);
        this.jobDelegate = new JobDelegate(this, pur);
        this.transDelegate = new TransDelegate(this, pur);
        this.unifiedRepositoryLockService = new UnifiedRepositoryLockService(pur);
        return;
    }
    try {
        if (log != null && purRepositoryConnector != null && purRepositoryConnector.getLog() != null) {
            purRepositoryConnector.getLog().setLogLevel(log.getLogLevel());
        }
        RepositoryConnectResult result = purRepositoryConnector.connect(username, password);
        this.user = result.getUser();
        this.connected = result.isSuccess();
        this.securityProvider = result.getSecurityProvider();
        this.securityManager = result.getSecurityManager();
        IUnifiedRepository r = result.getUnifiedRepository();
        try {
            this.pur = (IUnifiedRepository) Proxy.newProxyInstance(r.getClass().getClassLoader(), new Class<?>[] { IUnifiedRepository.class }, new UnifiedRepositoryInvocationHandler<IUnifiedRepository>(r));
            if (this.securityProvider != null) {
                this.securityProvider = (RepositorySecurityProvider) Proxy.newProxyInstance(this.securityProvider.getClass().getClassLoader(), new Class<?>[] { RepositorySecurityProvider.class }, new UnifiedRepositoryInvocationHandler<RepositorySecurityProvider>(this.securityProvider));
            }
        } catch (Throwable th) {
            if (log.isError()) {
                log.logError("Failed to setup repository connection", th);
            }
            connected = false;
        }
        this.unifiedRepositoryLockService = new UnifiedRepositoryLockService(pur);
        this.connectMessage = result.getConnectMessage();
        this.purRepositoryServiceRegistry = result.repositoryServiceRegistry();
        this.transDelegate = new TransDelegate(this, pur);
        this.jobDelegate = new JobDelegate(this, pur);
    } finally {
        if (connected) {
            if (log.isBasic()) {
                log.logBasic(BaseMessages.getString(PKG, "PurRepositoryMetastore.Create.Message"));
            }
            metaStore = new PurRepositoryMetaStore(this);
            // Create the default Pentaho namespace if it does not exist
            try {
                metaStore.createNamespace(PentahoDefaults.NAMESPACE);
                if (log.isBasic()) {
                    log.logBasic(BaseMessages.getString(PKG, "PurRepositoryMetastore.NamespaceCreateSuccess.Message", PentahoDefaults.NAMESPACE));
                }
            } catch (MetaStoreNamespaceExistsException e) {
            // Ignore this exception, we only use it to save a call to check if the namespace exists, as the
            // createNamespace()
            // call will do the check for us and throw this exception.
            } catch (MetaStoreException e) {
                log.logError(BaseMessages.getString(PKG, "PurRepositoryMetastore.NamespaceCreateException.Message", PentahoDefaults.NAMESPACE), e);
            }
            if (log.isBasic()) {
                log.logBasic(BaseMessages.getString(PKG, "PurRepository.ConnectSuccess.Message"));
            }
        }
    }
}
Also used : EEUserInfo(org.pentaho.di.repository.pur.model.EEUserInfo) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) RepositorySecurityProvider(org.pentaho.di.repository.RepositorySecurityProvider) PurRepositoryMetaStore(org.pentaho.di.repository.pur.metastore.PurRepositoryMetaStore) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository)

Aggregations

EEUserInfo (org.pentaho.di.repository.pur.model.EEUserInfo)11 Test (org.junit.Test)6 UIRepositoryRole (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryRole)6 HashSet (java.util.HashSet)5 IUIRole (org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole)4 IUser (org.pentaho.di.repository.IUser)3 EERoleInfo (org.pentaho.di.repository.pur.model.EERoleInfo)3 UIEERepositoryUser (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEERepositoryUser)3 Before (org.junit.Before)2 IRole (org.pentaho.di.repository.pur.model.IRole)2 IRoleSupportSecurityManager (org.pentaho.di.ui.repository.pur.services.IRoleSupportSecurityManager)2 IUIUser (org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser)2 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)2 IRepositorySyncWebService (com.pentaho.pdi.ws.IRepositorySyncWebService)1 RepositorySyncException (com.pentaho.pdi.ws.RepositorySyncException)1 ClientTransportException (com.sun.xml.ws.client.ClientTransportException)1 ExecutorService (java.util.concurrent.ExecutorService)1 WebServiceException (javax.xml.ws.WebServiceException)1 HttpResponse (org.apache.http.HttpResponse)1 UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)1