mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-1264: Audit is sensitive to MlText properties
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@67100 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -53,11 +53,13 @@ import org.alfresco.repo.transaction.TransactionalResourceHelper;
|
|||||||
import org.alfresco.service.cmr.audit.AuditQueryParameters;
|
import org.alfresco.service.cmr.audit.AuditQueryParameters;
|
||||||
import org.alfresco.service.cmr.audit.AuditService;
|
import org.alfresco.service.cmr.audit.AuditService;
|
||||||
import org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback;
|
import org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback;
|
||||||
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||||
import org.alfresco.service.cmr.repository.ContentService;
|
import org.alfresco.service.cmr.repository.ContentService;
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
|
import org.alfresco.service.cmr.repository.MLText;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
@@ -1277,6 +1279,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
|
|||||||
* @param reportFormat The format to write the header in
|
* @param reportFormat The format to write the header in
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
private void writeAuditTrailEntry(Writer writer, RecordsManagementAuditEntry entry,
|
private void writeAuditTrailEntry(Writer writer, RecordsManagementAuditEntry entry,
|
||||||
ReportFormat reportFormat) throws IOException
|
ReportFormat reportFormat) throws IOException
|
||||||
{
|
{
|
||||||
@@ -1360,13 +1363,19 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
|
|||||||
writer.write(getPropertyLabel(valueName));
|
writer.write(getPropertyLabel(valueName));
|
||||||
writer.write("</td><td>");
|
writer.write("</td><td>");
|
||||||
|
|
||||||
if(ContentModel.PROP_TITLE.equals(valueName) || ContentModel.PROP_DESCRIPTION.equals(valueName))
|
// inspect the property to determine it's data type
|
||||||
|
QName propDataType = DataTypeDefinition.TEXT;
|
||||||
|
PropertyDefinition propDef = dictionaryService.getProperty(valueName);
|
||||||
|
if (propDef != null)
|
||||||
{
|
{
|
||||||
Serializable oldValue = values.getFirst();
|
propDataType = propDef.getDataType().getName();
|
||||||
writer.write(oldValue == null ? "<none>" : StringEscapeUtils.escapeHtml(getFirstValueFromI18NMLTextValue(oldValue)));
|
}
|
||||||
|
|
||||||
|
if(DataTypeDefinition.MLTEXT.equals(propDataType))
|
||||||
|
{
|
||||||
|
writer.write(values.getFirst() == null ? "<none>" : StringEscapeUtils.escapeHtml(convertToMlText((Map)values.getFirst()).getDefaultValue()));
|
||||||
writer.write("</td><td>");
|
writer.write("</td><td>");
|
||||||
Serializable newValue = values.getSecond();
|
writer.write(values.getSecond() == null ? "<none>" : StringEscapeUtils.escapeHtml(convertToMlText((Map)values.getSecond()).getDefaultValue()));
|
||||||
writer.write(newValue == null ? "<none>" : StringEscapeUtils.escapeHtml(getFirstValueFromI18NMLTextValue(newValue)));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1425,10 +1434,19 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
|
|||||||
JSONObject changedValue = new JSONObject();
|
JSONObject changedValue = new JSONObject();
|
||||||
changedValue.put("name", getPropertyLabel(valueName));
|
changedValue.put("name", getPropertyLabel(valueName));
|
||||||
|
|
||||||
if(ContentModel.PROP_TITLE.equals(valueName) || ContentModel.PROP_DESCRIPTION.equals(valueName))
|
// inspect the property to determine it's data type
|
||||||
|
QName propDataType = DataTypeDefinition.TEXT;
|
||||||
|
PropertyDefinition propDef = dictionaryService.getProperty(valueName);
|
||||||
|
if (propDef != null)
|
||||||
{
|
{
|
||||||
changedValue.put("previous", getFirstValueFromI18NMLTextValue(values.getFirst()));
|
propDataType = propDef.getDataType().getName();
|
||||||
changedValue.put("new", getFirstValueFromI18NMLTextValue(values.getSecond()));
|
}
|
||||||
|
|
||||||
|
// handle output of mltext properties
|
||||||
|
if(DataTypeDefinition.MLTEXT.equals(propDataType))
|
||||||
|
{
|
||||||
|
changedValue.put("previous", values.getFirst() == null ? "" : convertToMlText((Map)values.getFirst()).getDefaultValue());
|
||||||
|
changedValue.put("new", values.getSecond() == null ? "" : convertToMlText((Map)values.getSecond()).getDefaultValue());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1450,20 +1468,18 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getFirstValueFromI18NMLTextValue(Serializable object)
|
/**
|
||||||
|
* Helper method to convert value to MLText
|
||||||
|
*
|
||||||
|
* @param map map of locale's and values
|
||||||
|
* @return {@link MLText} multilingual text value
|
||||||
|
*/
|
||||||
|
private MLText convertToMlText(Map<Locale, String> map)
|
||||||
{
|
{
|
||||||
String value = "";
|
MLText mlText = new MLText();
|
||||||
if((object != null) && (object instanceof HashMap))
|
mlText.putAll(map);
|
||||||
{
|
return mlText;
|
||||||
HashMap<Locale, String> hashmap = (HashMap<Locale, String>)object;
|
|
||||||
if(hashmap.size() > 0)
|
|
||||||
{
|
|
||||||
Locale locale = hashmap.keySet().iterator().next();
|
|
||||||
value = hashmap.get(locale);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user