mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge V4.1-BUG-FIX (4.1.1) to HEAD
38283: Merge V3.4-BUG-FIX (3.4.11) to V4.1-BUG-FIX (4.1.1) 38281: ALF-14340 CLONE: Alfresco crashes when viewing doclib / previewing - PDF with CMap - Fix rotate build failure on 4.1.1 and HEAD Disable 'ANY' (wild carded) transforms where one of the other intermediate transforms supports the transform. 38276: Fixed ALF-12524 "Check in/out to Google Docs actions are available for original document" - Updated comments for gdocs checkin evaluator - Added new doclib evaluators: evaluator.doclib.action.notWorkingCopy, evaluator.doclib.action.checkedOutAspect & evaluator.doclib.action.notCheckedOutAspect - Made sure evaluator.doclib.action.googleDocsCheckOut use notWorkingCopy & notCheckedOutAspect - Made sure both "google doc checkin" action's js function works for both working copy & original on Document Details page 38275: ALF-14784: Multi-valued Properties Not Serialized to JSON Correctly - Moved serialization of individual properties to JSON to separate method which is called recursively for lists git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@38285 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -250,6 +250,34 @@ public class ComplexContentTransformer extends AbstractContentTransformer2 imple
|
|||||||
boolean result = true;
|
boolean result = true;
|
||||||
String currentSourceMimetype = sourceMimetype;
|
String currentSourceMimetype = sourceMimetype;
|
||||||
Iterator<ContentTransformer> transformerIterator = transformers.iterator();
|
Iterator<ContentTransformer> transformerIterator = transformers.iterator();
|
||||||
|
|
||||||
|
// When using a wild card (null) intermediate transformer, don't
|
||||||
|
// say we support a transformation that one of the none null intermediate
|
||||||
|
// transformers can do on its own, to avoid double transformations.
|
||||||
|
// Not done when there are no wild card transformers, as there are cases
|
||||||
|
// where it makes sense to go via an intermediate format (quality/speed).
|
||||||
|
while (transformerIterator.hasNext())
|
||||||
|
{
|
||||||
|
ContentTransformer transformer = transformerIterator.next();
|
||||||
|
if (transformer == null)
|
||||||
|
{
|
||||||
|
transformerIterator = transformers.iterator();
|
||||||
|
while (transformerIterator.hasNext())
|
||||||
|
{
|
||||||
|
transformer = transformerIterator.next();
|
||||||
|
if (transformer != null)
|
||||||
|
{
|
||||||
|
if (transformer.isTransformableMimetype(sourceMimetype, targetMimetype, options))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
transformerIterator = transformers.iterator();
|
||||||
Iterator<String> intermediateMimetypeIterator = intermediateMimetypes.iterator();
|
Iterator<String> intermediateMimetypeIterator = intermediateMimetypes.iterator();
|
||||||
while (transformerIterator.hasNext())
|
while (transformerIterator.hasNext())
|
||||||
{
|
{
|
||||||
|
@@ -5,6 +5,7 @@ package org.alfresco.repo.jscript.app;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -261,6 +262,57 @@ public class JSONConversionComponent
|
|||||||
return userPermissionJSON;
|
return userPermissionJSON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the work of converting values to JSON.
|
||||||
|
*
|
||||||
|
* @param nodeRef
|
||||||
|
* @param propertyName
|
||||||
|
* @param key
|
||||||
|
* @param value
|
||||||
|
* @return the JSON value
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
|
protected Object propertyToJSON(NodeRef nodeRef, QName propertyName, String key, Serializable value)
|
||||||
|
{
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
// Has a decorator has been registered for this property?
|
||||||
|
if (propertyDecorators.containsKey(propertyName) == true)
|
||||||
|
{
|
||||||
|
JSONAware jsonAware = propertyDecorators.get(propertyName).decorate(propertyName, nodeRef, value);
|
||||||
|
if (jsonAware != null)
|
||||||
|
{
|
||||||
|
return jsonAware;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Built-in data type processing
|
||||||
|
if (value instanceof Date)
|
||||||
|
{
|
||||||
|
JSONObject dateObj = new JSONObject();
|
||||||
|
dateObj.put("value", JSONObject.escape(value.toString()));
|
||||||
|
dateObj.put("iso8601", JSONObject.escape(ISO8601DateFormat.format((Date)value)));
|
||||||
|
return dateObj;
|
||||||
|
}
|
||||||
|
else if (value instanceof List)
|
||||||
|
{
|
||||||
|
// Convert the List to a JSON list by recursively calling propertyToJSON
|
||||||
|
List jsonList = new ArrayList(((List) value).size());
|
||||||
|
for (Object listItem : (List) value) {
|
||||||
|
jsonList.add(propertyToJSON(nodeRef, propertyName, key, (Serializable) listItem));
|
||||||
|
}
|
||||||
|
return jsonList;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return value.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param nodeRef
|
* @param nodeRef
|
||||||
@@ -280,42 +332,8 @@ public class JSONConversionComponent
|
|||||||
{
|
{
|
||||||
String key = nameToString(propertyName, useShortQNames);
|
String key = nameToString(propertyName, useShortQNames);
|
||||||
Serializable value = properties.get(propertyName);
|
Serializable value = properties.get(propertyName);
|
||||||
|
|
||||||
if (value != null)
|
propertiesJSON.put(key, propertyToJSON(nodeRef, propertyName, key, value));
|
||||||
{
|
|
||||||
// Has a decorator has been registered for this property?
|
|
||||||
if (propertyDecorators.containsKey(propertyName) == true)
|
|
||||||
{
|
|
||||||
JSONAware jsonAware = propertyDecorators.get(propertyName).decorate(propertyName, nodeRef, value);
|
|
||||||
if (jsonAware != null)
|
|
||||||
{
|
|
||||||
propertiesJSON.put(key, jsonAware);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Built-in data type processing
|
|
||||||
if (value instanceof Date)
|
|
||||||
{
|
|
||||||
JSONObject dateObj = new JSONObject();
|
|
||||||
dateObj.put("value", JSONObject.escape(value.toString()));
|
|
||||||
dateObj.put("iso8601", JSONObject.escape(ISO8601DateFormat.format((Date)value)));
|
|
||||||
propertiesJSON.put(key, dateObj);
|
|
||||||
}
|
|
||||||
else if (value instanceof List)
|
|
||||||
{
|
|
||||||
propertiesJSON.put(key, value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
propertiesJSON.put(key, value.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
propertiesJSON.put(key, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (NamespaceException ne)
|
catch (NamespaceException ne)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user