public class CoreInstance extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
closeCoreSession(CloseableCoreSession session)
Use
CloseableCoreSession.close() instead. |
static void |
doPrivileged(CoreSession session,
Consumer<CoreSession> consumer)
Runs the given
Consumer with a system CoreSession while logged in as a system user. |
static <R> R |
doPrivileged(CoreSession session,
Function<CoreSession,R> function)
Runs the given
Function with a system CoreSession while logged in as a system user. |
static void |
doPrivileged(String repositoryName,
Consumer<CoreSession> consumer)
Runs the given
Consumer with a system CoreSession while logged in as a system user. |
static <R> R |
doPrivileged(String repositoryName,
Function<CoreSession,R> function)
Runs the given
Function with a system CoreSession while logged in as a system user. |
protected static String |
getCurrentPrincipalName()
Gets the name of the currently logged-in principal.
|
protected static NuxeoPrincipal |
getPrincipal(String username) |
CoreSession |
getSession(String sessionId)
Gets an existing open session for the given session id.
|
static CloseableCoreSession |
openCoreSession(String repositoryName)
Opens a
CoreSession for the currently logged-in user. |
static CloseableCoreSession |
openCoreSession(String repositoryName,
NuxeoPrincipal principal)
Opens a
CoreSession for the given principal. |
static CloseableCoreSession |
openCoreSession(String repositoryName,
String username)
MUST ONLY BE USED IN UNIT TESTS to open a
CoreSession for the given user. |
static CloseableCoreSession |
openCoreSessionSystem(String repositoryName)
Opens a
CoreSession for a system user. |
static CloseableCoreSession |
openCoreSessionSystem(String repositoryName,
String originatingUsername)
Opens a
CoreSession for a system user with an optional originating username. |
public static CloseableCoreSession openCoreSession(String repositoryName)
CoreSession for the currently logged-in user.
The session must be closed using CloseableCoreSession.close().
repositoryName - the repository name, or null for the default repositorypublic static CloseableCoreSession openCoreSession(String repositoryName, String username)
CoreSession for the given user.
The session must be closed using CloseableCoreSession.close().
repositoryName - the repository name, or null for the default repositoryusername - the user namepublic static CloseableCoreSession openCoreSessionSystem(String repositoryName)
CoreSession for a system user.
The session must be closed using CloseableCoreSession.close().
repositoryName - the repository name, or null for the default repositorypublic static CloseableCoreSession openCoreSessionSystem(String repositoryName, String originatingUsername)
CoreSession for a system user with an optional originating username.
The session must be closed using CloseableCoreSession.close().
repositoryName - the repository name, or null for the default repositoryoriginatingUsername - the originating username to set on the SystemPrincipalpublic static CloseableCoreSession openCoreSession(String repositoryName, NuxeoPrincipal principal)
CoreSession for the given principal.
The session must be closed using CloseableCoreSession.close().
repositoryName - the repository name, or null for the default repositoryprincipal - the principalpublic CoreSession getSession(String sessionId)
The returned CoreSession must not be closed, as it is owned by someone else.
sessionId - the session idpublic static void closeCoreSession(CloseableCoreSession session)
CloseableCoreSession.close() instead.protected static NuxeoPrincipal getPrincipal(String username)
protected static String getCurrentPrincipalName()
null if there was no loginpublic static <R> R doPrivileged(String repositoryName, Function<CoreSession,R> function)
Function with a system CoreSession while logged in as a system user.R - the function return typerepositoryName - the repository name for the CoreSessionfunction - the function taking a system CoreSession and returning a result of type <R>public static <R> R doPrivileged(CoreSession session, Function<CoreSession,R> function)
Function with a system CoreSession while logged in as a system user.R - the function return typesession - an existing sessionfunction - the function taking a system CoreSession and returning a result of type <R>public static void doPrivileged(String repositoryName, Consumer<CoreSession> consumer)
Consumer with a system CoreSession while logged in as a system user.repositoryName - the repository name for the CoreSessionconsumer - the consumer taking a system CoreSessionpublic static void doPrivileged(CoreSession session, Consumer<CoreSession> consumer)
Consumer with a system CoreSession while logged in as a system user.session - an existing sessionconsumer - the consumer taking a system CoreSessionCopyright © 2019 Nuxeo. All rights reserved.