use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IAclObject in project pentaho-kettle by pentaho.
the class ConnectionPermissionsController method applyOnObjectOnly.
/**
* applyOnObjectOnly is called to save acl for a file object only
*
* @param roList
* @param hideDialog
*/
private void applyOnObjectOnly(List<UIDatabaseConnection> roList, boolean hideDialog) {
try {
UIDatabaseConnection rd = roList.get(0);
if (rd instanceof IAclObject) {
((IAclObject) rd).setAcls(viewAclsModel);
} else {
// $NON-NLS-1$
throw new IllegalStateException(BaseMessages.getString(PKG, "PermissionsController.NoAclSupport"));
}
viewAclsModel.setModelDirty(false);
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Success"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
// $NON-NLS-1$
messageBox.setMessage(BaseMessages.getString(PKG, "PermissionsController.PermissionAppliedSuccessfully"));
messageBox.open();
} catch (AccessDeniedException ade) {
if (mainController == null || !mainController.handleLostRepository(ade)) {
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
messageBox.setMessage(ade.getLocalizedMessage());
messageBox.open();
}
}
}
use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IAclObject in project pentaho-kettle by pentaho.
the class PermissionsController method createBindings.
protected void createBindings() {
super.createBindings();
// $NON-NLS-1$
fileFolderLabel = (XulLabel) document.getElementById("file-folder-name");
// $NON-NLS-1$
aclDeck = (XulDeck) document.getElementById("acl-deck");
// $NON-NLS-1$
inheritParentPermissionCheckbox = (XulCheckbox) document.getElementById("inherit-from-parent-permission-checkbox");
bf.setBindingType(Binding.Type.ONE_WAY);
BindingConvertor<List<UIRepositoryObject>, List<UIRepositoryObjectAcl>> securityBindingConverter = new BindingConvertor<List<UIRepositoryObject>, List<UIRepositoryObjectAcl>>() {
@Override
public List<UIRepositoryObjectAcl> sourceToTarget(List<UIRepositoryObject> ro) {
if (ro == null) {
return null;
}
if (ro.size() <= 0) {
return null;
}
setSelectedRepositoryObject(ro);
if (!hasManageAclAccess()) {
// disable everything
applyAclButton.setDisabled(true);
addAclButton.setDisabled(true);
removeAclButton.setDisabled(true);
inheritParentPermissionCheckbox.setDisabled(true);
manageAclCheckbox.setDisabled(true);
deleteCheckbox.setDisabled(true);
writeCheckbox.setDisabled(true);
readCheckbox.setDisabled(true);
viewAclsModel.setHasManageAclAccess(false);
} else {
applyAclButton.setDisabled(false);
inheritParentPermissionCheckbox.setDisabled(false);
viewAclsModel.setHasManageAclAccess(true);
}
viewAclsModel.setRemoveEnabled(false);
List<UIRepositoryObjectAcl> selectedAclList = Collections.emptyList();
// we've moved to a new file/folder; need to clear out what the model thinks is selected
viewAclsModel.setSelectedAclList(selectedAclList);
permissionsCheckboxHandler.updateCheckboxes(EnumSet.noneOf(RepositoryFilePermission.class));
UIRepositoryObject repoObject = ro.get(0);
try {
if (repoObject instanceof IAclObject) {
((IAclObject) repoObject).getAcls(viewAclsModel);
} else {
// $NON-NLS-1$
throw new IllegalStateException(BaseMessages.getString(PKG, "PermissionsController.NoAclSupport"));
}
fileFolderLabel.setValue(// $NON-NLS-1$
BaseMessages.getString(PKG, "AclTab.UserRolePermission", repoObject.getName()));
bf.setBindingType(Binding.Type.ONE_WAY);
// $NON-NLS-1$ //$NON-NLS-2$
bf.createBinding(viewAclsModel, "acls", userRoleList, "elements");
updateInheritFromParentPermission();
} catch (AccessDeniedException ade) {
if (mainController == null || !mainController.handleLostRepository(ade)) {
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
messageBox.setMessage(BaseMessages.getString(PKG, "PermissionsController.UnableToGetAcls", repoObject.getName(), // $NON-NLS-1$
ade.getLocalizedMessage()));
messageBox.open();
}
} catch (Exception e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
messageBox.setMessage(BaseMessages.getString(PKG, "PermissionsController.UnableToGetAcls", repoObject.getName(), // $NON-NLS-1$
e.getLocalizedMessage()));
messageBox.open();
}
}
aclDeck.setSelectedIndex(ACL);
return viewAclsModel.getAcls();
}
@Override
public List<UIRepositoryObject> targetToSource(List<UIRepositoryObjectAcl> elements) {
return null;
}
};
// Binding between the selected repository objects and the user role list for acls
securityBinding = // $NON-NLS-1$ //$NON-NLS-2$
bf.createBinding(browseController, "repositoryObjects", userRoleList, "elements", securityBindingConverter);
securityBinding = // $NON-NLS-1$ //$NON-NLS-2$
bf.createBinding(browseController, "repositoryDirectories", userRoleList, "elements", securityBindingConverter);
bf.setBindingType(Binding.Type.BI_DIRECTIONAL);
// Binding Add Remove button to the inherit check box. If the checkbox is checked that disable add remove
// $NON-NLS-1$ //$NON-NLS-2$
bf.createBinding(viewAclsModel, "entriesInheriting", inheritParentPermissionCheckbox, "checked");
// Setting the default Deck to show no permission
aclDeck.setSelectedIndex(NO_ACL);
try {
if (securityBinding != null) {
securityBinding.fireSourceChanged();
}
} catch (Exception e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
// convert to runtime exception so it bubbles up through the UI
throw new RuntimeException(e);
}
}
}
use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IAclObject in project pentaho-kettle by pentaho.
the class PermissionsController method updateInheritFromParentPermission.
/*
* public void closeApplyAclConfirmationDialog() { applyAclConfirmationDialog.hide(); }
*/
/*
* If the user check or unchecks the inherit from parent checkbox, this method is called.
*/
public void updateInheritFromParentPermission() throws AccessDeniedException {
viewAclsModel.setEntriesInheriting(inheritParentPermissionCheckbox.isChecked());
if (inheritParentPermissionCheckbox.isChecked()) {
addAclButton.setDisabled(true);
UIRepositoryObject ro = repoObject.get(0);
if (ro instanceof IAclObject) {
// force inherit to true to get effective ACLs before apply...
((IAclObject) ro).clearAcl();
((IAclObject) ro).getAcls(viewAclsModel, true);
}
permissionsCheckboxHandler.updateCheckboxes(EnumSet.noneOf(RepositoryFilePermission.class));
} else {
addAclButton.setDisabled(!hasManageAclAccess());
permissionsCheckboxHandler.processCheckboxes();
}
}
use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IAclObject in project pentaho-kettle by pentaho.
the class PermissionsController method applyOnObjectOnly.
/**
* applyOnObjectOnly is called to save acl for a file object only
*
* @param roList
* @param hideDialog
*/
private void applyOnObjectOnly(List<UIRepositoryObject> roList, boolean hideDialog) {
try {
if (roList.get(0) instanceof UIRepositoryDirectory) {
UIRepositoryDirectory rd = (UIRepositoryDirectory) roList.get(0);
if (rd instanceof IAclObject) {
((IAclObject) rd).setAcls(viewAclsModel);
} else {
// $NON-NLS-1$
throw new IllegalStateException(BaseMessages.getString(PKG, "PermissionsController.NoAclSupport"));
}
} else {
UIRepositoryContent rc = (UIRepositoryContent) roList.get(0);
if (rc instanceof ILockObject && ((ILockObject) rc).isLocked()) {
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
// $NON-NLS-1$
messageBox.setMessage(BaseMessages.getString(PKG, "PermissionsController.LockedObjectWarning"));
messageBox.open();
viewAclsModel.setModelDirty(false);
return;
} else if (rc instanceof IAclObject) {
((IAclObject) rc).setAcls(viewAclsModel);
} else {
// $NON-NLS-1$
throw new IllegalStateException(BaseMessages.getString(PKG, "PermissionsController.NoAclSupport"));
}
}
/*
* if (hideDialog) { applyAclConfirmationDialog.hide(); }
*/
viewAclsModel.setModelDirty(false);
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Success"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
// $NON-NLS-1$
messageBox.setMessage(BaseMessages.getString(PKG, "PermissionsController.PermissionAppliedSuccessfully"));
messageBox.open();
} catch (AccessDeniedException ade) {
/*
* if (hideDialog) { applyAclConfirmationDialog.hide(); }
*/
if (mainController == null || !mainController.handleLostRepository(ade)) {
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
messageBox.setMessage(ade.getLocalizedMessage());
messageBox.open();
}
} catch (KettleException kex) {
if (mainController == null || !mainController.handleLostRepository(kex)) {
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
messageBox.setMessage(kex.getLocalizedMessage());
messageBox.open();
}
}
}
use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IAclObject in project pentaho-kettle by pentaho.
the class ConnectionPermissionsController method createBindings.
protected void createBindings() {
super.createBindings();
// $NON-NLS-1$
connNameLabel = (XulLabel) document.getElementById("conn-name");
bf.setBindingType(Binding.Type.ONE_WAY);
BindingConvertor<List<UIDatabaseConnection>, List<UIRepositoryObjectAcl>> securityBindingConverter = new BindingConvertor<List<UIDatabaseConnection>, List<UIRepositoryObjectAcl>>() {
@Override
public List<UIRepositoryObjectAcl> sourceToTarget(List<UIDatabaseConnection> ro) {
if (ro == null) {
return null;
}
if (ro.size() <= 0) {
return null;
}
setSelectedDatabaseConnections(ro);
if (!hasManageAclAccess()) {
applyAclButton.setDisabled(true);
addAclButton.setDisabled(true);
removeAclButton.setDisabled(true);
manageAclCheckbox.setDisabled(true);
deleteCheckbox.setDisabled(true);
writeCheckbox.setDisabled(true);
readCheckbox.setDisabled(true);
viewAclsModel.setHasManageAclAccess(false);
} else {
applyAclButton.setDisabled(false);
addAclButton.setDisabled(false);
viewAclsModel.setHasManageAclAccess(true);
}
viewAclsModel.setRemoveEnabled(false);
List<UIRepositoryObjectAcl> selectedAclList = Collections.emptyList();
// we've moved to a connection; need to clear out what the model thinks is selected
viewAclsModel.setSelectedAclList(selectedAclList);
permissionsCheckboxHandler.setAllChecked(false);
UIDatabaseConnection dbconnObject = ro.get(0);
try {
if (dbconnObject instanceof IAclObject) {
IAclObject aclObj = (IAclObject) dbconnObject;
// This is a special case for DB Connections, wipe out the isEnherting flag.
// This will cause the model to become "dirty", and prompt the user for changes the first time
// let's make sure the default creation behavior of connections is to be that inheritance is
// set to false, so this case never presents itself in the wild.
aclObj.getAcls(viewAclsModel);
if (viewAclsModel.isEntriesInheriting()) {
viewAclsModel.setEntriesInheriting(false);
aclObj.setAcls(viewAclsModel);
viewAclsModel.setModelDirty(false);
}
} else {
// $NON-NLS-1$
throw new IllegalStateException(BaseMessages.getString(PKG, "PermissionsController.NoAclSupport"));
}
connNameLabel.setValue(BaseMessages.getString(PKG, "AclTab.ConnectionPermission", // $NON-NLS-1$
dbconnObject.getDisplayName()));
bf.setBindingType(Binding.Type.ONE_WAY);
// $NON-NLS-1$ //$NON-NLS-2$
bf.createBinding(viewAclsModel, "acls", userRoleList, "elements");
} catch (AccessDeniedException ade) {
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
messageBox.setMessage(BaseMessages.getString(PKG, "PermissionsController.UnableToGetAcls", dbconnObject.getName(), // $NON-NLS-1$
ade.getLocalizedMessage()));
messageBox.open();
} catch (Exception e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
messageBox.setMessage(BaseMessages.getString(PKG, "PermissionsController.UnableToGetAcls", dbconnObject.getName(), // $NON-NLS-1$
e.getLocalizedMessage()));
messageBox.open();
}
}
return viewAclsModel.getAcls();
}
@Override
public List<UIDatabaseConnection> targetToSource(List<UIRepositoryObjectAcl> elements) {
// One way binding, nothing to do here
return null;
}
};
// Binding between the selected repository objects and the user role list for acls
securityBinding = bf.createBinding(connectionsController, "repositoryConnections", userRoleList, "elements", // $NON-NLS-1$ //$NON-NLS-2$
securityBindingConverter);
try {
if (securityBinding != null) {
securityBinding.fireSourceChanged();
}
} catch (Exception e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
// convert to runtime exception so it bubbles up through the UI
throw new RuntimeException(e);
}
}
}
Aggregations