Search in sources :

Example 1 with RepositoryLock

use of org.pentaho.di.repository.pur.model.RepositoryLock 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);
    }
}
Also used : IAbsSecurityProvider(org.pentaho.di.ui.repository.pur.services.IAbsSecurityProvider) DefaultBindingFactory(org.pentaho.ui.xul.binding.DefaultBindingFactory) JobGraph(org.pentaho.di.ui.spoon.job.JobGraph) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) PurRepository(org.pentaho.di.repository.pur.PurRepository) UnifiedRepositoryLockService(org.pentaho.di.repository.pur.UnifiedRepositoryLockService) Spoon(org.pentaho.di.ui.spoon.Spoon) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RepositoryLock(org.pentaho.di.repository.pur.model.RepositoryLock) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException)

Example 2 with RepositoryLock

use of org.pentaho.di.repository.pur.model.RepositoryLock 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);
    }
}
Also used : EEJobMeta(org.pentaho.di.repository.pur.model.EEJobMeta) PurRepository(org.pentaho.di.repository.pur.PurRepository) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) Spoon(org.pentaho.di.ui.spoon.Spoon) ILockService(org.pentaho.di.ui.repository.pur.services.ILockService) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface) RepositoryLock(org.pentaho.di.repository.pur.model.RepositoryLock) XulToolbarbutton(org.pentaho.ui.xul.components.XulToolbarbutton) KettleException(org.pentaho.di.core.exception.KettleException) ILockable(org.pentaho.di.repository.pur.model.ILockable)

Example 3 with RepositoryLock

use of org.pentaho.di.repository.pur.model.RepositoryLock in project pentaho-kettle by pentaho.

the class UIEEJob method lock.

public void lock(String lockNote) throws KettleException {
    RepositoryLock lock = lockService.lockJob(getObjectId(), lockNote);
    repObj.setLock(lock);
    uiParent.fireCollectionChanged();
}
Also used : RepositoryLock(org.pentaho.di.repository.pur.model.RepositoryLock)

Example 4 with RepositoryLock

use of org.pentaho.di.repository.pur.model.RepositoryLock in project pentaho-kettle by pentaho.

the class LazyUnifiedRepositoryDirectory method getRepositoryObjects.

@Override
public List<RepositoryElementMetaInterface> getRepositoryObjects() {
    if (fileChildren == null) {
        fileChildren = new ArrayList<RepositoryElementMetaInterface>();
        synchronized (fileChildren) {
            UnifiedRepositoryLockService lockService = (UnifiedRepositoryLockService) registry.getService(ILockService.class);
            RepositoryFileTree tree = repository.getTree(new RepositoryRequest(this.self.getPath(), true, 1, null));
            for (RepositoryFileTree tchild : tree.getChildren()) {
                RepositoryFile child = tchild.getFile();
                if (!child.isFolder()) {
                    RepositoryLock lock = null;
                    try {
                        lock = lockService.getLock(child);
                        RepositoryObjectType objectType = PurRepository.getObjectType(child.getName());
                        EERepositoryObject repositoryObject = new EERepositoryObject(child, this, null, objectType, null, lock, false);
                        repositoryObject.setVersioningEnabled(tchild.getVersioningEnabled());
                        repositoryObject.setVersionCommentEnabled(tchild.getVersionCommentEnabled());
                        fileChildren.add(repositoryObject);
                    } catch (KettleException e) {
                        logger.error("Error converting Unified Repository file to PDI RepositoryObject: " + child.getPath() + ". File will be skipped", e);
                    }
                }
            }
        }
    }
    return fileChildren;
}
Also used : EERepositoryObject(org.pentaho.di.repository.pur.model.EERepositoryObject) KettleException(org.pentaho.di.core.exception.KettleException) ILockService(org.pentaho.di.ui.repository.pur.services.ILockService) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) RepositoryRequest(org.pentaho.platform.api.repository2.unified.RepositoryRequest) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) RepositoryLock(org.pentaho.di.repository.pur.model.RepositoryLock) RepositoryFileTree(org.pentaho.platform.api.repository2.unified.RepositoryFileTree) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface)

Example 5 with RepositoryLock

use of org.pentaho.di.repository.pur.model.RepositoryLock in project pentaho-kettle by pentaho.

the class PurRepository method fillRepositoryDirectoryFromTree.

private void fillRepositoryDirectoryFromTree(final RepositoryDirectoryInterface parentDir, final RepositoryFileTree treeNode) throws KettleException {
    try {
        List<RepositoryElementMetaInterface> fileChildren = new ArrayList<RepositoryElementMetaInterface>();
        List<RepositoryFileTree> children = treeNode.getChildren();
        if (children != null) {
            for (RepositoryFileTree child : children) {
                if (child.getFile().isFolder()) {
                    RepositoryDirectory dir = new RepositoryDirectory(parentDir, child.getFile().getName());
                    dir.setObjectId(new StringObjectId(child.getFile().getId().toString()));
                    parentDir.addSubdirectory(dir);
                    fillRepositoryDirectoryFromTree(dir, child);
                } else {
                    // a real file, like a Transformation or Job
                    RepositoryLock lock = unifiedRepositoryLockService.getLock(child.getFile());
                    RepositoryObjectType objectType = getObjectType(child.getFile().getName());
                    fileChildren.add(new EERepositoryObject(child, parentDir, null, objectType, null, lock, false));
                }
            }
            parentDir.setRepositoryObjects(fileChildren);
        }
    } catch (Exception e) {
        throw new KettleException("Unable to load directory structure from repository", e);
    }
}
Also used : EERepositoryObject(org.pentaho.di.repository.pur.model.EERepositoryObject) KettleException(org.pentaho.di.core.exception.KettleException) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) ArrayList(java.util.ArrayList) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) RepositoryLock(org.pentaho.di.repository.pur.model.RepositoryLock) StringObjectId(org.pentaho.di.repository.StringObjectId) RepositoryFileTree(org.pentaho.platform.api.repository2.unified.RepositoryFileTree) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) UnifiedRepositoryCreateFileException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryCreateFileException) UnifiedRepositoryUpdateFileException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryUpdateFileException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) KettleException(org.pentaho.di.core.exception.KettleException) IdNotFoundException(org.pentaho.di.core.exception.IdNotFoundException) KettleSecurityException(org.pentaho.di.core.exception.KettleSecurityException) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface)

Aggregations

RepositoryLock (org.pentaho.di.repository.pur.model.RepositoryLock)8 KettleException (org.pentaho.di.core.exception.KettleException)5 RepositoryElementMetaInterface (org.pentaho.di.repository.RepositoryElementMetaInterface)3 RepositoryObjectType (org.pentaho.di.repository.RepositoryObjectType)3 EERepositoryObject (org.pentaho.di.repository.pur.model.EERepositoryObject)3 Spoon (org.pentaho.di.ui.spoon.Spoon)3 ArrayList (java.util.ArrayList)2 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)2 IdNotFoundException (org.pentaho.di.core.exception.IdNotFoundException)2 KettleFileException (org.pentaho.di.core.exception.KettleFileException)2 KettleSecurityException (org.pentaho.di.core.exception.KettleSecurityException)2 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)2 PurRepository (org.pentaho.di.repository.pur.PurRepository)2 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)2 ILockService (org.pentaho.di.ui.repository.pur.services.ILockService)2 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)2 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)2 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)2 RepositoryFileTree (org.pentaho.platform.api.repository2.unified.RepositoryFileTree)2 UnifiedRepositoryCreateFileException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryCreateFileException)2