Class IXConnection

java.lang.Object
de.elo.ix.client.IXConnection
All Implemented Interfaces:
IXConnectionIF, AutoCloseable

public class IXConnection extends Object implements IXConnectionIF, AutoCloseable
Indexserver connection class. An object of this class represents a connection to the Indexserver for a single user.

Instances of this class are usually created by an IXConnFactory object.

Example:

 Properties props = IXConnFactory.createConnProps(tp.url, 2, 10 * 60);
 Properties sessOpts = IXConnFactory.createSessionOptions("MyApp", "1.0", "");
 connFact = new IXConnFactory(props, sessOpts);
 IXServicePortC CONST = connFact.getCONST();
 IXConnection conn = connFact.create("Fritz", "geheim", "MYPC", null);
 EditInfo ed = conn.ix.checkoutDoc(docId, null, EditInfoC.mbSordDoc, LockC.NO);
 ...conn.logout();
 
 

Hint: do not rely on IXConnection being a class. Future versions of the API might define IXConnection as an interface.

  • Field Details

    • ixVal

      protected IXConnIXServicePortIF_2 ixVal
      Encapsulated Indexserver interface that obtains interface functions without ClientInfo parameter. Use this object to access the Indexserver.
    • connProps

      protected Properties connProps
      Connection properties. This properties are the same that have beed supplied to the IXConnFactory object.
    • databaseEngine

      protected String databaseEngine
      Database engine name.
    • implVersion

      protected String implVersion
      Indexserver version and build number.
    • eventBusApi

      protected EventBusApi eventBusApi
    • bclient

      protected final de.elo.ix.client.BClient_Indexserver bclient
    • auth

      protected final IXAuthenticationIF auth
    • url

      protected final String url
      Indexserver URL
    • CONST

      protected IXServicePortC CONST
    • connLogin

      @Deprecated protected IXConnLoginBYPS connLogin
      Deprecated.
      Compatibilty with API 7.0 and 8.0.
    • connFact

      @Deprecated protected final IXConnFactory connFact
      Deprecated.
      Compatibilty with API 7.0 and 8.0.
    • beforeCloseListener

      protected List<IXConnectionCloseListener> beforeCloseListener
      Listeners to be called before a connection is closed.
    • afterCloseListener

      protected List<IXConnectionCloseListener> afterCloseListener
      Listeners to be called after a connection has been closed.
  • Constructor Details

    • IXConnection

      protected IXConnection(IXConnFactory connFact, de.elo.ix.client.BClient_Indexserver bclient, IXAuthenticationIF auth, String url, Properties connProps)
      Constructor. Usually, objects of the IXConnection class are instanciate by one of the create methods of the IXConnFactory class.
      Parameters:
      connFact - IXConnFactory object used in getLogin() to obtain an ELO 8.0 compatible IXConnLogin object. Can be null, if getLogin() is not used.
      bclient - BClient object
      auth - Authentication callback interface
      url - Indexserver URL
      connProps - Connection properties.
    • IXConnection

      protected IXConnection(IXConnection rhs, IXAuthenticationIF auth, byps.BTransport transport)
      Copy constructor. This constructor is used to create a normalized connection.
      Parameters:
      rhs - base connection
      auth - authentication handler
      transport - BYPS transport
  • Method Details

    • ix

      Description copied from interface: IXConnectionIF
      Get Indexserver API object. Hint: Do not store the returned object in a variable. Always call IXConnection.ix() to obtain the API object. Do not rely on ix() returning an object of type IXConnIXServicePortIF_2.
      Specified by:
      ix in interface IXConnectionIF
      Returns:
      Indexserver interface object.
    • getLoginResult

      public LoginResult getLoginResult()
      Description copied from interface: IXConnectionIF
      Get LoginResult object.
      Specified by:
      getLoginResult in interface IXConnectionIF
      Returns:
      LoginResult object.
    • getUserId

      public int getUserId()
      Description copied from interface: IXConnectionIF
      Get current user ID.
      Specified by:
      getUserId in interface IXConnectionIF
      Returns:
      User ID.
    • getUserName

      public String getUserName()
      Description copied from interface: IXConnectionIF
      Get current user name.
      Specified by:
      getUserName in interface IXConnectionIF
      Returns:
      User name.
    • getConnProperties

      public Properties getConnProperties()
      Description copied from interface: IXConnectionIF
      Get the connection properties.
      Specified by:
      getConnProperties in interface IXConnectionIF
      Returns:
      Connection properties.
    • getEndpointUrl

      public String getEndpointUrl()
      Description copied from interface: IXConnectionIF
      Retuns the Indexserver URL
      Specified by:
      getEndpointUrl in interface IXConnectionIF
      Returns:
      URL
    • getSessionOptions

      public IXProperties getSessionOptions()
      Description copied from interface: IXConnectionIF
      Get the session options. They are requested from the IXConnLogin object.
      Specified by:
      getSessionOptions in interface IXConnectionIF
      Returns:
      Session options.
      See Also:
    • getVersion

      public String getVersion()
      Description copied from interface: IXConnectionIF
      Detect Indexserver version without build number.
      Specified by:
      getVersion in interface IXConnectionIF
      Returns:
      IX-Version
    • getMajorVersion

      public int getMajorVersion()
      Returns:
      MajorVersion as int
    • getImplVersion

      public String getImplVersion()
      Description copied from interface: IXConnectionIF
      Detect Indexserver version with build number.
      Specified by:
      getImplVersion in interface IXConnectionIF
      Returns:
      IX-Version
    • getInterfaceVersion

      @Deprecated public String getInterfaceVersion()
      Deprecated.
      Description copied from interface: IXConnectionIF
      Detect Indexserver SOAP interface version.
      Specified by:
      getInterfaceVersion in interface IXConnectionIF
      Returns:
      SOAP interface version
    • getClientVersion

      public String getClientVersion()
      Description copied from interface: IXConnectionIF
      Returns the version of the IXClient class, resp. the latest binary protocol version the IXClient class can understand.
      Specified by:
      getClientVersion in interface IXConnectionIF
      Returns:
      latest protocol version
      See Also:
    • getStreamVersion

      public String getStreamVersion()
      Description copied from interface: IXConnectionIF
      Returns the negotiated stream version.
      Specified by:
      getStreamVersion in interface IXConnectionIF
      Returns:
      negotiated protocol version
    • getServerTime

      public Date getServerTime()
      Description copied from interface: IXConnectionIF
      Gets the current server time.
      Specified by:
      getServerTime in interface IXConnectionIF
      Returns:
      Server time.
    • getCONST

      public IXServicePortC getCONST() throws byps.RemoteException
      Description copied from interface: IXConnectionIF
      Constants.
      Specified by:
      getCONST in interface IXConnectionIF
      Returns:
      Constant object.
      Throws:
      byps.RemoteException
    • getCONST

      public void getCONST(byps.BAsyncResult<IXServicePortC> asyncResult)
      Description copied from interface: IXConnectionIF
      Constants.
      Specified by:
      getCONST in interface IXConnectionIF
      Parameters:
      asyncResult - Callback interface that receives the result.
    • isoToDate

      public Date isoToDate(String iso)
      Description copied from interface: IXConnectionIF
      Convert an ISO date to a java.util.Date. The ISO date is assumed to be in the timezone of the current session.
      Specified by:
      isoToDate in interface IXConnectionIF
      Parameters:
      iso - ISO date
      Returns:
      java.util.Date (always UTC, use java.util.Calendar for formatting)
    • dateToIso

      public String dateToIso(Date dt)
      Description copied from interface: IXConnectionIF
      Convert a java.util.Date into an ISO date related to the current timezone.
      Specified by:
      dateToIso in interface IXConnectionIF
      Parameters:
      dt - Java date object
      Returns:
      ISO date
    • staticIsoToDate

      public static Date staticIsoToDate(String iso, boolean isUtc)
      Convert an ISO date into a java.util.Date object.
      Examples:
      iso isUtc return
      20100401000000 false Thu Apr 01 00:00:00 CEST 2010
      20100401000000 true Thu Apr 01 02:00:00 CEST 2010
      Parameters:
      iso - ISO date
      isUtc - true, if ISO date is in the UTC timezone.
      Returns:
      Date object
    • staticDateToIso

      public static String staticDateToIso(Date dt, boolean toUtc)
      Convert a java.util.Date object into a ISO date string.
      Examples:
      dt toUtc return
      Tue Apr 13 21:33:58 CEST 2010 false 20100413213358
      Tue Apr 13 21:33:58 CEST 2010 true 20100413193358
      Parameters:
      dt - Date object
      toUtc - true, if the returned string should contain an UTC date.
      Returns:
      ISO date
    • makeRawStreamServiceParamsFromUrl

      public static String[] makeRawStreamServiceParamsFromUrl(String url)
    • upload

      public String upload(String url, File file) throws byps.RemoteException
      Description copied from interface: IXConnectionIF
      Upload a file to the given URL.
      Specified by:
      upload in interface IXConnectionIF
      Parameters:
      url - Destination URL.
      file - File object.
      Returns:
      Upload result from DM or IX.
      Throws:
      byps.RemoteException
    • upload

      public String upload(String url, InputStream is, long contentLength, String contentType) throws byps.RemoteException
      Description copied from interface: IXConnectionIF
      Upload the bytes of a InputStream object to the given URL.
      Specified by:
      upload in interface IXConnectionIF
      Parameters:
      url - Destination URL.
      is - InputStream object to read from.
      contentLength - Number of bytes contained in is.
      contentType - MIME type of the data contained in is.
      Throws:
      byps.RemoteException
    • download

      public void download(String url, File file) throws byps.RemoteException
      Description copied from interface: IXConnectionIF
      Download a file from the given URL.
      Specified by:
      download in interface IXConnectionIF
      Parameters:
      url - URL to download.
      file - The contents are stored in this File object.
      Throws:
      byps.RemoteException
    • download

      public void download(String url, long offset, long length, IXClientIF.ContentStream cstrm) throws byps.RemoteException
      Description copied from interface: IXConnectionIF
      Download bytes from the given URL.
      Specified by:
      download in interface IXConnectionIF
      Parameters:
      url - URL to download.
      offset - If not 0, the content is loaded beginning at this byte offset.
      length - If not -1, only this number of bytes are downloaded.
      cstrm - The downloaded bytes are written into this stream object.
      Throws:
      byps.RemoteException
    • download

      public InputStream download(String downloadUrl, long offset, long length) throws byps.RemoteException
      Specified by:
      download in interface IXConnectionIF
      Throws:
      byps.RemoteException
    • download

      public void download(String url, long offset, long length, File file) throws byps.RemoteException
      Specified by:
      download in interface IXConnectionIF
      Throws:
      byps.RemoteException
    • encryptPassword

      public String encryptPassword(String s) throws byps.RemoteException
      Description copied from interface: IXConnectionIF
      Encrytps a password used to login or to supply an encryption set password.
      Specified by:
      encryptPassword in interface IXConnectionIF
      Parameters:
      s - Plain text password.
      Returns:
      Encrypted password.
      Throws:
      byps.RemoteException
    • logout

      @Deprecated public void logout()
      Deprecated.
      Use close instead.
      Description copied from interface: IXConnectionIF
      Internally calls close().
      Specified by:
      logout in interface IXConnectionIF
    • close

      public void close()
      Description copied from interface: IXConnectionIF
      Disconnect the IXConnection object and maybe logout the session. The session is logged out if it was not created by IXConnFactory.createFromTicket(ClientInfo).
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface IXConnectionIF
    • internalLogout

      protected void internalLogout()
    • getFileExt

      public String getFileExt(String fileName)
    • getFileExt

      public String getFileExt(File file)
      Description copied from interface: IXConnectionIF
      Returns the file extension of the given file name without dot.
      Specified by:
      getFileExt in interface IXConnectionIF
      Parameters:
      file - File object.
      Returns:
      File extension.
    • getFileMd5

      public String getFileMd5(File file) throws IOException
      Description copied from interface: IXConnectionIF
      Computes the MD5 hash for the given file.
      Specified by:
      getFileMd5 in interface IXConnectionIF
      Parameters:
      file - File object.
      Returns:
      MD5 hash in String format.
      Throws:
      IOException
    • getDatabaseEngine

      public String getDatabaseEngine()
      Description copied from interface: IXConnectionIF
      Returns the name of the database engine (MSSQL, ORACLE, DB2). If the conected Indexserver is older than 8.0, UNKNOWN is returned.
      Specified by:
      getDatabaseEngine in interface IXConnectionIF
      Returns:
      Database engine name.
    • truncate

      public String truncate(String s, int max)
      Description copied from interface: IXConnectionIF
      This function truncates s to the length of max.

      If the String s is not truncated, the return value is s itself. Thus, checking s == truncate(s) is sufficient to check, wether the s can be stored - the String.equals function need not to be called.

      Example:
      IXConnection ix = ...
      Sord sord = ...
      boolean canStore = sord.getName() == ix.truncate(sord.getName(), ix.getCONST().getSORD().getLnName());

      Specified by:
      truncate in interface IXConnectionIF
      Parameters:
      s - String to be truncated
      max - Database column width from a member length value of a constant class.
      Returns:
      Truncated String or s.
    • getEventBusApi

      public EventBusApi getEventBusApi()
      Specified by:
      getEventBusApi in interface IXConnectionIF
    • createConnectionForUser

      public IXConnection createConnectionForUser(String runAsName) throws byps.RemoteException
      Description copied from interface: IXConnectionIF
      Creates new connection for a "run as" user, running on the already existent ticket.
      Specified by:
      createConnectionForUser in interface IXConnectionIF
      Parameters:
      runAsName - User name
      Returns:
      IXConnection object
      Throws:
      byps.RemoteException
    • getFeedService

      public de.elo.ix.client.feed.FeedServiceAuth getFeedService()
      Description copied from interface: IXConnectionIF
      Get service interface for document feed.
      Specified by:
      getFeedService in interface IXConnectionIF
      Returns:
      service interface.
    • getMyELOService

      public de.elo.ix.client.myelo.MyELOServiceAuth getMyELOService()
    • getSystemInformation

      public de.elo.ix.client.system.SystemInformationAuth getSystemInformation()
      Description copied from interface: IXConnectionIF
      Get service interface for system information. EIX-3356
      Specified by:
      getSystemInformation in interface IXConnectionIF
      Returns:
      service interface
    • getHealthCheckService

      public de.elo.ix.client.health.HealthCheckServiceAuth getHealthCheckService()
      Description copied from interface: IXConnectionIF
      Get service interface for the health check service.
      Specified by:
      getHealthCheckService in interface IXConnectionIF
      Returns:
      service interface.
    • setFeedNotification

      public void setFeedNotification(de.elo.ix.client.feed.BSkeleton_FeedNotification feedNotification) throws byps.RemoteException
      Set notification interface for document feed events.
      Parameters:
      feedNotification - serivce interface
      Throws:
      byps.RemoteException
    • getRawStreamService

      public de.elo.ix.client.compatibility.RawStreamServiceAuth getRawStreamService()
      Description copied from interface: IXConnectionIF
      Internal interface for file upload and download.
      Specified by:
      getRawStreamService in interface IXConnectionIF
      Returns:
      service interface
    • getPluginService

      public de.elo.ix.client.plugin.PluginServiceAuth getPluginService()
      Description copied from interface: IXConnectionIF
      Get service interface for accessing plugins.
      Specified by:
      getPluginService in interface IXConnectionIF
      Returns:
      service interface.
    • getLdapService

      public de.elo.ix.client.ldap.LdapServiceAuth getLdapService()
      Description copied from interface: IXConnectionIF
      Get service interface for accessing LDAP.
      Specified by:
      getLdapService in interface IXConnectionIF
      Returns:
      service interface.
    • getConfigService

      public de.elo.ix.client.config.ConfigServiceAuth getConfigService()
      Description copied from interface: IXConnectionIF
      Configuration service interface.
      Specified by:
      getConfigService in interface IXConnectionIF
      Returns:
      service interface.
    • applyForNotifications

      public ApplyForNotificationsInfo applyForNotifications(ApplyForNotificationsInfo info, de.elo.ix.client.notify.BSkeleton_ClientNotification clientNotification) throws byps.RemoteException
      Specify, which notifications should be sent by the server.
      Parameters:
      info - Parameter object or null, if only the current settings should be returned.
      clientNotification - BSkeleton object with an implementation for the requested notifications.
      Returns:
      previous settings
      Throws:
      byps.RemoteException
      Since:
      9.00.000.012
    • getLogin

      @Deprecated public IXConnLogin getLogin()
      Deprecated.
      Compatibility with ELO 7.0, ELO 8.0
      Returns:
      IXConnLogin object
    • isExpired

      public boolean isExpired()
      Description copied from interface: IXConnectionIF
      Returns true, if the session is expired. The IXConnection object will automatically perform a re-login the next time an API function is called.
      Specified by:
      isExpired in interface IXConnectionIF
      Returns:
      true, if session is expired.
    • getAuthenticationType

      public EAuthenticationType getAuthenticationType()
      Specified by:
      getAuthenticationType in interface IXConnectionIF
    • setLostReverseConnectionHandler

      public void setLostReverseConnectionHandler(byps.BLostConnectionHandler lostConnectionHandler)
      Assign callback interface that is called if the connection is lost.
      Parameters:
      lostConnectionHandler - listener object
    • addAuthenticationListener

      public void addAuthenticationListener(IXAuthenticationListener lsn)
      Add callback interface that is called if authentication is renewed.
      Parameters:
      lsn -
    • removeAuthenticationListener

      public void removeAuthenticationListener(IXAuthenticationListener lsn)
      Remove callback interface for authentication.
      Parameters:
      lsn -
    • addBeforeCloseListener

      public void addBeforeCloseListener(IXConnectionCloseListener lsn)
      Add callback interface that is called before connection is closed.
      Parameters:
      lsn -
    • addAfterCloseListener

      public void addAfterCloseListener(IXConnectionCloseListener lsn)
      Add callback interface that is called after connection has been closed.
      Parameters:
      lsn -
    • removeBeforeCloseListener

      public void removeBeforeCloseListener(IXConnectionCloseListener lsn)
      Remove callback interface that is called before connection is closed.
      Parameters:
      lsn -
    • removeAfterCloseListener

      public void removeAfterCloseListener(IXConnectionCloseListener lsn)
      Remove callback interface that is called after connection has been closed.
      Parameters:
      lsn -
    • getFioService

      public de.elo.ix.client.fio.FioServiceAuth getFioService()
    • getHttpSession

      public String getHttpSession()
      Return HTTP session ID. Returns cookie JSESIONID supplied by Tomcat.
      Specified by:
      getHttpSession in interface IXConnectionIF
      Returns:
      Session ID
    • getHttpCookie

      public HttpCookie getHttpCookie(String name)
      Get HTTP session cookie. Gets the cookie with the given name.
      Specified by:
      getHttpCookie in interface IXConnectionIF
      Parameters:
      name - Cookie name, e.g. HConstants.HTTP_COOKIE_JSESSIONID
      Returns:
      Session cookie.
    • getHttpCookies

      public List<HttpCookie> getHttpCookies()
      Get HTTP cookies. EIX-3415
      Specified by:
      getHttpCookies in interface IXConnectionIF
      Returns:
      Cookies
    • setHttpCookies

      public void setHttpCookies(List<HttpCookie> cookies)
      Set (replace) all HTTP cookies. EIX-3415
      Specified by:
      setHttpCookies in interface IXConnectionIF
      Parameters:
      cookies - cookies
    • activateRoles

      public LoginResult activateRoles(List<Integer> roleIds) throws byps.RemoteException
      Replace the currently activated functional roles.
      Specified by:
      activateRoles in interface IXConnectionIF
      Parameters:
      roleIds - IDs of roles to activate.
      Returns:
      LoginResult object with updated permissions and group membership.
      Throws:
      byps.RemoteException
    • refreshLoginResult

      public LoginResult refreshLoginResult() throws byps.RemoteException
      Update the current user permissions in this connection object. This function calls getSessionFromTicket to receive the current LoginResult object that contains the current permissions and group memberships.
      Specified by:
      refreshLoginResult in interface IXConnectionIF
      Returns:
      LoginResult object with updated permissions and group membership.
      Throws:
      byps.RemoteException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getApprovedToken

      public String getApprovedToken()
      Return CSRF token to send approved REST requests. This token is used to identify CSRF attacks against operations in the rest-plugin. REST operations marked as "Approved" compare this token with the value stored in the servers session object. If the tokens do not match, the request is declined with error 403 (Forbidden). Send this token as HTTP header SessionManagement.HTTP_SESSION_HEADER_APPROVED in addition to the cookie returned by IXConnectionIF.getHttpSession() in each request.
      Specified by:
      getApprovedToken in interface IXConnectionIF
      Returns:
      CSRF token.
    • getTransportForNormalizedConnection

      protected byps.BTransport getTransportForNormalizedConnection()
      Copy the BTransport object to create a normalized connection.
      Returns:
      BTransport
    • createNormalizedConnection

      protected IXConnectionIF createNormalizedConnection(ClientInfo ci)
      Create a normalized connection object.
      Parameters:
      ci - Language, country and timezone are used by the resuting connection object.
      Returns:
      normalized connection
    • normalized

      public IXConnectionIF normalized()
      Provide a new connection object with the same session ticket initialized with language en, country US and timezone UTC.
        
       IXConnection conn = ... 
       try (IXConnectionIF connN = conn.normalized()) { 
         ClientInfo c = connN.getLoginResult().getClientInfo(); 
         System.out.println("language=" + c.getLanguage() + ", country=" + c.getCountry() + ", timeZone=" + c.getTimeZone()); 
         // prints: language=en,  country=US, timeZone=UTC> 
       } 
       
       
      This normalized connection object assumes that values of Sord.IDateIso and Sord.XDateIso are in timezone UTC. Numeric index fields of type DocMaskLineC.TYPE_NUMBER_F1, DocMaskLineC.TYPE_NUMBER_F2, DocMaskLineC.TYPE_NUMBER_F4, and DocMaskLineC.TYPE_NUMBER_F6 use a point as decimal separator (1000th grouping separators are not allowed). Numeric fields of type DocMaskLineC.TYPE_NUMBER and DocMaskLineC.TYPE_NUMBER_F0 are still interpreted by the server locale. Exception messages produces by IX are returned in English. The normalized connection must be closed after usage. EIX-1988
      Specified by:
      normalized in interface IXConnectionIF
      Returns:
      connection object
      See Also:
    • normalized

      public IXConnectionIF normalized(ClientInfo ci)
      Provide a new connection object with the same session ticket initialized with language, country and timezone from the given ClientInfo. EIX-3311
      Specified by:
      normalized in interface IXConnectionIF
      Parameters:
      ci - Language, country and time zone are used by the resulting connection object.
      Returns:
      Connection
      See Also:
    • getPackageService

      public de.elo.ix.client.PackageServiceAuth getPackageService()
      Get service interface for package data.
      Specified by:
      getPackageService in interface IXConnectionIF
      Returns:
      service interface.
    • getInstanceName

      public String getInstanceName()
      Return IXID defined in Indexserver options.
      Specified by:
      getInstanceName in interface IXConnectionIF
      Returns:
      Instance name