Skip to content

Commit

Permalink
recordDecision: reviewerRef and timestamp are filled in if missing.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed May 21, 2015
1 parent df98c3c commit b4f4a01
Showing 1 changed file with 9 additions and 2 deletions.
Expand Up @@ -64,6 +64,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
Expand Down Expand Up @@ -465,8 +466,6 @@ public void recordDecision(String campaignOid, long caseId, AccessCertificationD

Validate.notNull(campaignOid, "campaignOid");
Validate.notNull(decision, "decision");
Validate.notNull(decision.getReviewerRef(), "decision.reviewerRef");
Validate.notNull(decision.getReviewerRef().getOid(), "decision.reviewerRef.oid");

OperationResult result = parentResult.createSubresult(OPERATION_RECORD_DECISION);
try {
Expand All @@ -491,6 +490,14 @@ public void recordDecision(String campaignOid, long caseId, AccessCertificationD
}
}
AccessCertificationDecisionType decisionWithCorrectId = decision.clone();

if (decisionWithCorrectId.getTimestamp() == null) {
decisionWithCorrectId.setTimestamp(XmlTypeConverter.createXMLGregorianCalendar(new Date()));
}
if (decisionWithCorrectId.getReviewerRef() == null) {
UserType currentUser = securityEnforcer.getPrincipal().getUser();
decisionWithCorrectId.setReviewerRef(ObjectTypeUtil.createObjectRef(currentUser));
}
if (decisionWithCorrectId.getStageNumber() == 0) {
decisionWithCorrectId.setStageNumber(currentStage);
}
Expand Down

0 comments on commit b4f4a01

Please sign in to comment.