Package org.nuxeo.ecm.core.api
Class CoreInstance
- java.lang.Object
-
- org.nuxeo.ecm.core.api.CoreInstance
-
public class CoreInstance extends Object
The CoreInstance is the main access point to a CoreSession.
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
closeCoreSession(CloseableCoreSession session)
Deprecated.since 11.1, does nothingstatic void
doPrivileged(String repositoryName, Consumer<CoreSession> consumer)
Runs the givenConsumer
with a systemCoreSession
while logged in as a system user.static <R> R
doPrivileged(String repositoryName, Function<CoreSession,R> function)
Runs the givenFunction
with a systemCoreSession
while logged in as a system user.static void
doPrivileged(CoreSession session, Consumer<CoreSession> consumer)
Runs the givenConsumer
with a systemCoreSession
while logged in as a system user.static <R> R
doPrivileged(CoreSession session, Function<CoreSession,R> function)
Runs the givenFunction
with a systemCoreSession
while logged in as a system user.static CoreSession
getCoreSession(String repositoryName)
Gets aCoreSession
for the currently logged-in user.static CoreSession
getCoreSession(String repositoryName, String username)
MUST ONLY BE USED IN UNIT TESTS to get aCoreSession
for the given user.static CoreSession
getCoreSession(String repositoryName, NuxeoPrincipal principal)
Gets aCoreSession
for the given principal.static CoreSession
getCoreSessionSystem(String repositoryName)
Gets aCoreSession
for a system user.static CoreSession
getCoreSessionSystem(String repositoryName, String originatingUsername)
Gets aCoreSession
for a system user with an optional originating username.protected static String
getCurrentPrincipalName()
Gets the name of the currently logged-in principal.protected static NuxeoPrincipal
getPrincipal(String username)
static CloseableCoreSession
openCoreSession(String repositoryName)
Deprecated.since 11.1, usegetCoreSession(String)
insteadstatic CloseableCoreSession
openCoreSession(String repositoryName, String username)
Deprecated.since 11.1, usegetCoreSession(String, String)
insteadstatic CloseableCoreSession
openCoreSession(String repositoryName, NuxeoPrincipal principal)
Deprecated.since 11.1, usegetCoreSession(String, NuxeoPrincipal)
insteadstatic CloseableCoreSession
openCoreSessionSystem(String repositoryName)
Deprecated.since 11.1, usegetCoreSessionSystem(String)
insteadstatic CloseableCoreSession
openCoreSessionSystem(String repositoryName, String originatingUsername)
Deprecated.since 11.1, usegetCoreSessionSystem(String, String)
instead
-
-
-
Method Detail
-
getCoreSession
public static CoreSession getCoreSession(String repositoryName)
Gets aCoreSession
for the currently logged-in user.- Parameters:
repositoryName
- the repository name, ornull
for the default repository- Returns:
- the session
- Since:
- 11.1
-
getCoreSession
public static CoreSession getCoreSession(String repositoryName, String username)
MUST ONLY BE USED IN UNIT TESTS to get aCoreSession
for the given user.- Parameters:
repositoryName
- the repository name, ornull
for the default repositoryusername
- the user name- Returns:
- the session
- Since:
- 11.1
-
getCoreSessionSystem
public static CoreSession getCoreSessionSystem(String repositoryName)
Gets aCoreSession
for a system user.- Parameters:
repositoryName
- the repository name, ornull
for the default repository- Returns:
- the session
- Since:
- 11.1
-
getCoreSessionSystem
public static CoreSession getCoreSessionSystem(String repositoryName, String originatingUsername)
Gets aCoreSession
for a system user with an optional originating username.- Parameters:
repositoryName
- the repository name, ornull
for the default repositoryoriginatingUsername
- the originating username to set on the SystemPrincipal- Returns:
- the session
- Since:
- 11.1
-
getCoreSession
public static CoreSession getCoreSession(String repositoryName, NuxeoPrincipal principal)
Gets aCoreSession
for the given principal.- Parameters:
repositoryName
- the repository name, ornull
for the default repositoryprincipal
- the principal- Returns:
- the session
- Since:
- 11.1
-
openCoreSession
@Deprecated public static CloseableCoreSession openCoreSession(String repositoryName)
Deprecated.since 11.1, usegetCoreSession(String)
insteadOpens aCoreSession
for the currently logged-in user.- Parameters:
repositoryName
- the repository name, ornull
for the default repository- Returns:
- the session
- Since:
- 5.9.3
-
openCoreSession
@Deprecated public static CloseableCoreSession openCoreSession(String repositoryName, String username)
Deprecated.since 11.1, usegetCoreSession(String, String)
insteadMUST ONLY BE USED IN UNIT TESTS to open aCoreSession
for the given user.- Parameters:
repositoryName
- the repository name, ornull
for the default repositoryusername
- the user name- Returns:
- the session
- Since:
- 5.9.3
-
openCoreSessionSystem
@Deprecated public static CloseableCoreSession openCoreSessionSystem(String repositoryName)
Deprecated.since 11.1, usegetCoreSessionSystem(String)
insteadOpens aCoreSession
for a system user.- Parameters:
repositoryName
- the repository name, ornull
for the default repository- Returns:
- the session
- Since:
- 5.9.3
-
openCoreSessionSystem
@Deprecated public static CloseableCoreSession openCoreSessionSystem(String repositoryName, String originatingUsername)
Deprecated.since 11.1, usegetCoreSessionSystem(String, String)
insteadOpens aCoreSession
for a system user with an optional originating username.- Parameters:
repositoryName
- the repository name, ornull
for the default repositoryoriginatingUsername
- the originating username to set on the SystemPrincipal- Returns:
- the session
- Since:
- 8.1
-
openCoreSession
@Deprecated public static CloseableCoreSession openCoreSession(String repositoryName, NuxeoPrincipal principal)
Deprecated.since 11.1, usegetCoreSession(String, NuxeoPrincipal)
insteadOpens aCoreSession
for the given principal.- Parameters:
repositoryName
- the repository name, ornull
for the default repositoryprincipal
- the principal- Returns:
- the session
- Since:
- 5.9.3
-
closeCoreSession
@Deprecated public static void closeCoreSession(CloseableCoreSession session)
Deprecated.since 11.1, does nothingDoes nothing.- Since:
- 5.9.3
-
getPrincipal
protected static NuxeoPrincipal getPrincipal(String username)
-
getCurrentPrincipalName
protected static String getCurrentPrincipalName()
Gets the name of the currently logged-in principal.- Returns:
- the principal name, or
null
if there was no login - Since:
- 8.4
-
doPrivileged
public static <R> R doPrivileged(String repositoryName, Function<CoreSession,R> function)
Runs the givenFunction
with a systemCoreSession
while logged in as a system user.- Type Parameters:
R
- the function return type- Parameters:
repositoryName
- the repository name for theCoreSession
function
- the function taking a systemCoreSession
and returning a result of type<R>
- Returns:
- the result of the function
- Since:
- 8.4
-
doPrivileged
public static <R> R doPrivileged(CoreSession session, Function<CoreSession,R> function)
Runs the givenFunction
with a systemCoreSession
while logged in as a system user.- Type Parameters:
R
- the function return type- Parameters:
session
- an existing sessionfunction
- the function taking a systemCoreSession
and returning a result of type<R>
- Returns:
- the result of the function
- Since:
- 8.4
-
doPrivileged
public static void doPrivileged(String repositoryName, Consumer<CoreSession> consumer)
Runs the givenConsumer
with a systemCoreSession
while logged in as a system user.- Parameters:
repositoryName
- the repository name for theCoreSession
consumer
- the consumer taking a systemCoreSession
- Since:
- 8.4
-
doPrivileged
public static void doPrivileged(CoreSession session, Consumer<CoreSession> consumer)
Runs the givenConsumer
with a systemCoreSession
while logged in as a system user.- Parameters:
session
- an existing sessionconsumer
- the consumer taking a systemCoreSession
- Since:
- 8.4
-
-