// Path: src/main/java/org/lightadmin/jhipster/security/AuthoritiesConstants.java
// public final class AuthoritiesConstants {
// 
//     private AuthoritiesConstants() {
//     }
// 
//     public static final String ADMIN = "ROLE_ADMIN";
// 
//     public static final String USER = "ROLE_USER";
// 
//     public static final String ANONYMOUS = "ROLE_ANONYMOUS";
// }
// 
// Path: src/main/java/org/lightadmin/jhipster/service/AuditEventService.java
// @Service
// @Transactional
// public class AuditEventService {
// 
//     @Inject
//     private PersistenceAuditEventRepository persistenceAuditEventRepository;
// 
//     @Inject
//     private AuditEventConverter auditEventConverter;
// 
//     public List<AuditEvent> findAll() {
//         return auditEventConverter.convertToAuditEvent(persistenceAuditEventRepository.findAll());
//     }
// 
//     public List<AuditEvent> findByDates(LocalDateTime fromDate, LocalDateTime toDate) {
//         final List<PersistentAuditEvent> persistentAuditEvents =
//                 persistenceAuditEventRepository.findByDates(fromDate, toDate);
// 
//         return auditEventConverter.convertToAuditEvent(persistentAuditEvents);
//     }
// }
// 
// Path: src/main/java/org/lightadmin/jhipster/web/propertyeditors/LocaleDateTimeEditor.java
// public class LocaleDateTimeEditor extends PropertyEditorSupport {
// 
//     private final DateTimeFormatter formatter;
// 
//     private final boolean allowEmpty;
// 
//     /**
//      * Create a new LocaleDateTimeEditor instance, using the given format for
//      * parsing and rendering.
//      * <p/>
//      * The "allowEmpty" parameter states if an empty String should be allowed
//      * for parsing, i.e. get interpreted as null value. Otherwise, an
//      * IllegalArgumentException gets thrown.
//      *
//      * @param dateFormat DateFormat to use for parsing and rendering
//      * @param allowEmpty if empty strings should be allowed
//      */
//     public LocaleDateTimeEditor(String dateFormat, boolean allowEmpty) {
//         this.formatter = DateTimeFormat.forPattern(dateFormat);
//         this.allowEmpty = allowEmpty;
//     }
// 
//     /**
//      * Format the YearMonthDay as String, using the specified format.
//      *
//      * @return DateTime formatted string
//      */
//     public String getAsText() {
//         Date value = (Date) getValue();
//         return value != null ? new LocalDateTime(value).toString(formatter) : "";
//     }
// 
//     /**
//      * Parse the value from the given text, using the specified format.
//      *
//      * @param text the text to format
//      * @throws IllegalArgumentException
//      */
//     public void setAsText( String text ) throws IllegalArgumentException {
//         if ( allowEmpty && !StringUtils.hasText(text) ) {
//             // Treat empty String as null value.
//             setValue(null);
//         } else {
//             setValue(new LocalDateTime(formatter.parseDateTime(text)));
//         }
//     }
// }


import org.lightadmin.jhipster.security.AuthoritiesConstants;
import org.lightadmin.jhipster.service.AuditEventService;
import org.lightadmin.jhipster.web.propertyeditors.LocaleDateTimeEditor;
import org.joda.time.LocalDateTime;
import org.springframework.boot.actuate.audit.AuditEvent;
import org.springframework.http.MediaType;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.annotation.security.RolesAllowed;
import javax.inject.Inject;
import java.util.List;
package org.lightadmin.jhipster.web.rest;



/**
 * REST controller for getting the audit events.
 */
@RestController
@RequestMapping("/app")
public class AuditResource {

    @Inject
    private AuditEventService auditEventService;

    @InitBinder
    public void initBinder(WebDataBinder binder) {
        binder.registerCustomEditor(LocalDateTime.class, new LocaleDateTimeEditor("yyyy-MM-dd", false));
    }

