Search in sources :

Example 1 with ILockObject

use of org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject 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();
        }
    }
}
Also used : UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) KettleException(org.pentaho.di.core.exception.KettleException) AccessDeniedException(org.pentaho.di.ui.repository.repositoryexplorer.AccessDeniedException) ILockObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) IAclObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.IAclObject)

Example 2 with ILockObject

use of org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject in project pentaho-kettle by pentaho.

the class RepositoryLockController method onDragFromLocalTable.

// Object being dragged from the file listing table
public void onDragFromLocalTable(DropEvent event) {
    try {
        Collection<Object> selectedRepoObjects = fileTable.getSelectedItems();
        if (selectedRepoObjects.size() > 0) {
            for (Object ro : selectedRepoObjects) {
                if (ro instanceof UIRepositoryObject && ro instanceof ILockObject) {
                    final UIRepositoryContent contentToLock = (UIRepositoryContent) ro;
                    if (((ILockObject) contentToLock).isLocked()) {
                        // Content is locked, not allowed to move
                        event.setAccepted(false);
                        // $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, "BrowseController.MoveNotAllowed"));
                        messageBox.open();
                        break;
                    } else {
                        // Content is not locked, check default permissions
                        browseController.onDragFromLocalTable(event);
                    }
                } else if (ro instanceof UIRepositoryDirectory && repositoryDirectoryHasLockedObject(event, (UIRepositoryDirectory) ro)) {
                    // locked content nested in this directory. move not allowed.
                    event.setAccepted(false);
                    break;
                }
            }
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) ILockObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) ILockObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject) UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)

Example 3 with ILockObject

use of org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject in project pentaho-kettle by pentaho.

the class RepositoryLockController method lockContent.

public void lockContent() throws Exception {
    List<UIRepositoryObject> selectedRepoObjects = browseController.getSelectedFileItems();
    if (selectedRepoObjects.size() > 0 && selectedRepoObjects.get(0) instanceof UIRepositoryContent) {
        final UIRepositoryContent contentToLock = (UIRepositoryContent) selectedRepoObjects.get(0);
        if (((ILockObject) contentToLock).isLocked()) {
            // Unlock the item
            ((ILockObject) contentToLock).unlock();
            browseController.getSelectedItemsBinding().fireSourceChanged();
        } else {
            // Lock the item
            XulPromptBox lockNotePrompt = promptLockMessage(document, messages, null);
            lockNotePrompt.addDialogCallback(new XulDialogCallback<String>() {

                public void onClose(XulComponent component, Status status, String value) {
                    if (!status.equals(Status.CANCEL)) {
                        try {
                            ((ILockObject) contentToLock).lock(value);
                            browseController.getSelectedItemsBinding().fireSourceChanged();
                        } catch (Exception e) {
                            // convert to runtime exception so it bubbles up through the UI
                            throw new RuntimeException(e);
                        }
                    } else {
                        // $NON-NLS-1$
                        XulMenuitem lockMenuItem = (XulMenuitem) document.getElementById("lock-context-lock");
                        lockMenuItem.setSelected(false);
                        // $NON-NLS-1$
                        lockMenuItem = (XulMenuitem) document.getElementById("file-context-lock");
                        lockMenuItem.setSelected(false);
                    }
                }

                public void onError(XulComponent component, Throwable err) {
                    throw new RuntimeException(err);
                }
            });
            lockNotePrompt.open();
        }
    }
}
Also used : UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException) UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) ILockObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject) XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) XulComponent(org.pentaho.ui.xul.XulComponent)

Example 4 with ILockObject

use of org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject in project pentaho-kettle by pentaho.

the class RepositoryLockController method areAnyRepositoryObjectsLocked.

private boolean areAnyRepositoryObjectsLocked(DropEvent event, UIRepositoryObjects repositoryObjects) throws KettleException {
    for (UIRepositoryObject ro : repositoryObjects) {
        if (ro instanceof ILockObject) {
            final UIRepositoryContent contentToLock = (UIRepositoryContent) ro;
            if (((ILockObject) contentToLock).isLocked()) {
                // Content is locked, move is not allowed.
                event.setAccepted(false);
                // $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, "BrowseController.FolderMoveNotAllowed"));
                messageBox.open();
                return true;
            }
        }
    }
    return false;
}
Also used : UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) ILockObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent)

Example 5 with ILockObject

use of org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject in project pentaho-kettle by pentaho.

the class RevisionController method restoreRevision.

public void restoreRevision() {
    try {
        final Collection<UIRepositoryContent> content = fileTable.getSelectedItems();
        final UIRepositoryContent contentToRestore = content.iterator().next();
        Collection<UIRepositoryObjectRevision> versions = revisionTable.getSelectedItems();
        final UIRepositoryObjectRevision versionToRestore = versions.iterator().next();
        SwtConfirmBox confirmbox = promptCommitComment(document);
        if (contentToRestore instanceof ILockObject && ((ILockObject) contentToRestore).isLocked()) {
            // Cannot restore revision of locked content
            // $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, "RevisionsController.RestoreLockedFileNotAllowed"));
            messageBox.open();
            return;
        }
        confirmbox.addDialogCallback(new XulDialogCallback<String>() {

            public void onClose(XulComponent component, Status status, String value) {
                if (!status.equals(Status.CANCEL)) {
                    try {
                        if (contentToRestore instanceof IRevisionObject) {
                            ((IRevisionObject) contentToRestore).restoreRevision(versionToRestore, value);
                            List<UIRepositoryObject> objects = new ArrayList<UIRepositoryObject>();
                            objects.add(contentToRestore);
                            browseController.setRepositoryObjects(objects);
                        } else {
                            throw new IllegalStateException(BaseMessages.getString(PKG, // $NON-NLS-1$
                            "RevisionsController.RevisionsNotSupported"));
                        }
                    } catch (Exception e) {
                        if (mainController == null || !mainController.handleLostRepository(e)) {
                            // convert to runtime exception so it bubbles up through the UI
                            throw new RuntimeException(e);
                        }
                    }
                }
            }

            public void onError(XulComponent component, Throwable err) {
                if (mainController == null || !mainController.handleLostRepository(err)) {
                    throw new RuntimeException(err);
                }
            }
        });
        confirmbox.open();
    } catch (Exception e) {
        if (mainController == null || !mainController.handleLostRepository(e)) {
            throw new RuntimeException(new KettleException(e));
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IRevisionObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.IRevisionObject) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) SwtConfirmBox(org.pentaho.ui.xul.swt.tags.SwtConfirmBox) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException) UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) ILockObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject) UIRepositoryObjectRevision(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryObjectRevision) ArrayList(java.util.ArrayList) List(java.util.List) XulComponent(org.pentaho.ui.xul.XulComponent)

Aggregations

ILockObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject)5 UIRepositoryContent (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent)5 KettleException (org.pentaho.di.core.exception.KettleException)4 UIRepositoryObject (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject)4 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)3 XulException (org.pentaho.ui.xul.XulException)3 UIRepositoryDirectory (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory)2 XulComponent (org.pentaho.ui.xul.XulComponent)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IAclObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.IAclObject)1 IRevisionObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.IRevisionObject)1 UIRepositoryObjectRevision (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryObjectRevision)1 AccessDeniedException (org.pentaho.di.ui.repository.repositoryexplorer.AccessDeniedException)1 XulMenuitem (org.pentaho.ui.xul.components.XulMenuitem)1 XulPromptBox (org.pentaho.ui.xul.components.XulPromptBox)1 SwtConfirmBox (org.pentaho.ui.xul.swt.tags.SwtConfirmBox)1