Java Code Examples for org.pentaho.di.repository.Repository#hasService()

The following examples show how to use org.pentaho.di.repository.Repository#hasService() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PurRepositoryRevisionBrowserDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public PurRepositoryRevisionBrowserDialog( Shell parent, int style, Repository repository,
    RepositoryElementInterface element ) {
  this.display = parent.getDisplay();
  this.props = PropsUI.getInstance();
  this.repository = repository;
  this.element = element;

  try {
    if ( repository.hasService( IRevisionService.class ) ) {
      revisionService = (IRevisionService) repository.getService( IRevisionService.class );
    } else {
      throw new IllegalStateException();
    }
  } catch ( KettleException e ) {
    throw new IllegalStateException( e );
  }
  String name = element.getRepositoryElementType().toString() + " " + element.getRepositoryDirectory().getPath();
  if ( !name.endsWith( "/" ) )
    name += "/";
  name += element.getName();

  this.elementDescription = name;

  shell = new Shell( display, style | SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN );
  shell.setText( BaseMessages.getString( PKG, "PurRepositoryRevisionBrowserDialog.Dialog.Main.Title" ) ); //$NON-NLS-1$
}
 
Example 2
Source File: AbsContextMenuController.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void init( Repository repository ) throws ControllerInitializationException {
  try {
    if ( repository.hasService( IAbsSecurityProvider.class ) ) {
      service = (IAbsSecurityProvider) repository.getService( IAbsSecurityProvider.class );
      bf = new DefaultBindingFactory();
      bf.setDocument( this.getXulDomContainer().getDocumentRoot() );

      if ( bf != null ) {
        createBindings();
      }
      setAllowed( allowedActionsContains( service, IAbsSecurityProvider.CREATE_CONTENT_ACTION ) );
    }
  } catch ( KettleException e ) {
    throw new ControllerInitializationException( e );
  }
}
 
Example 3
Source File: UIEEJob.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public UIEEJob( RepositoryElementMetaInterface rc, UIRepositoryDirectory parent, Repository rep ) {
  super( rc, parent, rep );
  if ( !( rc instanceof EERepositoryObject ) ) {
    throw new IllegalArgumentException();
  }
  repObj = (EERepositoryObject) rc;
  try {
    if ( rep.hasService( ILockService.class ) ) {
      lockService = (ILockService) rep.getService( ILockService.class );
    } else {
      throw new IllegalStateException();
    }
    if ( rep.hasService( IRevisionService.class ) ) {
      revisionService = (IRevisionService) rep.getService( IRevisionService.class );
    } else {
      throw new IllegalStateException();
    }
    if ( rep.hasService( IAclService.class ) ) {
      aclService = (IAclService) rep.getService( IAclService.class );
    } else {
      throw new IllegalStateException();
    }
  } catch ( KettleException e ) {
    throw new RuntimeException( e );
  }
}
 
Example 4
Source File: UIEETransformation.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public UIEETransformation( RepositoryElementMetaInterface rc, UIRepositoryDirectory parent, Repository rep ) {
  super( rc, parent, rep );
  if ( !( rc instanceof EERepositoryObject ) ) {
    throw new IllegalArgumentException();
  }
  repObj = (EERepositoryObject) rc;
  try {
    if ( rep.hasService( ILockService.class ) ) {
      lockService = (ILockService) rep.getService( ILockService.class );
    } else {
      throw new IllegalStateException();
    }
    if ( rep.hasService( IRevisionService.class ) ) {
      revisionService = (IRevisionService) rep.getService( IRevisionService.class );
    } else {
      throw new IllegalStateException();
    }
    if ( rep.hasService( IAclService.class ) ) {
      aclService = (IAclService) rep.getService( IAclService.class );
    } else {
      throw new IllegalStateException();
    }
  } catch ( KettleException e ) {
    throw new RuntimeException( e );
  }
}
 
Example 5
Source File: SpoonMenuLockController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private ILockService getService( Repository repository ) throws KettleException {
  if ( repository.hasService( ILockService.class ) ) {
    return (ILockService) repository.getService( ILockService.class );
  } else {
    throw new IllegalStateException();
  }
}
 
Example 6
Source File: SpoonLockController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private ILockService getService( Repository repository ) throws KettleException {
  if ( service == null ) {
    if ( repository != null && repository.hasService( ILockService.class ) ) {
      return (ILockService) repository.getService( ILockService.class );
    } else {
      throw new IllegalStateException();
    }
  } else {
    return service;
  }
}
 
Example 7
Source File: RepositoryLockController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void init( Repository rep ) throws ControllerInitializationException {
  try {
    if ( rep != null && rep.hasService( ILockService.class ) ) {
      repository = rep;
      service = (ILockService) rep.getService( ILockService.class );
    } else {
      throw new ControllerInitializationException( BaseMessages.getString( PKG,
          "RepositoryLockController.ERROR_0001_UNABLE_TO_INITIAL_REPOSITORY_SERVICE", ILockService.class ) ); //$NON-NLS-1$

    }

    bindingFactory = new DefaultBindingFactory();
    bindingFactory.setDocument( getXulDomContainer().getDocumentRoot() );

    XulEventHandler eventHandler = getXulDomContainer().getEventHandler( "browseController" ); //$NON-NLS-1$

    if ( eventHandler instanceof BrowseController ) {
      browseController = (BrowseController) eventHandler;
    }

    // Disable row dragging if it is locked and the user does not have permissions
    fileTable = (XulTree) getXulDomContainer().getDocumentRoot().getElementById( "file-table" ); //$NON-NLS-1$
    folderTree = (XulTree) document.getElementById( "folder-tree" ); //$NON-NLS-1$
    lockFileMenuItem = (XulMenuitem) getXulDomContainer().getDocumentRoot().getElementById( "file-context-lock" ); //$NON-NLS-1$
    deleteFileMenuItem = (XulMenuitem) getXulDomContainer().getDocumentRoot().getElementById( "file-context-delete" ); //$NON-NLS-1$
    renameFileMenuItem = (XulMenuitem) getXulDomContainer().getDocumentRoot().getElementById( "file-context-rename" ); //$NON-NLS-1$

    messageBox = (XulMessageBox) document.createElement( "messagebox" ); //$NON-NLS-1$

    createBindings();
  } catch ( Exception e ) {
    throw new RuntimeException( e );
  }
}
 
