use of com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType in project midpoint by Evolveum.
the class ImportAction method executeAction.
@Override
protected void executeAction() {
ModelPortType port = createModelPort();
ModelExecuteOptionsType options = new ModelExecuteOptionsType();
options.setRaw(getParams().isRaw());
com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType object = readObject();
ObjectDeltaType delta = createAddDelta(object);
ObjectDeltaListType deltas = createDeltaList(delta);
OperationResultType resultType;
try {
ObjectDeltaOperationListType result = port.executeChanges(deltas, options);
List<ObjectDeltaOperationType> operations = result.getDeltaOperation();
ObjectDeltaOperationType operation = operations.get(0);
resultType = operation.getExecutionResult();
} catch (FaultMessage ex) {
//todo error handling
FaultType fault = ex.getFaultInfo();
resultType = fault.getOperationResult();
}
STD_OUT.info("Status: {}", resultType.getStatus());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType in project midpoint by Evolveum.
the class ModelClientUtil method createRawExecuteOption.
public static ModelExecuteOptionsType createRawExecuteOption() {
ModelExecuteOptionsType opts = new ModelExecuteOptionsType();
opts.setRaw(Boolean.TRUE);
return opts;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType in project midpoint by Evolveum.
the class TestSanityLegacy method test006reimportResourceDummy.
@Test
public void test006reimportResourceDummy() throws Exception {
TestUtil.displayTestTile("test006reimportResourceDummy");
//get object from repo (with version set and try to add it - it should be re-added, without error)
OperationResult repoResult = new OperationResult("getObject");
PrismObject<ResourceType> resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, repoResult);
assertNotNull(resource);
ModelExecuteOptionsType options = new ModelExecuteOptionsType();
options.setOverwrite(Boolean.TRUE);
options.setIsImport(Boolean.TRUE);
addObjectViaModelWS(resource.asObjectable(), options, new Holder<String>(), new Holder<OperationResultType>());
//TODO: add some asserts
//parse object from file again and try to add it - this should fail, becasue the same object already exists)
resource = PrismTestUtil.parseObject(new File(RESOURCE_DUMMY_FILENAME));
try {
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
options = new ModelExecuteOptionsType();
options.setIsImport(Boolean.TRUE);
addObjectViaModelWS(resource.asObjectable(), options, new Holder<String>(), resultHolder);
OperationResultType result = resultHolder.value;
TestUtil.assertFailure(result);
fail("Expected object already exists exception, but haven't got one.");
} catch (FaultMessage ex) {
LOGGER.info("fault {}", ex.getFaultInfo());
LOGGER.info("fault {}", ex.getCause());
if (ex.getFaultInfo() instanceof ObjectAlreadyExistsFaultType) {
// this is OK, we expect this
} else {
fail("Expected object already exists exception, but haven't got one.");
}
}
// ResourceType resourceType = uObject.asObjectable();
// assertNotNull("Reference on the connector must not be null in resource.",resourceType.getConnectorRef());
// assertNotNull("Missing oid reference on the connector",resourceType.getConnectorRef().getOid());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType in project midpoint by Evolveum.
the class TestSanityLegacy method addObjectViaModelWS.
private void addObjectViaModelWS(ObjectType objectType, ModelExecuteOptionsType options, Holder<String> oidHolder, Holder<OperationResultType> resultHolder) throws FaultMessage {
ObjectDeltaListType deltaList = new ObjectDeltaListType();
ObjectDeltaType objectDelta = new ObjectDeltaType();
objectDelta.setObjectToAdd(objectType);
QName type = objectType.asPrismObject().getDefinition().getTypeName();
objectDelta.setObjectType(type);
objectDelta.setChangeType(ChangeTypeType.ADD);
deltaList.getDelta().add(objectDelta);
ObjectDeltaOperationListType objectDeltaOperationListType = modelWeb.executeChanges(deltaList, options);
ObjectDeltaOperationType objectDeltaOperationType = getOdoFromDeltaOperationList(objectDeltaOperationListType, objectDelta);
resultHolder.value = objectDeltaOperationType.getExecutionResult();
oidHolder.value = ((ObjectType) objectDeltaOperationType.getObjectDelta().getObjectToAdd()).getOid();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType in project midpoint by Evolveum.
the class TestSanity method test006reimportResourceDummy.
@Test
public void test006reimportResourceDummy() throws Exception {
TestUtil.displayTestTile("test006reimportResourceDummy");
//get object from repo (with version set and try to add it - it should be re-added, without error)
OperationResult repoResult = new OperationResult("getObject");
PrismObject<ResourceType> resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, repoResult);
assertNotNull(resource);
ModelExecuteOptionsType options = new ModelExecuteOptionsType();
options.setOverwrite(Boolean.TRUE);
options.setIsImport(Boolean.TRUE);
addObjectViaModelWS(resource.asObjectable(), options, new Holder<String>(), new Holder<OperationResultType>());
//TODO: add some asserts
//parse object from file again and try to add it - this should fail, becasue the same object already exists)
resource = PrismTestUtil.parseObject(new File(RESOURCE_DUMMY_FILENAME));
try {
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
options = new ModelExecuteOptionsType();
options.setIsImport(Boolean.TRUE);
addObjectViaModelWS(resource.asObjectable(), options, new Holder<String>(), resultHolder);
OperationResultType result = resultHolder.value;
TestUtil.assertFailure(result);
fail("Expected object already exists exception, but haven't got one.");
} catch (FaultMessage ex) {
LOGGER.info("fault {}", ex.getFaultInfo());
LOGGER.info("fault {}", ex.getCause());
if (ex.getFaultInfo() instanceof ObjectAlreadyExistsFaultType) {
// this is OK, we expect this
} else {
fail("Expected object already exists exception, but haven't got one.");
}
}
// ResourceType resourceType = uObject.asObjectable();
// assertNotNull("Reference on the connector must not be null in resource.",resourceType.getConnectorRef());
// assertNotNull("Missing oid reference on the connector",resourceType.getConnectorRef().getOid());
}
Aggregations