use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class ModelRestService method compare.
@POST
@Path("/rpc/compare")
// @Produces({"text/html", "application/xml"})
@Consumes({ "application/xml" })
public <T extends ObjectType> Response compare(PrismObject<T> clientObject, @QueryParam("readOptions") List<String> restReadOptions, @QueryParam("compareOptions") List<String> restCompareOptions, @QueryParam("ignoreItems") List<String> restIgnoreItems, @Context MessageContext mc) {
Task task = RestServiceUtil.initRequest(mc);
OperationResult result = task.getResult().createSubresult(OPERATION_COMPARE);
Response response;
try {
ResponseBuilder builder;
List<ItemPath> ignoreItemPaths = ItemPath.fromStringList(restIgnoreItems);
final GetOperationOptions getOpOptions = GetOperationOptions.fromRestOptions(restReadOptions);
Collection<SelectorOptions<GetOperationOptions>> readOptions = getOpOptions != null ? SelectorOptions.createCollection(getOpOptions) : null;
ModelCompareOptions compareOptions = ModelCompareOptions.fromRestOptions(restCompareOptions);
CompareResultType compareResult = modelService.compareObject(clientObject, readOptions, compareOptions, ignoreItemPaths, task, result);
response = RestServiceUtil.createResponse(Response.Status.OK, compareResult, result);
// builder = Response.ok();
// builder.entity(compareResult);
//
// response = builder.build();
} catch (Exception ex) {
response = RestServiceUtil.handleException(result, ex);
}
result.computeStatus();
finishRequest(task);
return response;
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class ModelRestService method scheduleTasksNow.
@POST
@Path("tasks/{oid}/run")
public Response scheduleTasksNow(@PathParam("oid") String taskOid, @Context MessageContext mc) {
Task task = RestServiceUtil.initRequest(mc);
OperationResult parentResult = task.getResult().createSubresult(OPERATION_SCHEDULE_TASKS_NOW);
Collection<String> taskOids = MiscUtil.createCollection(taskOid);
Response response;
try {
model.scheduleTasksNow(taskOids, parentResult);
parentResult.computeStatus();
response = RestServiceUtil.createResponse(Response.Status.NO_CONTENT, parentResult);
// if (parentResult.isSuccess()) {
// response = Response.accepted().build();
// } else {
// response = Response.status(Status.INTERNAL_SERVER_ERROR).entity(parentResult.getMessage()).build();
// }
} catch (Exception ex) {
response = RestServiceUtil.handleException(parentResult, ex);
}
finishRequest(task);
return response;
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class ModelWebService method executeChanges.
@Override
public ObjectDeltaOperationListType executeChanges(ObjectDeltaListType deltaList, ModelExecuteOptionsType optionsType) throws FaultMessage {
notNullArgument(deltaList, "Object delta list must not be null.");
Task task = createTaskInstance(EXECUTE_CHANGES);
auditLogin(task);
OperationResult operationResult = task.getResult();
try {
Collection<ObjectDelta> deltas = DeltaConvertor.createObjectDeltas(deltaList, prismContext);
for (ObjectDelta delta : deltas) {
prismContext.adopt(delta);
}
ModelExecuteOptions options = ModelExecuteOptions.fromModelExecutionOptionsType(optionsType);
// brutally eliminating type-safety compiler barking
Collection<ObjectDeltaOperation<? extends ObjectType>> objectDeltaOperations = modelService.executeChanges((Collection) deltas, options, task, operationResult);
ObjectDeltaOperationListType retval = new ObjectDeltaOperationListType();
for (ObjectDeltaOperation objectDeltaOperation : objectDeltaOperations) {
ObjectDeltaOperationType objectDeltaOperationType = DeltaConvertor.toObjectDeltaOperationType(objectDeltaOperation, null);
retval.getDeltaOperation().add(objectDeltaOperationType);
}
return retval;
} catch (Exception ex) {
LoggingUtils.logException(LOGGER, "# MODEL executeChanges() failed", ex);
throwFault(ex, operationResult);
// notreached
return null;
} finally {
auditLogout(task);
}
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class ModelWebService method findShadowOwner.
@Override
public void findShadowOwner(String accountOid, Holder<UserType> userHolder, Holder<OperationResultType> result) throws FaultMessage {
notEmptyArgument(accountOid, "Account oid must not be null or empty.");
Task task = createTaskInstance(LIST_ACCOUNT_SHADOW_OWNER);
auditLogin(task);
OperationResult operationResult = task.getResult();
try {
PrismObject<UserType> user = model.findShadowOwner(accountOid, task, operationResult);
handleOperationResult(operationResult, result);
if (user != null) {
userHolder.value = user.asObjectable();
}
return;
} catch (Exception ex) {
LoggingUtils.logException(LOGGER, "# MODEL findShadowOwner() failed", ex);
throwFault(ex, operationResult);
} finally {
auditLogout(task);
}
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class ModelWebService method importFromResource.
@Override
public TaskType importFromResource(String resourceOid, QName objectClass) throws FaultMessage {
notEmptyArgument(resourceOid, "Resource oid must not be null or empty.");
notNullArgument(objectClass, "Object class must not be null.");
Task task = createTaskInstance(IMPORT_FROM_RESOURCE);
auditLogin(task);
OperationResult operationResult = task.getResult();
try {
model.importFromResource(resourceOid, objectClass, task, operationResult);
operationResult.computeStatus();
return handleTaskResult(task);
} catch (Exception ex) {
LoggingUtils.logException(LOGGER, "# MODEL importFromResource() failed", ex);
auditLogout(task);
throwFault(ex, operationResult);
// notreached
return null;
}
}
Aggregations