    @RequestMapping(value = "/rest/audits/all",
            method = RequestMethod.GET,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @RolesAllowed(AuthoritiesConstants.ADMIN)
    public List<AuditEvent> findAll() {
        return auditEventService.findAll();
    }

// Path: src/main/java/org/lightadmin/jhipster/security/AuthoritiesConstants.java
// public final class AuthoritiesConstants {
// 
//     private AuthoritiesConstants() {
//     }
// 
//     public static final String ADMIN = "ROLE_ADMIN";
// 
//     public static final String USER = "ROLE_USER";
// 
//     public static final String ANONYMOUS = "ROLE_ANONYMOUS";
// }
// 
// Path: src/main/java/org/lightadmin/jhipster/service/AuditEventService.java
// @Service
// @Transactional
// public class AuditEventService {
// 
//     @Inject
//     private PersistenceAuditEventRepository persistenceAuditEventRepository;
// 
//     @Inject
//     private AuditEventConverter auditEventConverter;
// 
//     public List<AuditEvent> findAll() {
//         return auditEventConverter.convertToAuditEvent(persistenceAuditEventRepository.findAll());
//     }
// 
//     public List<AuditEvent> findByDates(LocalDateTime fromDate, LocalDateTime toDate) {
//         final List<PersistentAuditEvent> persistentAuditEvents =
//                 persistenceAuditEventRepository.findByDates(fromDate, toDate);
// 
//         return auditEventConverter.convertToAuditEvent(persistentAuditEvents);
//     }
// }
// 
// Path: src/main/java/org/lightadmin/jhipster/web/propertyeditors/LocaleDateTimeEditor.java
// public class LocaleDateTimeEditor extends PropertyEditorSupport {
// 
//     private final DateTimeFormatter formatter;
// 
//     private final boolean allowEmpty;
// 
//     /**
//      * Create a new LocaleDateTimeEditor instance, using the given format for
//      * parsing and rendering.
//      * <p/>
//      * The "allowEmpty" parameter states if an empty String should be allowed
//      * for parsing, i.e. get interpreted as null value. Otherwise, an
//      * IllegalArgumentException gets thrown.
//      *
//      * @param dateFormat DateFormat to use for parsing and rendering
//      * @param allowEmpty if empty strings should be allowed
//      */
//     public LocaleDateTimeEditor(String dateFormat, boolean allowEmpty) {
//         this.formatter = DateTimeFormat.forPattern(dateFormat);
//         this.allowEmpty = allowEmpty;
//     }
// 
//     /**
//      * Format the YearMonthDay as String, using the specified format.
//      *
//      * @return DateTime formatted string
//      */
//     public String getAsText() {
//         Date value = (Date) getValue();
//         return value != null ? new LocalDateTime(value).toString(formatter) : "";
//     }
// 
//     /**
//      * Parse the value from the given text, using the specified format.
//      *
//      * @param text the text to format
//      * @throws IllegalArgumentException
//      */
//     public void setAsText( String text ) throws IllegalArgumentException {
//         if ( allowEmpty && !StringUtils.hasText(text) ) {
//             // Treat empty String as null value.
//             setValue(null);
//         } else {
//             setValue(new LocalDateTime(formatter.parseDateTime(text)));
//         }
//     }
// }


// Path: src/main/java/org/lightadmin/jhipster/web/rest/AuditResource.java
import org.lightadmin.jhipster.security.AuthoritiesConstants;
import org.lightadmin.jhipster.service.AuditEventService;
import org.lightadmin.jhipster.web.propertyeditors.LocaleDateTimeEditor;
import org.joda.time.LocalDateTime;
import org.springframework.boot.actuate.audit.AuditEvent;
import org.springframework.http.MediaType;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.annotation.security.RolesAllowed;
import javax.inject.Inject;
import java.util.List;

package org.lightadmin.jhipster.web.rest;



/**
 * REST controller for getting the audit events.
 */
@RestController
@RequestMapping("/app")
public class AuditResource {

    @Inject
    private AuditEventService auditEventService;

    @InitBinder
    public void initBinder(WebDataBinder binder) {
        binder.registerCustomEditor(LocalDateTime.class, new LocaleDateTimeEditor("yyyy-MM-dd", false));
    }

    @RequestMapping(value = "/rest/audits/all",
            method = RequestMethod.GET,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @RolesAllowed(AuthoritiesConstants.ADMIN)
    public List<AuditEvent> findAll() {
        return auditEventService.findAll();
    }

    @RequestMapping(value = "/rest/audits/byDates",