use of org.pentaho.di.repository.pur.model.ILockable in project pentaho-kettle by pentaho.
the class SpoonMenuLockController method updateMenu.
public void updateMenu(Document doc) {
try {
Spoon spoon = Spoon.getInstance();
// If we are working with an Enterprise Repository
if ((spoon != null) && (spoon.getRepository() != null) && (spoon.getRepository() instanceof PurRepository)) {
ILockService service = getService(spoon.getRepository());
EngineMetaInterface meta = spoon.getActiveMeta();
// If (meta is not null) and (meta is either a Transformation or Job)
if ((meta != null) && (meta instanceof ILockable)) {
RepositoryLock repoLock = null;
if (service != null && meta.getObjectId() != null) {
if (meta instanceof EEJobMeta) {
repoLock = service.getJobLock(meta.getObjectId());
} else {
repoLock = service.getTransformationLock(meta.getObjectId());
}
}
// If (there is a lock on this item) and (the UserInfo does not have permission to unlock this file)
if (repoLock != null) {
if (!service.canUnlockFileById(meta.getObjectId())) {
// User does not have modify permissions on this file
// $NON-NLS-1$
((XulToolbarbutton) doc.getElementById("toolbar-file-save")).setDisabled(true);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("file-save")).setDisabled(true);
}
}
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations