<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="Examples" id="definitions" xsi:schemaLocation=" http://www.omg.org/spec/BPMN/20100524/MODEL http://local.openicf.forgerock.org/BPMN20.xsd">
<process id="passwordChangeReminder" name="Password Change Reminder Process" isExecutable="true">
<startEvent id="start" activiti:initiator="startUserId"></startEvent>
<sequenceFlow id="sequenceFlow-24b05fd8-3b17-4e76-99bd-76d2753aee6b" sourceRef="start" targetRef="sendFirstNotification"></sequenceFlow>
<scriptTask id="sendFirstNotification" name="Send First Notification" scriptFormat="groovy" activiti:autoStoreVariables="false">
<script>
user = openidm.read(userId)
lastPasswordChange = user.lastPasswordSet
java.text.SimpleDateFormat formatUTC = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
formatUTC.setTimeZone(TimeZone.getTimeZone("UTC"));
requestDate = formatUTC.format(new Date());
def firstNotification = [
"receiverId": user['_id'],
"requesterId" : "",
"requester" : "",
"createDate" : requestDate,
"notificationType" : "info",
"notificationSubtype" : "",
"message" : "Your password will expire soon, change it!"
];
openidm.create("repo/ui/notification", null, firstNotification);
if (new Boolean(emailEnabled)) {
emailParams = [
from : 'usecasetest@forgerock.com',
to : user.mail,
subject : 'Password expiry notification',
type : 'text/plain',
body : 'Your password will expire soon, change it!'
]
openidm.action("external/email", 'sendEmail', emailParams);
}
execution.setVariable("lastPasswordChange", lastPasswordChange);
execution.setVariable("_id", user["_id"]);
execution.setVariable("mail", user["mail"]);
</script>
</scriptTask>
<sequenceFlow id="sequenceFlow-a7e10e64-2d57-4bd7-804e-e053e2f7364c" sourceRef="sendFirstNotification" targetRef="timer1"></sequenceFlow>
<intermediateCatchEvent id="timer1">
<timerEventDefinition>
<timeDuration>PT5M</timeDuration>
</timerEventDefinition>
</intermediateCatchEvent>
<sequenceFlow id="sequenceFlow-04b3c541-dbaf-493b-8eee-0a90c8753f50" sourceRef="timer1" targetRef="checkSecondNotification"></sequenceFlow>
<scriptTask id="checkSecondNotification" name="Check Second Notification" scriptFormat="groovy" activiti:autoStoreVariables="false">
<script>
user = openidm.read(userId)
passwordChanged = (user.lastPasswordSet != lastPasswordChange)
execution.setVariable("passwordChanged", passwordChanged)
</script>
</scriptTask>
<sequenceFlow id="sequenceFlow-1694b093-41ee-4142-aea6-c6049b8aa680" sourceRef="checkSecondNotification" targetRef="secondNotificationGateway"></sequenceFlow>
<exclusiveGateway id="secondNotificationGateway" name="Second Notification"></exclusiveGateway>
<sequenceFlow id="sequenceFlow-e6200d2c-4fb4-4b95-ba3b-ead77e36a989" sourceRef="secondNotificationGateway" targetRef="end">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${passwordChanged}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="sequenceFlow-fb499616-614a-4f77-a86d-438d94814de4" sourceRef="secondNotificationGateway" targetRef="sendSecondNotification">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${!passwordChanged}]]></conditionExpression>
</sequenceFlow>
<scriptTask id="sendSecondNotification" name="Send Second Notification" scriptFormat="groovy" activiti:autoStoreVariables="false">
<script>
java.text.SimpleDateFormat formatUTC = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
formatUTC.setTimeZone(TimeZone.getTimeZone("UTC"));
requestDate = formatUTC.format(new Date());
def secondNotification = [
"receiverId": _id,
"requesterId" : "",
"requester" : "",
"createDate" : requestDate,
"notificationType" : "info",
"notificationSubtype" : "",
"message" : "Your password will expire now, change it!"
];
openidm.create("repo/ui/notification", null, secondNotification)
if (new Boolean(emailEnabled)) {
emailParams = [
from : 'usecasetest@forgerock.com',
to : mail,
subject : 'Password expiry notification',
type : 'text/plain',
body : 'Your password will expire now, change it!'
]
openidm.action("external/email", 'sendEmail', emailParams);
}
</script>
</scriptTask>
<sequenceFlow id="sequenceFlow-6486cedd-3d24-42b9-87e2-5c0311158f23" sourceRef="sendSecondNotification" targetRef="timer2"></sequenceFlow>
<intermediateCatchEvent id="timer2">
<timerEventDefinition>
<timeDuration>PT2M</timeDuration>
</timerEventDefinition>
</intermediateCatchEvent>
<sequenceFlow id="sequenceFlow-0cf4e7a7-dc20-41d2-b9af-d08be4b49450" sourceRef="timer2" targetRef="checkInactivate"></sequenceFlow>
<scriptTask id="checkInactivate" name="Check Inactivation" scriptFormat="groovy" activiti:autoStoreVariables="false">
<script>
user = openidm.read(userId)
passwordChanged = (user.lastPasswordSet != lastPasswordChange)
execution.setVariable("passwordChanged", passwordChanged)
</script>
</scriptTask>
<sequenceFlow id="sequenceFlow-223cbfff-810e-45ba-b749-4b250a5e29df" sourceRef="checkInactivate" targetRef="inactivateGateway"></sequenceFlow>
<exclusiveGateway id="inactivateGateway" name="Inactivation"></exclusiveGateway>
<sequenceFlow id="sequenceFlow-03e0a6d1-bbce-42a1-8149-26d479bb70e5" sourceRef="inactivateGateway" targetRef="end">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${passwordChanged}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="sequenceFlow-4668da20-88cf-4e69-bb6a-8fee4c5f8bd7" sourceRef="inactivateGateway" targetRef="inactivateAccount">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${!passwordChanged}]]></conditionExpression>
</sequenceFlow>
<scriptTask id="inactivateAccount" name="Inactivate Account" scriptFormat="groovy" activiti:autoStoreVariables="false">
<script>
params = [[operation: 'replace', field:'accountStatus',value:'inactive']]
openidm.patch(userId, null, params)
if (new Boolean(emailEnabled)) {
emailParams = [
from : 'usecasetest@forgerock.com',
to : mail,
subject : 'Password expiry notification',
type : 'text/plain',
body : 'Your password is expired, your account has been inactivated. Please contact your administrator!'
]
openidm.action("external/email", 'sendEmail', emailParams);
}
</script>
</scriptTask>
<sequenceFlow id="sequenceFlow-e6c6b0e2-4024-4706-a9a4-3d8039bd0b7c" sourceRef="inactivateAccount" targetRef="end"></sequenceFlow>
<endEvent id="end"></endEvent>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_passwordChangeReminder">
<bpmndi:BPMNPlane bpmnElement="passwordChangeReminder" id="BPMNPlane_passwordChangeReminder">
<bpmndi:BPMNShape bpmnElement="start" id="BPMNShape_start">
<omgdc:Bounds height="35.0" width="35.0" x="0.0" y="111.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sendFirstNotification" id="BPMNShape_sendFirstNotification">
<omgdc:Bounds height="60.0" width="100.0" x="80.0" y="96.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="timer1" id="BPMNShape_timer1">
<omgdc:Bounds height="35.0" width="35.0" x="230.0" y="110.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="checkSecondNotification" id="BPMNShape_checkSecondNotification">
<omgdc:Bounds height="60.0" width="100.0" x="310.0" y="92.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="secondNotificationGateway" id="BPMNShape_secondNotificationGateway">
<omgdc:Bounds height="40.0" width="40.0" x="460.0" y="98.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sendSecondNotification" id="BPMNShape_sendSecondNotification">
<omgdc:Bounds height="60.0" width="100.0" x="550.0" y="150.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="timer2" id="BPMNShape_timer2">
<omgdc:Bounds height="35.0" width="35.0" x="700.0" y="167.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="checkInactivate" id="BPMNShape_checkInactivate">
<omgdc:Bounds height="60.0" width="100.0" x="780.0" y="155.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="inactivateGateway" id="BPMNShape_inactivateGateway">
<omgdc:Bounds height="40.0" width="40.0" x="930.0" y="170.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="inactivateAccount" id="BPMNShape_inactivateAccount">
<omgdc:Bounds height="60.0" width="100.0" x="1020.0" y="100.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end">
<omgdc:Bounds height="35.0" width="35.0" x="1170.0" y="115.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-24b05fd8-3b17-4e76-99bd-76d2753aee6b" id="BPMNEdge_sequenceFlow-24b05fd8-3b17-4e76-99bd-76d2753aee6b">
<omgdi:waypoint x="35.0" y="128.0"></omgdi:waypoint>
<omgdi:waypoint x="80.0" y="126.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-a7e10e64-2d57-4bd7-804e-e053e2f7364c" id="BPMNEdge_sequenceFlow-a7e10e64-2d57-4bd7-804e-e053e2f7364c">
<omgdi:waypoint x="180.0" y="126.0"></omgdi:waypoint>
<omgdi:waypoint x="192.0" y="126.0"></omgdi:waypoint>
<omgdi:waypoint x="192.0" y="125.0"></omgdi:waypoint>
<omgdi:waypoint x="230.0" y="127.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-04b3c541-dbaf-493b-8eee-0a90c8753f50" id="BPMNEdge_sequenceFlow-04b3c541-dbaf-493b-8eee-0a90c8753f50">
<omgdi:waypoint x="265.0" y="127.0"></omgdi:waypoint>
<omgdi:waypoint x="272.0" y="125.0"></omgdi:waypoint>
<omgdi:waypoint x="272.0" y="122.0"></omgdi:waypoint>
<omgdi:waypoint x="310.0" y="122.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-1694b093-41ee-4142-aea6-c6049b8aa680" id="BPMNEdge_sequenceFlow-1694b093-41ee-4142-aea6-c6049b8aa680">
<omgdi:waypoint x="410.0" y="122.0"></omgdi:waypoint>
<omgdi:waypoint x="422.0" y="122.0"></omgdi:waypoint>
<omgdi:waypoint x="422.0" y="118.0"></omgdi:waypoint>
<omgdi:waypoint x="460.0" y="118.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-e6200d2c-4fb4-4b95-ba3b-ead77e36a989" id="BPMNEdge_sequenceFlow-e6200d2c-4fb4-4b95-ba3b-ead77e36a989">
<omgdi:waypoint x="500.0" y="118.0"></omgdi:waypoint>
<omgdi:waypoint x="512.0" y="118.0"></omgdi:waypoint>
<omgdi:waypoint x="512.0" y="130.0"></omgdi:waypoint>
<omgdi:waypoint x="1170.0" y="132.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-fb499616-614a-4f77-a86d-438d94814de4" id="BPMNEdge_sequenceFlow-fb499616-614a-4f77-a86d-438d94814de4">
<omgdi:waypoint x="500.0" y="118.0"></omgdi:waypoint>
<omgdi:waypoint x="512.0" y="118.0"></omgdi:waypoint>
<omgdi:waypoint x="512.0" y="180.0"></omgdi:waypoint>
<omgdi:waypoint x="550.0" y="180.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-6486cedd-3d24-42b9-87e2-5c0311158f23" id="BPMNEdge_sequenceFlow-6486cedd-3d24-42b9-87e2-5c0311158f23">
<omgdi:waypoint x="650.0" y="180.0"></omgdi:waypoint>
<omgdi:waypoint x="662.0" y="180.0"></omgdi:waypoint>
<omgdi:waypoint x="662.0" y="182.0"></omgdi:waypoint>
<omgdi:waypoint x="700.0" y="184.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-0cf4e7a7-dc20-41d2-b9af-d08be4b49450" id="BPMNEdge_sequenceFlow-0cf4e7a7-dc20-41d2-b9af-d08be4b49450">
<omgdi:waypoint x="735.0" y="184.0"></omgdi:waypoint>
<omgdi:waypoint x="742.0" y="182.0"></omgdi:waypoint>
<omgdi:waypoint x="742.0" y="185.0"></omgdi:waypoint>
<omgdi:waypoint x="780.0" y="185.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-223cbfff-810e-45ba-b749-4b250a5e29df" id="BPMNEdge_sequenceFlow-223cbfff-810e-45ba-b749-4b250a5e29df">
<omgdi:waypoint x="880.0" y="185.0"></omgdi:waypoint>
<omgdi:waypoint x="892.0" y="185.0"></omgdi:waypoint>
<omgdi:waypoint x="892.0" y="190.0"></omgdi:waypoint>
<omgdi:waypoint x="930.0" y="190.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-03e0a6d1-bbce-42a1-8149-26d479bb70e5" id="BPMNEdge_sequenceFlow-03e0a6d1-bbce-42a1-8149-26d479bb70e5">
<omgdi:waypoint x="970.0" y="190.0"></omgdi:waypoint>
<omgdi:waypoint x="982.0" y="190.0"></omgdi:waypoint>
<omgdi:waypoint x="982.0" y="130.0"></omgdi:waypoint>
<omgdi:waypoint x="1170.0" y="132.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-4668da20-88cf-4e69-bb6a-8fee4c5f8bd7" id="BPMNEdge_sequenceFlow-4668da20-88cf-4e69-bb6a-8fee4c5f8bd7">
<omgdi:waypoint x="970.0" y="190.0"></omgdi:waypoint>
<omgdi:waypoint x="982.0" y="190.0"></omgdi:waypoint>
<omgdi:waypoint x="982.0" y="130.0"></omgdi:waypoint>
<omgdi:waypoint x="1020.0" y="130.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-e6c6b0e2-4024-4706-a9a4-3d8039bd0b7c" id="BPMNEdge_sequenceFlow-e6c6b0e2-4024-4706-a9a4-3d8039bd0b7c">
<omgdi:waypoint x="1120.0" y="130.0"></omgdi:waypoint>
<omgdi:waypoint x="1170.0" y="132.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>