Class IXConnectionWrapper

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

public abstract class IXConnectionWrapper extends Object implements IXConnectionIF
This class wraps a IXConnectionIF to intercept function calls.
  • Constructor Details

    • IXConnectionWrapper

      public IXConnectionWrapper()
  • Method Details

    • getInnerConnection

      protected abstract IXConnectionIF getInnerConnection()
      Return the wrapped connection object.
      Returns:
      Wrapped 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:
    • ix

      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()
      Get LoginResult object.
      Specified by:
      getLoginResult in interface IXConnectionIF
      Returns:
      LoginResult object.
    • getUserId

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

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

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

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

      public IXProperties getSessionOptions()
      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()
      Detect Indexserver version without build number.
      Specified by:
      getVersion in interface IXConnectionIF
      Returns:
      IX-Version
    • getImplVersion

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

      public String getInterfaceVersion()
      Detect Indexserver SOAP interface version.
      Specified by:
      getInterfaceVersion in interface IXConnectionIF
      Returns:
      SOAP interface version
    • getClientVersion

      public String getClientVersion()
      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()
      Returns the negotiated stream version.
      Specified by:
      getStreamVersion in interface IXConnectionIF
      Returns:
      negotiated protocol version
    • getServerTime

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

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

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

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

      public Date isoToDate(String iso)
      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)
      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
    • upload

      public String upload(String url, File file) throws byps.RemoteException
      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
      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
      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
      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 url, 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
      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

      public void logout()
      Internally calls close().
      Specified by:
      logout in interface IXConnectionIF
    • close

      public void close()
      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
    • getFileExt

      public String getFileExt(File file)
      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
      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()
      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)
      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
      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()
      Get service interface for document feed.
      Specified by:
      getFeedService in interface IXConnectionIF
      Returns:
      service interface.
    • getRawStreamService

      public de.elo.ix.client.compatibility.RawStreamServiceAuth getRawStreamService()
      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()
      Get service interface for accessing plugins.
      Specified by:
      getPluginService in interface IXConnectionIF
      Returns:
      service interface.
    • getHealthCheckService

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

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

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

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

      public boolean isExpired()
      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
    • 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)
      Return HTTP cookie. Returns cookie with the given name or null.
      Specified by:
      getHttpCookie in interface IXConnectionIF
      Parameters:
      name - Cookie name
      Returns:
      Cookie or null, if cookie does not exist.
    • 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
    • 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.
    • getPackageService

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