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 Principals for Users 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 Users in the backend or by importing users using
the GenericImporterActionService.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreatePrincipalTask(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 aPrincipalfor the given user, if he does not already have at least onePrincipal.Methods inherited from class AbstractPartitionedPersistTask
getTaskData, partition, partition, partitionMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface 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:AbstractPartitionedPersistTaskCreate a function that creates an instance of Z. This function is called once for each context and should be used to load entities (or otherContextrelated objects) which are used in every iteration.- Specified by:
createTaskDatain 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 aPrincipalfor the given user, if he does not already have at least onePrincipal.- Parameters:
a- an iterable ofUserentities for which aPrincipalshould be createdcommandContext- theCommandContext- Throws:
Exception
-