// Path: spring-data-jpa-auditing/src/main/java/org/programming/mitra/Action.java
// public enum Action {
// 
//     INSERTED("INSERTED"),
//     UPDATED("UPDATED"),
//     DELETED("DELETED");
// 
//     private final String name;
// 
//     private Action(String value) {
//         this.name = value;
//     }
// 
//     public String value() {
//         return this.name;
//     }
// 
//     @Override
//     public String toString() {
//         return name;
//     }
// }


import javax.persistence.EntityManager;
import javax.persistence.PrePersist;
import javax.persistence.PreRemove;
import javax.persistence.PreUpdate;
import javax.transaction.Transactional;
import static javax.transaction.Transactional.TxType.MANDATORY;
import static org.programming.mitra.Action.*;
package org.programming.mitra;



/**
 * @author Naresh Joshi
 */

public class FileEntityListener {

    @PrePersist
    public void prePersist(File target) {
        perform(target, INSERTED);
    }

    @PreUpdate
    public void preUpdate(File target) {
        perform(target, UPDATED);
    }

    @PreRemove
    public void preRemove(File target) {
        perform(target, DELETED);
    }

    @Transactional(MANDATORY)
// Path: spring-data-jpa-auditing/src/main/java/org/programming/mitra/Action.java
// public enum Action {
// 
//     INSERTED("INSERTED"),
//     UPDATED("UPDATED"),
//     DELETED("DELETED");
// 
//     private final String name;
// 
//     private Action(String value) {
//         this.name = value;
//     }
// 
//     public String value() {
//         return this.name;
//     }
// 
//     @Override
//     public String toString() {
//         return name;
//     }
// }


// Path: spring-data-jpa-auditing/src/main/java/org/programming/mitra/FileEntityListener.java
import javax.persistence.EntityManager;
import javax.persistence.PrePersist;
import javax.persistence.PreRemove;
import javax.persistence.PreUpdate;
import javax.transaction.Transactional;
import static javax.transaction.Transactional.TxType.MANDATORY;
import static org.programming.mitra.Action.*;

package org.programming.mitra;



/**
 * @author Naresh Joshi
 */

public class FileEntityListener {

    @PrePersist
    public void prePersist(File target) {
        perform(target, INSERTED);
    }

    @PreUpdate
    public void preUpdate(File target) {
        perform(target, UPDATED);
    }

    @PreRemove
    public void preRemove(File target) {
        perform(target, DELETED);
    }

    @Transactional(MANDATORY)
    private void perform(File target, Action action) {