Package de.elo.ix.client
Class IXConnectionWrapper
java.lang.Object
de.elo.ix.client.IXConnectionWrapper
- All Implemented Interfaces:
IXConnectionIF
,AutoCloseable
This class wraps a IXConnectionIF to intercept function calls.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionactivateRoles
(List<Integer> roleIds) Replace the currently activated functional roles.void
close()
Disconnect the IXConnection object and maybe logout the session.createConnectionForUser
(String runAsName) Creates new connection for a "run as" user, running on the already existent ticket.Convert a java.util.Date into an ISO date related to the current timezone.void
download
(String url, long offset, long length, IXClientIF.ContentStream cstrm) Download bytes from the given URL.void
void
Download a file from the given URL.Encrytps a password used to login or to supply an encryption set password.Return CSRF token to send approved REST requests.Returns the version of the IXClient class, resp.de.elo.ix.client.config.ConfigServiceAuth
Configuration service interface.Get the connection properties.getCONST()
Constants.void
getCONST
(byps.BAsyncResult<IXServicePortC> asyncResult) Constants.Returns the name of the database engine (MSSQL, ORACLE, DB2).Retuns the Indexserver URLde.elo.ix.client.feed.FeedServiceAuth
Get service interface for document feed.getFileExt
(File file) Returns the file extension of the given file name without dot.getFileMd5
(File file) Computes the MD5 hash for the given file.de.elo.ix.client.health.HealthCheckServiceAuth
Get service interface for the health check service.getHttpCookie
(String name) Return HTTP cookie.Return HTTP session ID.Detect Indexserver version with build number.protected abstract IXConnectionIF
Return the wrapped connection object.Return IXID defined in Indexserver options.Detect Indexserver SOAP interface version.de.elo.ix.client.ldap.LdapServiceAuth
Get service interface for accessing LDAP.Get LoginResult object.de.elo.ix.client.PackageServiceAuth
Get service interface for package data.de.elo.ix.client.plugin.PluginServiceAuth
Get service interface for accessing plugins.de.elo.ix.client.compatibility.RawStreamServiceAuth
Internal interface for file upload and download.Gets the current server time.Get the session options.Returns the negotiated stream version.de.elo.ix.client.system.SystemInformationAuth
Get service interface for system information.int
Get current user ID.Get current user name.Detect Indexserver version without build number.boolean
Returns true, if the session is expired.Convert an ISO date to a java.util.Date.ix()
Get Indexserver API object.void
logout()
Internally calls close().Provide a new connection object with the same session ticket initialized with language en, country US and timezone UTC.normalized
(ClientInfo ci) Provide a new connection object with the same session ticket initialized with language, country and timezone from the givenClientInfo
.Update the current user permissions in this connection object.This function truncates s to the length of max.Upload a file to the given URL.upload
(String url, InputStream is, long contentLength, String contentType) Upload the bytes of a InputStream object to the given URL.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface de.elo.ix.client.IXConnectionIF
getHttpCookies, setHttpCookies
-
Constructor Details
-
IXConnectionWrapper
public IXConnectionWrapper()
-
-
Method Details
-
getInnerConnection
Return the wrapped connection object.- Returns:
- Wrapped connection
-
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> }
Sord.IDateIso
andSord.XDateIso
are in timezone UTC. Numeric index fields of typeDocMaskLineC.TYPE_NUMBER_F1
,DocMaskLineC.TYPE_NUMBER_F2
,DocMaskLineC.TYPE_NUMBER_F4
, andDocMaskLineC.TYPE_NUMBER_F6
use a point as decimal separator (1000th grouping separators are not allowed). Numeric fields of typeDocMaskLineC.TYPE_NUMBER
andDocMaskLineC.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 interfaceIXConnectionIF
- Returns:
- connection object
- See Also:
-
normalized
Provide a new connection object with the same session ticket initialized with language, country and timezone from the givenClientInfo
. EIX-3311- Specified by:
normalized
in interfaceIXConnectionIF
- 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 interfaceIXConnectionIF
- Returns:
- Indexserver interface object.
-
getLoginResult
Get LoginResult object.- Specified by:
getLoginResult
in interfaceIXConnectionIF
- Returns:
- LoginResult object.
-
getUserId
public int getUserId()Get current user ID.- Specified by:
getUserId
in interfaceIXConnectionIF
- Returns:
- User ID.
-
getUserName
Get current user name.- Specified by:
getUserName
in interfaceIXConnectionIF
- Returns:
- User name.
-
getConnProperties
Get the connection properties.- Specified by:
getConnProperties
in interfaceIXConnectionIF
- Returns:
- Connection properties.
-
getEndpointUrl
Retuns the Indexserver URL- Specified by:
getEndpointUrl
in interfaceIXConnectionIF
- Returns:
- URL
-
getSessionOptions
Get the session options. They are requested from the IXConnLogin object.- Specified by:
getSessionOptions
in interfaceIXConnectionIF
- Returns:
- Session options.
- See Also:
-
getVersion
Detect Indexserver version without build number.- Specified by:
getVersion
in interfaceIXConnectionIF
- Returns:
- IX-Version
-
getImplVersion
Detect Indexserver version with build number.- Specified by:
getImplVersion
in interfaceIXConnectionIF
- Returns:
- IX-Version
-
getInterfaceVersion
Detect Indexserver SOAP interface version.- Specified by:
getInterfaceVersion
in interfaceIXConnectionIF
- Returns:
- SOAP interface version
-
getClientVersion
Returns the version of the IXClient class, resp. the latest binary protocol version the IXClient class can understand.- Specified by:
getClientVersion
in interfaceIXConnectionIF
- Returns:
- latest protocol version
- See Also:
-
getStreamVersion
Returns the negotiated stream version.- Specified by:
getStreamVersion
in interfaceIXConnectionIF
- Returns:
- negotiated protocol version
-
getServerTime
Gets the current server time.- Specified by:
getServerTime
in interfaceIXConnectionIF
- Returns:
- Server time.
-
getInstanceName
Return IXID defined in Indexserver options.- Specified by:
getInstanceName
in interfaceIXConnectionIF
- Returns:
- Instance name
-
getCONST
Constants.- Specified by:
getCONST
in interfaceIXConnectionIF
- Returns:
- Constant object.
- Throws:
byps.RemoteException
-
getCONST
Constants.- Specified by:
getCONST
in interfaceIXConnectionIF
- Parameters:
asyncResult
- Callback interface that receives the result.
-
isoToDate
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 interfaceIXConnectionIF
- Parameters:
iso
- ISO date- Returns:
- java.util.Date (always UTC, use java.util.Calendar for formatting)
-
dateToIso
Convert a java.util.Date into an ISO date related to the current timezone.- Specified by:
dateToIso
in interfaceIXConnectionIF
- Parameters:
dt
- Java date object- Returns:
- ISO date
-
upload
Upload a file to the given URL.- Specified by:
upload
in interfaceIXConnectionIF
- 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 interfaceIXConnectionIF
- Parameters:
url
- Destination URL.is
- InputStream object to read from.contentLength
- Number of bytes contained inis
.contentType
- MIME type of the data contained inis
.- Throws:
byps.RemoteException
-
download
Download a file from the given URL.- Specified by:
download
in interfaceIXConnectionIF
- Parameters:
url
- URL to download.file
- The contents are stored in thisFile
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 interfaceIXConnectionIF
- 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
- Specified by:
download
in interfaceIXConnectionIF
- Throws:
byps.RemoteException
-
download
- Specified by:
download
in interfaceIXConnectionIF
- Throws:
byps.RemoteException
-
encryptPassword
Encrytps a password used to login or to supply an encryption set password.- Specified by:
encryptPassword
in interfaceIXConnectionIF
- Parameters:
s
- Plain text password.- Returns:
- Encrypted password.
- Throws:
byps.RemoteException
-
logout
public void logout()Internally calls close().- Specified by:
logout
in interfaceIXConnectionIF
-
close
public void close()Disconnect the IXConnection object and maybe logout the session. The session is logged out if it was not created byIXConnFactory.createFromTicket(ClientInfo)
.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceIXConnectionIF
-
getFileExt
Returns the file extension of the given file name without dot.- Specified by:
getFileExt
in interfaceIXConnectionIF
- Parameters:
file
- File object.- Returns:
- File extension.
-
getFileMd5
Computes the MD5 hash for the given file.- Specified by:
getFileMd5
in interfaceIXConnectionIF
- Parameters:
file
- File object.- Returns:
- MD5 hash in String format.
- Throws:
IOException
-
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 interfaceIXConnectionIF
- Returns:
- Database engine name.
-
truncate
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 interfaceIXConnectionIF
- Parameters:
s
- String to be truncatedmax
- Database column width from a member length value of a constant class.- Returns:
- Truncated String or s.
-
getEventBusApi
- Specified by:
getEventBusApi
in interfaceIXConnectionIF
-
createConnectionForUser
Creates new connection for a "run as" user, running on the already existent ticket.- Specified by:
createConnectionForUser
in interfaceIXConnectionIF
- 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 interfaceIXConnectionIF
- Returns:
- service interface.
-
getRawStreamService
public de.elo.ix.client.compatibility.RawStreamServiceAuth getRawStreamService()Internal interface for file upload and download.- Specified by:
getRawStreamService
in interfaceIXConnectionIF
- Returns:
- service interface
-
getPluginService
public de.elo.ix.client.plugin.PluginServiceAuth getPluginService()Get service interface for accessing plugins.- Specified by:
getPluginService
in interfaceIXConnectionIF
- Returns:
- service interface.
-
getHealthCheckService
public de.elo.ix.client.health.HealthCheckServiceAuth getHealthCheckService()Get service interface for the health check service.- Specified by:
getHealthCheckService
in interfaceIXConnectionIF
- Returns:
- service interface.
-
getLdapService
public de.elo.ix.client.ldap.LdapServiceAuth getLdapService()Get service interface for accessing LDAP.- Specified by:
getLdapService
in interfaceIXConnectionIF
- Returns:
- service interface.
-
getConfigService
public de.elo.ix.client.config.ConfigServiceAuth getConfigService()Configuration service interface.- Specified by:
getConfigService
in interfaceIXConnectionIF
- Returns:
- service interface.
-
getSystemInformation
public de.elo.ix.client.system.SystemInformationAuth getSystemInformation()Get service interface for system information. EIX-3356- Specified by:
getSystemInformation
in interfaceIXConnectionIF
- 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 interfaceIXConnectionIF
- Returns:
- true, if session is expired.
-
getAuthenticationType
- Specified by:
getAuthenticationType
in interfaceIXConnectionIF
-
getHttpSession
Return HTTP session ID. Returns cookie JSESIONID supplied by Tomcat.- Specified by:
getHttpSession
in interfaceIXConnectionIF
- Returns:
- Session ID
-
getHttpCookie
Return HTTP cookie. Returns cookie with the given name or null.- Specified by:
getHttpCookie
in interfaceIXConnectionIF
- Parameters:
name
- Cookie name- Returns:
- Cookie or null, if cookie does not exist.
-
activateRoles
Replace the currently activated functional roles.- Specified by:
activateRoles
in interfaceIXConnectionIF
- Parameters:
roleIds
- IDs of roles to activate.- Returns:
- LoginResult object with updated permissions and group membership.
- Throws:
byps.RemoteException
-
refreshLoginResult
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 interfaceIXConnectionIF
- Returns:
- LoginResult object with updated permissions and group membership.
- Throws:
byps.RemoteException
-
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 headerSessionManagement.HTTP_SESSION_HEADER_APPROVED
in addition to the cookie returned byIXConnectionIF.getHttpSession()
in each request.- Specified by:
getApprovedToken
in interfaceIXConnectionIF
- Returns:
- CSRF token.
-
getPackageService
public de.elo.ix.client.PackageServiceAuth getPackageService()Get service interface for package data.- Specified by:
getPackageService
in interfaceIXConnectionIF
- Returns:
- service interface.
-