use of org.pentaho.di.repository.pur.UnifiedRepositoryLockService in project pentaho-kettle by pentaho.
the class SpoonLockController method init.
protected void init() {
try {
if ((Spoon.getInstance().getRepository() != null) && (Spoon.getInstance().getRepository().hasService(IAbsSecurityProvider.class))) {
IAbsSecurityProvider securityService = (IAbsSecurityProvider) Spoon.getInstance().getRepository().getService(IAbsSecurityProvider.class);
setCreateAllowed(allowedActionsContains(securityService, IAbsSecurityProvider.CREATE_CONTENT_ACTION));
}
shell = (((Spoon) SpoonFactory.getInstance()).getShell());
XulDomContainer container = getXulDomContainer();
bindingFactory = new DefaultBindingFactory();
bindingFactory.setDocument(container.getDocumentRoot());
bindingFactory.setBindingType(Type.ONE_WAY);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
bindingFactory.createBinding(this, "activeMetaUnlocked", "lock-context-locknotes", "disabled");
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
bindingFactory.createBinding(this, "lockingNotAllowed", "lock-context-lock", "disabled");
// Try transformation
if (container.getEventHandlers().containsKey("transgraph")) {
// $NON-NLS-1$
// $NON-NLS-1$
workingMeta = ((TransGraph) container.getEventHandler("transgraph")).getMeta();
} else if (container.getEventHandlers().containsKey("jobgraph")) {
// $NON-NLS-1$
// $NON-NLS-1$
workingMeta = ((JobGraph) container.getEventHandler("jobgraph")).getMeta();
}
RepositoryLock repoLock = fetchRepositoryLock(workingMeta);
if (repoLock != null) {
// $NON-NLS-1$
XulMenuitem lockMenuItem = (XulMenuitem) container.getDocumentRoot().getElementById("lock-context-lock");
lockMenuItem.setSelected(true);
// Permit locking/unlocking if the user owns the lock
if (Spoon.getInstance().getRepository() instanceof PurRepository) {
setLockingAllowed(new UnifiedRepositoryLockService(((PurRepository) Spoon.getInstance().getRepository()).getUnderlyingRepository()).canUnlockFileById(workingMeta.getObjectId()));
} else {
setLockingAllowed(repoLock.getLogin().equalsIgnoreCase(Spoon.getInstance().getRepository().getUserInfo().getLogin()));
}
} else {
setLockingAllowed(true);
}
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
firePropertyChange("activeMetaUnlocked", null, repoLock == null);
} catch (Exception e) {
// $NON-NLS-1$
log.error(BaseMessages.getString(PKG, "LockController.NoLockingSupport"), e);
new ErrorDialog(((Spoon) SpoonFactory.getInstance()).getShell(), BaseMessages.getString(PKG, "Dialog.Error"), e.getMessage(), // $NON-NLS-1$
e);
}
}
Aggregations