Search in sources :

Example 1 with EEJobMeta

use of org.pentaho.di.repository.pur.model.EEJobMeta 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 2 with EEJobMeta

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

the class PurRepository method loadJob.

@Override
public JobMeta loadJob(ObjectId idJob, String versionLabel) throws KettleException {
    try {
        RepositoryFile file = null;
        if (versionLabel != null) {
            file = pur.getFileAtVersion(idJob.getId(), versionLabel);
        } else {
            file = pur.getFileById(idJob.getId());
        }
        EEJobMeta jobMeta = new EEJobMeta();
        jobMeta.setName(file.getTitle());
        jobMeta.setDescription(file.getDescription());
        jobMeta.setObjectId(new StringObjectId(file.getId().toString()));
        jobMeta.setObjectRevision(getObjectRevision(new StringObjectId(file.getId().toString()), versionLabel));
        jobMeta.setRepository(this);
        jobMeta.setRepositoryDirectory(findDirectory(getParentPath(file.getPath())));
        // inject metastore
        jobMeta.setMetaStore(getMetaStore());
        readJobMetaSharedObjects(jobMeta);
        // Additional obfuscation through obscurity
        jobMeta.setRepositoryLock(unifiedRepositoryLockService.getLock(file));
        jobDelegate.dataNodeToElement(pur.getDataAtVersionForRead(idJob.getId(), versionLabel, NodeRepositoryFileData.class).getNode(), jobMeta);
        ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.JobMetaLoaded.id, jobMeta);
        jobMeta.clearChanged();
        return jobMeta;
    } catch (Exception e) {
        throw new KettleException("Unable to load job with id [" + idJob + "]", e);
    }
}
Also used : EEJobMeta(org.pentaho.di.repository.pur.model.EEJobMeta) KettleException(org.pentaho.di.core.exception.KettleException) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) StringObjectId(org.pentaho.di.repository.StringObjectId) 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)

Aggregations

KettleException (org.pentaho.di.core.exception.KettleException)2 EEJobMeta (org.pentaho.di.repository.pur.model.EEJobMeta)2 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1 EngineMetaInterface (org.pentaho.di.core.EngineMetaInterface)1 IdNotFoundException (org.pentaho.di.core.exception.IdNotFoundException)1 KettleFileException (org.pentaho.di.core.exception.KettleFileException)1 KettleSecurityException (org.pentaho.di.core.exception.KettleSecurityException)1 StringObjectId (org.pentaho.di.repository.StringObjectId)1 PurRepository (org.pentaho.di.repository.pur.PurRepository)1 ILockable (org.pentaho.di.repository.pur.model.ILockable)1 RepositoryLock (org.pentaho.di.repository.pur.model.RepositoryLock)1 ILockService (org.pentaho.di.ui.repository.pur.services.ILockService)1 Spoon (org.pentaho.di.ui.spoon.Spoon)1 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)1 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)1 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)1 UnifiedRepositoryCreateFileException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryCreateFileException)1 UnifiedRepositoryUpdateFileException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryUpdateFileException)1 XulMenuitem (org.pentaho.ui.xul.components.XulMenuitem)1 XulToolbarbutton (org.pentaho.ui.xul.components.XulToolbarbutton)1