mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-17 14:21:39 +00:00
Merge changes from support/6.2.N to release/6.2.N since 6.2.3-A1
acs-packaging 6.2.3-SNAPSHOT alfresco-enterprise-remote-api 7.94 alfresco-enterprise-repository 7.120 alfresco-remote-api 7.157 alfresco-repository 7.220 alfresco-data-model 8.50.21 alfresco-core 7.35 There were no changes needing to go into acs-packaging or alfresco-enterprise-repo MNT-21871: jackson databind vulnerabilities 6.2.N (#833) - upgrade to 2.10.5 - reconfigure object mapper with different inclusion criteria for value and contents (cherry picked from commit a570822375ab3beb8bb879af336fdf062d05f426) MNT-21936 : Audit query Rest API does not return the correct totalItems (#838) (#847) * 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 omitTotalItems property for AuditImpl#listAuditEntries (cherry picked from commit 91c49be12a21b23a87cd04b7584c230b2ec4b569) * bump alfresco-repository to 7.220 (cherry picked from commit 91957c4ccd905f677dd457c98406d6cabfa892c9) MNT-21936 : Audit query Rest API does not return the correct totalItems (#1253) (#1262) * 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) (cherry picked from commit 7e8ab16fe1af7d14d1b5dacb8dbdea30ccb7f30f) on branches merge/62N_13Oct, origin/merge/62N_13Oct
This commit is contained in:
4
pom.xml
4
pom.xml
@@ -57,8 +57,8 @@
|
|||||||
|
|
||||||
<dependency.spring.version>5.1.15.RELEASE</dependency.spring.version>
|
<dependency.spring.version>5.1.15.RELEASE</dependency.spring.version>
|
||||||
<dependency.antlr.version>3.5.2</dependency.antlr.version>
|
<dependency.antlr.version>3.5.2</dependency.antlr.version>
|
||||||
<dependency.jackson.version>2.10.2</dependency.jackson.version>
|
<dependency.jackson.version>2.10.5</dependency.jackson.version>
|
||||||
<dependency.jackson-databind.version>2.10.1</dependency.jackson-databind.version>
|
<dependency.jackson-databind.version>2.10.5</dependency.jackson-databind.version>
|
||||||
<dependency.cxf.version>3.3.5</dependency.cxf.version>
|
<dependency.cxf.version>3.3.5</dependency.cxf.version>
|
||||||
<dependency.opencmis.version>1.0.0</dependency.opencmis.version>
|
<dependency.opencmis.version>1.0.0</dependency.opencmis.version>
|
||||||
<dependency.pdfbox.version>2.0.19</dependency.pdfbox.version>
|
<dependency.pdfbox.version>2.0.19</dependency.pdfbox.version>
|
||||||
|
@@ -280,21 +280,28 @@ public class AuditImpl implements Audit
|
|||||||
|
|
||||||
// clear null elements
|
// clear null elements
|
||||||
entriesAudit.removeAll(Collections.singleton(null));
|
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();
|
totalItems = null;
|
||||||
return CollectionWithPagingInfo.asPaged(paging, empty, false, totalItems);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int end = Math.min(limit - 1, totalItems);
|
totalItems = hasMoreItems ? getAuditEntriesCountByApp(auditApplication) : totalRetrievedItems;
|
||||||
boolean hasMoreItems = totalItems > end;
|
|
||||||
|
|
||||||
entriesAudit = entriesAudit.subList(skipCount, end);
|
|
||||||
return CollectionWithPagingInfo.asPaged(paging, entriesAudit, hasMoreItems, totalItems);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -82,9 +82,8 @@ public class JacksonHelper implements InitializingBean
|
|||||||
//Configure the objectMapper ready for use
|
//Configure the objectMapper ready for use
|
||||||
objectMapper = new ObjectMapper();
|
objectMapper = new ObjectMapper();
|
||||||
objectMapper.registerModule(module);
|
objectMapper.registerModule(module);
|
||||||
objectMapper.setDefaultPropertyInclusion(JsonInclude.Include.NON_EMPTY);
|
objectMapper.setDefaultPropertyInclusion(
|
||||||
objectMapper.configOverride(java.util.Map.class)
|
JsonInclude.Value.construct(JsonInclude.Include.NON_EMPTY, JsonInclude.Include.ALWAYS));
|
||||||
.setInclude(JsonInclude.Value.construct(JsonInclude.Include.NON_EMPTY, null));
|
|
||||||
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
||||||
DateFormat DATE_FORMAT_ISO8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
DateFormat DATE_FORMAT_ISO8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
||||||
DATE_FORMAT_ISO8601.setTimeZone(TimeZone.getTimeZone("UTC"));
|
DATE_FORMAT_ISO8601.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
package org.alfresco.rest.api.tests;
|
package org.alfresco.rest.api.tests;
|
||||||
|
|
||||||
import static org.alfresco.rest.api.tests.util.RestApiUtil.toJsonAsStringNonNull;
|
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.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
@@ -405,6 +406,31 @@ public class AuditAppTest extends AbstractSingleNetworkSiteTest
|
|||||||
validateAuditEntryFields(ae, auditApp);
|
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
|
// Negative tests
|
||||||
// 401
|
// 401
|
||||||
setRequestContext(networkOne.getId(), networkAdmin, "wrongPassword");
|
setRequestContext(networkOne.getId(), networkAdmin, "wrongPassword");
|
||||||
|
@@ -261,4 +261,15 @@ public interface AuditComponent
|
|||||||
* @return a map containing min/max and the associated value
|
* @return a map containing min/max and the associated value
|
||||||
*/
|
*/
|
||||||
HashMap<String, Long> getAuditMinMaxByApp(String applicationName, List<String> extremes);
|
HashMap<String, Long> getAuditMinMaxByApp(String applicationName, List<String> extremes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Issue an audit query to retrieve count of records for a given application.
|
||||||
|
*
|
||||||
|
* @param applicationName the name of the application
|
||||||
|
* @return a map containing min/max and the associated value
|
||||||
|
*/
|
||||||
|
default int getAuditEntriesCountByApp(String applicationName)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -941,4 +941,18 @@ public class AuditComponentImpl implements AuditComponent
|
|||||||
|
|
||||||
return auditDAO.getAuditMinMaxByApp(applicationId, extremes);
|
return auditDAO.getAuditMinMaxByApp(applicationId, extremes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAuditEntriesCountByApp(String applicationName)
|
||||||
|
{
|
||||||
|
// Get the id for the application
|
||||||
|
AuditApplication app = auditModelRegistry.getAuditApplicationByName(applicationName);
|
||||||
|
Long applicationId = app.getApplicationId();
|
||||||
|
if (applicationId == null)
|
||||||
|
{
|
||||||
|
throw new AuditException("No persisted instance exists for audit application: " + app);
|
||||||
|
}
|
||||||
|
|
||||||
|
return auditDAO.getAuditEntriesCountByApp(applicationId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -177,4 +177,13 @@ public class AuditServiceImpl implements AuditService
|
|||||||
{
|
{
|
||||||
return auditComponent.getAuditMinMaxByApp(applicationName, extremes);
|
return auditComponent.getAuditMinMaxByApp(applicationName, extremes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getAuditEntriesCountByApp(String applicationName)
|
||||||
|
{
|
||||||
|
return auditComponent.getAuditEntriesCountByApp(applicationName);
|
||||||
|
}
|
||||||
}
|
}
|
@@ -233,4 +233,15 @@ public interface AuditDAO
|
|||||||
* @return a map containing min/max and the associated value
|
* @return a map containing min/max and the associated value
|
||||||
*/
|
*/
|
||||||
HashMap<String, Long> getAuditMinMaxByApp(long appId, List<String> extremes);
|
HashMap<String, Long> getAuditMinMaxByApp(long appId, List<String> extremes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Issue an audit query to retrieve count of records for a given application.
|
||||||
|
*
|
||||||
|
* @param applicationId the database id of the application
|
||||||
|
* @return a map containing min/max and the associated value
|
||||||
|
*/
|
||||||
|
default int getAuditEntriesCountByApp(long applicationId)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -65,6 +65,7 @@ public class AuditDAOImpl extends AbstractAuditDAOImpl
|
|||||||
private static final String DELETE_ENTRIES_BY_ID = "alfresco.audit.delete_AuditEntriesById";
|
private static final String DELETE_ENTRIES_BY_ID = "alfresco.audit.delete_AuditEntriesById";
|
||||||
private static final String INSERT_ENTRY = "alfresco.audit.insert.insert_AuditEntry";
|
private static final String INSERT_ENTRY = "alfresco.audit.insert.insert_AuditEntry";
|
||||||
private static final String SELECT_MINMAX_ENTRY_FOR_APP = "alfresco.audit.select_MinMaxAuditEntryId";
|
private static final String SELECT_MINMAX_ENTRY_FOR_APP = "alfresco.audit.select_MinMaxAuditEntryId";
|
||||||
|
private static final String SELECT_COUNT_ENTRIES_FOR_APP = "alfresco.audit.select_CountAuditEntryId";
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static final String SELECT_ENTRIES_SIMPLE = "alfresco.audit.select_AuditEntriesSimple";
|
private static final String SELECT_ENTRIES_SIMPLE = "alfresco.audit.select_AuditEntriesSimple";
|
||||||
@@ -223,6 +224,17 @@ public class AuditDAOImpl extends AbstractAuditDAOImpl
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAuditEntriesCountByApp(long applicationId)
|
||||||
|
{
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("auditAppId", applicationId);
|
||||||
|
|
||||||
|
int result = template.selectOne(SELECT_COUNT_ENTRIES_FOR_APP, params);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected void findAuditEntries(
|
protected void findAuditEntries(
|
||||||
|
@@ -241,4 +241,15 @@ public interface AuditService
|
|||||||
* @return a map containing min/max and the associated value
|
* @return a map containing min/max and the associated value
|
||||||
*/
|
*/
|
||||||
HashMap<String, Long> getAuditMinMaxByApp(String applicationName, List<String> extremes);
|
HashMap<String, Long> getAuditMinMaxByApp(String applicationName, List<String> extremes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Issue an audit query to retrieve min / max audit record id for a given application.
|
||||||
|
*
|
||||||
|
* @param applicationName the name of the application
|
||||||
|
* @return a map containing min/max and the associated value
|
||||||
|
*/
|
||||||
|
default int getAuditEntriesCountByApp(String applicationName)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -60,6 +60,10 @@
|
|||||||
<parameter property="max" jdbcType="VARCHAR" javaType="String"/>
|
<parameter property="max" jdbcType="VARCHAR" javaType="String"/>
|
||||||
</parameterMap>
|
</parameterMap>
|
||||||
|
|
||||||
|
<parameterMap id="parameter_AuditAppId" type="map">
|
||||||
|
<parameter property="auditAppId" jdbcType="BIGINT" javaType="Long"/>
|
||||||
|
</parameterMap>
|
||||||
|
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- SQL Snippets -->
|
<!-- SQL Snippets -->
|
||||||
<!-- -->
|
<!-- -->
|
||||||
@@ -277,6 +281,16 @@
|
|||||||
<include refid="select_AuditEntriesOrderBySnippet"/>
|
<include refid="select_AuditEntriesOrderBySnippet"/>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<!-- Get the count of audit entries for application -->
|
||||||
|
<select id="select_CountAuditEntryId" parameterMap="parameter_AuditAppId" resultType="int">
|
||||||
|
select
|
||||||
|
COUNT(id)
|
||||||
|
from
|
||||||
|
alf_audit_entry
|
||||||
|
where
|
||||||
|
alf_audit_entry.audit_app_id = #{auditAppId}
|
||||||
|
</select>
|
||||||
|
|
||||||
<!-- Get the maximum/minimum audit entry id for application -->
|
<!-- Get the maximum/minimum audit entry id for application -->
|
||||||
<select id="select_MinMaxAuditEntryId" parameterMap="parameter_IdMinMaxMap" resultMap="result_minMaxMap">
|
<select id="select_MinMaxAuditEntryId" parameterMap="parameter_IdMinMaxMap" resultMap="result_minMaxMap">
|
||||||
select
|
select
|
||||||
|
@@ -28,7 +28,7 @@ curl -s -X POST \
|
|||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-H "Accept: application/json" \
|
-H "Accept: application/json" \
|
||||||
-H "Travis-API-Version: 3" \
|
-H "Travis-API-Version: 3" \
|
||||||
-H "Authorization: token ${TRAVIS_ACCESS_TOKEN_TEMP}" \
|
-H "Authorization: token ${TRAVIS_ACCESS_TOKEN}" \
|
||||||
-d "${BODY}" \
|
-d "${BODY}" \
|
||||||
"${URL}" \
|
"${URL}" \
|
||||||
| tee /tmp/travis-request-output.txt
|
| tee /tmp/travis-request-output.txt
|
||||||
|
Reference in New Issue
Block a user