diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-common-SqlMap.xml index c8297429b6..2d62f3729a 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-common-SqlMap.xml @@ -41,9 +41,9 @@ - - - + + + @@ -60,14 +60,6 @@ - - - - - - - - @@ -156,9 +148,9 @@ diff --git a/source/java/org/alfresco/repo/audit/AuditComponent.java b/source/java/org/alfresco/repo/audit/AuditComponent.java index 435c6fd78d..03e83052db 100644 --- a/source/java/org/alfresco/repo/audit/AuditComponent.java +++ b/source/java/org/alfresco/repo/audit/AuditComponent.java @@ -209,7 +209,7 @@ public interface AuditComponent * @param from the start search time (null to start at the beginning) * @param to the end search time (null for no limit) * @param searchKey the audit key path that must exist (null to ignore) - * @param searchString an audit value string that must exist (null to ignore) + * @param searchValue an audit value that must exist (null to ignore) * @param maxResults the maximum number of results to retrieve (zero or negative to ignore) * * @since 3.2 @@ -217,6 +217,6 @@ public interface AuditComponent void auditQuery( AuditQueryCallback callback, String applicationName, String user, Long from, Long to, - String searchKey, String searchString, + String searchKey, Serializable searchValue, int maxResults); } diff --git a/source/java/org/alfresco/repo/audit/AuditComponentImpl.java b/source/java/org/alfresco/repo/audit/AuditComponentImpl.java index 1a41e81664..5a7eec6772 100644 --- a/source/java/org/alfresco/repo/audit/AuditComponentImpl.java +++ b/source/java/org/alfresco/repo/audit/AuditComponentImpl.java @@ -1315,7 +1315,7 @@ public class AuditComponentImpl implements AuditComponent String user, Long from, Long to, - String searchKey, String searchString, + String searchKey, Serializable searchValue, int maxResults) { ParameterCheck.mandatory("callback", callback); @@ -1327,6 +1327,6 @@ public class AuditComponentImpl implements AuditComponent return; } - auditDAO.findAuditEntries(callback, applicationName, user, from, to, searchKey, searchString, maxResults); + auditDAO.findAuditEntries(callback, applicationName, user, from, to, searchKey, searchValue, maxResults); } } diff --git a/source/java/org/alfresco/repo/audit/AuditServiceImpl.java b/source/java/org/alfresco/repo/audit/AuditServiceImpl.java index 901f56752a..57e8168b15 100644 --- a/source/java/org/alfresco/repo/audit/AuditServiceImpl.java +++ b/source/java/org/alfresco/repo/audit/AuditServiceImpl.java @@ -24,6 +24,7 @@ */ package org.alfresco.repo.audit; +import java.io.Serializable; import java.util.List; import javax.transaction.UserTransaction; @@ -188,12 +189,12 @@ public class AuditServiceImpl implements AuditService public void auditQuery( AuditQueryCallback callback, String applicationName, String user, Long from, Long to, - String searchKey, String searchString, + String searchKey, Serializable searchValue, int maxResults) { ParameterCheck.mandatory("callback", callback); - auditComponent.auditQuery(callback, applicationName, user, from, to, searchKey, searchString, maxResults); + auditComponent.auditQuery(callback, applicationName, user, from, to, searchKey, searchValue, maxResults); } } \ No newline at end of file diff --git a/source/java/org/alfresco/repo/audit/hibernate/HibernateAuditDAO.java b/source/java/org/alfresco/repo/audit/hibernate/HibernateAuditDAO.java index 275cf11625..092612f318 100644 --- a/source/java/org/alfresco/repo/audit/hibernate/HibernateAuditDAO.java +++ b/source/java/org/alfresco/repo/audit/hibernate/HibernateAuditDAO.java @@ -755,7 +755,7 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO, public void findAuditEntries( AuditQueryCallback callback, String applicationName, String user, Long from, Long to, - String searchKey, String searchString, + String searchKey, Serializable searchValue, int maxResults) { throw new UnsupportedOperationException(); diff --git a/source/java/org/alfresco/repo/domain/audit/AbstractAuditDAOImpl.java b/source/java/org/alfresco/repo/domain/audit/AbstractAuditDAOImpl.java index 9f6e439bce..c44189a3dd 100644 --- a/source/java/org/alfresco/repo/domain/audit/AbstractAuditDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/audit/AbstractAuditDAOImpl.java @@ -404,10 +404,14 @@ public abstract class AbstractAuditDAOImpl implements AuditDAO return; } } + // Resolve the application and username + String auditAppName = (String) propertyValueDAO.getPropertyValueById(row.getAuditAppNameId()).getSecond(); + String auditUser = (String) propertyValueDAO.getPropertyValueById(row.getAuditUserId()).getSecond(); + more = callback.handleAuditEntry( row.getAuditEntryId(), - row.getAuditAppName(), - row.getAuditUser(), + auditAppName, + auditUser, row.getAuditTime(), auditValues); } @@ -425,15 +429,15 @@ public abstract class AbstractAuditDAOImpl implements AuditDAO public void findAuditEntries( AuditQueryCallback callback, String applicationName, String user, Long from, Long to, - String searchKey, String searchString, + String searchKey, Serializable searchValue, int maxResults) { AuditQueryRowHandler rowHandler = new AuditQueryRowHandler(callback); - findAuditEntries(rowHandler, applicationName, user, from, to, maxResults, searchKey, searchString); + findAuditEntries(rowHandler, applicationName, user, from, to, maxResults, searchKey, searchValue); } protected abstract void findAuditEntries( AuditQueryRowHandler rowHandler, String applicationName, String user, Long from, Long to, int maxResults, - String searchKey, String searchString); + String searchKey, Serializable searchValue); } diff --git a/source/java/org/alfresco/repo/domain/audit/AuditDAO.java b/source/java/org/alfresco/repo/domain/audit/AuditDAO.java index 6d1c993f2a..e35d29573b 100644 --- a/source/java/org/alfresco/repo/domain/audit/AuditDAO.java +++ b/source/java/org/alfresco/repo/domain/audit/AuditDAO.java @@ -221,7 +221,8 @@ public interface AuditDAO * Find audit entries using the given parameters, any of which may be null. * * @param searchKey the audit path key to search for (optional) - * @param searchString the audit string value to search for (optional) + * @param searchValue the audit value to search for (optional). This can be + * of any type that is supported by the alf_prop_xxx tables. * * @see #findAuditEntries(AuditQueryCallback, String, String, Long, Long, int) * @@ -230,6 +231,6 @@ public interface AuditDAO void findAuditEntries( AuditQueryCallback callback, String applicationName, String user, Long from, Long to, - String searchKey, String searchString, + String searchKey, Serializable searchValue, int maxResults); } \ No newline at end of file diff --git a/source/java/org/alfresco/repo/domain/audit/AuditQueryParameters.java b/source/java/org/alfresco/repo/domain/audit/AuditQueryParameters.java index 82718a1555..ea200ab562 100644 --- a/source/java/org/alfresco/repo/domain/audit/AuditQueryParameters.java +++ b/source/java/org/alfresco/repo/domain/audit/AuditQueryParameters.java @@ -26,8 +26,6 @@ package org.alfresco.repo.domain.audit; import java.util.Date; -import org.alfresco.util.Pair; - /** * Query parameters for alf_audit_entry table. * @@ -37,12 +35,12 @@ import org.alfresco.util.Pair; public class AuditQueryParameters { private Long auditEntryId; - private Pair auditAppNameCrcPair; - private Pair auditUserCrcPair; + private Long auditAppNameId; + private Long auditUserId; private Long auditFromTime; private Long auditToTime; - private String searchKey; - private String searchValueString; + private Long searchKeyId; + private Long searchValueId; public AuditQueryParameters() { @@ -54,12 +52,12 @@ public class AuditQueryParameters StringBuilder sb = new StringBuilder(512); sb.append("AuditEntryParameters") .append("[ auditEntryId=").append(auditEntryId) - .append(", auditAppNameCrcPair=").append(auditAppNameCrcPair) - .append(", auditUserCrcPair=").append(auditUserCrcPair) + .append(", auditAppNameId=").append(auditAppNameId) + .append(", auditUserId=").append(auditUserId) .append(", auditFromTime").append(auditFromTime == null ? null : new Date(auditFromTime)) .append(", auditToTime").append(auditToTime == null ? null : new Date(auditToTime)) - .append(", searchKey").append(searchKey) - .append(", searchValueString").append(searchValueString) + .append(", searchKeyId").append(searchKeyId) + .append(", searchValueId").append(searchValueId) .append("]"); return sb.toString(); } @@ -74,34 +72,24 @@ public class AuditQueryParameters this.auditEntryId = entryId; } - public String getAuditAppNameShort() + public Long getAuditAppNameId() { - return auditAppNameCrcPair == null ? null : auditAppNameCrcPair.getFirst(); + return auditAppNameId; } - public Long getAuditAppNameCrc() + public void setAuditAppNameId(Long auditAppNameId) { - return auditAppNameCrcPair == null ? null : auditAppNameCrcPair.getSecond(); + this.auditAppNameId = auditAppNameId; } - public void setAuditAppNameCrcPair(Pair appNameCrcPair) + public Long getAuditUserId() { - this.auditAppNameCrcPair = appNameCrcPair; + return auditUserId; } - public String getAuditUserShort() + public void setAuditUserId(Long auditUserId) { - return auditUserCrcPair == null ? null : auditUserCrcPair.getFirst(); - } - - public Long getAuditUserCrc() - { - return auditUserCrcPair == null ? null : auditUserCrcPair.getSecond(); - } - - public void setAuditUserCrcPair(Pair userCrcPair) - { - this.auditUserCrcPair = userCrcPair; + this.auditUserId = auditUserId; } public Long getAuditFromTime() @@ -124,23 +112,23 @@ public class AuditQueryParameters this.auditToTime = to; } - public String getSearchKey() + public Long getSearchKeyId() { - return searchKey; + return searchKeyId; } - public void setSearchKey(String searchKey) + public void setSearchKeyId(Long searchKeyId) { - this.searchKey = searchKey; + this.searchKeyId = searchKeyId; } - public String getSearchValueString() + public Long getSearchValueId() { - return searchValueString; + return searchValueId; } - public void setSearchValueString(String searchValueString) + public void setSearchValueId(Long searchValueId) { - this.searchValueString = searchValueString; + this.searchValueId = searchValueId; } } diff --git a/source/java/org/alfresco/repo/domain/audit/AuditQueryResult.java b/source/java/org/alfresco/repo/domain/audit/AuditQueryResult.java index f0dba0e9ae..933667fa24 100644 --- a/source/java/org/alfresco/repo/domain/audit/AuditQueryResult.java +++ b/source/java/org/alfresco/repo/domain/audit/AuditQueryResult.java @@ -38,8 +38,8 @@ import org.alfresco.repo.domain.propval.PropertyIdSearchRow; public class AuditQueryResult { private Long auditEntryId; - private String auditAppName; - private String auditUser; + private Long auditAppNameId; + private Long auditUserId; private long auditTime; private Long auditValuesId; private List auditValues; @@ -54,8 +54,8 @@ public class AuditQueryResult StringBuilder sb = new StringBuilder(512); sb.append("AuditEntryResult") .append("[ auditEntryId=").append(auditEntryId) - .append(", auditAppName=").append(auditAppName) - .append(", auditUser=").append(auditUser) + .append(", auditAppNameId=").append(auditAppNameId) + .append(", auditUserId=").append(auditUserId) .append(", auditTime").append(new Date(auditTime)) .append(", auditValuesId=").append(auditValuesId) .append(", auditValues=").append(auditValues.size()) @@ -73,24 +73,24 @@ public class AuditQueryResult this.auditEntryId = entryId; } - public String getAuditAppName() + public Long getAuditAppNameId() { - return auditAppName; + return auditAppNameId; } - public void setAuditAppName(String appName) + public void setAuditAppNameId(Long auditAppNameId) { - this.auditAppName = appName; + this.auditAppNameId = auditAppNameId; } - public String getAuditUser() + public Long getAuditUserId() { - return auditUser; + return auditUserId; } - public void setAuditUser(String user) + public void setAuditUserId(Long auditUserId) { - this.auditUser = user; + this.auditUserId = auditUserId; } public long getAuditTime() diff --git a/source/java/org/alfresco/repo/domain/audit/ibatis/AuditDAOImpl.java b/source/java/org/alfresco/repo/domain/audit/ibatis/AuditDAOImpl.java index 53c47be4b3..45bed5fd70 100644 --- a/source/java/org/alfresco/repo/domain/audit/ibatis/AuditDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/audit/ibatis/AuditDAOImpl.java @@ -191,24 +191,55 @@ public class AuditDAOImpl extends AbstractAuditDAOImpl protected void findAuditEntries( final AuditQueryRowHandler rowHandler, String appName, String user, Long from, Long to, int maxResults, - String searchKey, String searchString) + String searchKey, Serializable searchValue) { AuditQueryParameters params = new AuditQueryParameters(); if (appName != null) { // Look up the application's ID (this is unique) - Pair appNameCrcPair = propertyValueDAO.getPropertyStringCaseSensitiveSearchParameters(appName); - params.setAuditAppNameCrcPair(appNameCrcPair); + Pair appNamePair = propertyValueDAO.getPropertyValue(appName); + if (appNamePair == null) + { + // No such value + return; + } + params.setAuditAppNameId(appNamePair.getFirst()); } if (user != null) { - Pair userCrcPair = propertyValueDAO.getPropertyStringCaseSensitiveSearchParameters(user); - params.setAuditUserCrcPair(userCrcPair); + // Look up the application's ID (this is unique) + Pair userPair = propertyValueDAO.getPropertyValue(user); + if (userPair == null) + { + // No such value + return; + } + params.setAuditUserId(userPair.getFirst()); } params.setAuditFromTime(from); params.setAuditToTime(to); - params.setSearchKey(searchKey); - params.setSearchValueString(searchString); + if (searchKey != null) + { + // Look up the ID of the search key + Pair searchKeyPair = propertyValueDAO.getPropertyValue(searchKey); + if (searchKeyPair == null) + { + // No such value + return; + } + params.setSearchKeyId(searchKeyPair.getFirst()); + } + if (searchValue != null) + { + // Look up the ID of the search key + Pair searchValuePair = propertyValueDAO.getPropertyValue(searchValue); + if (searchValuePair == null) + { + // No such value + return; + } + params.setSearchValueId(searchValuePair.getFirst()); + } // RowHandlers in RowHandlers: See 'groupBy' issue https://issues.apache.org/jira/browse/IBATIS-503 RowHandler shreddedRowHandler = new RowHandler() diff --git a/source/java/org/alfresco/repo/domain/propval/PropertyValueDAO.java b/source/java/org/alfresco/repo/domain/propval/PropertyValueDAO.java index c8512b4098..ae33ac0810 100644 --- a/source/java/org/alfresco/repo/domain/propval/PropertyValueDAO.java +++ b/source/java/org/alfresco/repo/domain/propval/PropertyValueDAO.java @@ -44,18 +44,24 @@ public interface PropertyValueDAO // 'alf_prop_class' accessors //================================ /** + * FOR INTERNAL USE ONLY: Do not use directly; see interface comments. + *

