mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged 5.2.N-AUDIT-API (5.2.2) to 5.2.N (5.2.2)
137875 anechifor: REPO-1784 - Retrieve Audit Applications Implementation subtask - REPO-2580 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@137958 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
package org.alfresco.rest.api;
|
||||
|
||||
import org.alfresco.rest.api.model.AuditApp;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
|
||||
/**
|
||||
@@ -47,10 +49,10 @@ public interface Audit
|
||||
/**
|
||||
* Lists audit applications
|
||||
*
|
||||
* @param parameters
|
||||
* @param paging
|
||||
* @return Collection of audit apps
|
||||
*/
|
||||
//CollectionWithPagingInfo<AuditApp> listAuditApps(Parameters parameters);
|
||||
CollectionWithPagingInfo<AuditApp> getAuditApps(Paging paging);
|
||||
|
||||
/**
|
||||
* Updates a single audit application by id
|
||||
@@ -60,7 +62,8 @@ public interface Audit
|
||||
* @param parameters
|
||||
* @return an audit entry
|
||||
*/
|
||||
//AuditApp update(String auditAppId, AuditApp auditApp, Parameters parameters);
|
||||
// AuditApp update(String auditAppId, AuditApp auditApp, Parameters
|
||||
// parameters);
|
||||
|
||||
/**
|
||||
* Gets a single audit entry by id
|
||||
@@ -69,22 +72,25 @@ public interface Audit
|
||||
* @param parameters
|
||||
* @return an audit entry
|
||||
*/
|
||||
//AuditEntry getAuditEntry(long auditEntryId, Parameters parameters);
|
||||
// AuditEntry getAuditEntry(long auditEntryId, Parameters parameters);
|
||||
|
||||
/**
|
||||
* Lists audit entries
|
||||
*
|
||||
* @param auditAppId if null then across all audit apps
|
||||
* @param auditAppId
|
||||
* if null then across all audit apps
|
||||
* @param parameters
|
||||
* @return Collection of audit entries
|
||||
*/
|
||||
//CollectionWithPagingInfo<AuditEntry> listAuditEntries(String auditAppId, Parameters parameters);
|
||||
// CollectionWithPagingInfo<AuditEntry> listAuditEntries(String auditAppId,
|
||||
// Parameters parameters);
|
||||
|
||||
/**
|
||||
* Deletes a set of audit entries
|
||||
*
|
||||
* @param set of auditEntryIds
|
||||
* @param set
|
||||
* of auditEntryIds
|
||||
* @return
|
||||
*/
|
||||
//void deleteAuditEntries(List<Long> auditEntryIds);
|
||||
// void deleteAuditEntries(List<Long> auditEntryIds);
|
||||
}
|
||||
|
@@ -26,7 +26,6 @@
|
||||
|
||||
package org.alfresco.rest.api.audit;
|
||||
|
||||
|
||||
import org.alfresco.rest.api.Audit;
|
||||
import org.alfresco.rest.api.model.AuditApp;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
@@ -43,9 +42,9 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
*
|
||||
* @author janv
|
||||
*/
|
||||
@EntityResource(name="audit-applications", title = "Audit Applications")
|
||||
public class AuditApplicationsEntityResource implements EntityResourceAction.ReadById<AuditApp>,
|
||||
EntityResourceAction.Read<AuditApp>, EntityResourceAction.Update<AuditApp>, InitializingBean
|
||||
@EntityResource(name = "audit-applications", title = "Audit Applications")
|
||||
public class AuditApplicationsEntityResource implements EntityResourceAction.ReadById<AuditApp>, EntityResourceAction.Read<AuditApp>,
|
||||
EntityResourceAction.Update<AuditApp>, InitializingBean
|
||||
{
|
||||
private Audit audit;
|
||||
|
||||
@@ -61,25 +60,24 @@ public class AuditApplicationsEntityResource implements EntityResourceAction.Rea
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title="", description="")
|
||||
@WebApiDescription(title = "Returns audit application for audit app id")
|
||||
public AuditApp readById(String auditAppId, Parameters parameters) throws EntityNotFoundException
|
||||
{
|
||||
return audit.getAuditApp(auditAppId, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Update group", description = "Update group")
|
||||
@WebApiDescription(title = "Update audit", description = "Update audit")
|
||||
public AuditApp update(String auditAppId, AuditApp auditApp, Parameters parameters)
|
||||
{
|
||||
//return audit.update(auditAppId, auditApp, parameters);
|
||||
// return audit.update(auditAppId, auditApp, parameters);
|
||||
return null; // TODO fixme
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title="", description="")
|
||||
public CollectionWithPagingInfo<AuditApp> readAll(Parameters params)
|
||||
@WebApiDescription(title = "Get List of audit applications", description = "Get List of Audit Applications")
|
||||
public CollectionWithPagingInfo<AuditApp> readAll(Parameters parameters)
|
||||
{
|
||||
//return audit.listAuditApps(params);
|
||||
return null; // TODO fixme
|
||||
return audit.getAuditApps(parameters.getPaging());
|
||||
}
|
||||
}
|
||||
|
@@ -25,14 +25,23 @@
|
||||
*/
|
||||
package org.alfresco.rest.api.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.alfresco.rest.api.Audit;
|
||||
import org.alfresco.rest.api.model.AuditApp;
|
||||
import org.alfresco.rest.framework.core.exceptions.DisabledServiceException;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.service.cmr.audit.AuditService;
|
||||
|
||||
import java.util.Map;
|
||||
import org.alfresco.service.cmr.audit.AuditService.AuditApplication;
|
||||
|
||||
/**
|
||||
* Handles audit (applications & entries)
|
||||
@@ -52,7 +61,7 @@ public class AuditImpl implements Audit
|
||||
|
||||
private void checkEnabled()
|
||||
{
|
||||
if (! auditService.isAuditEnabled())
|
||||
if (!auditService.isAuditEnabled())
|
||||
{
|
||||
throw new DisabledServiceException(DISABLED);
|
||||
}
|
||||
@@ -89,4 +98,46 @@ public class AuditImpl implements Audit
|
||||
}
|
||||
return auditApp;
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user