<?xml version="1.0" encoding="UTF-8"?>
 <objectTemplate xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
                xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
                xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
                xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
                xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
                xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
                oid="83cc1d77-dedc-4269-a051-b006821a9c79"
                version="33">
   <name>Folders Template</name>
   <mapping>
      <name>Assign Basic role to Box Folders</name>
      <authoritative>true</authoritative>
      <strength>strong</strength>
      <expression>
         <assignmentTargetSearch xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                 xsi:type="c:SearchObjectRefExpressionEvaluatorType">
            <targetType>RoleType</targetType>
            <filter>
                <q:text>name = "Box Folde"</q:text>
            </filter>
         </assignmentTargetSearch>
      </expression>
      <target>
         <c:path>assignment</c:path>
      </target>
   </mapping>
   <mapping>
      <name>Host to box</name>
      <authoritative>true</authoritative>
      <strength>strong</strength>
      <source>
         <name>hostname</name>
         <c:path>extension/parent.name</c:path>
      </source>
      <expression>
         <assignmentTargetSearch xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                 xsi:type="c:SearchObjectRefExpressionEvaluatorType">
            <targetType>c:OrgType</targetType>
            <filter>
                <q:text>c:name = ```
                        parent = hostname
                        if (parent.equals("All Files")) {
                        return "Folders";
                        } else {
                        return parent;
                        }
                        ```
                </q:text>
            </filter>
            <createOnDemand>true</createOnDemand>
            <populateObject>
               <populateItem>
                  <expression>
                     <script xsi:type="c:ScriptExpressionEvaluatorType">
                        <code>
                                    hostname
                                </code>
                     </script>
                  </expression>
                  <target>
                     <c:path>name</c:path>
                  </target>
               </populateItem>
               <populateItem>
                  <expression>
                     <assignmentTargetSearch xsi:type="c:SearchObjectRefExpressionEvaluatorType">
                        <targetType>c:OrgType</targetType>
                        <filter>
                            <q:text>c:name = "Folders"</q:text>
                        </filter>
                     </assignmentTargetSearch>
                  </expression>
                  <target>
                     <c:path>assignment</c:path>
                  </target>
               </populateItem>
            </populateObject>
         </assignmentTargetSearch>
      </expression>
      <target>
         <c:path>assignment</c:path>
         <set>
            <condition>
               <script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                       xsi:type="c:ScriptExpressionEvaluatorType">
                  <code>
                     import com.evolveum.midpoint.schema.constants.*
                     import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType
                     leader = midpoint.searchObjectByName(OrgType.class, "Folders");
                     value.targetRef != null &amp;&amp; value.targetRef.type == OrgType.COMPLEX_TYPE &amp;&amp; (value.targetRef.getOid().equals(leader.getOid()))
                  </code>
               </script>
            </condition>
         </set>
      </target>
   </mapping>
</objectTemplate>
