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

74253: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (5.0/Cloud)
      74025: Merged DEV to V4.2-BUG-FIX (4.2.3)
         74013: MNT-11653 : Content Model <override> doesnt allow overriding "enforcement"
         Changed the mandatory type validation.
         Added model validation against xsd in the test.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@74886 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Will Abson
2014-06-25 16:33:06 +00:00
parent d34f7762d2
commit 67ebe0412b
2 changed files with 165 additions and 134 deletions

View File

@@ -262,7 +262,10 @@
<xs:complexType name="association">
<xs:sequence>
<xs:group ref="dd:TextualDescription"></xs:group>
<xs:element name="source" maxOccurs="1" minOccurs="0">
<xs:element name="source" maxOccurs="1" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="role" type="xs:string" maxOccurs="1"
minOccurs="0" />
<xs:element name="mandatory" type="xs:boolean"
maxOccurs="1" minOccurs="0" />
@@ -271,7 +274,10 @@
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:element name="target">
<xs:complexType>
<xs:sequence>
<xs:element name="class" type="xs:string" maxOccurs="1" minOccurs="1" />
<xs:element name="role" type="xs:string" maxOccurs="1" minOccurs="0" />
<xs:element name="mandatory" type="dd:mandatoryDef"
maxOccurs="1" minOccurs="0" />
@@ -301,7 +307,7 @@
<xs:complexType name="propertyOverride">
<xs:sequence>
</xs:extension>
<xs:element name="mandatory" type="dd:mandatoryDef"
maxOccurs="1" minOccurs="0" />
<xs:element name="default" type="xs:string"
maxOccurs="1" minOccurs="0" />

View File

@@ -25,6 +25,13 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.XMLConstants;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
@@ -36,6 +43,7 @@ import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryException;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.ModelDefinition;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
@@ -46,6 +54,7 @@ import org.alfresco.test_category.OwnJVMTestsCategory;
import org.alfresco.util.BaseAlfrescoSpringTest;
import org.alfresco.util.PropertyMap;
import org.junit.experimental.categories.Category;
import org.springframework.util.ResourceUtils;
/**
* Dictionary model type unit test
@@ -975,6 +984,22 @@ public class DictionaryModelTypeTest extends BaseAlfrescoSpringTest
setComplete();
endTransaction();
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
// Validate the model
ContentReader reader = DictionaryModelTypeTest.this.contentService.getReader(modelNode, ContentModel.PROP_CONTENT);
Source transferReportSource = new StreamSource(reader.getContentInputStream());
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
final String schemaLocation = "classpath:alfresco/model/modelSchema.xsd";
Schema schema = sf.newSchema(ResourceUtils.getURL(schemaLocation));
Validator validator = schema.newValidator();
validator.validate(transferReportSource);
return null;
}
});
// create node using new type
final NodeRef node1 = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<NodeRef>()
{