<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Thank you very much, your tips was very helpful, now everything
      is working.</p>
    <p>Best regards,<br>
      Wojciech Staszewski<br>
    </p>
    <br>
    <div class="moz-cite-prefix">W dniu 27.06.2018 o 09:17, Ivan Noris
      pisze:<br>
    </div>
    <blockquote type="cite"
      cite="mid:d1d7afd2-a098-98ef-d75d-ec346fbc48bf@evolveum.com">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <p>Wojciech,<br>
      </p>
      <p>this might be a result of your groovy construction:<br>
      </p>
      <p><span class="js-keyword">def </span><span
          class="js-punctuation">(</span><span class="js-variable">firstfamilyname</span><span
          class="js-punctuation">, </span><span class="js-variable">secondfamilyname</span><span
          class="js-punctuation">) </span><span class="js-operator">= </span><span
          class="js-variable">user</span><span class="js-operator">?</span><span
          class="js-punctuation">.</span><span class="js-variable">getFamilyName</span><span
          class="js-punctuation">(</span><span class="js-punctuation">)</span><span
          class="js-operator">?</span><span class="js-punctuation">.</span><span
          class="js-variable">toString</span><span
          class="js-punctuation">(</span><span class="js-punctuation">)</span><span
          class="js-operator">?</span><span class="js-punctuation">.</span><span
          class="js-variable">tokenize</span><span
          class="js-punctuation">(</span><span class="js-string">'-'</span><span
          class="js-punctuation">)</span></p>
      <p><span class="js-punctuation">This will throw NPE when user is
          null.</span></p>
      <p><br>
      </p>
      <pre id="stacktrace" class="border hidden" style="display: block;">java.lang.NullPointerException: Cannot invoke method getAt() on null object
        at Script1.run(Script1.groovy:3)</pre>
      <p><span class="js-punctuation"></span></p>
      <p><span class="js-punctuation">You can check using <a
            class="moz-txt-link-freetext"
            href="http://groovyconsole.appspot.com/"
            moz-do-not-send="true">http://groovyconsole.appspot.com/</a></span></p>
      <p><span class="js-punctuation">You cannot set the two variables
          using tokenize if the user is null.</span></p>
      <p><span class="js-punctuation">I would suggest to check user
          object first and not run anything else in case of delete.<br>
        </span></p>
      <p><span class="js-punctuation">Best regards,</span></p>
      <p><span class="js-punctuation">Ivan<br>
        </span></p>
      <br>
      <div class="moz-cite-prefix">On 26.06.2018 23:07, Wojciech
        Staszewski wrote:<br>
      </div>
      <blockquote type="cite"
        cite="mid:cf6decda-3122-4385-7c81-bd7f5dcd8544@diagnostyka.pl">
        <pre wrap="">Hello!

I try to delete user but I get an error.
The error comes from pre-iteration expression of one of assigned resources.

Error:
Couldn't delete user.
Message
java.lang.NullPointerException: Cannot invoke method getAt() on null
object in (new) pre-iteration expression in account(ID
{.../connector/icf-1/resource-schema-3}uid = [ 94740706 ], type 'AAA',
<a class="moz-txt-link-freetext" href="resource:xxx-oid-xxx%28resource" moz-do-not-send="true">resource:xxx-oid-xxx(resource</a> name))
Parameters
options   
[ModelExecuteOptions(executeImmediatelyAfterApproval=false,force=false,reconcile=false,reconcileAffected=false)]
Error
java.lang.NullPointerException: Cannot invoke method getAt() on null
object in (new) pre-iteration expression in account(ID
{.../connector/icf-1/resource-schema-3}uid = [ 94740706 ], type 'AAA',
<a class="moz-txt-link-freetext" href="resource:xxx-oid-xxx%28resource" moz-do-not-send="true">resource:xxx-oid-xxx(resource</a> name))

I have no "getAt()" method in the expression.
The pre-iteration expression:

            <preIterationCondition>
               <variable>
                  <name>firstname</name>
                  <c:path>$shadow/attributes/ri:firstname</c:path>
               </variable>
               <variable>
                  <name>surname</name>
                  <c:path>$shadow/attributes/ri:surname</c:path>
               </variable>
               <variable>
                  <name>login</name>
                  <c:path>$shadow/attributes/ri:login</c:path>
               </variable>
               <script xmlns:xsi=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema-instance" moz-do-not-send="true">"http://www.w3.org/2001/XMLSchema-instance"</a>
                       xsi:type="c:ScriptExpressionEvaluatorType">
                  <code>
                      def (firstfamilyname,secondfamilyname) =
user?.getFamilyName()?.toString()?.tokenize('-');
            def templogin =
basic.norm(user?.getGivenName()?.toString()?.replace("Ł","L")?.replace("ł","l")?.toString()?.take(1))?.toUpperCase()
+
basic.norm(firstfamilyname?.replace("Ł","L")?.replace("ł","l"))?.toString()?.toUpperCase()
+ iterationToken;
            return midpoint.isUniqueAccountValue(resource, shadow,
'login', templogin);
        </code>
               </script>
            </preIterationCondition>

This expression takes first letter of the user given name, whole first
family name (both normalized), example: Anna Smith-Wilson = ASMITH and
checks if this calculated login exists in the resource.

The resource has "disable instead delete" mechanism applied taken from
training labs materials.

Questions:

1) Why midPoint tries to delete account from this resource instead
disable and unassign it (disable instead delete)?
2) Why midPoint runs the pre-iteration condition on delete operation?
Isn't it a create operation specific expression?
3) Where to find getAt() method, as it is not present in the expression?

Thanks!
Wojciech Staszewski
_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com" moz-do-not-send="true">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint" moz-do-not-send="true">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
      </blockquote>
      <br>
      <pre class="moz-signature" cols="72">-- 
Ivan Noris
Senior Identity Engineer
evolveum.com
</pre>
      <!--'"--><br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
    </blockquote>
  </body>
</html>