public class CoreInstance extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
closeCoreSession(CoreSession session)
Use
CoreSession.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.
|
static CoreInstance |
getInstance()
Deprecated.
since 8.4, use
CoreSessionService directly. |
int |
getNumberOfSessions()
Deprecated.
since 8.4, use
CoreSessionService.getNumberOfOpenCoreSessions() directly |
protected static NuxeoPrincipal |
getPrincipal(Map<String,Serializable> map) |
protected static NuxeoPrincipal |
getPrincipal(String username) |
Collection<CoreSessionService.CoreSessionRegistrationInfo> |
getRegistrationInfos()
Deprecated.
since 8.4, use
CoreSessionService.getCoreSessionRegistrationInfos() directly |
CoreSession |
getSession(String sessionId)
Gets an existing open session for the given session id.
|
static CoreSession |
openCoreSession(String repositoryName)
Opens a
CoreSession for the currently logged-in user. |
static CoreSession |
openCoreSession(String repositoryName,
Map<String,Serializable> context)
NOT PUBLIC, DO NOT CALL.
|
static CoreSession |
openCoreSession(String repositoryName,
NuxeoPrincipal principal)
MUST ONLY BE USED IN UNIT TESTS to open a
CoreSession for the given principal. |
static CoreSession |
openCoreSession(String repositoryName,
Principal principal)
MUST ONLY BE USED IN UNIT TESTS to open a
CoreSession for the given principal. |
static CoreSession |
openCoreSession(String repositoryName,
String username)
MUST ONLY BE USED IN UNIT TESTS to open a
CoreSession for the given user. |
static CoreSession |
openCoreSessionSystem(String repositoryName)
Opens a
CoreSession for a system user. |
static CoreSession |
openCoreSessionSystem(String repositoryName,
String originatingUsername)
Opens a
CoreSession for a system user with an optional originating username. |
public static CoreInstance getInstance()
CoreSessionService directly.public static CoreSession openCoreSession(String repositoryName)
CoreSession for the currently logged-in user.
The session must be closed using CoreSession.close().
repositoryName - the repository name, or null for the default repositorypublic static CoreSession openCoreSession(String repositoryName, String username)
CoreSession for the given user.
The session must be closed using CoreSession.close().
repositoryName - the repository name, or null for the default repositoryusername - the user namepublic static CoreSession openCoreSessionSystem(String repositoryName)
CoreSession for a system user.
The session must be closed using CoreSession.close().
repositoryName - the repository name, or null for the default repositorypublic static CoreSession openCoreSessionSystem(String repositoryName, String originatingUsername)
CoreSession for a system user with an optional originating username.
The session must be closed using CoreSession.close().
repositoryName - the repository name, or null for the default repositoryoriginatingUsername - the originating username to set on the SystemPrincipalpublic static CoreSession openCoreSession(String repositoryName, Map<String,Serializable> context)
Opens a CoreSession for the given context.
repositoryName - the repository name, or null for the default repositorycontext - the session open contextpublic static CoreSession openCoreSession(String repositoryName, Principal principal)
CoreSession for the given principal.
The session must be closed using CoreSession.close().
repositoryName - the repository name, or null for the default repositoryprincipal - the principalpublic static CoreSession openCoreSession(String repositoryName, NuxeoPrincipal principal)
CoreSession for the given principal.
The session must be closed using CoreSession.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(CoreSession session)
CoreSession.close() instead.protected static NuxeoPrincipal getPrincipal(Map<String,Serializable> map)
protected static NuxeoPrincipal getPrincipal(String username)
@Deprecated public int getNumberOfSessions()
CoreSessionService.getNumberOfOpenCoreSessions() directly@Deprecated public Collection<CoreSessionService.CoreSessionRegistrationInfo> getRegistrationInfos()
CoreSessionService.getCoreSessionRegistrationInfos() directlyprotected 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 © 2018 Nuxeo. All rights reserved.