extremes)
+ {
+ return auditComponent.getAuditMinMaxByApp(applicationName, extremes);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getAuditEntriesCountByApp(String applicationName)
+ {
+ return auditComponent.getAuditEntriesCountByApp(applicationName);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getAuditEntriesCountByAppAndProperties(String applicationName, AuditQueryParameters parameters)
+ {
+ return auditComponent.getAuditEntriesCountByAppAndProperties(applicationName, parameters);
+ }
+}
diff --git a/repository/src/main/java/org/alfresco/repo/domain/CrcHelper.java b/repository/src/main/java/org/alfresco/repo/domain/CrcHelper.java
index d3cdb157b6..6163e666b7 100644
--- a/repository/src/main/java/org/alfresco/repo/domain/CrcHelper.java
+++ b/repository/src/main/java/org/alfresco/repo/domain/CrcHelper.java
@@ -1,123 +1,116 @@
-/*
- * #%L
- * Alfresco Repository
- * %%
- * Copyright (C) 2005 - 2024 Alfresco Software Limited
- * %%
- * This file is part of the Alfresco software.
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- * #L%
- */
-
-package org.alfresco.repo.domain;
-
-import java.io.UnsupportedEncodingException;
-import java.util.zip.CRC32;
-
-import org.alfresco.util.Pair;
-
-/**
- * Helper class to calculate CRC values for string persistence.
- *
- * @author Derek Hulley
- * @since 3.2
- */
-public class CrcHelper
-{
- public static final String EMPTY_STRING = ".empty";
-
- /**
- * Calculate a persistable, unique pair of values that can be persisted in a database unique
- * key and guarantee correct case-sensitivity.
- *
- * While the short-string version of the value is always lowercase, the CRC is
- * calculated from the virgin string if case-sensitivity is enforced; in the case-insensitive
- * case, the CRC is calculated from a lowercase version of the string.
- *
- * If the value is an empty string, then {@link #EMPTY_STRING} is used instead. This ensures
- * that persisted values don't fall foul of the Oracle empty string comparison "behaviour" i.e
- * you should never persist an empty string in Oracle as it equates to a SQL NULL.
- *
- * @param value the raw value that will be persisted
- * @param dataLength the maximum number of characters that can be persisted
- * @param useCharsFromStart true if the shortened string value must be made from
- * the first characters of the string or false to use
- * characters from the end of the string.
- * @param caseSensitive true if the resulting pair must be case-sensitive or
- * false if the pair must be case-insensitive.
- * @return Return the persistable pair. The result will never be null,
- * but the individual pair values will be null if the
- * value given is null
- */
- public static Pair getStringCrcPair(
- String value,
- int dataLength,
- boolean useCharsFromStart,
- boolean caseSensitive)
- {
- String valueLowerCase;
- if (value == null)
- {
- return new Pair(null, null);
- }
- else if (value.length() == 0)
- {
- value = CrcHelper.EMPTY_STRING;
- valueLowerCase = value;
- }
- else
- {
- valueLowerCase = value.toLowerCase();
- }
- Long valueCrc;
- try
- {
- CRC32 crc = new CRC32();
- if (caseSensitive)
- {
- crc.update(value.getBytes("UTF-8"));
- }
- else
- {
- crc.update(valueLowerCase.getBytes("UTF-8"));
- }
- valueCrc = crc.getValue();
- }
- catch (UnsupportedEncodingException e)
- {
- throw new RuntimeException("UTF-8 encoding is not supported");
- }
- // Crc Value will change based on the case-sensitive, So we need to get the short value based on case-sensitive
- String valueShort = null;
- String currentValue = caseSensitive ? value : valueLowerCase;
- int valueLen = currentValue.length();
- if (valueLen < dataLength)
- {
- valueShort = currentValue;
- }
- else if (useCharsFromStart)
- {
- valueShort = currentValue.substring(0, dataLength - 1);
- }
- else
- {
- valueShort = currentValue.substring(valueLen - dataLength);
- }
- return new Pair(valueShort, valueCrc);
- }
-}
\ No newline at end of file
+/*
+ * #%L
+ * Alfresco Repository
+ * %%
+ * Copyright (C) 2005 - 2016 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ * #L%
+ */
+
+package org.alfresco.repo.domain;
+
+import java.io.UnsupportedEncodingException;
+import java.util.zip.CRC32;
+
+import org.alfresco.util.Pair;
+
+/**
+ * Helper class to calculate CRC values for string persistence.
+ *
+ * @author Derek Hulley
+ * @since 3.2
+ */
+public class CrcHelper
+{
+ public static final String EMPTY_STRING = ".empty";
+
+ /**
+ * Calculate a persistable, unique pair of values that can be persisted in a database unique key and guarantee correct case-sensitivity.
+ *
+ * While the short-string version of the value is always lowercase, the CRC is calculated from the virgin string if case-sensitivity is enforced; in the case-insensitive case, the CRC is calculated from a lowercase version of the string.
+ *
+ * If the value is an empty string, then {@link #EMPTY_STRING} is used instead. This ensures that persisted values don't fall foul of the Oracle empty string comparison "behaviour" i.e you should never persist an empty string in Oracle as it equates to a SQL NULL.
+ *
+ * @param value
+ * the raw value that will be persisted
+ * @param dataLength
+ * the maximum number of characters that can be persisted
+ * @param useCharsFromStart
+ * true if the shortened string value must be made from the first characters of the string or false to use characters from the end of the string.
+ * @param caseSensitive
+ * true if the resulting pair must be case-sensitive or false if the pair must be case-insensitive.
+ * @return Return the persistable pair. The result will never be null, but the individual pair values will be null if the value given is null
+ */
+ public static Pair getStringCrcPair(
+ String value,
+ int dataLength,
+ boolean useCharsFromStart,
+ boolean caseSensitive)
+ {
+ String valueLowerCase;
+ if (value == null)
+ {
+ return new Pair(null, null);
+ }
+ else if (value.length() == 0)
+ {
+ value = CrcHelper.EMPTY_STRING;
+ valueLowerCase = value;
+ }
+ else
+ {
+ valueLowerCase = value.toLowerCase();
+ }
+ Long valueCrc;
+ try
+ {
+ CRC32 crc = new CRC32();
+ if (caseSensitive)
+ {
+ crc.update(value.getBytes("UTF-8"));
+ }
+ else
+ {
+ crc.update(valueLowerCase.getBytes("UTF-8"));
+ }
+ valueCrc = crc.getValue();
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new RuntimeException("UTF-8 encoding is not supported");
+ }
+ // Get the short value (case-sensitive or not)
+ String valueShort = null;
+ int valueLen = valueLowerCase.length();
+ if (valueLen < dataLength)
+ {
+ valueShort = valueLowerCase;
+ }
+ else if (useCharsFromStart)
+ {
+ valueShort = valueLowerCase.substring(0, dataLength - 1);
+ }
+ else
+ {
+ valueShort = valueLowerCase.substring(valueLen - dataLength);
+ }
+ return new Pair(valueShort, valueCrc);
+ }
+}
diff --git a/repository/src/main/java/org/alfresco/repo/domain/audit/AuditDAO.java b/repository/src/main/java/org/alfresco/repo/domain/audit/AuditDAO.java
index cac517706e..e2835c9dbf 100644
--- a/repository/src/main/java/org/alfresco/repo/domain/audit/AuditDAO.java
+++ b/repository/src/main/java/org/alfresco/repo/domain/audit/AuditDAO.java
@@ -1,258 +1,285 @@
-/*
- * #%L
- * Alfresco Repository
- * %%
- * Copyright (C) 2005 - 2024 Alfresco Software Limited
- * %%
- * This file is part of the Alfresco software.
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- * #L%
- */
-package org.alfresco.repo.domain.audit;
-
-import java.io.Serializable;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback;
-import org.alfresco.service.cmr.repository.ContentData;
-import org.alfresco.util.Pair;
-
-/**
- * DAO services for alf_audit_XXX tables.
- *
- * The older methods are supported by a different implementation and will eventually
- * be deprecated and phased out.
- *
- * @author Derek Hulley
- * @since 3.2
- */
-public interface AuditDAO
-{
- /*
- * V3.2 methods after here only, please
- */
-
- /**
- * Information about the audit application to be passed in an out of the interface.
- *
- * @author Derek Hulley
- * @since 3.2
- */
- public static class AuditApplicationInfo
- {
- private Long id;
- private String name;
- private Long modelId;
- private Long disabledPathsId;
-
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
- sb.append("AuditApplicationInfo ")
- .append("[ id=").append(id)
- .append(", name=").append(name)
- .append(", modelId=").append(modelId)
- .append(", disabledPathsId=").append(disabledPathsId)
- .append("]");
- return sb.toString();
- }
-
- public Long getId()
- {
- return id;
- }
- public void setId(Long id)
- {
- this.id = id;
- }
- public String getName()
- {
- return name;
- }
- public void setname(String name)
- {
- this.name = name;
- }
- public Long getModelId()
- {
- return modelId;
- }
- public void setModelId(Long modelId)
- {
- this.modelId = modelId;
- }
- public Long getDisabledPathsId()
- {
- return disabledPathsId;
- }
- public void setDisabledPathsId(Long disabledPathsId)
- {
- this.disabledPathsId = disabledPathsId;
- }
- }
-
- /**
- * Creates a new audit model entry or finds an existing one
- *
- * @param url the URL of the configuration
- * @return Returns the ID of the config matching the input stream and the
- * content storage details
- * @since 3.2
- */
- Pair getOrCreateAuditModel(URL url);
-
- /**
- * Get the audit application details.
- *
- * @param applicationName the name of the application
- * @return Returns details of an existing application or null if it doesn't exist
- *
- * @since 3.2
- */
- AuditApplicationInfo getAuditApplication(String applicationName);
-
- /**
- * Creates a new audit application. The application name must be unique.
- *
- * @param application the name of the application
- * @param modelId the ID of the model configuration
- *
- * @since 3.2
- */
- AuditApplicationInfo createAuditApplication(String application, Long modelId);
-
- /**
- * Update the audit application to refer to a new model.
- * If the model did not change, then nothing will be done.
- *
- * @param id the ID of the audit application
- * @param modelId the ID of the new model
- *
- * @since 3.2
- */
- void updateAuditApplicationModel(Long id, Long modelId);
-
- /**
- * Update the audit application to hold a new set of disabled paths.
- * If the value did not change, then nothing will be done.
- *
- * @param id the ID of the audit application
- * @param disabledPaths the new disabled paths
- *
- * @since 3.2
- */
- void updateAuditApplicationDisabledPaths(Long id, Set disabledPaths);
-
- /**
- * Delete audit entries for the application, possibly limiting the time range.
- *
- * @param applicationId an existing audit application ID
- * @param fromTime the minimum entry time (inclusive, optional)
- * @param toTime the maximum entry time (exclusive, optional)
- * @return Returns the number of entries deleted
- *
- * @since 3.2
- */
- int deleteAuditEntries(Long applicationId, Long fromTime, Long toTime);
-
- /**
- * Delete audit entries for the application for given id range.
- *
- * @param applicationId an existing audit application ID
- * @param fromId the minimum fromId (inclusive, optional)
- * @param toId the maximum toId (exclusive, optional)
- * @return Returns the number of entries deleted
- *
- * @since 5.2.2
- */
- int deleteAuditEntriesByIdRange(Long applicationId, Long fromId, Long toId);
-
- /**
- * Delete a discrete list of audit entries. Duplicate entries are collapsed
- * and the number of entries deleted will match the count of unique IDs in
- * the list; otherwise a concurrency condition has occured and an exception
- * will be generated.
- *
- * @param auditEntryIds the IDs of all audit entries to delete
- * @return Returns the number of entries deleted
- */
- int deleteAuditEntries(List auditEntryIds);
-
- /**
- * Create a new audit entry with the given map of values.
- *
- * @param applicationId an existing audit application ID
- * @param time the time (ms since epoch) to log the entry against
- * @param username the authenticated user (null if not present)
- * @param values the values to record
- * @return Returns the unique entry ID
- *
- * @since 3.2
- */
- Long createAuditEntry(Long applicationId, long time, String username, Map values);
-
- /**
- * Find audit entries using the given parameters, any of which may be null
- *
- * @param callback the data callback per entry
- * @param parameters the parameters for the query (may not be null)
- * @param maxResults the maximum number of results to retrieve (must be greater than 0)
- *
- * @throws IllegalArgumentException if maxResults less or equal to zero
- */
- void findAuditEntries(
- AuditQueryCallback callback,
- org.alfresco.service.cmr.audit.AuditQueryParameters parameters,
- int maxResults);
-
- /**
- * Issue an audit query to retrieve min / max audit record id for a given application.
- *
- * @param appId the database id of the application
- * @param extremes a list containing min/max or both
- * @return a map containing min/max and the associated value
- */
- HashMap getAuditMinMaxByApp(long appId, List 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;
- }
-
- /**
- * Issue an audit query to retrieve count of records for a given application and properties
- *
- * @param parameters audit parameters provided by the where
clause on the ReST API
- * @return a map containing min/max and the associated value
- */
- default int getAuditEntriesCountByAppAndProperties(org.alfresco.service.cmr.audit.AuditQueryParameters parameters)
- {
- return -1;
- }
-}
\ No newline at end of file
+/*
+ * #%L
+ * Alfresco Repository
+ * %%
+ * Copyright (C) 2005 - 2016 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ * #L%
+ */
+package org.alfresco.repo.domain.audit;
+
+import java.io.Serializable;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback;
+import org.alfresco.service.cmr.repository.ContentData;
+import org.alfresco.util.Pair;
+
+/**
+ * DAO services for alf_audit_XXX tables.
+ *
+ * The older methods are supported by a different implementation and will eventually be deprecated and phased out.
+ *
+ * @author Derek Hulley
+ * @since 3.2
+ */
+public interface AuditDAO
+{
+ /* V3.2 methods after here only, please */
+
+ /**
+ * Information about the audit application to be passed in an out of the interface.
+ *
+ * @author Derek Hulley
+ * @since 3.2
+ */
+ public static class AuditApplicationInfo
+ {
+ private Long id;
+ private String name;
+ private Long modelId;
+ private Long disabledPathsId;
+
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("AuditApplicationInfo ")
+ .append("[ id=").append(id)
+ .append(", name=").append(name)
+ .append(", modelId=").append(modelId)
+ .append(", disabledPathsId=").append(disabledPathsId)
+ .append("]");
+ return sb.toString();
+ }
+
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setname(String name)
+ {
+ this.name = name;
+ }
+
+ public Long getModelId()
+ {
+ return modelId;
+ }
+
+ public void setModelId(Long modelId)
+ {
+ this.modelId = modelId;
+ }
+
+ public Long getDisabledPathsId()
+ {
+ return disabledPathsId;
+ }
+
+ public void setDisabledPathsId(Long disabledPathsId)
+ {
+ this.disabledPathsId = disabledPathsId;
+ }
+ }
+
+ /**
+ * Creates a new audit model entry or finds an existing one
+ *
+ * @param url
+ * the URL of the configuration
+ * @return Returns the ID of the config matching the input stream and the content storage details
+ * @since 3.2
+ */
+ Pair getOrCreateAuditModel(URL url);
+
+ /**
+ * Get the audit application details.
+ *
+ * @param applicationName
+ * the name of the application
+ * @return Returns details of an existing application or null if it doesn't exist
+ *
+ * @since 3.2
+ */
+ AuditApplicationInfo getAuditApplication(String applicationName);
+
+ /**
+ * Creates a new audit application. The application name must be unique.
+ *
+ * @param application
+ * the name of the application
+ * @param modelId
+ * the ID of the model configuration
+ *
+ * @since 3.2
+ */
+ AuditApplicationInfo createAuditApplication(String application, Long modelId);
+
+ /**
+ * Update the audit application to refer to a new model. If the model did not change, then nothing will be done.
+ *
+ * @param id
+ * the ID of the audit application
+ * @param modelId
+ * the ID of the new model
+ *
+ * @since 3.2
+ */
+ void updateAuditApplicationModel(Long id, Long modelId);
+
+ /**
+ * Update the audit application to hold a new set of disabled paths. If the value did not change, then nothing will be done.
+ *
+ * @param id
+ * the ID of the audit application
+ * @param disabledPaths
+ * the new disabled paths
+ *
+ * @since 3.2
+ */
+ void updateAuditApplicationDisabledPaths(Long id, Set disabledPaths);
+
+ /**
+ * Delete audit entries for the application, possibly limiting the time range.
+ *
+ * @param applicationId
+ * an existing audit application ID
+ * @param fromTime
+ * the minimum entry time (inclusive, optional)
+ * @param toTime
+ * the maximum entry time (exclusive, optional)
+ * @return Returns the number of entries deleted
+ *
+ * @since 3.2
+ */
+ int deleteAuditEntries(Long applicationId, Long fromTime, Long toTime);
+
+ /**
+ * Delete audit entries for the application for given id range.
+ *
+ * @param applicationId
+ * an existing audit application ID
+ * @param fromId
+ * the minimum fromId (inclusive, optional)
+ * @param toId
+ * the maximum toId (exclusive, optional)
+ * @return Returns the number of entries deleted
+ *
+ * @since 5.2.2
+ */
+ int deleteAuditEntriesByIdRange(Long applicationId, Long fromId, Long toId);
+
+ /**
+ * Delete a discrete list of audit entries. Duplicate entries are collapsed and the number of entries deleted will match the count of unique IDs in the list; otherwise a concurrency condition has occured and an exception will be generated.
+ *
+ * @param auditEntryIds
+ * the IDs of all audit entries to delete
+ * @return Returns the number of entries deleted
+ */
+ int deleteAuditEntries(List auditEntryIds);
+
+ /**
+ * Create a new audit entry with the given map of values.
+ *
+ * @param applicationId
+ * an existing audit application ID
+ * @param time
+ * the time (ms since epoch) to log the entry against
+ * @param username
+ * the authenticated user (null if not present)
+ * @param values
+ * the values to record
+ * @return Returns the unique entry ID
+ *
+ * @since 3.2
+ */
+ Long createAuditEntry(Long applicationId, long time, String username, Map values);
+
+ /**
+ * Find audit entries using the given parameters, any of which may be null
+ *
+ * @param callback
+ * the data callback per entry
+ * @param parameters
+ * the parameters for the query (may not be null)
+ * @param maxResults
+ * the maximum number of results to retrieve (must be greater than 0)
+ *
+ * @throws IllegalArgumentException
+ * if maxResults less or equal to zero
+ */
+ void findAuditEntries(
+ AuditQueryCallback callback,
+ org.alfresco.service.cmr.audit.AuditQueryParameters parameters,
+ int maxResults);
+
+ /**
+ * Issue an audit query to retrieve min / max audit record id for a given application.
+ *
+ * @param appId
+ * the database id of the application
+ * @param extremes
+ * a list containing min/max or both
+ * @return a map containing min/max and the associated value
+ */
+ HashMap getAuditMinMaxByApp(long appId, List 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;
+ }
+
+ /**
+ * Issue an audit query to retrieve count of records for a given application and properties
+ *
+ * @param applicationName
+ * name of the application to be queried
+ * @param parameters
+ * audit parameters provided by the where
clause on the ReST API
+ * @return a map containing min/max and the associated value
+ */
+ default int getAuditEntriesCountByAppAndProperties(String applicationName, org.alfresco.service.cmr.audit.AuditQueryParameters parameters)
+ {
+ return -1;
+ }
+}
diff --git a/repository/src/main/java/org/alfresco/repo/domain/audit/ibatis/AuditDAOImpl.java b/repository/src/main/java/org/alfresco/repo/domain/audit/ibatis/AuditDAOImpl.java
index 12468dbf8e..78a922d615 100644
--- a/repository/src/main/java/org/alfresco/repo/domain/audit/ibatis/AuditDAOImpl.java
+++ b/repository/src/main/java/org/alfresco/repo/domain/audit/ibatis/AuditDAOImpl.java
@@ -1,316 +1,315 @@
-/*
- * #%L
- * Alfresco Repository
- * %%
- * Copyright (C) 2005 - 2024 Alfresco Software Limited
- * %%
- * This file is part of the Alfresco software.
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- * #L%
- */
-package org.alfresco.repo.domain.audit.ibatis;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import org.alfresco.repo.domain.audit.AbstractAuditDAOImpl;
-import org.alfresco.repo.domain.audit.AuditApplicationEntity;
-import org.alfresco.repo.domain.audit.AuditDeleteParameters;
-import org.alfresco.repo.domain.audit.AuditEntryEntity;
-import org.alfresco.repo.domain.audit.AuditModelEntity;
-import org.alfresco.repo.domain.audit.AuditQueryParameters;
-import org.alfresco.repo.domain.audit.AuditQueryResult;
-import org.alfresco.repo.domain.propval.PropertyValueDAO.PropertyFinderCallback;
-import org.alfresco.util.Pair;
-import org.apache.ibatis.session.RowBounds;
-import org.mybatis.spring.SqlSessionTemplate;
-import org.springframework.dao.ConcurrencyFailureException;
-
-/**
- * iBatis-specific implementation of the DAO for alf_audit_XXX tables.
- *
- * @author Derek Hulley
- * @since 3.2
- */
-public class AuditDAOImpl extends AbstractAuditDAOImpl
-{
- private static final String SELECT_MODEL_BY_CRC = "alfresco.audit.select_AuditModelByCrc";
- private static final String INSERT_MODEL = "alfresco.audit.insert.insert_AuditModel";
-
- private static final String SELECT_APPLICATION_BY_ID = "alfresco.audit.select_AuditApplicationById";
- private static final String SELECT_APPLICATION_BY_NAME_ID = "alfresco.audit.select_AuditApplicationByNameId";
- private static final String INSERT_APPLICATION = "alfresco.audit.insert.insert_AuditApplication";
- private static final String UPDATE_APPLICATION = "alfresco.audit.update_AuditApplication";
-
- private static final String DELETE_ENTRIES = "alfresco.audit.delete_AuditEntries";
- 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 SELECT_MINMAX_ENTRY_FOR_APP = "alfresco.audit.select_MinMaxAuditEntryId";
- private static final String SELECT_COUNT_ENTRIES_FOR_APP = "alfresco.audit.select_CountAuditEntryId";
- private static final String SELECT_COUNT_ENTRIES_FOR_APP_WITH_PROPERTIES = "select_CountAuditEntryIdWithWhereClause";
-
- @SuppressWarnings("unused")
- private static final String SELECT_ENTRIES_SIMPLE = "alfresco.audit.select_AuditEntriesSimple";
- private static final String SELECT_ENTRIES_WITH_VALUES = "alfresco.audit.select_AuditEntriesWithValues";
- private static final String SELECT_ENTRIES_WITHOUT_VALUES = "alfresco.audit.select_AuditEntriesWithoutValues";
-
- private SqlSessionTemplate template;
-
- public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate)
- {
- this.template = sqlSessionTemplate;
- }
-
- @Override
- protected AuditModelEntity getAuditModelByCrc(long crc)
- {
- AuditModelEntity entity = new AuditModelEntity();
- entity.setContentCrc(crc);
- entity = template.selectOne(
- SELECT_MODEL_BY_CRC,
- entity);
- // Done
- return entity;
- }
-
- @Override
- protected AuditModelEntity createAuditModel(Long contentDataId, long crc)
- {
- AuditModelEntity entity = new AuditModelEntity();
- entity.setContentDataId(contentDataId);
- entity.setContentCrc(crc);
- template.insert(INSERT_MODEL, entity);
- return entity;
- }
-
- @Override
- protected AuditApplicationEntity getAuditApplicationById(Long id)
- {
- Map params = new HashMap(11);
- params.put("id", id);
- AuditApplicationEntity entity = template.selectOne(
- SELECT_APPLICATION_BY_ID,
- params);
- // Done
- if (logger.isDebugEnabled())
- {
- logger.debug("Searched for audit application ID " + id + " and found: " + entity);
- }
- return entity;
- }
-
- @Override
- protected AuditApplicationEntity getAuditApplicationByName(String appName)
- {
- // Resolve the name as a property ID
- Pair appNamePair = propertyValueDAO.getPropertyValue(appName);
- if (appNamePair == null)
- {
- // There will be no results
- return null;
- }
-
- Map params = new HashMap(11);
- params.put("id", appNamePair.getFirst());
- AuditApplicationEntity entity = template.selectOne(
- SELECT_APPLICATION_BY_NAME_ID,
- params);
- // Done
- if (logger.isDebugEnabled())
- {
- logger.debug("Searched for audit application '" + appName + "' and found: " + entity);
- }
- return entity;
- }
-
- @Override
- protected AuditApplicationEntity createAuditApplication(Long appNameId, Long modelId, Long disabledPathsId)
- {
- AuditApplicationEntity entity = new AuditApplicationEntity();
- entity.setVersion((short)0);
- entity.setApplicationNameId(appNameId);
- entity.setAuditModelId(modelId);
- entity.setDisabledPathsId(disabledPathsId);
- template.insert(INSERT_APPLICATION, entity);
- return entity;
- }
-
- @Override
- protected AuditApplicationEntity updateAuditApplication(AuditApplicationEntity entity)
- {
- AuditApplicationEntity updateEntity = new AuditApplicationEntity();
- updateEntity.setId(entity.getId());
- updateEntity.setVersion(entity.getVersion());
- updateEntity.incrementVersion();
- updateEntity.setApplicationNameId(entity.getApplicationNameId());
- updateEntity.setAuditModelId(entity.getAuditModelId());
- updateEntity.setDisabledPathsId(entity.getDisabledPathsId());
-
- int updated = template.update(UPDATE_APPLICATION, updateEntity);
- if (updated != 1)
- {
- // unexpected number of rows affected
- throw new ConcurrencyFailureException("Incorrect number of rows affected for updateAuditApplication: " + updateEntity + ": expected 1, actual " + updated);
- }
-
- // Done
- return updateEntity;
- }
-
- public int deleteAuditEntries(Long applicationId, Long from, Long to)
- {
- AuditDeleteParameters params = new AuditDeleteParameters();
- params.setAuditApplicationId(applicationId);
- params.setAuditFromTime(from);
- params.setAuditToTime(to);
- return template.delete(DELETE_ENTRIES, params);
- }
-
- public int deleteAuditEntriesByIdRange(Long applicationId, Long fromId, Long toId)
- {
- AuditDeleteParameters params = new AuditDeleteParameters();
- params.setAuditApplicationId(applicationId);
- params.setAuditFromId(fromId);
- params.setAuditToId(toId);
- return template.delete(DELETE_ENTRIES, params);
- }
-
- @Override
- protected int deleteAuditEntriesImpl(List auditEntryIds)
- {
- AuditDeleteParameters params = new AuditDeleteParameters();
- params.setAuditEntryIds(auditEntryIds);
- return template.delete(DELETE_ENTRIES_BY_ID, params);
- }
-
- @Override
- protected AuditEntryEntity createAuditEntry(Long applicationId, long time, Long usernameId, Long valuesId)
- {
- AuditEntryEntity entity = new AuditEntryEntity();
- entity.setAuditApplicationId(applicationId);
- entity.setAuditTime(time);
- entity.setAuditUserId(usernameId);
- entity.setAuditValuesId(valuesId);
- template.insert(INSERT_ENTRY, entity);
- return entity;
- }
-
- public HashMap getAuditMinMaxByApp(long appId, List extremes)
- {
- // Build parameters to be used in the query. Filter the duplicates when inserting into map
- Map params = extremes.stream().collect(Collectors.toMap(s -> s, s -> Boolean.TRUE, (s1, s2) -> s1));
- params.put("auditAppId", appId);
-
- HashMap result = template.selectOne(SELECT_MINMAX_ENTRY_FOR_APP, params);
-
- return result;
- }
-
- @Override
- public int getAuditEntriesCountByApp(long applicationId)
- {
- Map params = new HashMap<>();
- params.put("auditAppId", applicationId);
-
- int result = template.selectOne(SELECT_COUNT_ENTRIES_FOR_APP, params);
-
- return result;
- }
-
- @Override
- public int getAuditEntriesCountByAppAndProperties(org.alfresco.service.cmr.audit.AuditQueryParameters parameters)
- {
- AuditQueryParameters dbParameters = convertFromRestAuditQueryParameters(parameters);
-
- int result = template.selectOne(SELECT_COUNT_ENTRIES_FOR_APP_WITH_PROPERTIES, dbParameters);
-
- return result;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected void findAuditEntries(
- final AuditQueryRowHandler rowHandler,
- int maxResults,
- org.alfresco.service.cmr.audit.AuditQueryParameters restParameters)
- {
- AuditQueryParameters params = convertFromRestAuditQueryParameters(restParameters);
- if (params==null)
- {
- return;
- }
-
- if (maxResults > 0)
- {
- // Query without getting the values. We gather all the results and batch-fetch the audited
- // values afterwards.
- final Map resultsByValueId = new HashMap(173);
- PropertyFinderCallback propertyFinderCallback = new PropertyFinderCallback()
- {
- public void handleProperty(Long id, Serializable value)
- {
- // get the row
- AuditQueryResult row = resultsByValueId.get(id);
- try
- {
- row.setAuditValue((Map) value);
- }
- catch (ClassCastException e)
- {
- // The handler will deal with the entry
- }
- }
- };
-
- List rows = template.selectList(SELECT_ENTRIES_WITHOUT_VALUES, params, new RowBounds(0, maxResults));
- for (AuditQueryResult row : rows)
- {
- resultsByValueId.put(row.getAuditValuesId(), row);
- if (resultsByValueId.size() >= 100)
- {
- // Fetch values for the results. The treemap is ordered.
- List valueIds = new ArrayList(resultsByValueId.keySet());
- propertyValueDAO.getPropertiesByIds(valueIds, propertyFinderCallback);
- // Clear and continue
- resultsByValueId.clear();
- }
- }
- // Process any remaining results
- if (resultsByValueId.size() > 0)
- {
- // Fetch values for the results. The treemap is ordered.
- List valueIds = new ArrayList(resultsByValueId.keySet());
- propertyValueDAO.getPropertiesByIds(valueIds, propertyFinderCallback);
- }
- // Now pass the filled-out results to the row handler (order-preserved)
- for (AuditQueryResult row : rows)
- {
- rowHandler.processResult(row);
- }
- }
- else
- {
- throw new IllegalArgumentException("maxResults must be greater than 0");
- }
- }
-}
-
+/*
+ * #%L
+ * Alfresco Repository
+ * %%
+ * Copyright (C) 2005 - 2016 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ * #L%
+ */
+package org.alfresco.repo.domain.audit.ibatis;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import org.apache.ibatis.session.RowBounds;
+import org.mybatis.spring.SqlSessionTemplate;
+import org.springframework.dao.ConcurrencyFailureException;
+
+import org.alfresco.repo.domain.audit.AbstractAuditDAOImpl;
+import org.alfresco.repo.domain.audit.AuditApplicationEntity;
+import org.alfresco.repo.domain.audit.AuditDeleteParameters;
+import org.alfresco.repo.domain.audit.AuditEntryEntity;
+import org.alfresco.repo.domain.audit.AuditModelEntity;
+import org.alfresco.repo.domain.audit.AuditQueryParameters;
+import org.alfresco.repo.domain.audit.AuditQueryResult;
+import org.alfresco.repo.domain.propval.PropertyValueDAO.PropertyFinderCallback;
+import org.alfresco.util.Pair;
+
+/**
+ * iBatis-specific implementation of the DAO for alf_audit_XXX tables.
+ *
+ * @author Derek Hulley
+ * @since 3.2
+ */
+public class AuditDAOImpl extends AbstractAuditDAOImpl
+{
+ private static final String SELECT_MODEL_BY_CRC = "alfresco.audit.select_AuditModelByCrc";
+ private static final String INSERT_MODEL = "alfresco.audit.insert.insert_AuditModel";
+
+ private static final String SELECT_APPLICATION_BY_ID = "alfresco.audit.select_AuditApplicationById";
+ private static final String SELECT_APPLICATION_BY_NAME_ID = "alfresco.audit.select_AuditApplicationByNameId";
+ private static final String INSERT_APPLICATION = "alfresco.audit.insert.insert_AuditApplication";
+ private static final String UPDATE_APPLICATION = "alfresco.audit.update_AuditApplication";
+
+ private static final String DELETE_ENTRIES = "alfresco.audit.delete_AuditEntries";
+ 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 SELECT_MINMAX_ENTRY_FOR_APP = "alfresco.audit.select_MinMaxAuditEntryId";
+ private static final String SELECT_COUNT_ENTRIES_FOR_APP = "alfresco.audit.select_CountAuditEntryId";
+ private static final String SELECT_COUNT_ENTRIES_FOR_APP_WITH_PROPERTIES = "select_CountAuditEntryIdWithWhereClause";
+
+ @SuppressWarnings("unused")
+ private static final String SELECT_ENTRIES_SIMPLE = "alfresco.audit.select_AuditEntriesSimple";
+ private static final String SELECT_ENTRIES_WITH_VALUES = "alfresco.audit.select_AuditEntriesWithValues";
+ private static final String SELECT_ENTRIES_WITHOUT_VALUES = "alfresco.audit.select_AuditEntriesWithoutValues";
+
+ private SqlSessionTemplate template;
+
+ public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate)
+ {
+ this.template = sqlSessionTemplate;
+ }
+
+ @Override
+ protected AuditModelEntity getAuditModelByCrc(long crc)
+ {
+ AuditModelEntity entity = new AuditModelEntity();
+ entity.setContentCrc(crc);
+ entity = template.selectOne(
+ SELECT_MODEL_BY_CRC,
+ entity);
+ // Done
+ return entity;
+ }
+
+ @Override
+ protected AuditModelEntity createAuditModel(Long contentDataId, long crc)
+ {
+ AuditModelEntity entity = new AuditModelEntity();
+ entity.setContentDataId(contentDataId);
+ entity.setContentCrc(crc);
+ template.insert(INSERT_MODEL, entity);
+ return entity;
+ }
+
+ @Override
+ protected AuditApplicationEntity getAuditApplicationById(Long id)
+ {
+ Map params = new HashMap(11);
+ params.put("id", id);
+ AuditApplicationEntity entity = template.selectOne(
+ SELECT_APPLICATION_BY_ID,
+ params);
+ // Done
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("Searched for audit application ID " + id + " and found: " + entity);
+ }
+ return entity;
+ }
+
+ @Override
+ protected AuditApplicationEntity getAuditApplicationByName(String appName)
+ {
+ // Resolve the name as a property ID
+ Pair appNamePair = propertyValueDAO.getPropertyValue(appName);
+ if (appNamePair == null)
+ {
+ // There will be no results
+ return null;
+ }
+
+ Map params = new HashMap(11);
+ params.put("id", appNamePair.getFirst());
+ AuditApplicationEntity entity = template.selectOne(
+ SELECT_APPLICATION_BY_NAME_ID,
+ params);
+ // Done
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("Searched for audit application '" + appName + "' and found: " + entity);
+ }
+ return entity;
+ }
+
+ @Override
+ protected AuditApplicationEntity createAuditApplication(Long appNameId, Long modelId, Long disabledPathsId)
+ {
+ AuditApplicationEntity entity = new AuditApplicationEntity();
+ entity.setVersion((short) 0);
+ entity.setApplicationNameId(appNameId);
+ entity.setAuditModelId(modelId);
+ entity.setDisabledPathsId(disabledPathsId);
+ template.insert(INSERT_APPLICATION, entity);
+ return entity;
+ }
+
+ @Override
+ protected AuditApplicationEntity updateAuditApplication(AuditApplicationEntity entity)
+ {
+ AuditApplicationEntity updateEntity = new AuditApplicationEntity();
+ updateEntity.setId(entity.getId());
+ updateEntity.setVersion(entity.getVersion());
+ updateEntity.incrementVersion();
+ updateEntity.setApplicationNameId(entity.getApplicationNameId());
+ updateEntity.setAuditModelId(entity.getAuditModelId());
+ updateEntity.setDisabledPathsId(entity.getDisabledPathsId());
+
+ int updated = template.update(UPDATE_APPLICATION, updateEntity);
+ if (updated != 1)
+ {
+ // unexpected number of rows affected
+ throw new ConcurrencyFailureException("Incorrect number of rows affected for updateAuditApplication: " + updateEntity + ": expected 1, actual " + updated);
+ }
+
+ // Done
+ return updateEntity;
+ }
+
+ public int deleteAuditEntries(Long applicationId, Long from, Long to)
+ {
+ AuditDeleteParameters params = new AuditDeleteParameters();
+ params.setAuditApplicationId(applicationId);
+ params.setAuditFromTime(from);
+ params.setAuditToTime(to);
+ return template.delete(DELETE_ENTRIES, params);
+ }
+
+ public int deleteAuditEntriesByIdRange(Long applicationId, Long fromId, Long toId)
+ {
+ AuditDeleteParameters params = new AuditDeleteParameters();
+ params.setAuditApplicationId(applicationId);
+ params.setAuditFromId(fromId);
+ params.setAuditToId(toId);
+ return template.delete(DELETE_ENTRIES, params);
+ }
+
+ @Override
+ protected int deleteAuditEntriesImpl(List auditEntryIds)
+ {
+ AuditDeleteParameters params = new AuditDeleteParameters();
+ params.setAuditEntryIds(auditEntryIds);
+ return template.delete(DELETE_ENTRIES_BY_ID, params);
+ }
+
+ @Override
+ protected AuditEntryEntity createAuditEntry(Long applicationId, long time, Long usernameId, Long valuesId)
+ {
+ AuditEntryEntity entity = new AuditEntryEntity();
+ entity.setAuditApplicationId(applicationId);
+ entity.setAuditTime(time);
+ entity.setAuditUserId(usernameId);
+ entity.setAuditValuesId(valuesId);
+ template.insert(INSERT_ENTRY, entity);
+ return entity;
+ }
+
+ public HashMap getAuditMinMaxByApp(long appId, List extremes)
+ {
+ // Build parameters to be used in the query. Filter the duplicates when inserting into map
+ Map params = extremes.stream().collect(Collectors.toMap(s -> s, s -> Boolean.TRUE, (s1, s2) -> s1));
+ params.put("auditAppId", appId);
+
+ HashMap result = template.selectOne(SELECT_MINMAX_ENTRY_FOR_APP, params);
+
+ return result;
+ }
+
+ @Override
+ public int getAuditEntriesCountByApp(long applicationId)
+ {
+ Map params = new HashMap<>();
+ params.put("auditAppId", applicationId);
+
+ int result = template.selectOne(SELECT_COUNT_ENTRIES_FOR_APP, params);
+
+ return result;
+ }
+
+ @Override
+ public int getAuditEntriesCountByAppAndProperties(String applicationName, org.alfresco.service.cmr.audit.AuditQueryParameters parameters)
+ {
+ AuditQueryParameters dbParameters = convertFromRestAuditQueryParameters(parameters);
+
+ int result = template.selectOne(SELECT_COUNT_ENTRIES_FOR_APP_WITH_PROPERTIES, dbParameters);
+
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void findAuditEntries(
+ final AuditQueryRowHandler rowHandler,
+ int maxResults,
+ org.alfresco.service.cmr.audit.AuditQueryParameters restParameters)
+ {
+ AuditQueryParameters params = convertFromRestAuditQueryParameters(restParameters);
+ if (params == null)
+ {
+ return;
+ }
+
+ if (maxResults > 0)
+ {
+ // Query without getting the values. We gather all the results and batch-fetch the audited
+ // values afterwards.
+ final Map resultsByValueId = new HashMap(173);
+ PropertyFinderCallback propertyFinderCallback = new PropertyFinderCallback() {
+ public void handleProperty(Long id, Serializable value)
+ {
+ // get the row
+ AuditQueryResult row = resultsByValueId.get(id);
+ try
+ {
+ row.setAuditValue((Map) value);
+ }
+ catch (ClassCastException e)
+ {
+ // The handler will deal with the entry
+ }
+ }
+ };
+
+ List rows = template.selectList(SELECT_ENTRIES_WITHOUT_VALUES, params, new RowBounds(0, maxResults));
+ for (AuditQueryResult row : rows)
+ {
+ resultsByValueId.put(row.getAuditValuesId(), row);
+ if (resultsByValueId.size() >= 100)
+ {
+ // Fetch values for the results. The treemap is ordered.
+ List valueIds = new ArrayList(resultsByValueId.keySet());
+ propertyValueDAO.getPropertiesByIds(valueIds, propertyFinderCallback);
+ // Clear and continue
+ resultsByValueId.clear();
+ }
+ }
+ // Process any remaining results
+ if (resultsByValueId.size() > 0)
+ {
+ // Fetch values for the results. The treemap is ordered.
+ List valueIds = new ArrayList(resultsByValueId.keySet());
+ propertyValueDAO.getPropertiesByIds(valueIds, propertyFinderCallback);
+ }
+ // Now pass the filled-out results to the row handler (order-preserved)
+ for (AuditQueryResult row : rows)
+ {
+ rowHandler.processResult(row);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("maxResults must be greater than 0");
+ }
+ }
+}
diff --git a/repository/src/main/java/org/alfresco/repo/domain/propval/PropertyStringValueEntity.java b/repository/src/main/java/org/alfresco/repo/domain/propval/PropertyStringValueEntity.java
index 56e188fbf6..6a396ed0f4 100644
--- a/repository/src/main/java/org/alfresco/repo/domain/propval/PropertyStringValueEntity.java
+++ b/repository/src/main/java/org/alfresco/repo/domain/propval/PropertyStringValueEntity.java
@@ -1,173 +1,158 @@
-/*
- * #%L
- * Alfresco Repository
- * %%
- * Copyright (C) 2005 - 2024 Alfresco Software Limited
- * %%
- * This file is part of the Alfresco software.
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- * #L%
- */
-package org.alfresco.repo.domain.propval;
-
-import org.alfresco.repo.domain.CrcHelper;
-import org.alfresco.util.EqualsHelper;
-import org.alfresco.util.Pair;
-
-/**
- * Entity bean for alf_prop_string_value table.
- *
- * @author Derek Hulley
- * @since 3.2
- */
-public class PropertyStringValueEntity
-{
- public static final String EMPTY_STRING = "";
- public static final String EMPTY_STRING_REPLACEMENT = ".empty";
-
- private Long id;
- private String stringValue;
- private String stringEndLower;
- private Long stringCrc;
- private String stringLower;
-
- public PropertyStringValueEntity()
- {
- }
-
- @Override
- public int hashCode()
- {
- return (stringValue == null ? 0 : stringValue.hashCode());
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- {
- return true;
- }
- else if (obj != null && obj instanceof PropertyStringValueEntity)
- {
- PropertyStringValueEntity that = (PropertyStringValueEntity) obj;
- return EqualsHelper.nullSafeEquals(this.stringValue, that.stringValue);
- }
- else
- {
- return false;
- }
- }
-
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder(512);
- sb.append("PropertyStringValueEntity")
- .append("[ ID=").append(id)
- .append(", stringValue=").append(stringValue)
- .append("]");
- return sb.toString();
- }
-
- public Pair getEntityPair()
- {
- if (stringValue != null && stringValue.equals(PropertyStringValueEntity.EMPTY_STRING_REPLACEMENT))
- {
- return new Pair(id, PropertyStringValueEntity.EMPTY_STRING);
- }
- else
- {
- return new Pair(id, stringValue);
- }
- }
-
- /**
- * Set the string and string-end values
- */
- public void setValue(String value)
- {
- if (value == null)
- {
- throw new IllegalArgumentException("Null strings cannot be persisted");
- }
- if (value != null && value.equals(PropertyStringValueEntity.EMPTY_STRING))
- {
- // Oracle: We can't insert empty strings into the column.
- value = PropertyStringValueEntity.EMPTY_STRING_REPLACEMENT;
- }
- stringValue = value;
- // Calculate the crc value from the original value
- Pair crcPair = CrcHelper.getStringCrcPair(value, 16, false, true);
- stringEndLower = crcPair.getFirst();
- stringCrc = crcPair.getSecond();
- // Calculate the crc value with case-insensitive
- Pair crcPairWithCaseInSensitive = CrcHelper.getStringCrcPair(value, 16, false, false);
- stringLower = crcPairWithCaseInSensitive.getFirst();
- }
-
- public Long getId()
- {
- return id;
- }
-
- public void setId(Long id)
- {
- this.id = id;
- }
-
- public String getStringValue()
- {
- return stringValue;
- }
-
- public void setStringValue(String stringValue)
- {
- this.stringValue = stringValue;
- }
-
- public String getStringEndLower()
- {
- return stringEndLower;
- }
-
- public void setStringEndLower(String stringEndLower)
- {
- this.stringEndLower = stringEndLower;
- }
-
- public Long getStringCrc()
- {
- return stringCrc;
- }
-
- public void setStringCrc(Long stringCrc)
- {
- this.stringCrc = stringCrc;
- }
-
- public String getStringLower()
- {
- return stringLower;
- }
-
- public void setStringLower(String stringLower)
- {
- this.stringLower = stringLower;
- }
-}
+/*
+ * #%L
+ * Alfresco Repository
+ * %%
+ * Copyright (C) 2005 - 2016 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ * #L%
+ */
+package org.alfresco.repo.domain.propval;
+
+import org.alfresco.repo.domain.CrcHelper;
+import org.alfresco.util.EqualsHelper;
+import org.alfresco.util.Pair;
+
+/**
+ * Entity bean for alf_prop_string_value table.
+ *
+ * @author Derek Hulley
+ * @since 3.2
+ */
+public class PropertyStringValueEntity
+{
+ public static final String EMPTY_STRING = "";
+ public static final String EMPTY_STRING_REPLACEMENT = ".empty";
+
+ private Long id;
+ private String stringValue;
+ private String stringEndLower;
+ private Long stringCrc;
+
+ public PropertyStringValueEntity()
+ {}
+
+ @Override
+ public int hashCode()
+ {
+ return (stringValue == null ? 0 : stringValue.hashCode());
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ else if (obj != null && obj instanceof PropertyStringValueEntity)
+ {
+ PropertyStringValueEntity that = (PropertyStringValueEntity) obj;
+ return EqualsHelper.nullSafeEquals(this.stringValue, that.stringValue);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder(512);
+ sb.append("PropertyStringValueEntity")
+ .append("[ ID=").append(id)
+ .append(", stringValue=").append(stringValue)
+ .append("]");
+ return sb.toString();
+ }
+
+ public Pair getEntityPair()
+ {
+ if (stringValue != null && stringValue.equals(PropertyStringValueEntity.EMPTY_STRING_REPLACEMENT))
+ {
+ return new Pair(id, PropertyStringValueEntity.EMPTY_STRING);
+ }
+ else
+ {
+ return new Pair(id, stringValue);
+ }
+ }
+
+ /**
+ * Set the string and string-end values
+ */
+ public void setValue(String value)
+ {
+ if (value == null)
+ {
+ throw new IllegalArgumentException("Null strings cannot be persisted");
+ }
+ if (value != null && value.equals(PropertyStringValueEntity.EMPTY_STRING))
+ {
+ // Oracle: We can't insert empty strings into the column.
+ value = PropertyStringValueEntity.EMPTY_STRING_REPLACEMENT;
+ }
+ stringValue = value;
+ // Calculate the crc value from the original value
+ Pair crcPair = CrcHelper.getStringCrcPair(value, 16, false, true);
+ stringEndLower = crcPair.getFirst();
+ stringCrc = crcPair.getSecond();
+ }
+
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ public String getStringValue()
+ {
+ return stringValue;
+ }
+
+ public void setStringValue(String stringValue)
+ {
+ this.stringValue = stringValue;
+ }
+
+ public String getStringEndLower()
+ {
+ return stringEndLower;
+ }
+
+ public void setStringEndLower(String stringEndLower)
+ {
+ this.stringEndLower = stringEndLower;
+ }
+
+ public Long getStringCrc()
+ {
+ return stringCrc;
+ }
+
+ public void setStringCrc(Long stringCrc)
+ {
+ this.stringCrc = stringCrc;
+ }
+}
diff --git a/repository/src/main/java/org/alfresco/service/cmr/audit/AuditService.java b/repository/src/main/java/org/alfresco/service/cmr/audit/AuditService.java
index bbb2f886ac..d02e2ee711 100644
--- a/repository/src/main/java/org/alfresco/service/cmr/audit/AuditService.java
+++ b/repository/src/main/java/org/alfresco/service/cmr/audit/AuditService.java
@@ -1,266 +1,298 @@
-/*
- * #%L
- * Alfresco Repository
- * %%
- * Copyright (C) 2005 - 2024 Alfresco Software Limited
- * %%
- * This file is part of the Alfresco software.
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- * #L%
- */
-package org.alfresco.service.cmr.audit;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * The public API by which applications can query the audit logs and enable or disable auditing.
- *
- * @author Derek Hulley
- */
-public interface AuditService
-{
- /**
- * @return Returns true if auditing is globally enabled
- *
- * @since 3.4
- */
- boolean isAuditEnabled();
-
- /**
- * Enable or disable the global auditing state
- *
- * @param enable true to enable auditing globally or false to disable
- *
- * @since 3.4
- */
- void setAuditEnabled(boolean enable);
-
- /**
- * Helper bean to carry information about an audit application.
- *
- * @author Derek Hulley
- * @since 3.4
- */
- public static class AuditApplication
- {
- private final String name;
- private final String key;
- private final boolean enabled;
- /**
- * Constructor for final variables
- */
- public AuditApplication(String name, String key, boolean enabled)
- {
- this.name = name;
- this.key = key;
- this.enabled = enabled;
- }
- public String getName()
- {
- return name;
- }
- public String getKey()
- {
- return key;
- }
- public boolean isEnabled()
- {
- return enabled;
- }
- }
-
- /**
- * Get all registered audit applications
- *
- * @return Returns a map of audit applications keyed by their name
- *
- * @since 3.4
- */
- Map getAuditApplications();
-
- /**
- * @param applicationName the name of the application to check
- * @param path the path to check
- * @return Returns true if auditing is enabled for the given path
- *
- * @since 3.2
- */
- boolean isAuditEnabled(String applicationName, String path);
-
- /**
- * Enable auditing for an application path
- *
- * @param applicationName the name of the application to check
- * @param path the path to enable
- *
- * @since 3.2
- */
- void enableAudit(String applicationName, String path);
-
- /**
- * Disable auditing for an application path
- *
- * @param applicationName the name of the application to check
- * @param path the path to disable
- *
- * @since 3.2
- */
- void disableAudit(String applicationName, String path);
-
- /**
- * Remove all audit entries for the given application
- *
- * @param applicationName the name of the application for which to remove entries
- * @return Returns the number of audit entries deleted
- *
- * @since 3.2
- *
- * @deprecated Use {@link #clearAudit(String, Long, Long)}
- */
- int clearAudit(String applicationName);
-
- /**
- * Remove audit entries for the given application between the time ranges. If no start
- * time is given then entries are deleted as far back as they exist. If no end time is
- * given then entries are deleted up until the current time.
- *
- * @param applicationName the name of the application for which to remove entries
- * @param fromTime the start time of entries to remove (inclusive and optional)
- * @param toTime the end time of entries to remove (exclusive and optional)
- * @return Returns the number of audit entries deleted
- *
- * @since 3.4
- */
- int clearAudit(String applicationName, Long fromTime, Long toTime);
-
- /**
- * Remove audit entries for the given application between the audit entry ids.
- *
- * @param applicationName the name of the application for which to remove entries
- * @param fromId the start time of entries to remove (inclusive and optional)
- * @param toId the end time of entries to remove (exclusive and optional)
- * @return Returns the number of audit entries deleted
- *
- * @since 5.2.2
- */
- int clearAuditByIdRange(String applicationName, Long fromId, Long toId);
-
- /**
- * Delete a discrete list of audit entries.
- *
- * This method should not be called while processing
- * {@link #auditQuery(AuditQueryCallback, AuditQueryParameters, int) query results}.
- *
- * @param auditEntryIds the IDs of all audit entries to delete
- * @return Returns the number of audit entries deleted
- *
- * @since 3.4
- */
- int clearAudit(List auditEntryIds);
-
- /**
- * The interface that will be used to give query results to the calling code.
- *
- * @since 3.2
- */
- public static interface AuditQueryCallback
- {
- /**
- * Determines whether this callback requires the values argument to be populated when {@link #handleAuditEntry}
- * is called.
- *
- * @return true
if this callback requires the values argument to be populated
- */
- boolean valuesRequired();
-
- /**
- * Handle a row of audit entry data.
- *
- * @param entryId the unique audit entry ID
- * @param applicationName the name of the application
- * @param user the user that logged the entry
- * @param time the time of the entry
- * @param values the values map as created
- * @return Return true to continue processing rows or false to stop
- */
- boolean handleAuditEntry(
- Long entryId,
- String applicationName,
- String user,
- long time,
- Map values);
-
- /**
- * Handle audit entry failures
- *
- * @param entryId the entry ID
- * @param errorMsg the error message
- * @param error the exception causing the error (may be null)
- * @return Return true to continue processing rows or false to stop
- */
- boolean handleAuditEntryError(Long entryId, String errorMsg, Throwable error);
- }
-
- /**
- * Issue an audit query using the given parameters and consuming results in the callback.
- * Results are returned in entry order, corresponding to time order.
- *
- * @param callback the callback that will handle results
- * @param parameters the parameters for the query (may not be null)
- * @param maxResults the maximum number of results to retrieve (must be greater than 0)
- *
- * @throws IllegalArgumentException if maxResults less or equal to zero
- *
- * @since 3.3
- */
- void auditQuery(AuditQueryCallback callback, AuditQueryParameters parameters, int maxResults);
-
- /**
- * Issue an audit query to retrieve min / max audit record id for a given application.
- *
- * @param applicationName the name of the application
- * @param extremes a list containing min/max or both
- * @return a map containing min/max and the associated value
- */
- HashMap getAuditMinMaxByApp(String applicationName, List 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;
- }
-
- /**
- * Issue an audit query to retrieve min / max audit record id for a given application and properties
- *
- * @param parameters audit parameters provided by the where
clause on the ReST API
- * @return a map containing min/max and the associated value
- */
- default int getAuditEntriesCountByAppAndProperties(AuditQueryParameters parameters)
- {
- return -1;
- }
-}
+/*
+ * #%L
+ * Alfresco Repository
+ * %%
+ * Copyright (C) 2005 - 2016 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ * #L%
+ */
+package org.alfresco.service.cmr.audit;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The public API by which applications can query the audit logs and enable or disable auditing.
+ *
+ * @author Derek Hulley
+ */
+public interface AuditService
+{
+ /**
+ * @return Returns true if auditing is globally enabled
+ *
+ * @since 3.4
+ */
+ boolean isAuditEnabled();
+
+ /**
+ * Enable or disable the global auditing state
+ *
+ * @param enable
+ * true to enable auditing globally or false to disable
+ *
+ * @since 3.4
+ */
+ void setAuditEnabled(boolean enable);
+
+ /**
+ * Helper bean to carry information about an audit application.
+ *
+ * @author Derek Hulley
+ * @since 3.4
+ */
+ public static class AuditApplication
+ {
+ private final String name;
+ private final String key;
+ private final boolean enabled;
+
+ /**
+ * Constructor for final variables
+ */
+ public AuditApplication(String name, String key, boolean enabled)
+ {
+ this.name = name;
+ this.key = key;
+ this.enabled = enabled;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public boolean isEnabled()
+ {
+ return enabled;
+ }
+ }
+
+ /**
+ * Get all registered audit applications
+ *
+ * @return Returns a map of audit applications keyed by their name
+ *
+ * @since 3.4
+ */
+ Map getAuditApplications();
+
+ /**
+ * @param applicationName
+ * the name of the application to check
+ * @param path
+ * the path to check
+ * @return Returns true if auditing is enabled for the given path
+ *
+ * @since 3.2
+ */
+ boolean isAuditEnabled(String applicationName, String path);
+
+ /**
+ * Enable auditing for an application path
+ *
+ * @param applicationName
+ * the name of the application to check
+ * @param path
+ * the path to enable
+ *
+ * @since 3.2
+ */
+ void enableAudit(String applicationName, String path);
+
+ /**
+ * Disable auditing for an application path
+ *
+ * @param applicationName
+ * the name of the application to check
+ * @param path
+ * the path to disable
+ *
+ * @since 3.2
+ */
+ void disableAudit(String applicationName, String path);
+
+ /**
+ * Remove all audit entries for the given application
+ *
+ * @param applicationName
+ * the name of the application for which to remove entries
+ * @return Returns the number of audit entries deleted
+ *
+ * @since 3.2
+ *
+ * @deprecated Use {@link #clearAudit(String, Long, Long)}
+ */
+ int clearAudit(String applicationName);
+
+ /**
+ * Remove audit entries for the given application between the time ranges. If no start time is given then entries are deleted as far back as they exist. If no end time is given then entries are deleted up until the current time.
+ *
+ * @param applicationName
+ * the name of the application for which to remove entries
+ * @param fromTime
+ * the start time of entries to remove (inclusive and optional)
+ * @param toTime
+ * the end time of entries to remove (exclusive and optional)
+ * @return Returns the number of audit entries deleted
+ *
+ * @since 3.4
+ */
+ int clearAudit(String applicationName, Long fromTime, Long toTime);
+
+ /**
+ * Remove audit entries for the given application between the audit entry ids.
+ *
+ * @param applicationName
+ * the name of the application for which to remove entries
+ * @param fromId
+ * the start time of entries to remove (inclusive and optional)
+ * @param toId
+ * the end time of entries to remove (exclusive and optional)
+ * @return Returns the number of audit entries deleted
+ *
+ * @since 5.2.2
+ */
+ int clearAuditByIdRange(String applicationName, Long fromId, Long toId);
+
+ /**
+ * Delete a discrete list of audit entries.
+ *
+ * This method should not be called while processing {@link #auditQuery(AuditQueryCallback, AuditQueryParameters, int) query results}.
+ *
+ * @param auditEntryIds
+ * the IDs of all audit entries to delete
+ * @return Returns the number of audit entries deleted
+ *
+ * @since 3.4
+ */
+ int clearAudit(List auditEntryIds);
+
+ /**
+ * The interface that will be used to give query results to the calling code.
+ *
+ * @since 3.2
+ */
+ public static interface AuditQueryCallback
+ {
+ /**
+ * Determines whether this callback requires the values argument to be populated when {@link #handleAuditEntry} is called.
+ *
+ * @return true
if this callback requires the values argument to be populated
+ */
+ boolean valuesRequired();
+
+ /**
+ * Handle a row of audit entry data.
+ *
+ * @param entryId
+ * the unique audit entry ID
+ * @param applicationName
+ * the name of the application
+ * @param user
+ * the user that logged the entry
+ * @param time
+ * the time of the entry
+ * @param values
+ * the values map as created
+ * @return Return true to continue processing rows or false to stop
+ */
+ boolean handleAuditEntry(
+ Long entryId,
+ String applicationName,
+ String user,
+ long time,
+ Map values);
+
+ /**
+ * Handle audit entry failures
+ *
+ * @param entryId
+ * the entry ID
+ * @param errorMsg
+ * the error message
+ * @param error
+ * the exception causing the error (may be