Merged 5.2.N-AUDIT-API (5.2.2) to 5.2.N (5.2.2)

137905 anechifor: REPO-2619 - adding implementation of listAuditEntries


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@137965 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2017-07-12 12:09:55 +00:00
parent 0da3bb1492
commit 8ed0f981b8
3 changed files with 17 additions and 12 deletions

View File

@@ -815,6 +815,10 @@
<bean class="org.alfresco.rest.api.audit.AuditApplicationsEntityResource"> <bean class="org.alfresco.rest.api.audit.AuditApplicationsEntityResource">
<property name="audit" ref="AuditApi" /> <property name="audit" ref="AuditApi" />
</bean> </bean>
<bean class="org.alfresco.rest.api.audit.AuditApplicationsAuditEntriesRelation">
<property name="audit" ref="AuditApi" />
</bean>
<bean class="org.alfresco.rest.api.downloads.DownloadsEntityResource"> <bean class="org.alfresco.rest.api.downloads.DownloadsEntityResource">
<property name="downloads" ref="Downloads" /> <property name="downloads" ref="Downloads" />

View File

@@ -35,6 +35,8 @@ import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.util.ParameterCheck; import org.alfresco.util.ParameterCheck;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
@RelationshipResource(name = "audit-entries", entityResource = AuditApplicationsEntityResource.class, title = "Audit Application Entries") @RelationshipResource(name = "audit-entries", entityResource = AuditApplicationsEntityResource.class, title = "Audit Application Entries")
public class AuditApplicationsAuditEntriesRelation implements RelationshipResourceAction.Read<AuditEntry>, InitializingBean public class AuditApplicationsAuditEntriesRelation implements RelationshipResourceAction.Read<AuditEntry>, InitializingBean
{ {
@@ -56,7 +58,6 @@ public class AuditApplicationsAuditEntriesRelation implements RelationshipResour
@Override @Override
public CollectionWithPagingInfo<AuditEntry> readAll(String auditAppId, Parameters parameters) public CollectionWithPagingInfo<AuditEntry> readAll(String auditAppId, Parameters parameters)
{ {
return audit.listAuditEntries(auditAppId, parameters); return audit.listAuditEntries(auditAppId, parameters);
} }

View File

@@ -173,7 +173,6 @@ public class AuditImpl implements Audit
return CollectionWithPagingInfo.asPaged(paging, auditApps, hasMoreItems, totalItems); return CollectionWithPagingInfo.asPaged(paging, auditApps, hasMoreItems, totalItems);
} }
@Override @Override
public CollectionWithPagingInfo<AuditEntry> listAuditEntries(String auditAppId, Parameters parameters) public CollectionWithPagingInfo<AuditEntry> listAuditEntries(String auditAppId, Parameters parameters)
{ {
@@ -186,14 +185,14 @@ public class AuditImpl implements Audit
forward = sortProp.getSecond(); forward = sortProp.getSecond();
// Parse where clause properties. // Parse where clause properties.
List<AuditEntry> entriesAfterWhereQuery = new ArrayList<AuditEntry>(); List<AuditEntry> entriesAudit = new ArrayList<AuditEntry>();
Query q = parameters.getQuery(); Query q = parameters.getQuery();
if (q != null) if (q != null && q.getTree() != null)
{ {
// filtering via "where" clause // filtering via "where" clause
AuditEntryQueryWalker propertyWalker = new AuditEntryQueryWalker(); AuditEntryQueryWalker propertyWalker = new AuditEntryQueryWalker();
QueryHelper.walk(q, propertyWalker); QueryHelper.walk(q, propertyWalker);
entriesAfterWhereQuery = getQueryResultAuditEntries(auditAppId, propertyWalker, MAX_ITEMS_AUDIT_ENTRIES, forward); entriesAudit = getQueryResultAuditEntries(auditAppId, propertyWalker, MAX_ITEMS_AUDIT_ENTRIES, forward);
} }
// paging // paging
@@ -202,7 +201,7 @@ public class AuditImpl implements Audit
int skipCount = paging.getSkipCount(); int skipCount = paging.getSkipCount();
int maxItems = paging.getMaxItems(); int maxItems = paging.getMaxItems();
int max = skipCount + maxItems; // to detect hasMoreItems int max = skipCount + maxItems; // to detect hasMoreItems
int totalItems = entriesAfterWhereQuery.size(); int totalItems = entriesAudit.size();
if (skipCount >= totalItems) if (skipCount >= totalItems)
{ {
@@ -214,8 +213,8 @@ public class AuditImpl implements Audit
int end = Math.min(max, totalItems); int end = Math.min(max, totalItems);
boolean hasMoreItems = totalItems > end; boolean hasMoreItems = totalItems > end;
entriesAfterWhereQuery = entriesAfterWhereQuery.subList(skipCount, end); entriesAudit = entriesAudit.subList(skipCount, end);
return CollectionWithPagingInfo.asPaged(paging, entriesAfterWhereQuery, hasMoreItems, totalItems); return CollectionWithPagingInfo.asPaged(paging, entriesAudit, hasMoreItems, totalItems);
} }
} }
@@ -225,7 +224,7 @@ public class AuditImpl implements Audit
* @return * @return
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
private Pair<String, Boolean> getAuditEntrySortProp(Parameters parameters) private Pair<String, Boolean> getAuditEntrySortProp(Parameters parameters)
{ {
Pair<String, Boolean> sortProp = null; Pair<String, Boolean> sortProp = null;
List<SortColumn> sortCols = parameters.getSorting(); List<SortColumn> sortCols = parameters.getSorting();
@@ -334,7 +333,10 @@ public class AuditImpl implements Audit
params.setUser(propertyWalker.getCreatedByUser()); params.setUser(propertyWalker.getCreatedByUser());
params.setFromTime(propertyWalker.getFromTime()); params.setFromTime(propertyWalker.getFromTime());
params.setToTime(propertyWalker.getToTime()); params.setToTime(propertyWalker.getToTime());
params.addSearchKey(propertyWalker.getValuesKey(), propertyWalker.getValuesValue()); if (propertyWalker.getValuesKey() != null && propertyWalker.getValuesValue() != null)
{
params.addSearchKey(propertyWalker.getValuesKey(), propertyWalker.getValuesValue());
}
// create the callback for auditQuery method // create the callback for auditQuery method
final AuditQueryCallback callback = new AuditQueryCallback() final AuditQueryCallback callback = new AuditQueryCallback()
@@ -363,7 +365,6 @@ public class AuditImpl implements Audit
return results; return results;
} }
@Override @Override
public AuditApp update(String auditAppId, AuditApp auditApp, Parameters parameters) public AuditApp update(String auditAppId, AuditApp auditApp, Parameters parameters)
{ {
@@ -390,5 +391,4 @@ public class AuditImpl implements Audit
return new AuditApp(auditApplication.getKey().substring(1), auditApplication.getName(), auditApp.getIsEnabled()); return new AuditApp(auditApplication.getKey().substring(1), auditApplication.getName(), auditApp.getIsEnabled());
} }
} }