mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merge 7.0.0-A8 changes to new projects:
alfresco-remote-api 8.238 alfresco-repository 8.286 alfresco-data-model 8.158 alfresco-core 8.50 MNT-21936 : Audit query Rest API does not return the correct totalItems (#838) * MNT-21936 : Audit query Rest API does not return the correct totalItems Retrieve audit entries count if it has more items Require new release of alfresco-repository. * MNT-21936 : introduced skipTotalItems property for AuditImpl#listAuditEntries * MNT-21936 : Change skipTotalItems to omitTotalItems to align with API Spec * update alfresco-repository dependency (cherry picked from commit 91c49be12a21b23a87cd04b7584c230b2ec4b569) Bump dependency.webscripts.version from 8.8 to 8.10 (#1252) Bumps `dependency.webscripts.version` from 8.8 to 8.10. Updates `spring-surf-core-configservice` from 8.8 to 8.10 Updates `spring-webscripts` from 8.8 to 8.10 - [Release notes](https://github.com/Alfresco/surf-webscripts/releases) - [Commits](https://github.com/Alfresco/surf-webscripts/compare/spring-surf-webscripts-parent-8.8...spring-surf-webscripts-parent-8.10) Updates `spring-webscripts-api` from 8.8 to 8.10 Updates `spring-webscripts` from 8.8 to 8.10 - [Release notes](https://github.com/Alfresco/surf-webscripts/releases) - [Commits](https://github.com/Alfresco/surf-webscripts/compare/spring-surf-webscripts-parent-8.8...spring-surf-webscripts-parent-8.10) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> (cherry picked from commit 8434f5f06fbd973c24688e5c7ec3d54b8513d858) MNT-21936 : Audit query Rest API does not return the correct totalItems (#1253) * MNT-21936 : Audit query Rest API does not return the correct totalItems Add CountAuditEntryId select, that provides the total number of items for a specific auditApp Add getAuditEntriesCountByApp(long appId) in AuditDAO interface and its implementation in AuditDAOImpl Add getAuditEntriesCountByApp(String applicationName) in AuditComponent interface and its implementation in AuditComponentImpl Add getAuditEntriesCountByApp(String applicationName) in AuditService interface and its implementation in AuditServiceImpl * MNT-21936 : Added default implementation for getAuditEntriesCountByApp() in AuditComponent AuditService and AuditDAOImpl (cherry picked from commit 706251642bb5ef6dbb0a059bf6a0cd4f7b72ab43)
This commit is contained in:
@@ -280,21 +280,28 @@ public class AuditImpl implements Audit
|
||||
|
||||
// clear null elements
|
||||
entriesAudit.removeAll(Collections.singleton(null));
|
||||
int totalItems = entriesAudit.size();
|
||||
int totalRetrievedItems = entriesAudit.size();
|
||||
int end = Math.min(limit - 1, totalRetrievedItems);
|
||||
boolean hasMoreItems = totalRetrievedItems > end;
|
||||
|
||||
if (skipCount >= totalItems)
|
||||
String omitTotalItemsParameter = parameters.getParameter("omitTotalItems");
|
||||
boolean omitTotalItems = (null != omitTotalItemsParameter) && Boolean.parseBoolean(omitTotalItemsParameter);
|
||||
|
||||
Integer totalItems;
|
||||
|
||||
if (omitTotalItems)
|
||||
{
|
||||
List<AuditEntry> empty = Collections.emptyList();
|
||||
return CollectionWithPagingInfo.asPaged(paging, empty, false, totalItems);
|
||||
totalItems = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
int end = Math.min(limit - 1, totalItems);
|
||||
boolean hasMoreItems = totalItems > end;
|
||||
|
||||
entriesAudit = entriesAudit.subList(skipCount, end);
|
||||
return CollectionWithPagingInfo.asPaged(paging, entriesAudit, hasMoreItems, totalItems);
|
||||
totalItems = hasMoreItems ? getAuditEntriesCountByApp(auditApplication) : totalRetrievedItems;
|
||||
}
|
||||
|
||||
entriesAudit = (skipCount >= totalRetrievedItems)
|
||||
? Collections.emptyList()
|
||||
: entriesAudit.subList(skipCount, end);
|
||||
return CollectionWithPagingInfo.asPaged(paging, entriesAudit, hasMoreItems, totalItems);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -882,4 +889,10 @@ public class AuditImpl implements Audit
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getAuditEntriesCountByApp(AuditService.AuditApplication auditApplication)
|
||||
{
|
||||
final String applicationName = auditApplication.getKey().substring(1);
|
||||
return auditService.getAuditEntriesCountByApp(applicationName);
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@
|
||||
package org.alfresco.rest.api.tests;
|
||||
|
||||
import static org.alfresco.rest.api.tests.util.RestApiUtil.toJsonAsStringNonNull;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
@@ -405,6 +406,31 @@ public class AuditAppTest extends AbstractSingleNetworkSiteTest
|
||||
validateAuditEntryFields(ae, auditApp);
|
||||
}
|
||||
|
||||
// MNT-21936 Audit query Rest API does not return the correct totalItems
|
||||
int auditEntriesTotalItems = auditEntries.getPaging().getTotalItems();
|
||||
|
||||
// set maxItems to 1
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("maxItems","1");
|
||||
|
||||
auditEntries = auditAppsProxy.getAuditAppEntries(auditApp.getId(), params,
|
||||
HttpServletResponse.SC_OK);
|
||||
|
||||
int AuditEntriesTotalItemsAfterLimit = auditEntries.getPaging().getTotalItems();
|
||||
int retrievedAuditEntriesCount = auditEntries.getPaging().getCount();
|
||||
// When totalItems are retrieved using getAuditEntriesCountByApp() method that was introduced in MNT-21936
|
||||
// 2 audit entries will be created.
|
||||
assertEquals(auditEntriesTotalItems + 2, AuditEntriesTotalItemsAfterLimit);
|
||||
assertEquals(1, retrievedAuditEntriesCount);
|
||||
|
||||
// set omitTotalItems to true.
|
||||
params.put("omitTotalItems", "true");
|
||||
auditEntries = auditAppsProxy.getAuditAppEntries(auditApp.getId(), params,
|
||||
HttpServletResponse.SC_OK);
|
||||
|
||||
// verify that totalItems is null.
|
||||
assertNull(auditEntries.getPaging().getTotalItems());
|
||||
|
||||
// Negative tests
|
||||
// 401
|
||||
setRequestContext(networkOne.getId(), networkAdmin, "wrongPassword");
|
||||
|
Reference in New Issue
Block a user