Listing all the audit applications uses the listAuditApps method of the AuditApi.
For more information about this ReST API endpoint, see List Audit Applications.
For a description of the common parameters, such as fields, see Common Parameters.
import org.alfresco.core.handler.AuditApi; import org.alfresco.core.model.AuditAppEntry; import org.alfresco.core.model.AuditAppPaging; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.io.IOException; import java.util.List; @Component public class ListAuditAppsCmd { static final Logger LOGGER = LoggerFactory.getLogger(ListAuditAppsCmd.class); @Autowired AuditApi auditApi; public void execute() throws IOException { Integer skipCount = 0; Integer maxItems = 100; List<String> fields = null; LOGGER.info("Listing active audit applications in the repository:"); AuditAppPaging auditApps = auditApi.listAuditApps(skipCount, maxItems, fields).getBody(); for (AuditAppEntry auditAppEntry: auditApps.getList().getEntries()) { LOGGER.info(" {}", auditAppEntry); } } }
Executing this code will list the audit applications that have been activated, if you have enabled auditing and activated the alfresco-access audit application, then you will see the following listing of audit apps:
% java -jar target/rest-api-0.0.1-SNAPSHOT.jar list-audit-apps 2021-05-07 12:48:12.434 INFO 36995 --- [ main] o.a.tutorial.restapi.RestApiApplication : Started RestApiApplication in 3.525 seconds (JVM running for 4.089) 2021-05-07 12:48:12.436 INFO 36995 --- [ main] o.a.tutorial.restapi.RestApiApplication : args[0]: list-audit-apps 2021-05-07 12:48:12.437 INFO 36995 --- [ main] o.a.tutorial.restapi.ListAuditAppsCmd : Listing active audit applications in the repository: 2021-05-07 12:48:12.912 INFO 36995 --- [ main] o.a.tutorial.restapi.ListAuditAppsCmd : class AuditAppEntry { entry: class AuditApp { id: tagging name: Alfresco Tagging Service isEnabled: true maxEntryId: null minEntryId: null } } 2021-05-07 12:48:12.913 INFO 36995 --- [ main] o.a.tutorial.restapi.ListAuditAppsCmd : class AuditAppEntry { entry: class AuditApp { id: alfresco-access name: alfresco-access isEnabled: true maxEntryId: null minEntryId: null } }