Package de.elo.ix.client
Class IXConnection
java.lang.Object
de.elo.ix.client.IXConnection
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionprotected List<IXConnectionCloseListener>
Listeners to be called after a connection has been closed.protected final IXAuthenticationIF
protected final de.elo.ix.client.BClient_Indexserver
protected List<IXConnectionCloseListener>
Listeners to be called before a connection is closed.protected final IXConnFactory
Deprecated.protected IXConnLoginBYPS
Deprecated.protected Properties
Connection properties.protected IXServicePortC
protected String
Database engine name.protected EventBusApi
protected String
Indexserver version and build number.protected IXConnIXServicePortIF_2
Encapsulated Indexserver interface that obtains interface functions without ClientInfo parameter.protected final String
Indexserver URL -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
IXConnection
(IXConnection rhs, IXAuthenticationIF auth, byps.BTransport transport) Copy constructor.protected
IXConnection
(IXConnFactory connFact, de.elo.ix.client.BClient_Indexserver bclient, IXAuthenticationIF auth, String url, Properties connProps) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionactivateRoles
(List<Integer> roleIds) Replace the currently activated functional roles.void
Add callback interface that is called after connection has been closed.void
Add callback interface that is called if authentication is renewed.void
Add callback interface that is called before connection is closed.applyForNotifications
(ApplyForNotificationsInfo info, de.elo.ix.client.notify.BSkeleton_ClientNotification clientNotification) Specify, which notifications should be sent by the server.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.protected IXConnectionIF
Create a normalized connection object.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.getFileExt
(String fileName) getFileMd5
(File file) Computes the MD5 hash for the given file.de.elo.ix.client.fio.FioServiceAuth
de.elo.ix.client.health.HealthCheckServiceAuth
Get service interface for the health check service.getHttpCookie
(String name) Get HTTP session cookie.Get HTTP cookies.Return HTTP session ID.Detect Indexserver version with build number.Return IXID defined in Indexserver options.Deprecated.de.elo.ix.client.ldap.LdapServiceAuth
Get service interface for accessing LDAP.getLogin()
Deprecated.Get LoginResult object.int
de.elo.ix.client.myelo.MyELOServiceAuth
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.protected byps.BTransport
Copy the BTransport object to create a normalized connection.int
Get current user ID.Get current user name.Detect Indexserver version without build number.protected void
boolean
Returns true, if the session is expired.Convert an ISO date to a java.util.Date.ix()
Get Indexserver API object.void
logout()
Deprecated.Use close instead.static String[]
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.void
Remove callback interface that is called after connection has been closed.void
Remove callback interface for authentication.void
Remove callback interface that is called before connection is closed.void
setFeedNotification
(de.elo.ix.client.feed.BSkeleton_FeedNotification feedNotification) Set notification interface for document feed events.void
setHttpCookies
(List<HttpCookie> cookies) Set (replace) all HTTP cookies.void
setLostReverseConnectionHandler
(byps.BLostConnectionHandler lostConnectionHandler) Assign callback interface that is called if the connection is lost.static String
staticDateToIso
(Date dt, boolean toUtc) Convert a java.util.Date object into a ISO date string.static Date
staticIsoToDate
(String iso, boolean isUtc) Convert an ISO date into a java.util.Date object.toString()
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.
-
Field Details
-
ixVal
Encapsulated Indexserver interface that obtains interface functions without ClientInfo parameter. Use this object to access the Indexserver. -
connProps
Connection properties. This properties are the same that have beed supplied to the IXConnFactory object. -
databaseEngine
Database engine name. -
implVersion
Indexserver version and build number. -
eventBusApi
-
bclient
protected final de.elo.ix.client.BClient_Indexserver bclient -
auth
-
url
Indexserver URL -
CONST
-
connLogin
Deprecated.Compatibilty with API 7.0 and 8.0. -
connFact
Deprecated.Compatibilty with API 7.0 and 8.0. -
beforeCloseListener
Listeners to be called before a connection is closed. -
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 objectauth
- Authentication callback interfaceurl
- Indexserver URLconnProps
- Connection properties.
-
IXConnection
Copy constructor. This constructor is used to create a normalized connection.- Parameters:
rhs
- base connectionauth
- authentication handlertransport
- 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 interfaceIXConnectionIF
- Returns:
- Indexserver interface object.
-
getLoginResult
Description copied from interface:IXConnectionIF
Get LoginResult object.- Specified by:
getLoginResult
in interfaceIXConnectionIF
- Returns:
- LoginResult object.
-
getUserId
public int getUserId()Description copied from interface:IXConnectionIF
Get current user ID.- Specified by:
getUserId
in interfaceIXConnectionIF
- Returns:
- User ID.
-
getUserName
Description copied from interface:IXConnectionIF
Get current user name.- Specified by:
getUserName
in interfaceIXConnectionIF
- Returns:
- User name.
-
getConnProperties
Description copied from interface:IXConnectionIF
Get the connection properties.- Specified by:
getConnProperties
in interfaceIXConnectionIF
- Returns:
- Connection properties.
-
getEndpointUrl
Description copied from interface:IXConnectionIF
Retuns the Indexserver URL- Specified by:
getEndpointUrl
in interfaceIXConnectionIF
- Returns:
- URL
-
getSessionOptions
Description copied from interface:IXConnectionIF
Get the session options. They are requested from the IXConnLogin object.- Specified by:
getSessionOptions
in interfaceIXConnectionIF
- Returns:
- Session options.
- See Also:
-
getVersion
Description copied from interface:IXConnectionIF
Detect Indexserver version without build number.- Specified by:
getVersion
in interfaceIXConnectionIF
- Returns:
- IX-Version
-
getMajorVersion
public int getMajorVersion()- Returns:
- MajorVersion as int
-
getImplVersion
Description copied from interface:IXConnectionIF
Detect Indexserver version with build number.- Specified by:
getImplVersion
in interfaceIXConnectionIF
- Returns:
- IX-Version
-
getInterfaceVersion
Deprecated.Description copied from interface:IXConnectionIF
Detect Indexserver SOAP interface version.- Specified by:
getInterfaceVersion
in interfaceIXConnectionIF
- Returns:
- SOAP interface version
-
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 interfaceIXConnectionIF
- Returns:
- latest protocol version
- See Also:
-
getStreamVersion
Description copied from interface:IXConnectionIF
Returns the negotiated stream version.- Specified by:
getStreamVersion
in interfaceIXConnectionIF
- Returns:
- negotiated protocol version
-
getServerTime
Description copied from interface:IXConnectionIF
Gets the current server time.- Specified by:
getServerTime
in interfaceIXConnectionIF
- Returns:
- Server time.
-
getCONST
Description copied from interface:IXConnectionIF
Constants.- Specified by:
getCONST
in interfaceIXConnectionIF
- Returns:
- Constant object.
- Throws:
byps.RemoteException
-
getCONST
Description copied from interface:IXConnectionIF
Constants.- Specified by:
getCONST
in interfaceIXConnectionIF
- Parameters:
asyncResult
- Callback interface that receives the result.
-
isoToDate
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 interfaceIXConnectionIF
- Parameters:
iso
- ISO date- Returns:
- java.util.Date (always UTC, use java.util.Calendar for formatting)
-
dateToIso
Description copied from interface:IXConnectionIF
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
-
staticIsoToDate
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 dateisUtc
- true, if ISO date is in the UTC timezone.- Returns:
- Date object
-
staticDateToIso
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 objecttoUtc
- true, if the returned string should contain an UTC date.- Returns:
- ISO date
-
makeRawStreamServiceParamsFromUrl
-
upload
Description copied from interface:IXConnectionIF
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 Description copied from interface:IXConnectionIF
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
Description copied from interface:IXConnectionIF
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 Description copied from interface:IXConnectionIF
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
public InputStream download(String downloadUrl, long offset, long length) throws byps.RemoteException - Specified by:
download
in interfaceIXConnectionIF
- Throws:
byps.RemoteException
-
download
- Specified by:
download
in interfaceIXConnectionIF
- Throws:
byps.RemoteException
-
encryptPassword
Description copied from interface:IXConnectionIF
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
Deprecated.Use close instead.Description copied from interface:IXConnectionIF
Internally calls close().- Specified by:
logout
in interfaceIXConnectionIF
-
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 byIXConnFactory.createFromTicket(ClientInfo)
.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceIXConnectionIF
-
internalLogout
protected void internalLogout() -
getFileExt
-
getFileExt
Description copied from interface:IXConnectionIF
Returns the file extension of the given file name without dot.- Specified by:
getFileExt
in interfaceIXConnectionIF
- Parameters:
file
- File object.- Returns:
- File extension.
-
getFileMd5
Description copied from interface:IXConnectionIF
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
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 interfaceIXConnectionIF
- Returns:
- Database engine name.
-
truncate
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 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
Description copied from interface:IXConnectionIF
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()Description copied from interface:IXConnectionIF
Get service interface for document feed.- Specified by:
getFeedService
in interfaceIXConnectionIF
- 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 interfaceIXConnectionIF
- 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 interfaceIXConnectionIF
- 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 interfaceIXConnectionIF
- 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 interfaceIXConnectionIF
- 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 interfaceIXConnectionIF
- Returns:
- service interface.
-
getConfigService
public de.elo.ix.client.config.ConfigServiceAuth getConfigService()Description copied from interface:IXConnectionIF
Configuration service interface.- Specified by:
getConfigService
in interfaceIXConnectionIF
- 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.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 interfaceIXConnectionIF
- Returns:
- true, if session is expired.
-
getAuthenticationType
- Specified by:
getAuthenticationType
in interfaceIXConnectionIF
-
setLostReverseConnectionHandler
public void setLostReverseConnectionHandler(byps.BLostConnectionHandler lostConnectionHandler) Assign callback interface that is called if the connection is lost.- Parameters:
lostConnectionHandler
- listener object
-
addAuthenticationListener
Add callback interface that is called if authentication is renewed.- Parameters:
lsn
-
-
removeAuthenticationListener
Remove callback interface for authentication.- Parameters:
lsn
-
-
addBeforeCloseListener
Add callback interface that is called before connection is closed.- Parameters:
lsn
-
-
addAfterCloseListener
Add callback interface that is called after connection has been closed.- Parameters:
lsn
-
-
removeBeforeCloseListener
Remove callback interface that is called before connection is closed.- Parameters:
lsn
-
-
removeAfterCloseListener
Remove callback interface that is called after connection has been closed.- Parameters:
lsn
-
-
getFioService
public de.elo.ix.client.fio.FioServiceAuth getFioService() -
getHttpSession
Return HTTP session ID. Returns cookie JSESIONID supplied by Tomcat.- Specified by:
getHttpSession
in interfaceIXConnectionIF
- Returns:
- Session ID
-
getHttpCookie
Get HTTP session cookie. Gets the cookie with the given name.- Specified by:
getHttpCookie
in interfaceIXConnectionIF
- Parameters:
name
- Cookie name, e.g. HConstants.HTTP_COOKIE_JSESSIONID- Returns:
- Session cookie.
-
getHttpCookies
Get HTTP cookies. EIX-3415- Specified by:
getHttpCookies
in interfaceIXConnectionIF
- Returns:
- Cookies
-
setHttpCookies
Set (replace) all HTTP cookies. EIX-3415- Specified by:
setHttpCookies
in interfaceIXConnectionIF
- Parameters:
cookies
- cookies
-
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
-
toString
-
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.
-
getTransportForNormalizedConnection
protected byps.BTransport getTransportForNormalizedConnection()Copy the BTransport object to create a normalized connection.- Returns:
- BTransport
-
createNormalizedConnection
Create a normalized connection object.- Parameters:
ci
- Language, country and timezone are used by the resuting connection object.- Returns:
- normalized 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:
-
getPackageService
public de.elo.ix.client.PackageServiceAuth getPackageService()Get service interface for package data.- Specified by:
getPackageService
in interfaceIXConnectionIF
- Returns:
- service interface.
-
getInstanceName
Return IXID defined in Indexserver options.- Specified by:
getInstanceName
in interfaceIXConnectionIF
- Returns:
- Instance name
-