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