Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)

78692: ACE-2346: Merged V4.2-BUG-FIX (4.2.4) to HEAD-BUG-FIX (5.0/Cloud)
      76534: MNT-10226: Web Script - Status 500 error on 'Edit Properties' page after adding 'Restrictable' aspect through CMIS 1.1 API
         - Convert default value in appliance with type of the property.
      76654: MNT-10226: Web Script - Status 500 error on 'Edit Properties' page after adding 'Restrictable' aspect through CMIS 1.1 API
         - Fix unit test failures: now webscripts return values with appropriate type, so in tests it should be compared with value of the expected type.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@82630 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Erik Winlof
2014-09-03 12:49:30 +00:00
parent 4c87326df4
commit b1453aa246
3 changed files with 24 additions and 5 deletions

View File

@@ -818,6 +818,16 @@ public class NodePropertyValue implements Cloneable, Serializable
return valueType.getOrdinalNumber();
}
/**
* If property value of the type <code>QName</code> is supported
*
* @param typeQName the type qualified name
*/
public static boolean isDataTypeSupported(QName typeQName)
{
return valueTypesByPropertyType.keySet().contains(typeQName);
}
/** the type of the property, prior to serialization persistence */
private ValueType actualType;
/** the type of persistence used */

View File

@@ -31,6 +31,7 @@ import java.util.Set;
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint;
import org.alfresco.repo.dictionary.constraint.RegisteredConstraint;
import org.alfresco.repo.domain.node.NodePropertyValue;
import org.alfresco.repo.forms.Field;
import org.alfresco.repo.forms.FieldGroup;
import org.alfresco.repo.forms.PropertyFieldDefinition;
@@ -166,7 +167,15 @@ public class PropertyFieldProcessor extends QNameFieldProcessor<PropertyDefiniti
PropertyDefinition propDef = data.getPropertyDefinition(name);
if (propDef != null)
{
return propDef.getDefaultValue();
QName typeQName = propDef.getDataType().getName();
String strDefaultValue = propDef.getDefaultValue();
if (NodePropertyValue.isDataTypeSupported(typeQName))
{
// convert to the appropriate type
NodePropertyValue pv = new NodePropertyValue(typeQName, strDefaultValue);
return pv.getValue(typeQName);
}
return strDefaultValue;
}
return null;
}

View File

@@ -159,14 +159,14 @@ public class WorkflowFormProcessorTest extends TestCase
String fieldName = PRIORITY_NAME.toPrefixString(namespaceService);
List<String> fields = Arrays.asList(fieldName);
Form form = processForm(fields);
checkSingleProperty(form, fieldName, "2");
checkSingleProperty(form, fieldName, 2);
// Check Status field is added to Form, when explicitly typed as a
// property.
String fullPropertyName = "prop:" + fieldName;
fields = Arrays.asList(fullPropertyName);
form = processForm(fields);
checkSingleProperty(form, fieldName, "2");
checkSingleProperty(form, fieldName, 2);
checkPackageActionGroups(form.getFormData());
}
@@ -194,7 +194,7 @@ public class WorkflowFormProcessorTest extends TestCase
String priorityField = PRIORITY_NAME.toPrefixString(namespaceService);
List<String> fields = Arrays.asList(fakeFieldName, priorityField);
Form form = processForm(fields);
checkSingleProperty(form, priorityField, "2");
checkSingleProperty(form, priorityField, 2);
checkPackageActionGroups(form.getFormData());
}
@@ -219,7 +219,7 @@ public class WorkflowFormProcessorTest extends TestCase
FormData formData = form.getFormData();
assertEquals(fieldData, formData.getFieldData("assoc_bpm_assignee").getValue());
checkPackageActionGroups(formData);
assertEquals("2", formData.getFieldData("prop_bpm_workflowPriority").getValue());
assertEquals(2, formData.getFieldData("prop_bpm_workflowPriority").getValue());
}
public void testGeneratePackageItems() throws Exception