Example 8
Source File: UIEEDatabaseConnection.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void initializeService( Repository rep ) {
  try {
    if ( rep.hasService( IAclService.class ) ) {
      aclService = (IAclService) rep.getService( IAclService.class );
    } else {
      throw new IllegalStateException();
    }
  } catch ( KettleException e ) {
    throw new RuntimeException( e );
  }

}
 
Example 9
Source File: UIEERepositoryDirectory.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void initializeService( Repository rep ) {
  try {
    if ( rep.hasService( IAclService.class ) ) {
      aclService = (IAclService) rep.getService( IAclService.class );
    } else {
      throw new IllegalStateException();
    }
  } catch ( KettleException e ) {
    throw new RuntimeException( e );
  }

}
 
Example 10
Source File: EESpoonPlugin.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Override UI elements to reflect the users capabilities as described by their permission levels
 */
private void doOnSecurityUpdate() throws KettleException {
  initMainSpoonContainer();
  Repository repository = getSpoonInstance().getRepository();
  // Repository User
  if ( repository != null && repository.hasService( IRoleSupportSecurityManager.class ) ) {
    UIObjectRegistry.getInstance().registerUIRepositoryUserClass( UIEERepositoryUser.class );
  } else {
    UIObjectRegistry.getInstance().registerUIRepositoryUserClass( UIObjectRegistry.DEFAULT_UIREPOSITORYUSER_CLASS );
  }
  // Repository Directory
  if ( repository != null && repository.hasService( IAclService.class ) ) {
    UIObjectRegistry.getInstance().registerUIRepositoryDirectoryClass( UIEERepositoryDirectory.class );
    UIObjectRegistry.getInstance().registerUIDatabaseConnectionClass( UIEEDatabaseConnection.class );
  } else {
    UIObjectRegistry.getInstance().registerUIRepositoryDirectoryClass( UIObjectRegistry.DEFAULT_UIDIR_CLASS );
  }
  // Repository Role
  if ( repository != null && repository.hasService( IAbsSecurityProvider.class ) ) {
    UIEEObjectRegistery.getInstance().registerUIRepositoryRoleClass( UIAbsRepositoryRole.class );
    IAbsSecurityProvider securityProvider = (IAbsSecurityProvider) repository.getService( IAbsSecurityProvider.class );

    enablePermission( securityProvider );
  }
  // Job & Transformation =
  if ( repository.hasService( ILockService.class ) ) {
    UIObjectRegistry.getInstance().registerUIJobClass( UIEEJob.class );
    UIObjectRegistry.getInstance().registerUITransformationClass( UIEETransformation.class );
    SpoonDelegateRegistry.getInstance().registerSpoonJobDelegateClass( SpoonEEJobDelegate.class );
    SpoonDelegateRegistry.getInstance().registerSpoonTransDelegateClass( SpoonEETransformationDelegate.class );
  } else {
    UIObjectRegistry.getInstance().registerUIJobClass( UIObjectRegistry.DEFAULT_UIJOB_CLASS );
    UIObjectRegistry.getInstance().registerUITransformationClass( UIObjectRegistry.DEFAULT_UITRANS_CLASS );
    SpoonDelegateRegistry.getInstance().registerSpoonJobDelegateClass( SpoonDelegateRegistry.DEFAULT_SPOONJOBDELEGATE_CLASS );
    SpoonDelegateRegistry.getInstance().registerSpoonTransDelegateClass( SpoonDelegateRegistry.DEFAULT_SPOONTRANSDELEGATE_CLASS );
  }
}
 
Example 11
Source File: SpoonEETransformationDelegate.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public SpoonEETransformationDelegate( Spoon spoon ) {
  super( spoon );
  Repository repository = spoon.getRepository();
  try {
    if ( repository.hasService( ILockService.class ) ) {
      service = (ILockService) repository.getService( ILockService.class );
    } else {
      throw new IllegalStateException();
    }
  } catch ( KettleException e ) {
    throw new RuntimeException( e );
  }
}
 
Example 12
Source File: SpoonEEJobDelegate.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public SpoonEEJobDelegate( Spoon spoon ) {
  super( spoon );
  Repository repository = spoon.getRepository();
  try {
    if ( repository.hasService( ILockService.class ) ) {
      service = (ILockService) repository.getService( ILockService.class );
    } else {
      throw new IllegalStateException();
    }
  } catch ( KettleException e ) {
    throw new RuntimeException( e );
  }
}
 
Example 13
Source File: SpoonLockController.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private boolean supportsLocking( Repository repository ) throws KettleException {
  return repository.hasService( ILockService.class );
}