[New] Implemented StrolchTransaction.setSuppressAuditsForAudits()
This commit is contained in:
parent
4789264975
commit
5cdffcc450
|
@ -85,6 +85,7 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
private TransactionCloseStrategy closeStrategy;
|
private TransactionCloseStrategy closeStrategy;
|
||||||
private boolean suppressUpdates;
|
private boolean suppressUpdates;
|
||||||
private boolean suppressAudits;
|
private boolean suppressAudits;
|
||||||
|
private boolean suppressAuditsForAudits;
|
||||||
private boolean suppressDoNothingLogging;
|
private boolean suppressDoNothingLogging;
|
||||||
private TransactionResult txResult;
|
private TransactionResult txResult;
|
||||||
|
|
||||||
|
@ -224,11 +225,21 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
this.suppressAudits = suppressAudits;
|
this.suppressAudits = suppressAudits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSuppressAuditsForAudits(boolean suppressAuditsForAudits) {
|
||||||
|
this.suppressAuditsForAudits = suppressAuditsForAudits;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSuppressAudits() {
|
public boolean isSuppressAudits() {
|
||||||
return this.suppressAudits;
|
return this.suppressAudits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSuppressAuditsForAudits() {
|
||||||
|
return this.suppressAuditsForAudits;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSuppressDoNothingLogging() {
|
public boolean isSuppressDoNothingLogging() {
|
||||||
return suppressDoNothingLogging;
|
return suppressDoNothingLogging;
|
||||||
|
@ -889,7 +900,7 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
|
|
||||||
List<Audit> audits = new ArrayList<>();
|
List<Audit> audits = new ArrayList<>();
|
||||||
|
|
||||||
// this is bad... doesn't account for a created and deleted in same TX...
|
// TODO this is bad... doesn't account for a created and deleted in same TX...
|
||||||
|
|
||||||
if (this.orderMap != null) {
|
if (this.orderMap != null) {
|
||||||
if (this.realm.isAuditTrailEnabledForRead())
|
if (this.realm.isAuditTrailEnabledForRead())
|
||||||
|
@ -907,7 +918,7 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
auditsFor(audits, AccessType.DELETE, Tags.RESOURCE, this.resourceMap.getDeleted());
|
auditsFor(audits, AccessType.DELETE, Tags.RESOURCE, this.resourceMap.getDeleted());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.auditTrail != null) {
|
if (this.auditTrail != null && !isSuppressAuditsForAudits()) {
|
||||||
if (this.realm.isAuditTrailEnabledForRead())
|
if (this.realm.isAuditTrailEnabledForRead())
|
||||||
auditsForAudits(audits, AccessType.READ, Tags.AUDIT, this.auditTrail.getRead());
|
auditsForAudits(audits, AccessType.READ, Tags.AUDIT, this.auditTrail.getRead());
|
||||||
auditsForAudits(audits, AccessType.CREATE, Tags.AUDIT, this.auditTrail.getCreated());
|
auditsForAudits(audits, AccessType.CREATE, Tags.AUDIT, this.auditTrail.getCreated());
|
||||||
|
@ -915,7 +926,9 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
auditsForAudits(audits, AccessType.DELETE, Tags.AUDIT, this.auditTrail.getDeleted());
|
auditsForAudits(audits, AccessType.DELETE, Tags.AUDIT, this.auditTrail.getDeleted());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!audits.isEmpty())
|
||||||
this.realm.getAuditTrail().addAll(this, audits);
|
this.realm.getAuditTrail().addAll(this, audits);
|
||||||
|
|
||||||
long auditTrailDuration = System.nanoTime() - auditTrailStart;
|
long auditTrailDuration = System.nanoTime() - auditTrailStart;
|
||||||
return auditTrailDuration;
|
return auditTrailDuration;
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,6 +287,16 @@ public interface StrolchTransaction extends AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public void setSuppressAudits(boolean suppressAudits);
|
public void setSuppressAudits(boolean suppressAudits);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the given argument is true, then no {@link Audit Audits} for Audits are written. Since the {@link AuditTrail}
|
||||||
|
* is also audited, {@link Audit Audits} for Audits are generated, this allows to suppress this should that be
|
||||||
|
* required.
|
||||||
|
*
|
||||||
|
* @param suppressAuditsForAudits
|
||||||
|
* true to suppress writing {@link Audit Audits}, false to enable them
|
||||||
|
*/
|
||||||
|
public void setSuppressAuditsForAudits(boolean suppressAuditsForAudits);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if writing {@link Audit Audits} is currently suppressed
|
* Returns true if writing {@link Audit Audits} is currently suppressed
|
||||||
*
|
*
|
||||||
|
@ -294,6 +304,13 @@ public interface StrolchTransaction extends AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public boolean isSuppressAudits();
|
public boolean isSuppressAudits();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if writing {@link Audit Audits} for Audits is currently suppressed
|
||||||
|
*
|
||||||
|
* @return true if writing {@link Audit Audits} for Audits is currently suppressed
|
||||||
|
*/
|
||||||
|
public boolean isSuppressAuditsForAudits();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the given argument is true, then logging of a {@link TransactionCloseStrategy#DO_NOTHING} will be suppressed
|
* If the given argument is true, then logging of a {@link TransactionCloseStrategy#DO_NOTHING} will be suppressed
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package li.strolch.service.privilege.roles;
|
||||||
|
|
||||||
|
import li.strolch.agent.api.ComponentContainer;
|
||||||
|
import li.strolch.persistence.api.StrolchTransaction;
|
||||||
|
import li.strolch.service.api.Command;
|
||||||
|
|
||||||
|
public class PrivilageAddOrReplacePrivilegeOnRoleCommand extends Command {
|
||||||
|
|
||||||
|
public PrivilageAddOrReplacePrivilegeOnRoleCommand(ComponentContainer container, StrolchTransaction tx) {
|
||||||
|
super(container, tx);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doCommand() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue