use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method modifyRoleAssignment.
protected boolean modifyRoleAssignment(Class clazz, String oid, boolean isAdd, String... roleOids) throws FaultMessage {
ItemDeltaType assignmentDelta = new ItemDeltaType();
if (isAdd) {
assignmentDelta.setModificationType(ModificationTypeType.ADD);
} else {
assignmentDelta.setModificationType(ModificationTypeType.DELETE);
}
assignmentDelta.setPath(ModelClientUtil.createItemPathType("assignment"));
for (String roleOid : roleOids) {
AssertJUnit.assertNotNull("role OID is null", roleOid);
assignmentDelta.getValue().add(createRoleAssignment(roleOid));
}
ObjectDeltaType deltaType = new ObjectDeltaType();
deltaType.setObjectType(ModelClientUtil.getTypeQName(clazz));
deltaType.setChangeType(ChangeTypeType.MODIFY);
deltaType.setOid(oid);
deltaType.getItemDelta().add(assignmentDelta);
ObjectDeltaListType deltaListType = new ObjectDeltaListType();
deltaListType.getDelta().add(deltaType);
ObjectDeltaOperationListType objectDeltaOperationList = modelPort.executeChanges(deltaListType, null);
Boolean success = null;
for (ObjectDeltaOperationType objectDeltaOperation : objectDeltaOperationList.getDeltaOperation()) {
if (oid.equals(objectDeltaOperation.getObjectDelta().getOid())) {
if (!OperationResultStatusType.SUCCESS.equals(objectDeltaOperation.getExecutionResult().getStatus())) {
System.out.println("*** Operation result = " + objectDeltaOperation.getExecutionResult().getStatus() + ": " + objectDeltaOperation.getExecutionResult().getMessage());
success = false;
} else {
if (success == null) {
success = true;
}
}
}
}
return Boolean.TRUE.equals(success);
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.
the class WorkItemDto method getFocus.
// Expects that we deal with primary changes of the focus (i.e. not of projections)
// Beware: returns the full object; regardless of the security settings
public ObjectType getFocus(PageBase pageBase) {
if (focus != null) {
return focus;
}
WfContextType wfc = getWorkflowContext();
WfPrimaryChangeProcessorStateType state = WfContextUtil.getPrimaryChangeProcessorState(wfc);
if (state == null || state.getDeltasToProcess() == null || state.getDeltasToProcess().getFocusPrimaryDelta() == null) {
return null;
}
ObjectDeltaType delta = state.getDeltasToProcess().getFocusPrimaryDelta();
if (delta.getChangeType() == ChangeTypeType.ADD) {
focus = CloneUtil.clone((ObjectType) delta.getObjectToAdd());
} else if (delta.getChangeType() == ChangeTypeType.MODIFY) {
String oid = delta.getOid();
if (oid == null) {
throw new IllegalStateException("No OID in object modify delta: " + delta);
}
if (delta.getObjectType() == null) {
throw new IllegalStateException("No object type in object modify delta: " + delta);
}
Class<? extends ObjectType> clazz = ObjectTypes.getObjectTypeFromTypeQName(delta.getObjectType()).getClassDefinition();
Task task = pageBase.createSimpleTask("getObject");
PrismObject<?> object = pageBase.getSecurityEnforcer().runPrivileged(() -> WebModelServiceUtils.loadObject(clazz, oid, pageBase, task, task.getResult()));
if (object != null) {
focus = (ObjectType) object.asObjectable();
try {
ObjectDelta<Objectable> objectDelta = DeltaConvertor.createObjectDelta(delta, pageBase.getPrismContext());
objectDelta.applyTo((PrismObject) focus.asPrismObject());
} catch (SchemaException e) {
throw new SystemException("Cannot apply delta to focus object: " + e.getMessage(), e);
}
focus = (ObjectType) object.asObjectable();
}
} else {
// DELETE case: nothing to do here
}
return focus;
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.
the class RObjectDeltaOperation method fromRepo.
public static ObjectDeltaOperation fromRepo(RObjectDeltaOperation operation, PrismContext prismContext) throws DtoTranslationException {
ObjectDeltaOperation odo = new ObjectDeltaOperation();
try {
if (operation.getDelta() != null) {
ObjectDeltaType delta = prismContext.parserFor(operation.getDelta()).parseRealValue(ObjectDeltaType.class);
odo.setObjectDelta(DeltaConvertor.createObjectDelta(delta, prismContext));
}
if (operation.getFullResult() != null) {
OperationResultType resultType = prismContext.parserFor(operation.getFullResult()).parseRealValue(OperationResultType.class);
odo.setExecutionResult(OperationResult.createOperationResult(resultType));
}
odo.setObjectName(RPolyString.fromRepo(operation.getObjectName()));
odo.setResourceOid(operation.getResourceOid());
odo.setResourceName(RPolyString.fromRepo(operation.getResourceName()));
} catch (Exception ex) {
throw new DtoTranslationException(ex.getMessage(), ex);
}
return odo;
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.
the class Main method changeUserPassword.
private static void changeUserPassword(ModelPortType modelPort, String oid, String newPassword) throws FaultMessage {
ItemDeltaType passwordDelta = new ItemDeltaType();
passwordDelta.setModificationType(ModificationTypeType.REPLACE);
passwordDelta.setPath(ModelClientUtil.createItemPathType("credentials/password/value"));
passwordDelta.getValue().add(ModelClientUtil.createProtectedString(newPassword));
ObjectDeltaType deltaType = new ObjectDeltaType();
deltaType.setObjectType(ModelClientUtil.getTypeQName(UserType.class));
deltaType.setChangeType(ChangeTypeType.MODIFY);
deltaType.setOid(oid);
deltaType.getItemDelta().add(passwordDelta);
ObjectDeltaListType deltaListType = new ObjectDeltaListType();
deltaListType.getDelta().add(deltaType);
modelPort.executeChanges(deltaListType, null);
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.
the class Main method modifyRoleModifyInducement.
private static void modifyRoleModifyInducement(ModelPortType modelPort, String roleOid) throws IOException, SAXException, FaultMessage {
ItemDeltaType inducementDelta = new ItemDeltaType();
inducementDelta.setModificationType(ModificationTypeType.ADD);
inducementDelta.setPath(ModelClientUtil.createItemPathType("inducement[3]/construction/attribute"));
inducementDelta.getValue().add(ModelClientUtil.parseElement("<value>\n" + " <ref xmlns:ri=\"http://midpoint.evolveum.com/xml/ns/public/resource/instance-3\">ri:pager</ref>\n" + " <outbound>\n" + " <expression>\n" + " <value>00-000-001</value>\n" + " <value>00-000-003</value>\n" + " </expression>\n" + " </outbound>\n" + " </value>"));
ObjectDeltaType deltaType = new ObjectDeltaType();
deltaType.setObjectType(ModelClientUtil.getTypeQName(RoleType.class));
deltaType.setChangeType(ChangeTypeType.MODIFY);
deltaType.setOid(roleOid);
deltaType.getItemDelta().add(inducementDelta);
ObjectDeltaListType deltaListType = new ObjectDeltaListType();
deltaListType.getDelta().add(deltaType);
ObjectDeltaOperationListType objectDeltaOperationList = modelPort.executeChanges(deltaListType, null);
for (ObjectDeltaOperationType objectDeltaOperation : objectDeltaOperationList.getDeltaOperation()) {
if (!OperationResultStatusType.SUCCESS.equals(objectDeltaOperation.getExecutionResult().getStatus())) {
System.out.println("*** Operation result = " + objectDeltaOperation.getExecutionResult().getStatus() + ": " + objectDeltaOperation.getExecutionResult().getMessage());
}
}
}
Aggregations