use of org.pentaho.di.repository.RepositorySecurityProvider in project pentaho-kettle by pentaho.
the class Spoon method checkIsVersioningEnabledOnServer.
private static boolean checkIsVersioningEnabledOnServer(Repository rep, EngineMetaInterface jobTransMeta) {
boolean versioningEnabled = true;
String fullPath = getJobTransfFullPath(jobTransMeta);
RepositorySecurityProvider repositorySecurityProvider = rep != null && rep.getSecurityProvider() != null ? rep.getSecurityProvider() : null;
if (repositorySecurityProvider != null && fullPath != null) {
versioningEnabled = repositorySecurityProvider.isVersioningEnabled(fullPath);
}
return versioningEnabled;
}
use of org.pentaho.di.repository.RepositorySecurityProvider in project pentaho-kettle by pentaho.
the class Spoon method saveToRepositoryConfirmed.
public boolean saveToRepositoryConfirmed(EngineMetaInterface meta) throws KettleException {
if (!Utils.isEmpty(meta.getName()) && rep != null) {
ObjectId existingId = null;
if (meta instanceof TransMeta) {
existingId = rep.getTransformationID(meta.getName(), meta.getRepositoryDirectory());
}
if (meta instanceof JobMeta) {
existingId = rep.getJobId(meta.getName(), meta.getRepositoryDirectory());
}
boolean saved = false;
if (meta.getObjectId() == null) {
meta.setObjectId(existingId);
}
try {
shell.setCursor(cursor_hourglass);
// created and or modified...
if (meta.getCreatedDate() == null) {
meta.setCreatedDate(new Date());
if (capabilities.supportsUsers()) {
meta.setCreatedUser(rep.getUserInfo().getLogin());
}
}
// Keep info on who & when this transformation was
// changed...
meta.setModifiedDate(new Date());
if (capabilities.supportsUsers()) {
meta.setModifiedUser(rep.getUserInfo().getLogin());
}
boolean versioningEnabled = true;
boolean versionCommentsEnabled = true;
String fullPath = getJobTransfFullPath(meta);
RepositorySecurityProvider repositorySecurityProvider = rep != null && rep.getSecurityProvider() != null ? rep.getSecurityProvider() : null;
if (repositorySecurityProvider != null && fullPath != null) {
versioningEnabled = repositorySecurityProvider.isVersioningEnabled(fullPath);
versionCommentsEnabled = repositorySecurityProvider.allowsVersionComments(fullPath);
}
// Finally before saving, ask for a version comment (if
// applicable)
//
String versionComment = null;
boolean versionOk;
if (!versioningEnabled || !versionCommentsEnabled) {
versionOk = true;
versionComment = "";
} else {
versionOk = false;
}
while (!versionOk) {
versionComment = RepositorySecurityUI.getVersionComment(shell, rep, meta.getName(), fullPath, false);
// if the version comment is null, the user hit cancel, exit.
if (rep != null && rep.getSecurityProvider() != null && rep.getSecurityProvider().allowsVersionComments(fullPath) && versionComment == null) {
return false;
}
if (Utils.isEmpty(versionComment) && rep.getSecurityProvider().isVersioningEnabled(fullPath) && rep.getSecurityProvider().isVersionCommentMandatory()) {
if (!RepositorySecurityUI.showVersionCommentMandatoryDialog(shell)) {
// no, I don't want to enter a
return false;
// version comment and yes,
// it's mandatory.
}
} else {
versionOk = true;
}
}
if (versionOk) {
SaveProgressDialog spd = new SaveProgressDialog(shell, rep, meta, versionComment);
if (spd.open()) {
saved = true;
if (!props.getSaveConfirmation()) {
MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "Spoon.Message.Warning.SaveOK"), null, BaseMessages.getString(PKG, "Spoon.Message.Warning.TransformationWasStored"), MessageDialog.QUESTION, new String[] { BaseMessages.getString(PKG, "Spoon.Message.Warning.OK") }, 0, BaseMessages.getString(PKG, "Spoon.Message.Warning.NotShowThisMessage"), props.getSaveConfirmation());
MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
md.open();
props.setSaveConfirmation(md.getToggleState());
}
// Handle last opened files...
props.addLastFile(meta.getFileType(), meta.getName(), meta.getRepositoryDirectory().getPath(), true, getRepositoryName(), getUsername(), null);
saveSettings();
addMenuLast();
setShellText();
}
}
} finally {
shell.setCursor(null);
}
return saved;
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
// "There is no repository connection available."
mb.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.NoRepositoryConnection.Message"));
// "No repository available."
mb.setText(BaseMessages.getString(PKG, "Spoon.Dialog.NoRepositoryConnection.Title"));
mb.open();
}
return false;
}
use of org.pentaho.di.repository.RepositorySecurityProvider in project pentaho-kettle by pentaho.
the class AbstractPermissionsController method init.
protected void init(Repository rep) throws Exception {
if (rep != null && rep.hasService(RepositorySecurityProvider.class)) {
service = (RepositorySecurityProvider) rep.getService(RepositorySecurityProvider.class);
} else {
throw new ControllerInitializationException(BaseMessages.getString(PKG, "PermissionsController.ERROR_0001_UNABLE_TO_INITIAL_REPOSITORY_SERVICE", // $NON-NLS-1$
RepositorySecurityManager.class));
}
// $NON-NLS-1$
messageBox = (XulMessageBox) document.createElement("messagebox");
viewAclsModel = new UIRepositoryObjectAcls();
manageAclsModel = new UIRepositoryObjectAclModel(viewAclsModel);
bf = new DefaultBindingFactory();
bf.setDocument(this.getXulDomContainer().getDocumentRoot());
mainController = (MainController) this.getXulDomContainer().getEventHandler("mainController");
// $NON-NLS-1$
confirmBox = (XulConfirmBox) document.createElement("confirmbox");
// $NON-NLS-1$
confirmBox.setTitle(BaseMessages.getString(PKG, "PermissionsController.RemoveAclWarning"));
// $NON-NLS-1$
confirmBox.setMessage(BaseMessages.getString(PKG, "PermissionsController.RemoveAclWarningText"));
// $NON-NLS-1$
confirmBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
// $NON-NLS-1$
confirmBox.setCancelLabel(BaseMessages.getString(PKG, "Dialog.Cancel"));
confirmBox.addDialogCallback(new XulDialogCallback<Object>() {
public void onClose(XulComponent sender, Status returnCode, Object retVal) {
if (returnCode == Status.ACCEPT) {
viewAclsModel.removeSelectedAcls();
}
}
public void onError(XulComponent sender, Throwable t) {
}
});
}
use of org.pentaho.di.repository.RepositorySecurityProvider 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