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());
}
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);
}
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());
}
Aggregations