<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:611281217;
        mso-list-type:hybrid;
        mso-list-template-ids:1308231008 536870913 536870915 536870917 536870913 536870915 536870917 536870913 536870915 536870917;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l1
        {mso-list-id:1586500597;
        mso-list-type:hybrid;
        mso-list-template-ids:1851530524 536870927 536870937 536870939 536870927 536870937 536870939 536870927 536870937 536870939;}
@list l1:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l1:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l1:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="en-CH" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I am trying to find a way to remove notFound objects faster. Here are three ways I tried:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<ol style="margin-top:0in" start="1" type="1">
<li class="MsoListParagraph" style="margin-left:0in;mso-list:l1 level1 lfo1"><span lang="EN-US">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.<o:p></o:p></span></li></ol>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-US">But this takes a long time.
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<ol style="margin-top:0in" start="2" type="1">
<li class="MsoListParagraph" style="margin-left:0in;mso-list:l1 level1 lfo1"><span lang="EN-US">I tried to access directly to the databases, which is extremely fast.
<o:p></o:p></span></li></ol>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-US">For example, I can find out all users with assignment/targetRef which is no longer exists in midpoint with the query:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span lang="EN-US">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;<o:p></o:p></span></b></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-US">But even if I deleted the entries from
<b>m_assignment</b>, 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.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<ol style="margin-top:0in" start="3" type="1">
<li class="MsoListParagraph" style="margin-left:0in;mso-list:l1 level1 lfo1"><span lang="EN-US">I modify the xml file of user directly.
<o:p></o:p></span></li></ol>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-US">For example, the xml from “Edit Raw” of a user always show the name of the reference as a comment, like this:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-US"><parentOrgRef oid="6b81005f-88c4-4dbd-a724-9c4384336748" relation="org:default" type="c:OrgType"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-US">        <!-- Org317187 --><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-US"></parentOrgRef> <o:p>
</o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-US">But if the reference is deleted, then it shows this (Without a comment):<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-US"><parentOrgRef oid="6b81005f-88c4-4dbd-a724-9c4384336748" relation="org:default" type="c:OrgType"/><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-US">With some basic programming these entries without a comment can be removed easily. I then import the objects back to midpoint using ninja:<br>
java -jar ninja.jar -m /opt/midpoint/var import -O -i ../testUsers.xml -l 4 -r<br>
Things works fine so far.<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Here are 2 questions I want to ask:<o:p></o:p></span></p>
<ul style="margin-top:0in" type="disc">
<li class="MsoListParagraph" style="margin-left:0in;mso-list:l0 level1 lfo2"><span lang="EN-US">Is there any concern of what I did with approach 3?<o:p></o:p></span></li><li class="MsoListParagraph" style="margin-left:0in;mso-list:l0 level1 lfo2"><span lang="EN-US">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.
<br>
<br>
Xml file from ninja export doesn’t show comment.<o:p></o:p></span></li></ul>
<p class="MsoListParagraph"><span lang="EN-US">java -jar ninja.jar -m /opt/midpoint/var export -t user -O ../var/outUsers.xml -l 4 -r<br>
<img width="1075" height="156" style="width:11.2in;height:1.625in" id="Picture_x0020_1" src="cid:image001.png@01D95814.76A14150">
<o:p></o:p></span></p>
<p class="MsoListParagraph"><span lang="EN-US"><br>
I tried using <a href="https://github.com/Evolveum/midpoint/blob/aea690c051daaf348fae4cb6211fde973ebadfbf/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/component/PageDebugDownloadBehaviour.java">
these</a> three lines in a bulk action to write out xml. The writing to xml file works but entries show no comment.
<o:p></o:p></span></p>
<p class="MsoListParagraph"><span lang="EN-US"><img border="0" width="546" height="334" style="width:5.6916in;height:3.4833in" id="Picture_x0020_6" src="cid:image002.png@01D95816.F9F15D90"></span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Any advice/suggestion is welcome!!<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Thank you very much for reading the email and your help!<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Best regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Hsin-Fang<o:p></o:p></span></p>
</div>
</body>
</html>