use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class SchemaDebugUtil method prettyPrint.
public static String prettyPrint(ItemDeltaType change) throws SchemaException {
if (change == null) {
return "null";
}
StringBuilder sb = new StringBuilder("ProperyModification(");
sb.append(change.getModificationType());
sb.append(",");
if (change.getPath() != null) {
//FIXME : xpath vs itemPath
XPathHolder xpath = new XPathHolder(change.getPath().getItemPath());
sb.append(xpath.toString());
} else {
sb.append("xpath=null");
}
sb.append(",");
List<RawType> values = change.getValue();
for (RawType value : values) {
// todo implement correctly...
sb.append(prettyPrint(value.serializeToXNode()));
sb.append(",");
}
return sb.toString();
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class ModelWebServiceTest method nonExistingUidModify.
@Test(expectedExceptions = FaultMessage.class)
public void nonExistingUidModify() throws FaultMessage, ObjectNotFoundException, SchemaException, JAXBException, IOException {
final String oid = "1";
ObjectDeltaType objectDeltaType = new ObjectDeltaType();
objectDeltaType.setChangeType(ChangeTypeType.MODIFY);
objectDeltaType.setObjectType(UserType.COMPLEX_TYPE);
objectDeltaType.setOid(oid);
ItemDeltaType mod1 = new ItemDeltaType();
mod1.setModificationType(ModificationTypeType.ADD);
// ItemDeltaType.Value value = new ItemDeltaType.Value();
// value.getAny().add(DOMUtil.createElement(DOMUtil.getDocument(), new QName(SchemaConstants.NS_C, "fullName")));
mod1.setPath(new ItemPathType(new ItemPath(UserType.F_FULL_NAME)));
objectDeltaType.getItemDelta().add(mod1);
when(repositoryService.getObject(any(Class.class), eq(oid), any(Collection.class), any(OperationResult.class))).thenThrow(new ObjectNotFoundException("Oid '" + oid + "' not found."));
final UserType user = (UserType) PrismTestUtil.parseObject(new File(TEST_FOLDER_CONTROLLER, "./addObject/add-user-without-name.xml")).asObjectable();
setSecurityContext(user);
ObjectDeltaListType deltaListType = new ObjectDeltaListType();
deltaListType.getDelta().add(objectDeltaType);
try {
modelService.executeChanges(deltaListType, null);
} catch (FaultMessage ex) {
ModelTUtil.assertObjectNotFoundFault(ex);
} finally {
SecurityContextHolder.getContext().setAuthentication(null);
}
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class TestModelWebServiceNegative method createShadowReplaceChange.
// TODO: more negative tests
private ObjectDeltaType createShadowReplaceChange(String oid, String path, final String value, QName type) {
ObjectDeltaType objectChange = new ObjectDeltaType();
objectChange.setOid(oid);
objectChange.setChangeType(ChangeTypeType.MODIFY);
objectChange.setObjectType(ObjectTypes.SHADOW.getTypeQName());
ItemDeltaType itemDeltaType = new ItemDeltaType();
itemDeltaType.setModificationType(ModificationTypeType.REPLACE);
ItemPathType itemPath = new ItemPathType(path);
itemDeltaType.setPath(itemPath);
PrimitiveXNode<String> xnode = new PrimitiveXNode<>();
ValueParser<String> valueParser = new ValueParser<String>() {
@Override
public String parse(QName typeName, XNodeProcessorEvaluationMode mode) throws SchemaException {
return value;
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public String getStringValue() {
return value;
}
@Override
public Map<String, String> getPotentiallyRelevantNamespaces() {
throw new UnsupportedOperationException();
}
};
xnode.setValueParser(valueParser);
if (type != null) {
xnode.setExplicitTypeDeclaration(true);
xnode.setTypeQName(type);
}
RawType rawValue = new RawType(xnode, prismContext);
itemDeltaType.getValue().add(rawValue);
objectChange.getItemDelta().add(itemDeltaType);
return objectChange;
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class AbstractManualResourceTest method findPendingOperation.
private PendingOperationType findPendingOperation(PrismObject<ShadowType> shadow, OperationResultStatusType expectedResult, ItemPath itemPath) {
List<PendingOperationType> pendingOperations = shadow.asObjectable().getPendingOperation();
for (PendingOperationType pendingOperation : pendingOperations) {
OperationResultStatusType result = pendingOperation.getResultStatus();
if (result == null) {
result = OperationResultStatusType.IN_PROGRESS;
}
if (pendingOperation.getResultStatus() != expectedResult) {
continue;
}
if (itemPath == null) {
return pendingOperation;
}
ObjectDeltaType delta = pendingOperation.getDelta();
assertNotNull("No delta in pending operation in " + shadow, delta);
for (ItemDeltaType itemDelta : delta.getItemDelta()) {
ItemPath deltaPath = itemDelta.getPath().getItemPath();
if (itemPath.equivalent(deltaPath)) {
return pendingOperation;
}
}
}
return null;
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class ReportUtils method printDelta.
public static String printDelta(ObjectDeltaType delta, String objectName, String resourceName) {
StringBuilder sb = new StringBuilder();
switch(delta.getChangeType()) {
case MODIFY:
Collection<ItemDeltaType> modificationDeltas = delta.getItemDelta();
if (modificationDeltas != null && !modificationDeltas.isEmpty()) {
sb.append(printChangeType(objectName, delta, "Modify", resourceName));
}
for (ItemDeltaType itemDelta : modificationDeltas) {
sb.append(prettyPrintForReport(itemDelta));
}
sb.setLength(Math.max(sb.length() - 1, 0));
break;
case ADD:
ObjectType objectToAdd = (ObjectType) delta.getObjectToAdd();
if (objectToAdd != null) {
sb.append(printChangeType(objectName, delta, "Add", resourceName));
if (objectToAdd.getName() != null) {
sb.append(prettyPrintForReport(objectToAdd.getClass().getSimpleName()));
sb.append("=");
sb.append(objectToAdd.getName().toString());
}
sb.append(" {");
sb.append(prettyPrintForReport(objectToAdd));
sb.append("}");
}
break;
case DELETE:
sb.append(printChangeType(objectName, delta, "Delete", resourceName));
break;
}
return sb.toString();
}
Aggregations