Class ExtSourceSql

All Implemented Interfaces:
ExtSourceSimpleApi, Serializable, Comparable<PerunBean>
Direct Known Subclasses:
ExtSourceSqlComplex

public class ExtSourceSql extends ExtSource implements ExtSourceSimpleApi
Author:
Michal Prochazka michalp@ics.muni.cz
See Also:
Serialized Form
  • Constructor Details

    • ExtSourceSql

      public ExtSourceSql()
  • Method Details

    • setPerunBlImpl

      public static PerunBlImpl setPerunBlImpl(PerunBlImpl perun)
    • findSubjectsLogins

      public List<Map<String,​String>> findSubjectsLogins(String searchString)
      Description copied from interface: ExtSourceSimpleApi
      Finds all subjects logins in the external source, that contains searchString. This method is used for getting all logins of subjects in external source and then use them to searching in external source for other subjects attributes.
      Specified by:
      findSubjectsLogins in interface ExtSourceSimpleApi
      Returns:
      list of maps, which contains attr_name->attr_value but only for login definition eg. login;MichalS
    • findSubjectsLogins

      public List<Map<String,​String>> findSubjectsLogins(String searchString, int maxResults)
      Description copied from interface: ExtSourceSimpleApi
      Finds all subjects logins in the external source, that contains searchString, limited by the maxResults. This method is used for getting all logins of subjects in external source and then use them to searching in external source for other subjects attributes
      Specified by:
      findSubjectsLogins in interface ExtSourceSimpleApi
      maxResults - limit returned results
      Returns:
      list of maps, which contains attr_name->attr_value but only for login definition eg. login;MichalS
    • getSubjectByLogin

      public Map<String,​String> getSubjectByLogin(String login) throws SubjectNotExistsException
      Description copied from interface: ExtSourceSimpleApi
      Finds subject from the external source by the primary login used in external source.
      Specified by:
      getSubjectByLogin in interface ExtSourceSimpleApi
      Parameters:
      login - login used in the external source
      Returns:
      map which contains attr_name -> attr_value, e.g. firstName->Michal
      Throws:
      SubjectNotExistsException - if the subject cannot be found
    • getGroupSubjects

      public List<Map<String,​String>> getGroupSubjects(Map<String,​String> attributes)
      Description copied from interface: ExtSourceSimpleApi
      Get the list of the subjects in the external group.
      Specified by:
      getGroupSubjects in interface ExtSourceSimpleApi
      Parameters:
      attributes - map of attributes used for quering the external source
      Returns:
      list of maps, which contains attr_name->attr_value, e.g. firstName->Michal
    • getUsersSubjects

      public List<Map<String,​String>> getUsersSubjects()
      Description copied from interface: ExtSourceSimpleApi
      Get the list of subjects from the external source.
      Specified by:
      getUsersSubjects in interface ExtSourceSimpleApi
      Returns:
      list of maps, which contains attr_name->attr_value, e.g. firstName->Michal
    • querySource

      protected List<Map<String,​String>> querySource(String query, String searchString, int maxResults)
    • createConnection

      protected void createConnection()
    • close

      public void close()
      Description copied from interface: ExtSourceSimpleApi
      If extSource needs to be closed, this method must be called.
      Specified by:
      close in interface ExtSourceSimpleApi
    • getSubjectGroups

      public List<Map<String,​String>> getSubjectGroups(Map<String,​String> attributes) throws ExtSourceUnsupportedOperationException
      Description copied from interface: ExtSourceSimpleApi
      Get the list of the subject groups in the external source.
      Specified by:
      getSubjectGroups in interface ExtSourceSimpleApi
      Parameters:
      attributes - map of attributes used for quering the external source
      Returns:
      list of maps, which contains attr name and attr value
      Throws:
      ExtSourceUnsupportedOperationException
    • groupQuery

      protected List<Map<String,​String>> groupQuery(String query, String searchString, int maxResults)
      Get subject groups from an external source
      Parameters:
      query - to select subject groups
      searchString - by which will be ? in query replaced
      maxResults - maximum subjects to get
      Returns:
      list of subjects
      Throws:
      InternalErrorException
    • getAttributes

      protected Map<String,​String> getAttributes()
    • getPreparedStatement

      protected PreparedStatement getPreparedStatement(String query, String searchString, int maxResults) throws SQLException
      Prepares query statement from query. - substitutes character '?' by searchString. - set max results limit.
      Parameters:
      query - basic query
      searchString - search string
      maxResults - limit of max results where 0 is unlimited
      Returns:
      Throws:
      SQLException