Class BlueMindCalendarSessions
java.lang.Object
org.exoplatform.bluemind.calendar.service.BlueMindCalendarSessions
The calendar contributions' one door onto BlueMind's REST API: every REST
conversation they hold goes through
BlueMindRestClient.call(org.exoplatform.bluemind.client.BlueMindAccountSource, java.util.function.Function<org.exoplatform.bluemind.client.BlueMindSession, T>), or
open(org.exoplatform.caldav.client.CalDavEndpoint) for an operation of several calls, whose holder translates its
session's failures (CalDavFailures.translate(org.exoplatform.bluemind.client.exception.BlueMindException)); either is keyed and
credentialed from the host's endpoint.
Three things are decided here and nowhere else:
- Who a session is kept for (
keyOf(org.exoplatform.caldav.client.CalDavEndpoint)): the declared server, the eXo login the endpoint was minted for, the account the configured provider addresses on that server, and the calendar's login origin — so that no session ever serves an account other than the one it was minted for (EXO-90397). An endpoint without an eXo login, or whose provider cannot name the account it would address, is not keyed: its call opens its own session and closes it. - Where the credentials come from: a
CaldavAccountSourceover the endpoint, which also says whether a refused login may be retried once on fresh material (EXO-89649). - What a failure is: anything the library throws through
call(org.exoplatform.caldav.client.CalDavEndpoint, java.util.function.Function<org.exoplatform.bluemind.client.BlueMindSession, T>), the job's own calls included, leaves as the host's type (CalDavFailures); a session fromopen(org.exoplatform.caldav.client.CalDavEndpoint)throws the library's types, which its holder translates. Nothing of typeBlueMindExceptioncrosses a calendar SPI.
-
Constructor Summary
ConstructorsConstructorDescriptionBlueMindCalendarSessions(HttpClient httpClient, org.exoplatform.caldav.provider.CaldavCredentialsResolver caldavCredentialsResolver) The seam the protocol tests use: a client over a handed-in transport that keeps nothing, so each call opens and closes its own session.BlueMindCalendarSessions(org.exoplatform.bluemind.client.BlueMindRestClient restClient, org.exoplatform.caldav.provider.CaldavCredentialsResolver caldavCredentialsResolver, boolean keeps) The door over the add-on's client. -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptsCredentials(org.exoplatform.caldav.client.CalDavEndpoint endpoint) Whether the endpoint's configured credentials are a login and password this API can take, without calling the server.<T> Tcall(org.exoplatform.caldav.client.CalDavEndpoint endpoint, Function<org.exoplatform.bluemind.client.BlueMindSession, T> job) Runs one job inside a REST session opened as the endpoint's account — the kept one when there is one, a fresh login otherwise — with every failure translated to the host's types.voidDrops and closes the sessions kept for one eXo user on one declared server.voidDrops every session the calendar keeps, because its declared servers changed under them: only the keys of the "caldav:" namespace, since the client's cache is the add-on's one cache and the mail connector's sessions have nothing to do with a calendar registration.org.exoplatform.bluemind.client.BlueMindSessionopen(org.exoplatform.caldav.client.CalDavEndpoint endpoint) Opens a REST session as the endpoint's account for an operation of several calls that must share it — the kept one when there is one, a fresh login otherwise.tools.jackson.databind.JsonNodeParses a JSON answer.
-
Constructor Details
-
BlueMindCalendarSessions
public BlueMindCalendarSessions(org.exoplatform.bluemind.client.BlueMindRestClient restClient, org.exoplatform.caldav.provider.CaldavCredentialsResolver caldavCredentialsResolver, boolean keeps) The door over the add-on's client.- Parameters:
restClient- the BlueMind REST clientcaldavCredentialsResolver- the credentials seamkeeps- whether the client's session cache keeps anything
-
BlueMindCalendarSessions
public BlueMindCalendarSessions(HttpClient httpClient, org.exoplatform.caldav.provider.CaldavCredentialsResolver caldavCredentialsResolver) The seam the protocol tests use: a client over a handed-in transport that keeps nothing, so each call opens and closes its own session.- Parameters:
httpClient- the transportcaldavCredentialsResolver- the credentials seam
-
-
Method Details
-
call
public <T> T call(org.exoplatform.caldav.client.CalDavEndpoint endpoint, Function<org.exoplatform.bluemind.client.BlueMindSession, T> job) Runs one job inside a REST session opened as the endpoint's account — the kept one when there is one, a fresh login otherwise — with every failure translated to the host's types.- Type Parameters:
T- what the job produces- Parameters:
endpoint- the account's endpoint, minted by the host from its registryjob- the calls to make with the session- Returns:
- what the job produced
- Throws:
UnsupportedOperationException- when the configured credentials are not a login and passwordorg.exoplatform.caldav.client.CalDavAuthenticationException- when BlueMind refuses the loginorg.exoplatform.caldav.client.CalDavUnreachableException- when the server cannot be reachedorg.exoplatform.caldav.client.CalDavException- on any other failure
-
open
public org.exoplatform.bluemind.client.BlueMindSession open(org.exoplatform.caldav.client.CalDavEndpoint endpoint) Opens a REST session as the endpoint's account for an operation of several calls that must share it — the kept one when there is one, a fresh login otherwise. The caller closes it; what the session's own calls throw is the library's type, which the caller translates (CalDavFailures.translate(org.exoplatform.bluemind.client.exception.BlueMindException)).- Parameters:
endpoint- the account's endpoint, minted by the host from its registry- Returns:
- the session, to close
- Throws:
UnsupportedOperationException- when the configured credentials are not a login and passwordorg.exoplatform.caldav.client.CalDavAuthenticationException- when BlueMind refuses the loginorg.exoplatform.caldav.client.CalDavUnreachableException- when the server cannot be reachedorg.exoplatform.caldav.client.CalDavException- on any other failure
-
acceptsCredentials
public boolean acceptsCredentials(org.exoplatform.caldav.client.CalDavEndpoint endpoint) Whether the endpoint's configured credentials are a login and password this API can take, without calling the server.- Parameters:
endpoint- the account's endpoint- Returns:
- true when the provider produces a Basic login and password
-
parse
Parses a JSON answer.- Parameters:
body- the bodyuri- the request, for the message- Returns:
- the tree
- Throws:
org.exoplatform.caldav.client.CalDavException- when the body is not JSON
-
forget
Drops and closes the sessions kept for one eXo user on one declared server.- Parameters:
serverId- the declared server, null for the legacy deployment propertyexoLogin- the eXo login whose sessions go
-
forgetAll
public void forgetAll()Drops every session the calendar keeps, because its declared servers changed under them: only the keys of the "caldav:" namespace, since the client's cache is the add-on's one cache and the mail connector's sessions have nothing to do with a calendar registration.
-