Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APPS-3129] Reverting changes related to mnt-24137(quick link issue) #3086

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO;
import org.alfresco.repo.domain.propval.PropertyStringValueEntity;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO;
import org.alfresco.repo.domain.propval.PropertyStringValueEntity;

/**
* RM V3.3 Hold audit entries values patch unit test
*
Expand All @@ -55,7 +56,6 @@ public class RMv33HoldAuditEntryValuesPatchUnitTest
@InjectMocks
private RMv33HoldAuditEntryValuesPatch patch;


@Before
public void setUp()
{
Expand Down Expand Up @@ -89,19 +89,20 @@ public void holdAuditEntriesAreUpdatedAfterUpgrade()
verify(mockedRecordsManagementQueryDAO, times(1)).updatePropertyStringValueEntity(addToHoldPropertyStringValueEntity);
verify(mockedRecordsManagementQueryDAO, times(1)).getPropertyStringValueEntity("removeFromHold");
verify(mockedRecordsManagementQueryDAO, times(1)).updatePropertyStringValueEntity(removeFromHoldPropertyStringValueEntity);

verify(mockedRecordsManagementQueryDAO, times(1)).getPropertyStringValueEntity("deleteHold");
verify(mockedRecordsManagementQueryDAO, times(1)).updatePropertyStringValueEntity(deleteHoldPropertyStringValueEntity);

assertEquals("Add To Hold", addToHoldPropertyStringValueEntity.getStringValue());
assertEquals("add to hold", addToHoldPropertyStringValueEntity.getStringLower());
assertEquals("add to hold", addToHoldPropertyStringValueEntity.getStringEndLower());
assertEquals(Long.valueOf(770_786_109L), addToHoldPropertyStringValueEntity.getStringCrc());

assertEquals("Remove From Hold", removeFromHoldPropertyStringValueEntity.getStringValue());
assertEquals("remove from hold", removeFromHoldPropertyStringValueEntity.getStringLower());
assertEquals("remove from hold", removeFromHoldPropertyStringValueEntity.getStringEndLower());
assertEquals(Long.valueOf(2_967_613_012L), removeFromHoldPropertyStringValueEntity.getStringCrc());

assertEquals("Delete Hold", deleteHoldPropertyStringValueEntity.getStringValue());
assertEquals("delete hold", deleteHoldPropertyStringValueEntity.getStringLower());
assertEquals("delete hold", deleteHoldPropertyStringValueEntity.getStringEndLower());
assertEquals(Long.valueOf(132_640_810L), deleteHoldPropertyStringValueEntity.getStringCrc());
}

Expand All @@ -123,5 +124,3 @@ public void patchRunWithSuccessWhenNoHoldEntries()
verify(mockedRecordsManagementQueryDAO, times(0)).updatePropertyStringValueEntity(any());
}
}


54 changes: 28 additions & 26 deletions remote-api/src/main/java/org/alfresco/rest/api/impl/AuditImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

// list of equals filter's auditEntry (via where clause)
private final static Set<String> LIST_AUDIT_ENTRY_EQUALS_QUERY_PROPERTIES = new HashSet<>(
Arrays.asList(new String[] { CREATED_BY_USER, VALUES_KEY, VALUES_VALUE }));
Arrays.asList(new String[]{CREATED_BY_USER, VALUES_KEY, VALUES_VALUE}));

Check warning

Code scanning / PMD

Unnecessary explicit array creation for varargs method call Warning

Unnecessary explicit array creation for varargs method call

// map of sort parameters for the moment one createdAt
private final static Map<String, String> SORT_PARAMS_TO_NAMES;
Expand Down Expand Up @@ -295,23 +295,29 @@
}
else
{
if (hasMoreItems) {
if (q != null) {
if (hasMoreItems)
{
if (q != null)
{
// filtering via "where" clause
AuditEntryQueryWalker propertyWalker = new AuditEntryQueryWalker();
QueryHelper.walk(q, propertyWalker);
totalItems = getAuditEntriesCountByAppAndProperties(auditApplication, propertyWalker);
} else {
}
else
{
totalItems = getAuditEntriesCountByApp(auditApplication);
}
} else {
}
else
{
totalItems = totalRetrievedItems;
}
}

entriesAudit = (skipCount >= totalRetrievedItems)
? Collections.emptyList()
: entriesAudit.subList(skipCount, end);
? Collections.emptyList()
: entriesAudit.subList(skipCount, end);
return CollectionWithPagingInfo.asPaged(paging, entriesAudit, hasMoreItems, totalItems);
}

Expand Down Expand Up @@ -475,8 +481,7 @@
final Map<String, UserInfo> mapUserInfo = new HashMap<>(10);

// create the callback for auditQuery method
final AuditQueryCallback callback = new AuditQueryCallback()
{
final AuditQueryCallback callback = new AuditQueryCallback() {
public boolean valuesRequired()
{
return ((includeParam != null) && (includeParam.contains(PARAM_INCLUDE_VALUES)));
Expand Down Expand Up @@ -532,7 +537,7 @@
params.setApplicationName(auditApplication.getName());
params.setFromId(auditEntryId);
params.setToId(auditEntryId + 1);

List<String> includeParam = new ArrayList<>();
if (parameters != null)
{
Expand All @@ -545,8 +550,7 @@
final List<AuditEntry> results = new ArrayList<>();

// create the callback for auditQuery method
final AuditQueryCallback callback = new AuditQueryCallback()
{
final AuditQueryCallback callback = new AuditQueryCallback() {
public boolean valuesRequired()
{
return ((includeParam != null) && (includeParam.contains(PARAM_INCLUDE_VALUES)));
Expand Down Expand Up @@ -710,8 +714,7 @@
@Override
public CollectionWithPagingInfo<AuditEntry> listAuditEntriesByNodeId(String nodeId, Parameters parameters)
{
AuthenticationUtil.runAs(new RunAsWork<Void>()
{
AuthenticationUtil.runAs(new RunAsWork<Void>() {
public Void doWork() throws Exception
{
checkEnabled();
Expand Down Expand Up @@ -772,17 +775,15 @@
final List<AuditEntry> results = new ArrayList<>();

String auditAppId = "alfresco-access";
String auditApplicationName = AuthenticationUtil.runAs(new RunAsWork<String>()
{
String auditApplicationName = AuthenticationUtil.runAs(new RunAsWork<String>() {

Check warning

Code scanning / PMD

Explicit type arguments can be replaced by a diamond: `new RunAsWork<>()` Warning

Explicit type arguments can be replaced by a diamond: new RunAsWork<>()
public String doWork() throws Exception
{
return findAuditAppByIdOr404(auditAppId).getName();
}
}, AuthenticationUtil.getSystemUserName());

// create the callback for auditQuery method
final AuditQueryCallback callback = new AuditQueryCallback()
{
final AuditQueryCallback callback = new AuditQueryCallback() {
public boolean valuesRequired()
{
return ((includeParam != null) && (includeParam.contains(PARAM_INCLUDE_VALUES)));
Expand All @@ -808,8 +809,7 @@
Long toTime = propertyWalker.getToTime();
validateWhereBetween(nodeRef.getId(), fromTime, toTime);

AuthenticationUtil.runAs(new RunAsWork<Object>()
{
AuthenticationUtil.runAs(new RunAsWork<Object>() {

Check warning

Code scanning / PMD

Explicit type arguments can be replaced by a diamond: `new RunAsWork<>()` Warning

Explicit type arguments can be replaced by a diamond: new RunAsWork<>()
public Object doWork() throws Exception
{
// QueryParameters
Expand All @@ -820,7 +820,7 @@
pathParams.setFromTime(fromTime);
pathParams.setToTime(toTime);
pathParams.setApplicationName(auditApplicationName);
pathParams.addSearchKey("/"+auditAppId+"/transaction/path", nodePath);
pathParams.addSearchKey("/" + auditAppId + "/transaction/path", nodePath);
auditService.auditQuery(callback, pathParams, limit);

AuditQueryParameters copyFromPathParams = new AuditQueryParameters();
Expand All @@ -830,7 +830,7 @@
copyFromPathParams.setFromTime(fromTime);
copyFromPathParams.setToTime(toTime);
copyFromPathParams.setApplicationName(auditApplicationName);
copyFromPathParams.addSearchKey("/"+auditAppId+"/transaction/copy/from/path", nodePath);
copyFromPathParams.addSearchKey("/" + auditAppId + "/transaction/copy/from/path", nodePath);
auditService.auditQuery(callback, copyFromPathParams, limit);

AuditQueryParameters moveFromPathParams = new AuditQueryParameters();
Expand All @@ -840,7 +840,7 @@
moveFromPathParams.setFromTime(fromTime);
moveFromPathParams.setToTime(toTime);
moveFromPathParams.setApplicationName(auditApplicationName);
moveFromPathParams.addSearchKey("/"+auditAppId+"/transaction/move/from/path", nodePath);
moveFromPathParams.addSearchKey("/" + auditAppId + "/transaction/move/from/path", nodePath);
auditService.auditQuery(callback, moveFromPathParams, limit);

return null;
Expand All @@ -857,7 +857,7 @@

public AuditEntriesByNodeIdQueryWalker()
{
super(new HashSet<>(Arrays.asList(new String[] { CREATED_BY_USER })), null);
super(new HashSet<>(Arrays.asList(new String[]{CREATED_BY_USER})), null);

Check warning

Code scanning / PMD

Unnecessary explicit array creation for varargs method call Warning

Unnecessary explicit array creation for varargs method call
}

@Override
Expand Down Expand Up @@ -909,14 +909,16 @@

public int getAuditEntriesCountByAppAndProperties(AuditService.AuditApplication auditApplication, AuditEntryQueryWalker propertyWalker)
{
final String applicationName = auditApplication.getKey().substring(1);
AuditQueryParameters parameters = new AuditQueryParameters();
parameters.setApplicationName(auditApplication.getName());
parameters.setApplicationName(applicationName);
parameters.setFromTime(propertyWalker.getFromTime());
parameters.setToTime(propertyWalker.getToTime());
parameters.setFromId(propertyWalker.getFromId());
parameters.setToId(propertyWalker.getToId());

parameters.setUser(propertyWalker.getCreatedByUser());

return auditService.getAuditEntriesCountByAppAndProperties(parameters);
return auditService.getAuditEntriesCountByAppAndProperties(applicationName, parameters);
}
}
Loading
Loading