Skip to content

Commit

Permalink
MID-4583 audit target owner type changed to FocusType. added one column
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Apr 13, 2018
1 parent fd65832 commit 215ab2d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
Expand Up @@ -37,10 +37,7 @@
import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordPropertyType;
import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType;
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.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType;
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;
Expand Down Expand Up @@ -112,7 +109,7 @@ public class AuditEventRecord implements DebugDumpable {
private PrismReferenceValue target;

// user that the target "belongs to"????: store OID, name
private PrismObject<UserType> targetOwner;
private PrismObject<FocusType> targetOwner;

// event type
private AuditEventType eventType;
Expand Down Expand Up @@ -269,11 +266,11 @@ public void setTarget(PrismObject<?> targetObject) {
}
}

public PrismObject<UserType> getTargetOwner() {
public PrismObject<FocusType> getTargetOwner() {
return targetOwner;
}

public void setTargetOwner(PrismObject<UserType> targetOwner) {
public void setTargetOwner(PrismObject<FocusType> targetOwner) {
this.targetOwner = targetOwner;
}

Expand Down
Expand Up @@ -141,8 +141,6 @@ private AuditEventRecord getAuditEventRecord(int expectedCount, int index) {
AuditEventRecord eventRecord = RAuditEventRecord.fromRepo(records.get(index), prismContext);
session.getTransaction().commit();
return eventRecord;
} catch (DtoTranslationException e) {
throw new SystemException(e);
} finally {
session.close();
}
Expand Down
Expand Up @@ -236,7 +236,7 @@ private void listRecordsIterativeAttempt(String query, Map<String, Object> param
audit.setInitiator(resolve(session, raudit.getInitiatorOid(), raudit.getInitiatorName(), defaultIfNull(raudit.getInitiatorType(), RObjectType.USER)));
audit.setAttorney(resolve(session, raudit.getAttorneyOid(), raudit.getAttorneyName(), RObjectType.USER));
audit.setTarget(resolve(session, raudit.getTargetOid(), raudit.getTargetName(), raudit.getTargetType()));
audit.setTargetOwner(resolve(session, raudit.getTargetOwnerOid(), raudit.getTargetOwnerName(), RObjectType.USER));
audit.setTargetOwner(resolve(session, raudit.getTargetOwnerOid(), raudit.getTargetOwnerName(), raudit.getTargetOwnerType()));
count++;
if (!handler.handle(audit)) {
LOGGER.trace("Skipping handling of objects after {} was handled. ", audit);
Expand Down
Expand Up @@ -95,9 +95,10 @@ public class RAuditEventRecord implements Serializable {
private String targetOid;
private String targetName;
private RObjectType targetType;
// prism object - user
// prism object
private String targetOwnerOid;
private String targetOwnerName;
private RObjectType targetOwnerType;

private RAuditEventType eventType;
private RAuditEventStage eventStage;
Expand Down Expand Up @@ -271,6 +272,15 @@ public Timestamp getTimestamp() {
return timestamp;
}

@Enumerated(EnumType.ORDINAL)
public RObjectType getTargetOwnerType() {
return targetOwnerType;
}

public void setTargetOwnerType(RObjectType targetOwnerType) {
this.targetOwnerType = targetOwnerType;
}

public void setMessage(String message) {
this.message = message;
}
Expand Down Expand Up @@ -417,6 +427,7 @@ public boolean equals(Object o) {
targetType == that.targetType &&
Objects.equals(targetOwnerOid, that.targetOwnerOid) &&
Objects.equals(targetOwnerName, that.targetOwnerName) &&
Objects.equals(targetOwnerType, that.targetOwnerType) &&
eventType == that.eventType &&
eventStage == that.eventStage &&
Objects.equals(deltas, that.deltas) &&
Expand All @@ -436,7 +447,7 @@ public int hashCode() {
.hash(id, timestamp, eventIdentifier, sessionIdentifier, taskIdentifier, taskOID, hostIdentifier,
remoteHostAddress, nodeIdentifier, initiatorOid, initiatorName, initiatorType,
attorneyOid, attorneyName, targetOid, targetName, targetType, targetOwnerOid,
targetOwnerName, eventType, eventStage, deltas, channel, outcome, parameter, message,
targetOwnerName, targetOwnerType, eventType, eventStage, deltas, channel, outcome, parameter, message,
changedItems, propertyValues, referenceValues, result);
}

Expand Down Expand Up @@ -485,6 +496,7 @@ public static RAuditEventRecord toRepo(AuditEventRecord record, PrismContext pri
PrismObject targetOwner = record.getTargetOwner();
repo.setTargetOwnerName(getOrigName(targetOwner));
repo.setTargetOwnerOid(targetOwner.getOid());
repo.setTargetOwnerType(ClassMapper.getHQLTypeForClass(targetOwner.getCompileTimeClass()));
}
if (record.getInitiator() != null) {
PrismObject<? extends ObjectType> initiator = record.getInitiator();
Expand Down Expand Up @@ -544,8 +556,7 @@ public static RAuditEventRecord toRepo(AuditEventRecord record, PrismContext pri
return repo;
}

public static AuditEventRecord fromRepo(RAuditEventRecord repo, PrismContext prismContext)
throws DtoTranslationException {
public static AuditEventRecord fromRepo(RAuditEventRecord repo, PrismContext prismContext) {

AuditEventRecord audit = new AuditEventRecord();
audit.setChannel(repo.getChannel());
Expand Down

0 comments on commit 215ab2d

Please sign in to comment.