use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class ModelRestService method resumeTasks.
// @DELETE
// @Path("tasks/{oid}/suspend")
// public Response suspendAndDeleteTasks(@PathParam("oid") String taskOid, @Context MessageContext mc) {
//
// Task task = RestServiceUtil.initRequest(mc);
// OperationResult parentResult = task.getResult().createSubresult(OPERATION_SUSPEND_AND_DELETE_TASKS);
//
// Response response;
// Collection<String> taskOids = MiscUtil.createCollection(taskOid);
// try {
// model.suspendAndDeleteTasks(taskOids, WAIT_FOR_TASK_STOP, true, parentResult);
//
// parentResult.computeStatus();
// 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;
// }
@POST
@Path("/tasks/{oid}/resume")
public Response resumeTasks(@PathParam("oid") String taskOid, @Context MessageContext mc) {
Task task = RestServiceUtil.initRequest(mc);
OperationResult parentResult = task.getResult().createSubresult(OPERATION_RESUME_TASKS);
Response response;
Collection<String> taskOids = MiscUtil.createCollection(taskOid);
try {
model.resumeTasks(taskOids, parentResult);
parentResult.computeStatus();
response = RestServiceUtil.createResponse(Response.Status.ACCEPTED, 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 ModelRestService method getLogFileSize.
@GET
@Path("/log/size")
@Produces({ "text/plain" })
public Response getLogFileSize(@Context MessageContext mc) {
Task task = RestServiceUtil.initRequest(mc);
OperationResult result = task.getResult().createSubresult(OPERATION_GET_LOG_FILE_SIZE);
Response response;
try {
long size = modelDiagnosticService.getLogFileSize(task, result);
response = RestServiceUtil.createResponse(Response.Status.OK, String.valueOf(size), result);
// ResponseBuilder builder = Response.ok();
// builder.entity(String.valueOf(size));
// 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 getLog.
@GET
@Path("/log")
@Produces({ "text/plain" })
public Response getLog(@QueryParam("fromPosition") Long fromPosition, @QueryParam("maxSize") Long maxSize, @Context MessageContext mc) {
Task task = RestServiceUtil.initRequest(mc);
OperationResult result = task.getResult().createSubresult(OPERATION_GET_LOG_FILE_CONTENT);
Response response;
try {
LogFileContentType content = modelDiagnosticService.getLogFileContent(fromPosition, maxSize, task, result);
ResponseBuilder builder = Response.ok();
builder.entity(content.getContent());
builder.header("ReturnedDataPosition", content.getAt());
builder.header("ReturnedDataComplete", content.isComplete());
builder.header("CurrentLogFileSize", content.getLogFileSize());
response = builder.build();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Cannot get log file content: fromPosition={}, maxSize={}", ex, fromPosition, maxSize);
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 notifyChange.
@POST
@Path("/notifyChange")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, "application/yaml" })
public Response notifyChange(ResourceObjectShadowChangeDescriptionType changeDescription, @Context UriInfo uriInfo, @Context MessageContext mc) {
LOGGER.debug("model rest service for notify change operation start");
Validate.notNull(changeDescription, "Chnage description must not be null");
Task task = RestServiceUtil.initRequest(mc);
OperationResult parentResult = task.getResult().createSubresult(OPERATION_NOTIFY_CHANGE);
Response response;
try {
model.notifyChange(changeDescription, parentResult, task);
response = RestServiceUtil.createResponse(Response.Status.OK, parentResult);
// return Response.ok().build();
// String oldShadowOid = changeDescription.getOldShadowOid();
// if (oldShadowOid != null){
// URI resourceURI = uriInfo.getAbsolutePathBuilder().path(oldShadowOid).build(oldShadowOid);
// return Response.accepted().location(resourceURI).build();
// } else {
// changeDescription.get
// }
// response = Response.seeOther((uriInfo.getBaseUriBuilder().path(this.getClass(), "getObject").build(ObjectTypes.TASK.getRestType(), task.getOid()))).build();
} catch (Exception ex) {
response = RestServiceUtil.handleException(parentResult, ex);
}
parentResult.computeStatus();
finishRequest(task);
return response;
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class ModelRestService method getValuePolicyForUser.
@GET
@Path("/users/{id}/policy")
public Response getValuePolicyForUser(@PathParam("id") String oid, @Context MessageContext mc) {
LOGGER.debug("getValuePolicyForUser start");
Task task = RestServiceUtil.initRequest(mc);
OperationResult parentResult = task.getResult().createSubresult(OPERATION_GET);
Response response;
try {
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createRaw());
PrismObject<UserType> user = model.getObject(UserType.class, oid, options, task, parentResult);
CredentialsPolicyType policy = modelInteraction.getCredentialsPolicy(user, task, parentResult);
response = RestServiceUtil.createResponse(Response.Status.OK, policy, parentResult);
// ResponseBuilder builder = Response.ok();
// builder.entity(policy);
// response = builder.build();
} catch (Exception ex) {
response = RestServiceUtil.handleException(parentResult, ex);
}
parentResult.computeStatus();
finishRequest(task);
LOGGER.debug("getValuePolicyForUser finish");
return response;
}
Aggregations