Class CreatePrincipalTask
java.lang.Object
ch.tocco.nice2.persist.core.api.exec.AbstractPartitionedPersistTask<Entity,Void,ch.tocco.nice2.usermanager.api.tasks.CreatePrincipalTask.TaskData>
ch.tocco.nice2.usermanager.api.tasks.CreatePrincipalTask
- All Implemented Interfaces:
PersistTask<Iterable<Entity>,
Iterable<Void>>
public class CreatePrincipalTask
extends AbstractPartitionedPersistTask<Entity,Void,ch.tocco.nice2.usermanager.api.tasks.CreatePrincipalTask.TaskData>
CreatePrincipalTask
can be used to to create Principal
s for User
s which do not have at least one Principal
assigned.
As each User
needs at least one Principal
to login, they get automatically created by the
PrincipalEntityListener
during creation of new User
s in the backend or by importing users using
the GenericImporterActionService
.- See Also:
-
Constructor Summary
ConstructorDescriptionCreatePrincipalTask
(PrincipalService principalService, EntityDefaultValueService entityDefaultValueService) -
Method Summary
Modifier and TypeMethodDescriptionCreate a function that creates an instance of Z.run
(Optional<Iterable<Entity>> a, CommandContext commandContext) Creates aPrincipal
for the given user, if he does not already have at least onePrincipal
.Methods inherited from class ch.tocco.nice2.persist.core.api.exec.AbstractPartitionedPersistTask
getTaskData, partition, partition, partition
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ch.tocco.nice2.persist.core.api.exec.PersistTask
andThenDo, compose, compose2, composeWhen, discardResult, expand, expand, getDescription, ifElse, orWhen, orWhenNot, passWhen, passWhenNot, skipErrors, unwrap
-
Constructor Details
-
CreatePrincipalTask
public CreatePrincipalTask(PrincipalService principalService, EntityDefaultValueService entityDefaultValueService)
-
-
Method Details
-
createTaskData
protected Function<Context,ch.tocco.nice2.usermanager.api.tasks.CreatePrincipalTask.TaskData> createTaskData()Description copied from class:AbstractPartitionedPersistTask
Create a function that creates an instance of Z. This function is called once for each context and should be used to load entities (or otherContext
related objects) which are used in every iteration.- Specified by:
createTaskData
in classAbstractPartitionedPersistTask<Entity,
Void, ch.tocco.nice2.usermanager.api.tasks.CreatePrincipalTask.TaskData>
-
run
@Nullable public @Nullable Iterable<Void> run(Optional<Iterable<Entity>> a, CommandContext commandContext) throws Exception Creates aPrincipal
for the given user, if he does not already have at least onePrincipal
.- Parameters:
a
- an iterable ofUser
entities for which aPrincipal
should be createdcommandContext
- theCommandContext
- Throws:
Exception
-