Search in sources :

Example 1 with AuditApp

use of org.alfresco.rest.api.model.AuditApp in project alfresco-remote-api by Alfresco.

the class AuditImpl method update.

@Override
public AuditApp update(String auditAppId, AuditApp auditApp, Parameters parameters) {
    checkEnabled();
    AuditService.AuditApplication auditApplication = findAuditAppByIdOr404(auditAppId);
    // Enable/Disable audit application
    if (auditApp.getIsEnabled() && !auditApplication.isEnabled()) {
        auditService.enableAudit(auditApplication.getName(), null);
    } else if (!auditApp.getIsEnabled() && auditApplication.isEnabled()) {
        auditService.disableAudit(auditApplication.getName(), null);
    }
    return new AuditApp(auditApplication.getKey().substring(1), auditApplication.getName(), auditApp.getIsEnabled());
}
Also used : AuditApplication(org.alfresco.service.cmr.audit.AuditService.AuditApplication) AuditApp(org.alfresco.rest.api.model.AuditApp) AuditService(org.alfresco.service.cmr.audit.AuditService)

Example 2 with AuditApp

use of org.alfresco.rest.api.model.AuditApp in project alfresco-remote-api by Alfresco.

the class AuditImpl method getAuditApps.

@Override
public CollectionWithPagingInfo<AuditApp> getAuditApps(Paging paging) {
    checkEnabled();
    Map<String, AuditService.AuditApplication> auditApplicationsByName = auditService.getAuditApplications();
    Set<String> audAppsName = new TreeSet<String>(auditApplicationsByName.keySet());
    Iterator<String> audAppsNameIt = audAppsName.iterator();
    int skipCount = paging.getSkipCount();
    int maxItems = paging.getMaxItems();
    int totalItems = audAppsName.size();
    int end = skipCount + maxItems;
    if (skipCount >= totalItems) {
        List<AuditApp> empty = Collections.emptyList();
        return CollectionWithPagingInfo.asPaged(paging, empty, false, totalItems);
    }
    List<AuditApp> auditApps = new ArrayList<AuditApp>(totalItems);
    int count = 0;
    for (int i = 0; i < end && audAppsNameIt.hasNext(); i++) {
        String auditAppName = audAppsNameIt.next();
        if (i < skipCount) {
            continue;
        }
        count++;
        AuditApplication auditApplication = auditApplicationsByName.get(auditAppName);
        auditApps.add(new AuditApp(auditApplication.getKey().substring(1), auditApplication.getName(), auditApplication.isEnabled()));
    }
    boolean hasMoreItems = (skipCount + count < totalItems);
    return CollectionWithPagingInfo.asPaged(paging, auditApps, hasMoreItems, totalItems);
}
Also used : AuditApp(org.alfresco.rest.api.model.AuditApp) TreeSet(java.util.TreeSet) AuditApplication(org.alfresco.service.cmr.audit.AuditService.AuditApplication) ArrayList(java.util.ArrayList)

Example 3 with AuditApp

use of org.alfresco.rest.api.model.AuditApp in project alfresco-remote-api by Alfresco.

the class AuditImpl method getAuditApp.

@Override
public AuditApp getAuditApp(String auditAppId, Parameters parameters) {
    checkEnabled();
    AuditService.AuditApplication auditApplication = findAuditAppByIdOr404(auditAppId);
    return new AuditApp(auditApplication.getKey().substring(1), auditApplication.getName(), auditApplication.isEnabled());
}
Also used : AuditApplication(org.alfresco.service.cmr.audit.AuditService.AuditApplication) AuditApp(org.alfresco.rest.api.model.AuditApp) AuditService(org.alfresco.service.cmr.audit.AuditService)

Aggregations

AuditApp (org.alfresco.rest.api.model.AuditApp)3 AuditApplication (org.alfresco.service.cmr.audit.AuditService.AuditApplication)3 AuditService (org.alfresco.service.cmr.audit.AuditService)2 ArrayList (java.util.ArrayList)1 TreeSet (java.util.TreeSet)1