[Midpoint-dev] remove notFound objects

Hsin-Fang Hsu hsin-fang.hsu at itconcepts.ch
Thu Mar 16 14:53:20 CET 2023


Hi,

I am trying to find a way to remove notFound objects faster. Here are three ways I tried:


  1.  create a bulk action to go through all users/orgs/roles in midpoint and find if any of their assignment/roleMembershipRef/parentOrgRef/linkRef cannot be found in midpoint.
But this takes a long time.


  1.  I tried to access directly to the databases, which is extremely fast.
For example, I can find out all users with assignment/targetRef which is no longer exists in midpoint with the query:
select username, targetoid from (select u.name_orig as username, o.name_orig as targetname, a.targetref_targetoid as targetoid from ((select name_orig, oid from m_user) as u left join (select targetref_targetoid, owner_oid from m_assignment) as a on u.oid=a.owner_oid left join (select name_orig, oid from m_object) as o on o.oid=a.targetref_targetoid)) as f where targetname IS NULL and targetoid IS NOT NULL;

But even if I deleted the entries from m_assignment, the fullobject of m_user table won’t be updated even after user recompute. So, the xml from edit raw of the user still shows the assignment with a dead targetRef.


  1.  I modify the xml file of user directly.
For example, the xml from “Edit Raw” of a user always show the name of the reference as a comment, like this:
<parentOrgRef oid="6b81005f-88c4-4dbd-a724-9c4384336748" relation="org:default" type="c:OrgType">
        <!-- Org317187 -->
</parentOrgRef>

But if the reference is deleted, then it shows this (Without a comment):
<parentOrgRef oid="6b81005f-88c4-4dbd-a724-9c4384336748" relation="org:default" type="c:OrgType"/>

With some basic programming these entries without a comment can be removed easily. I then import the objects back to midpoint using ninja:
java -jar ninja.jar -m /opt/midpoint/var import -O -i ../testUsers.xml -l 4 -r
Things works fine so far.

Here are 2 questions I want to ask:

  *   Is there any concern of what I did with approach 3?
  *   These comments only show up with GUI editRaw or export(see figure below).  I want to know a way to export the xml with code.

Xml file from ninja export doesn’t show comment.

java -jar ninja.jar -m /opt/midpoint/var export -t user -O ../var/outUsers.xml -l 4 -r
[cid:image001.png at 01D95814.76A14150]

I tried using these<https://github.com/Evolveum/midpoint/blob/aea690c051daaf348fae4cb6211fde973ebadfbf/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/component/PageDebugDownloadBehaviour.java> three lines in a bulk action to write out xml. The writing to xml file works but entries show no comment.

[cid:image002.png at 01D95816.F9F15D90]


Any advice/suggestion is welcome!!

Thank you very much for reading the email and your help!

Best regards,
Hsin-Fang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint-dev/attachments/20230316/88db9671/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 24381 bytes
Desc: image001.png
URL: <https://lists.evolveum.com/pipermail/midpoint-dev/attachments/20230316/88db9671/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 67603 bytes
Desc: image002.png
URL: <https://lists.evolveum.com/pipermail/midpoint-dev/attachments/20230316/88db9671/attachment-0003.png>


More information about the midPoint-dev mailing list