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"));
}
}
}
}
Aggregations