[midPoint] ModelClient Question
Pavol Mederly
mederly at evolveum.com
Fri Mar 28 11:53:22 CET 2014
Hello Alexander,
I've enhanced our sample to cover also this case. You can find it in
today's commit:
https://github.com/Evolveum/midpoint/commit/4ad1df9eb787ebee0f1ba4cf5920d29ac31797bb
The code looks like this:
private static void changeUserGivenName(ModelPortType modelPort, String
oid, String newValue) throws FaultMessage {
Document doc = ModelClientUtil.getDocumnent();
ObjectModificationType userDelta = new ObjectModificationType();
userDelta.setOid(oid);
ItemDeltaType itemDelta = new ItemDeltaType();
itemDelta.setModificationType(ModificationTypeType.REPLACE);
ItemDeltaType.Value itemValue = new ItemDeltaType.Value();
*itemValue.getAny().add(ModelClientUtil.toJaxbElement(ModelClientUtil.COMMON_GIVEN_NAME,
ModelClientUtil.createPolyStringType(newValue, doc)));**
* itemDelta.setValue(itemValue);
userDelta.getModification().add(itemDelta);
modelPort.modifyObject(ModelClientUtil.getTypeUri(UserType.class),
userDelta);
}
Instead of setting "path = givenName", value to replace =
"<value>abc</value>" it is necessary to set the parameters as following:
path = (nothing)
value to replace = <givenName>abc</givenName>
(Note that I've also added appropriate QName constant into
ModelClientUtil, although you can of course provide such a value
directly in your code.)
Hope this helps,
Pavol
On 27. 3. 2014 18:29, Alexander Grzesik wrote:
>
> Hi,
>
> I am trying to use the ModelClient to use Midpoint as IDM Backend for
> an external application.
>
> Based on the ModelSample I was able to create, delete, modify roles
> and change password of a user.
>
> What I did not found out is how to modify a simple attribute of a User
> (e.g. givenName).
>
> My code looks like this:
>
> Document doc = ModelClientUtil./getDocumnent/();
>
> ObjectModificationType userDelta = *new*ObjectModificationType();
>
> userDelta.setOid(oid);
>
> ItemDeltaType delta = new ItemDeltaType();
>
> delta.setModificationType(ModificationTypeType.REPLACE);
>
> delta.setPath(ModelClientUtil.createPathElement("givenName", doc));
>
> ItemDeltaType.Value value = new ItemDeltaType.Value();
>
> value.getAny().add(
>
> ModelClientUtil.toJaxbElement(ModelClientUtil.COMMON_VALUE,
>
> ModelClientUtil.createPolyStringType((String) newValue, doc)));
>
> delta.setValue(value);
>
> userDelta.getModification().add(delta);
>
> modelPort.modifyObject(ModelClientUtil.getTypeUri(UserType.class),
> userDelta);
>
> I get the following error:
>
> com.evolveum.midpoint.xml.ns._public.common.fault_1_wsdl.FaultMessage:
> Looking for definition of class class
> com.evolveum.midpoint.prism.PrismContainerDefinition but found
> PPD:{.../common/common-2a}givenName
> {http://prism.evolveum.com/xml/ns/public/types-2}PolyStringType[0,1],RCU
>
> Could you give me an example how to modify properties of a User via
> the ModelClient api?
>
> Thanks
>
> Alexander
>
>
>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> http://lists.evolveum.com/mailman/listinfo/midpoint
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20140328/7bf41e1d/attachment.htm>
More information about the midPoint
mailing list