本文整理了Java中com.evolveum.midpoint.task.api.Task.getOwner()
方法的一些代码示例,展示了Task.getOwner()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.getOwner()
方法的具体详情如下:
包路径:com.evolveum.midpoint.task.api.Task
类名称:Task
方法名:getOwner
[英]Returns user that owns this task. It usually means the user that started the task or a system used that is used to execute the task. The owner will be used to determine access rights of the task, will be used for auditing, etc.
[中]返回负责此任务的用户。它通常指启动任务的用户或用于执行任务的系统。所有者将用于确定任务的访问权限,用于审核等。
代码示例来源:origin: Evolveum/midpoint
public PrismObject<UserType> getRequester(Task task, OperationResult result) {
if (task.getOwner() == null) {
LOGGER.warn("No requester in task {} -- continuing, but the situation is suspicious.", task);
return null;
}
// let's get fresh data (not the ones read on user login)
PrismObject<UserType> requester;
try {
requester = repositoryService.getObject(UserType.class, task.getOwner().getOid(), null, result);
} catch (ObjectNotFoundException e) {
LoggingUtils.logException(LOGGER, "Couldn't get data about task requester (" + task.getOwner() + "), because it does not exist in repository anymore. Using cached data.", e);
requester = task.getOwner().clone();
} catch (SchemaException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get data about task requester (" + task.getOwner() + "), due to schema exception. Using cached data.", e);
requester = task.getOwner().clone();
}
return requester;
}
代码示例来源:origin: Evolveum/midpoint
@Override
protected String getBody(Event event, GeneralNotifierType generalNotifierType, String transport, Task opTask, OperationResult opResult) throws SchemaException {
final TaskEvent taskEvent = (TaskEvent) event;
final Task task = taskEvent.getTask();
final String taskName = PolyString.getOrig(task.getName());
StringBuilder body = new StringBuilder();
body.append("Notification about task-related operation.\n\n");
body.append("Task: ").append(taskName).append("\n");
body.append("Handler: ").append(task.getHandlerUri()).append("\n\n");
if (taskEvent.getTaskRunResult() != null) {
body.append("Run result status: ").append(taskEvent.getTaskRunResult().getRunResultStatus()).append("\n");
}
body.append("Status: ").append(taskEvent.getOperationResultStatus()).append("\n");
String message = taskEvent.getMessage();
if (StringUtils.isNotBlank(message)) {
body.append("Message: ").append(message).append("\n");
}
body.append("Progress: ").append(taskEvent.getProgress()).append("\n");
body.append("\n");
body.append("Notification created on: ").append(new Date()).append("\n\n");
if (task.getOwner() != null) {
UserType owner = task.getOwner().asObjectable();
body.append("Task owner: ");
body.append(owner.getFullName()).append(" (").append(owner.getName()).append(")");
body.append("\n");
}
body.append("Channel: ").append(event.getChannel()).append("\n\n");
return body.toString();
}
代码示例来源:origin: Evolveum/midpoint
private <F extends ObjectType> MetadataType collectRequestMetadata(LensContext<F> context, XMLGregorianCalendar now, Task task) {
MetadataType metaData = new MetadataType();
metaData.setCreateChannel(LensUtil.getChannel(context, task)); // TODO is this really used?
metaData.setRequestTimestamp(now);
if (task.getOwner() != null) {
metaData.setRequestorRef(createObjectRef(task.getOwner(), prismContext));
}
// It is not necessary to store requestor comment here as it is preserved in context.options field.
return metaData;
}
代码示例来源:origin: Evolveum/midpoint
private void createAndProcessEvent(Task task, TaskRunResult runResult, EventOperationType operationType) {
TaskEvent event = new TaskEvent(lightweightIdentifierGenerator, task, runResult, operationType, task.getChannel());
if (task.getOwner() != null) {
event.setRequester(new SimpleObjectRefImpl(notificationsUtil, task.getOwner().asObjectable()));
event.setRequestee(new SimpleObjectRefImpl(notificationsUtil, task.getOwner().asObjectable()));
} else {
LOGGER.debug("No owner for task " + task + ", therefore no requester and requestee will be set for event " + event.getId());
}
Task opTask = taskManager.createTaskInstance(OPERATION_PROCESS_EVENT);
notificationManager.processEvent(event, opTask, opTask.getResult());
}
代码示例来源:origin: Evolveum/midpoint
private <F extends ObjectType> void applyCreateMetadata(LensContext<F> context, MetadataType metaData, XMLGregorianCalendar now, Task task) {
String channel = LensUtil.getChannel(context, task);
metaData.setCreateChannel(channel);
metaData.setCreateTimestamp(now);
if (task.getOwner() != null) {
metaData.setCreatorRef(createObjectRef(task.getOwner(), prismContext));
}
metaData.setCreateTaskRef(task.getOid() != null ? createObjectRef(task.getTaskPrismObject(), prismContext) : null);
}
代码示例来源:origin: Evolveum/midpoint
protected void auditLogin(Task task) {
AuditEventRecord record = new AuditEventRecord(AuditEventType.CREATE_SESSION, AuditEventStage.REQUEST);
record.setInitiatorAndLoginParameter(task.getOwner());
record.setChannel(SchemaConstants.CHANNEL_WEB_SERVICE_URI);
record.setTimestamp(System.currentTimeMillis());
record.setOutcome(OperationResultStatus.SUCCESS);
auditService.audit(record, task);
}
代码示例来源:origin: Evolveum/midpoint
@Override
public void auditLogout(ConnectionEnvironment connEnv, Task task) {
AuditEventRecord record = new AuditEventRecord(AuditEventType.TERMINATE_SESSION, AuditEventStage.REQUEST);
record.setInitiatorAndLoginParameter(task.getOwner());
record.setTimestamp(System.currentTimeMillis());
record.setOutcome(OperationResultStatus.SUCCESS);
storeConnectionEnvironment(record, connEnv);
auditService.audit(record, task);
}
代码示例来源:origin: Evolveum/midpoint
protected void auditLogout(Task task) {
AuditEventRecord record = new AuditEventRecord(AuditEventType.TERMINATE_SESSION, AuditEventStage.REQUEST);
record.setInitiatorAndLoginParameter(task.getOwner());
record.setChannel(SchemaConstants.CHANNEL_WEB_SERVICE_URI);
record.setTimestamp(System.currentTimeMillis());
record.setOutcome(OperationResultStatus.SUCCESS);
auditService.audit(record, task);
}
代码示例来源:origin: Evolveum/midpoint
protected void fillInReviewerRelatedEvent(ObjectReferenceType reviewerOrDeputyRef, ObjectReferenceType actualReviewerRef,
Task task, CertReviewEvent event) {
event.setRequestee(new SimpleObjectRefImpl(notificationsUtil, reviewerOrDeputyRef));
event.setRequester(new SimpleObjectRefImpl(notificationsUtil, task.getOwner())); // or campaign owner?
event.setActualReviewer(new SimpleObjectRefImpl(notificationsUtil, actualReviewerRef));
}
代码示例来源:origin: Evolveum/midpoint
protected void fillInEvent(AccessCertificationCampaignType campaign, Task task, AccessCertificationEvent event) {
event.setRequestee(new SimpleObjectRefImpl(notificationsUtil, campaign.getOwnerRef()));
if (task != null) {
event.setRequester(new SimpleObjectRefImpl(notificationsUtil, task.getOwner()));
event.setChannel(task.getChannel());
}
}
代码示例来源:origin: Evolveum/midpoint
private void setCommonEventProperties(PrismObject<?> object, Task task, ModelContext<?> modelContext, Event event) {
if (task.getOwner() != null) {
event.setRequester(new SimpleObjectRefImpl(notificationsUtil, task.getOwner().asObjectable()));
} else {
LOGGER.debug("No owner for task " + task + ", therefore no requester will be set for event " + event.getId());
}
// if no OID in object (occurs in 'add' operation), we artificially insert it into the object)
if (object.getOid() == null && modelContext.getFocusContext() != null && modelContext.getFocusContext().getOid() != null) {
object = object.clone();
object.setOid(modelContext.getFocusContext().getOid());
}
event.setRequestee(new SimpleObjectRefImpl(notificationsUtil, (ObjectType) object.asObjectable()));
}
}
代码示例来源:origin: Evolveum/midpoint
@Override
public WfTaskCreationInstruction prepareJobCreationInstruction(GeneralChangeProcessorScenarioType scenarioType, LensContext<?> context, WfTask rootWfTask, com.evolveum.midpoint.task.api.Task taskFromModel, OperationResult result) throws SchemaException {
GeneralChangeProcessorSpecificContent processorInstruction = new GeneralChangeProcessorSpecificContent(context);
processorInstruction.setScenarioBeanName(scenarioType.getBeanName());
WfTaskCreationInstruction instruction = WfTaskCreationInstruction.createWfOnly(rootWfTask.getChangeProcessor(), processorInstruction, null);
instruction.setProcessName(scenarioType.getProcessName());
instruction.setRequesterRef(taskFromModel.getOwner());
instruction.setTaskName("Workflow-monitoring task");
instruction.setProcessInterfaceBean(defaultProcessMidPointInterface);
return instruction;
}
代码示例来源:origin: Evolveum/midpoint
public <F extends ObjectType, T extends ObjectType> Collection<ItemDelta<?,?>> createModifyMetadataDeltas(LensContext<F> context,
ItemPath metadataPath, Class<T> objectType, XMLGregorianCalendar now, Task task) throws SchemaException {
return prismContext.deltaFor(objectType)
.item(metadataPath.append(MetadataType.F_MODIFY_CHANNEL)).replace(LensUtil.getChannel(context, task))
.item(metadataPath.append(MetadataType.F_MODIFY_TIMESTAMP)).replace(now)
.item(metadataPath.append(MetadataType.F_MODIFIER_REF)).replace(createObjectRef(task.getOwner(), prismContext))
.item(metadataPath.append(MetadataType.F_MODIFY_TASK_REF)).replaceRealValues(
task.getOid() != null ? singleton(createObjectRef(task.getTaskPrismObject(), prismContext)) : emptySet())
.asItemDeltas();
}
代码示例来源:origin: Evolveum/midpoint
private void setOperationContext(OperationExecutionType operation,
OperationResultStatusType overallStatus, XMLGregorianCalendar now, String channel, Task task) {
if (task.getParentForLightweightAsynchronousTask() != null) {
task = task.getParentForLightweightAsynchronousTask();
}
if (task.isPersistent()) {
operation.setTaskRef(ObjectTypeUtil.createObjectRef(task.getTaskPrismObject(), prismContext));
}
operation.setStatus(overallStatus);
operation.setInitiatorRef(ObjectTypeUtil.createObjectRef(task.getOwner(), prismContext)); // TODO what if the real initiator is different? (e.g. when executing approved changes)
operation.setChannel(channel);
operation.setTimestamp(now);
}
代码示例来源:origin: Evolveum/midpoint
/**
* Creates a root job creation instruction.
*
* @param changeProcessor reference to the change processor responsible for the whole operation
* @param modelContext model context in which the original model operation is carried out
* @param taskFromModel task in which the original model operation is carried out
* @param contextForRoot model context that should be put into the root task (might be different from the modelContext)
* @return the job creation instruction
* @throws SchemaException
*/
public WfTaskCreationInstruction createInstructionForRoot(ChangeProcessor changeProcessor, ModelContext modelContext, Task taskFromModel, ModelContext contextForRoot, OperationResult result) throws SchemaException {
WfTaskCreationInstruction<?, ?> instruction;
if (contextForRoot != null) {
instruction = WfTaskCreationInstruction.createModelOnly(changeProcessor, contextForRoot);
} else {
instruction = WfTaskCreationInstruction.createEmpty(changeProcessor);
}
LocalizableMessage rootTaskName = determineRootTaskName(modelContext);
String rootTaskNameInDefaultLocale = localizationService.translate(rootTaskName, Locale.getDefault());
instruction.setLocalizableTaskName(rootTaskName);
instruction.setTaskName(rootTaskNameInDefaultLocale);
instruction.setTaskObject(determineRootTaskObject(modelContext));
instruction.setTaskOwner(taskFromModel.getOwner());
instruction.setCreateTaskAsWaiting();
instruction.setObjectRef(modelContext, result);
instruction.setRequesterRef(getRequester(taskFromModel, result));
return instruction;
}
代码示例来源:origin: Evolveum/midpoint
private ResourceObjectEvent createRequest(OperationStatus status,
ResourceOperationDescription operationDescription,
Task task,
OperationResult result) {
ResourceObjectEvent event = new ResourceObjectEvent(lightweightIdentifierGenerator);
event.setAccountOperationDescription(operationDescription);
event.setOperationStatus(status);
event.setChangeType(operationDescription.getObjectDelta().getChangeType()); // fortunately there's 1:1 mapping
String accountOid = operationDescription.getObjectDelta().getOid();
PrismObject<UserType> user = findRequestee(accountOid, task, result, operationDescription.getObjectDelta().isDelete());
if (user != null) {
event.setRequestee(new SimpleObjectRefImpl(notificationsUtil, user.asObjectable()));
} // otherwise, appropriate messages were already logged
if (task != null && task.getOwner() != null) {
event.setRequester(new SimpleObjectRefImpl(notificationsUtil, task.getOwner()));
} else {
LOGGER.warn("No owner for task {}, therefore no requester will be set for event {}", task, event.getId());
}
if (task != null && task.getChannel() != null) {
event.setChannel(task.getChannel());
} else if (operationDescription.getSourceChannel() != null) {
event.setChannel(operationDescription.getSourceChannel());
}
return event;
}
代码示例来源:origin: Evolveum/midpoint
private void startWorkflowProcessInstance(WfTask wfTask, WfTaskCreationInstruction<?,?> instruction, OperationResult parentResult) {
OperationResult result = parentResult.createSubresult(DOT_CLASS + "startWorkflowProcessInstance");
try {
LOGGER.trace("startWorkflowProcessInstance starting; instruction = {}", instruction);
Task task = wfTask.getTask();
StartProcessCommand spc = new StartProcessCommand();
spc.setProcessName(instruction.getProcessName());
spc.setProcessInstanceName(instruction.getProcessInstanceName());
spc.setSendStartConfirmation(instruction.isSendStartConfirmation());
spc.setVariablesFrom(instruction.getAllProcessVariables());
spc.addVariable(CommonProcessVariableNames.VARIABLE_MIDPOINT_TASK_OID, task.getOid());
spc.setProcessOwner(task.getOwner().getOid());
activitiInterface.startActivitiProcessInstance(spc, task, result);
auditProcessStart(wfTask, spc.getVariables(), result);
notifyProcessStart(wfTask, result);
} catch (SchemaException|RuntimeException|ObjectNotFoundException|ObjectAlreadyExistsException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't send a request to start a process instance to workflow management system", e);
result.recordFatalError("Couldn't send a request to start a process instance to workflow management system: " + e.getMessage(), e);
throw new SystemException("Workflow process instance creation could not be requested", e);
} finally {
result.computeStatusIfUnknown();
}
LOGGER.trace("startWorkflowProcessInstance finished");
}
代码示例来源:origin: Evolveum/midpoint
metaData.setCreateChannel(channel);
metaData.setCreateTimestamp(clock.currentTimeXMLGregorianCalendar());
if (task.getOwner() != null) {
metaData.setCreatorRef(ObjectTypeUtil.createObjectRef(task.getOwner(), prismContext));
代码示例来源:origin: Evolveum/midpoint
secondChildTask.setOwner(rootTask.getOwner());
secondChildTask.pushHandlerUri(SINGLE_TASK_HANDLER_URI, new ScheduleType(), null);
secondPrerequisiteTask.setOwner(rootTask.getOwner());
secondPrerequisiteTask.addDependent(rootTask.getTaskIdentifier());
secondPrerequisiteTask.pushHandlerUri(TaskConstants.NOOP_TASK_HANDLER_URI, new ScheduleType(), null);
代码示例来源:origin: Evolveum/midpoint
PrismObject<UserType> owner = null;
if (ctx.getTask() != null) {
owner = ctx.getTask().getOwner();
内容来源于网络,如有侵权,请联系作者删除!