use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class PageReports method runReportPerformed.
protected void runReportPerformed(AjaxRequestTarget target, ReportType report) {
RunReportPopupPanel runReportPopupPanel = new RunReportPopupPanel(getMainPopupBodyId(), report) {
private static final long serialVersionUID = 1L;
protected void runConfirmPerformed(AjaxRequestTarget target, ReportType reportType, PrismContainer<ReportParameterType> reportParam) {
OperationResult result = new OperationResult(OPERATION_RUN_REPORT);
try {
Task task = createSimpleTask(OPERATION_RUN_REPORT);
getReportManager().runReport(reportType.asPrismObject(), reportParam, task, result);
} catch (Exception ex) {
result.recordFatalError(ex);
} finally {
result.computeStatusIfUnknown();
}
showResult(result);
target.add(getFeedbackPanel(), get(createComponentPath(ID_MAIN_FORM)));
hideMainPopup(target);
}
;
};
showMainPopup(runReportPopupPanel, target);
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class TestIntegrationObjectWrapperFactory method test802EditSchemaJackPropReadSomeModifySomeUser.
/**
* MID-3126
*/
@Test
public void test802EditSchemaJackPropReadSomeModifySomeUser() throws Exception {
final String TEST_NAME = "test800EditSchemaJackPropReadAllModifySomeUser";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
cleanupAutzTest(USER_JACK_OID);
assignRole(USER_JACK_OID, ROLE_PROP_READ_SOME_MODIFY_SOME_USER_OID);
login(USER_JACK_USERNAME);
ObjectWrapperFactory factory = new ObjectWrapperFactory(getServiceLocator());
PrismObject<UserType> user = getUser(USER_JACK_OID);
display("user before", user);
// WHEN
TestUtil.displayWhen(TEST_NAME);
Task task = taskManager.createTaskInstance(TEST_NAME);
ObjectWrapper<UserType> objectWrapper = factory.createObjectWrapper("user display name", "user description", user, ContainerStatus.MODIFYING, task);
// THEN
TestUtil.displayThen(TEST_NAME);
IntegrationTestTools.display("Wrapper after", objectWrapper);
assertEquals("Wrong object wrapper readOnly", Boolean.FALSE, (Boolean) objectWrapper.isReadonly());
ContainerWrapper<UserType> mainContainerWrapper = objectWrapper.findMainContainerWrapper();
assertEquals("Wrong main container wrapper readOnly", Boolean.FALSE, (Boolean) mainContainerWrapper.isReadonly());
ItemWrapper nameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_NAME);
assertEquals("Wrong name readOnly", Boolean.TRUE, (Boolean) nameWrapper.isReadonly());
assertEquals("Wrong name visible", Boolean.TRUE, (Boolean) nameWrapper.isVisible());
assertEquals("Wrong name definition.canRead", Boolean.TRUE, (Boolean) nameWrapper.getItemDefinition().canRead());
assertEquals("Wrong name definition.canAdd", Boolean.FALSE, (Boolean) nameWrapper.getItemDefinition().canAdd());
assertEquals("Wrong name definition.canModify", Boolean.FALSE, (Boolean) nameWrapper.getItemDefinition().canModify());
ItemWrapper givenNameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_GIVEN_NAME);
assertEquals("Wrong givenName readOnly", Boolean.TRUE, (Boolean) givenNameWrapper.isReadonly());
// Emphasized property. But the role given no access to this. Therefore is should not be visible.
// MID-3206
assertEquals("Wrong givenName visible", Boolean.FALSE, (Boolean) givenNameWrapper.isVisible());
assertEquals("Wrong givenName definition.canRead", Boolean.FALSE, (Boolean) givenNameWrapper.getItemDefinition().canRead());
assertEquals("Wrong givenName definition.canAdd", Boolean.FALSE, (Boolean) givenNameWrapper.getItemDefinition().canAdd());
assertEquals("Wrong givenName definition.canModify", Boolean.FALSE, (Boolean) givenNameWrapper.getItemDefinition().canModify());
ItemWrapper fullNameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_FULL_NAME);
assertEquals("Wrong fullName readOnly", Boolean.FALSE, (Boolean) fullNameWrapper.isReadonly());
assertEquals("Wrong fullName visible", Boolean.TRUE, (Boolean) fullNameWrapper.isVisible());
assertEquals("Wrong fullName definition.canRead", Boolean.TRUE, (Boolean) fullNameWrapper.getItemDefinition().canRead());
assertEquals("Wrong fullName definition.canAdd", Boolean.FALSE, (Boolean) fullNameWrapper.getItemDefinition().canAdd());
assertEquals("Wrong fullName definition.canModify", Boolean.TRUE, (Boolean) fullNameWrapper.getItemDefinition().canModify());
ItemWrapper additionalNameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_ADDITIONAL_NAME);
assertEquals("Wrong additionalName readOnly", Boolean.FALSE, (Boolean) additionalNameWrapper.isReadonly());
assertEquals("Wrong additionalName visible", Boolean.FALSE, (Boolean) additionalNameWrapper.isVisible());
assertEquals("Wrong additionalName definition.canRead", Boolean.FALSE, (Boolean) additionalNameWrapper.getItemDefinition().canRead());
assertEquals("Wrong additionalName definition.canAdd", Boolean.FALSE, (Boolean) additionalNameWrapper.getItemDefinition().canAdd());
assertEquals("Wrong additionalName definition.canModify", Boolean.TRUE, (Boolean) additionalNameWrapper.getItemDefinition().canModify());
ItemWrapper localityNameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_LOCALITY);
// Is this OK?
assertEquals("Wrong locality readOnly", Boolean.TRUE, (Boolean) localityNameWrapper.isReadonly());
assertEquals("Wrong locality visible", Boolean.FALSE, (Boolean) localityNameWrapper.isVisible());
assertEquals("Wrong locality definition.canRead", Boolean.FALSE, (Boolean) localityNameWrapper.getItemDefinition().canRead());
assertEquals("Wrong locality definition.canAdd", Boolean.FALSE, (Boolean) localityNameWrapper.getItemDefinition().canAdd());
assertEquals("Wrong locality definition.canModify", Boolean.FALSE, (Boolean) localityNameWrapper.getItemDefinition().canModify());
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class TestIntegrationObjectWrapperFactory method test220AssignRoleLandluberToWally.
@Test
public void test220AssignRoleLandluberToWally() throws Exception {
final String TEST_NAME = "test220AssignRoleLandluberToWally";
TestUtil.displayTestTile(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TestIntegrationObjectWrapperFactory.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
DummyGroup mapmakers = new DummyGroup(GROUP_DUMMY_MAPMAKERS_NAME);
dummyResource.addGroup(mapmakers);
PrismObject<UserType> user = createUser(USER_WALLY_NAME, USER_WALLY_FULLNAME, true);
addObject(user);
userWallyOid = user.getOid();
assignRole(userWallyOid, ROLE_MAPMAKER_OID, task, result);
// preconditions
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<UserType> userAfter = getUser(userWallyOid);
display("User after change execution", userAfter);
accountWallyOid = getSingleLinkOid(userAfter);
PrismObject<ShadowType> shadow = getShadowModel(accountWallyOid);
shadow.findReference(ShadowType.F_RESOURCE_REF).getValue().setObject(resourceDummy);
display("Shadow", shadow);
DummyGroup dummyGroup = dummyResource.getGroupByName(GROUP_DUMMY_MAPMAKERS_NAME);
assertNotNull("No group on dummy resource", dummyGroup);
display("Group", dummyGroup);
assertGroupMember(dummyGroup, USER_WALLY_NAME);
// WHEN
TestUtil.displayWhen(TEST_NAME);
ObjectWrapperFactory factory = new ObjectWrapperFactory(getServiceLocator());
ObjectWrapper<ShadowType> objectWrapper = factory.createObjectWrapper("shadow display name", "shadow description", shadow, ContainerStatus.MODIFYING, task);
// THEN
TestUtil.displayThen(TEST_NAME);
display("Wrapper after", objectWrapper);
WrapperTestUtil.assertWrapper(objectWrapper, "shadow display name", "shadow description", shadow, ContainerStatus.MODIFYING);
assertEquals("wrong number of containers in " + objectWrapper, 9, objectWrapper.getContainers().size());
ContainerWrapper attributesContainerWrapper = objectWrapper.findContainerWrapper(new ItemPath(ShadowType.F_ATTRIBUTES));
WrapperTestUtil.assertWrapper(attributesContainerWrapper, "prismContainer.shadow.mainPanelDisplayName", new ItemPath(ShadowType.F_ATTRIBUTES), shadow.findContainer(ShadowType.F_ATTRIBUTES), true, ContainerStatus.MODIFYING);
WrapperTestUtil.assertPropertyWrapper(attributesContainerWrapper, dummyResourceCtl.getAttributeFullnameQName(), USER_WALLY_FULLNAME);
WrapperTestUtil.assertPropertyWrapper(attributesContainerWrapper, SchemaConstants.ICFS_NAME, USER_WALLY_NAME);
assertEquals("wrong number of items in " + attributesContainerWrapper, 16, attributesContainerWrapper.getItems().size());
ContainerWrapper<ActivationType> activationContainerWrapper = objectWrapper.findContainerWrapper(new ItemPath(UserType.F_ACTIVATION));
WrapperTestUtil.assertWrapper(activationContainerWrapper, "ShadowType.activation", UserType.F_ACTIVATION, shadow, ContainerStatus.MODIFYING);
WrapperTestUtil.assertPropertyWrapper(activationContainerWrapper, ActivationType.F_ADMINISTRATIVE_STATUS, ActivationStatusType.ENABLED);
WrapperTestUtil.assertPropertyWrapper(activationContainerWrapper, ActivationType.F_LOCKOUT_STATUS, null);
ContainerWrapper<ShadowAssociationType> associationContainerWrapper = objectWrapper.findContainerWrapper(new ItemPath(ShadowType.F_ASSOCIATION));
assertNotNull("No association container wrapper", associationContainerWrapper);
assertEquals("wrong number of items in " + associationContainerWrapper, 2, associationContainerWrapper.getItems().size());
ItemWrapper groupAssociationWrapper = associationContainerWrapper.findPropertyWrapper(RESOURCE_DUMMY_ASSOCIATION_GROUP_QNAME);
assertNotNull("No group association property wrapper", groupAssociationWrapper);
assertTrue("Wrong type of group association property wrapper: " + groupAssociationWrapper.getClass(), groupAssociationWrapper instanceof AssociationWrapper);
List<ValueWrapper> groupAssociationValues = groupAssociationWrapper.getValues();
assertEquals("wrong number of values in " + groupAssociationWrapper, 1, groupAssociationValues.size());
ValueWrapper groupAssociationValue = groupAssociationValues.get(0);
PrismContainerValue<ShadowAssociationType> groupAssociationValuePVal = (PrismContainerValue<ShadowAssociationType>) groupAssociationValue.getValue();
display("groupAssociationValuePVal", groupAssociationValuePVal);
assertEquals("wrong number of values in " + groupAssociationValue, ValueStatus.NOT_CHANGED, groupAssociationValue.getStatus());
assertEquals("Wrong group association name", RESOURCE_DUMMY_ASSOCIATION_GROUP_QNAME, groupAssociationValuePVal.findProperty(ShadowAssociationType.F_NAME).getRealValue());
PrismContainer<ShadowIdentifiersType> groupAssociationValueIdentifiers = groupAssociationValuePVal.findContainer(ShadowAssociationType.F_IDENTIFIERS);
PrismProperty<String> groupAssociationUidProp = groupAssociationValueIdentifiers.findProperty(new QName(null, "uid"));
PrismAsserts.assertPropertyValue(groupAssociationUidProp, GROUP_DUMMY_MAPMAKERS_NAME);
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class ModelRestService method generateValue.
@POST
@Path("/{type}/{oid}/generate")
@Consumes({ "application/xml", "application/json", "application/yaml" })
@Produces({ "application/xml", "application/json", "application/yaml" })
public <O extends ObjectType> Response generateValue(@PathParam("type") String type, @PathParam("oid") String oid, PolicyItemsDefinitionType policyItemsDefinition, @Context MessageContext mc) {
Task task = RestServiceUtil.initRequest(mc);
OperationResult parentResult = task.getResult().createSubresult(OPERATION_GENERATE_VALUE);
Class<O> clazz = ObjectTypes.getClassFromRestType(type);
Response response;
if (policyItemsDefinition == null) {
response = createNoPolicyItemsDefinitionsResponse(parentResult);
} else {
try {
PrismObject<O> object = model.getObject(clazz, oid, null, task, parentResult);
modelInteraction.generateValue(object, policyItemsDefinition, task, parentResult);
parentResult.computeStatusIfUnknown();
if (parentResult.isSuccess()) {
response = RestServiceUtil.createResponse(Response.Status.OK, policyItemsDefinition, parentResult, true);
} else {
response = RestServiceUtil.createResponse(Response.Status.BAD_REQUEST, parentResult, parentResult);
}
// ResponseBuilder responseBuilder = Response.ok(policyItemsDefinition);
// response = responseBuilder.build();
} catch (Exception ex) {
parentResult.computeStatus();
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 validateValue.
@POST
@Path("/{type}/{oid}/validate")
@Consumes({ "application/xml", "application/json", "application/yaml" })
@Produces({ "application/xml", "application/json", "application/yaml" })
public <O extends ObjectType> Response validateValue(@PathParam("type") String type, @PathParam("oid") String oid, PolicyItemsDefinitionType policyItemsDefinition, @Context MessageContext mc) {
Task task = RestServiceUtil.initRequest(mc);
OperationResult parentResult = task.getResult().createSubresult(OPERATION_VALIDATE_VALUE);
Class<O> clazz = ObjectTypes.getClassFromRestType(type);
Response response;
if (policyItemsDefinition == null) {
response = createNoPolicyItemsDefinitionsResponse(parentResult);
} else {
try {
PrismObject<O> object = model.getObject(clazz, oid, null, task, parentResult);
modelInteraction.validateValue(object, policyItemsDefinition, task, parentResult);
parentResult.computeStatusIfUnknown();
ResponseBuilder responseBuilder;
if (parentResult.isAcceptable()) {
response = RestServiceUtil.createResponse(Response.Status.OK, policyItemsDefinition, parentResult, true);
} else {
responseBuilder = Response.status(Status.CONFLICT).entity(parentResult);
response = responseBuilder.build();
}
} catch (Exception ex) {
parentResult.computeStatus();
response = RestServiceUtil.handleException(parentResult, ex);
}
}
finishRequest(task);
return response;
}
Aggregations