* alf_prop_class accessor * * @param id the ID (may not be null) */ Pair> getPropertyClassById(Long id); /** + * FOR INTERNAL USE ONLY: Do not use directly; see interface comments. + *

* alf_prop_class accessor * * @param value the value to find the ID for (may not be null) */ Pair> getPropertyClass(Class value); /** + * FOR INTERNAL USE ONLY: Do not use directly; see interface comments. + *

* alf_prop_class accessor * * @param value the value to find the ID for (may not be null) @@ -66,18 +72,24 @@ public interface PropertyValueDAO // 'alf_prop_date_value' accessors //================================ /** + * FOR INTERNAL USE ONLY: Do not use directly; see interface comments. + *

* alf_prop_date_value accessor * * @param id the ID (may not be null) */ Pair getPropertyDateValueById(Long id); /** + * FOR INTERNAL USE ONLY: Do not use directly; see interface comments. + *

* alf_prop_date_value accessor * * @param value the value to find the ID for (may not be null) */ Pair getPropertyDateValue(Date value); /** + * FOR INTERNAL USE ONLY: Do not use directly; see interface comments. + *

* alf_prop_date_value accessor * * @param value the value to find the ID for (may not be null) @@ -93,18 +105,24 @@ public interface PropertyValueDAO */ Pair getPropertyStringCaseSensitiveSearchParameters(String value); /** + * FOR INTERNAL USE ONLY: Do not use directly; see interface comments. + *

* alf_prop_string_value accessor * * @param id the ID (may not be null) */ Pair getPropertyStringValueById(Long id); /** + * FOR INTERNAL USE ONLY: Do not use directly; see interface comments. + *

* alf_prop_string_value accessor * * @param value the value to find the ID for (may not be null) */ Pair getPropertyStringValue(String value); /** + * FOR INTERNAL USE ONLY: Do not use directly; see interface comments. + *

* alf_prop_string_value accessor * * @param value the value to find the ID for (may not be null) @@ -115,18 +133,24 @@ public interface PropertyValueDAO // 'alf_prop_double_value' accessors //================================ /** + * FOR INTERNAL USE ONLY: Do not use directly; see interface comments. + *

* alf_prop_double_value accessor * * @param id the ID (may not be null) */ Pair getPropertyDoubleValueById(Long id); /** + * FOR INTERNAL USE ONLY: Do not use directly; see interface comments. + *

* alf_prop_double_value accessor * * @param value the value to find the ID for (may not be null) */ Pair getPropertyDoubleValue(Double value); /** + * FOR INTERNAL USE ONLY: Do not use directly; see interface comments. + *

* alf_prop_double_value accessor * * @param value the value to find the ID for (may not be null) @@ -137,12 +161,16 @@ public interface PropertyValueDAO // 'alf_prop_serializable_value' accessors //================================ /** + * FOR INTERNAL USE ONLY: Do not use directly; see interface comments. + *

* alf_prop_serializable_value accessor * * @param id the ID (may not be null) */ Pair getPropertySerializableValueById(Long id); /** + * FOR INTERNAL USE ONLY: Do not use directly; see interface comments. + *

* alf_prop_serializable_value accessor * * @param value the value to find the ID for (may not be null) @@ -153,18 +181,24 @@ public interface PropertyValueDAO // 'alf_prop_value' accessors //================================ /** + * Use for accessing unique properties; see interface comments. + *

* alf_prop_value accessor: get a property based on the database ID * * @param id the ID (may not be null) */ Pair getPropertyValueById(Long id); /** + * Use for accessing unique properties; see interface comments. + *

* alf_prop_value accessor: find a property based on the value * * @param value the value to find the ID for (may be null) */ Pair getPropertyValue(Serializable value); /** + * Use for accessing unique properties; see interface comments. + *

* alf_prop_value accessor: find or create a property based on the value. * Note: This method will not recurse into maps or collections. Use the * dedicated methods if you want recursion; otherwise maps and collections will @@ -181,6 +215,8 @@ public interface PropertyValueDAO // 'alf_prop_root' accessors //================================ /** + * Use for accessing non-unique, exploded properties; see interface comments. + *

* alf_prop_root accessor: get a property based on the database ID * * @param id the ID (may not be null) @@ -189,6 +225,8 @@ public interface PropertyValueDAO */ Serializable getPropertyById(Long id); /** + * Use for accessing non-unique, exploded properties; see interface comments. + *

* alf_prop_root accessor: find or create a property based on the value. *

* All collections and maps will be opened up to any depth. @@ -199,6 +237,8 @@ public interface PropertyValueDAO Long createProperty(Serializable value); /** + * Use for accessing non-unique, exploded properties; see interface comments. + *

* alf_prop_root accessor: update the property root to contain a new value. * * @param id the ID of the root property to change @@ -207,6 +247,8 @@ public interface PropertyValueDAO void updateProperty(Long id, Serializable value); /** + * Use for accessing non-unique, exploded properties; see interface comments. + *

* alf_prop_root accessor: delete a property root completely * * @param id the ID of the root property to delete diff --git a/source/java/org/alfresco/service/cmr/audit/AuditService.java b/source/java/org/alfresco/service/cmr/audit/AuditService.java index 9c2e37b444..b173e37b93 100644 --- a/source/java/org/alfresco/service/cmr/audit/AuditService.java +++ b/source/java/org/alfresco/service/cmr/audit/AuditService.java @@ -196,7 +196,7 @@ public interface AuditService * @param from the start search time (null to start at the beginning) * @param to the end search time (null for no limit) * @param searchKey the audit key path that must exist (null to ignore) - * @param searchString an audit value string that must exist (null to ignore) + * @param searchValue an audit value that must exist (null to ignore) * @param maxResults the maximum number of results to retrieve (zero or negative to ignore) * * @since 3.2 @@ -204,6 +204,6 @@ public interface AuditService void auditQuery( AuditQueryCallback callback, String applicationName, String user, Long from, Long to, - String searchKey, String searchString, + String searchKey, Serializable searchValue, int maxResults); }