Client Side Transfer Report now validates against its XSD + unit test.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19870 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2010-04-15 16:59:21 +00:00
parent 8b72422af1
commit f4a15e7448
3 changed files with 93 additions and 55 deletions

View File

@@ -1740,8 +1740,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest
Validator validator = schema.newValidator(); Validator validator = schema.newValidator();
try try
{ {
//TODO Test does not work validator.validate(transferReportSource);
//validator.validate(transferReportSource);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@@ -1,64 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<schema <xs:schema targetNamespace="http://www.alfresco.org/model/transferReport/1.0"
targetNamespace="http://www.alfresco.org/model/transferReport/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:report="http://www.alfresco.org/model/transferReport/1.0" xmlns:report="http://www.alfresco.org/model/transferReport/1.0"
xmlns="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"> elementFormDefault="qualified">
<!-- XML Schema for the client side transferReport --> <!-- XML Schema for the client side transferReport owned by the
alfresco transferService -->
<element name="transferReport" type="report:transferReport" > <xs:element name="transferReport" type="report:transferReport">
<annotation> <xs:annotation>
<documentation>This is an Alfresco client side transfer report</documentation> <xs:documentation>This is an Alfresco client side transfer report</xs:documentation>
</annotation> </xs:annotation>
</element> </xs:element>
<complexType name="transferReport"> <xs:complexType name="transferReport">
<annotation> <xs:annotation>
<documentation> <xs:documentation>
The Alfresco client side transfer report The Alfresco client side transfer report
</documentation> </xs:documentation>
</annotation> </xs:annotation>
<sequence> <xs:sequence>
<element name="target" type="report:target" maxOccurs="1" <xs:element name="target" type="report:target" maxOccurs="1"
minOccurs="1"> minOccurs="1">
</element> </xs:element>
<element name="definition" type="report:definition" <xs:element name="definition" type="report:definition"
maxOccurs="1" minOccurs="1"> maxOccurs="1" minOccurs="1">
</element> </xs:element>
<element name="exception" type="report:exception" maxOccurs="1" <xs:sequence maxOccurs="unbounded" minOccurs="0">
<xs:element name="node" type="report:node">
</xs:element>
</xs:sequence>
<xs:element name="exception" type="report:exception" maxOccurs="1"
minOccurs="0"> minOccurs="0">
</element> </xs:element>
<element name="events" type="report:events"></element> <xs:element name="events" type="report:events">
</sequence> </xs:element>
</complexType> </xs:sequence>
</xs:complexType>
<complexType name="target"> <xs:complexType name="target">
<annotation> <xs:annotation>
<documentation> <xs:documentation>
The destination of the transfer The destination of the transfer
</documentation> </xs:documentation>
</annotation> </xs:annotation>
<attribute name="name" type="string"></attribute> <xs:attribute name="name" type="string"></xs:attribute>
<attribute name="endpointPort" type="int"></attribute> <xs:attribute name="endpointPort" type="int"></xs:attribute>
<attribute name="endpointHost" type="string"></attribute> <xs:attribute name="endpointHost" type="string"></xs:attribute>
</complexType> </xs:complexType>
<complexType name="definition"></complexType> <xs:complexType name="definition">
</xs:complexType>
<complexType name="events"> <xs:complexType name="node">
<sequence maxOccurs="unbounded" minOccurs="0"> <xs:annotation>
<element name="event" type="report:event"></element> <xs:documentation>
</sequence> The nodes being transferred
</complexType> </xs:documentation>
</xs:annotation>
<complexType name="event"> <xs:sequence>
</complexType> <xs:element name="primaryParent" maxOccurs="1"
minOccurs="0" type="report:primaryParent">
</xs:element>
</xs:sequence>
<complexType name="exception"> <xs:attribute name="nodeRef" type="string"></xs:attribute>
</complexType> </xs:complexType>
<element name="report" type="string"></element> <xs:complexType name="events">
</schema> <xs:sequence maxOccurs="unbounded" minOccurs="0">
<xs:element name="event" type="report:event"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="event" mixed="true">
<xs:attribute name="date" type="dateTime"></xs:attribute>
</xs:complexType>
<xs:complexType name="exception">
</xs:complexType>
<xs:complexType name="primaryParent">
<xs:sequence>
<xs:element name="parentAssoc" type="report:parentAssoc"/>
<xs:element name="primaryPath" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="parentAssoc" mixed="true">
<xs:attribute name="from" use="required" type="xs:string"/>
<xs:attribute name="isPrimary" use="required" type="xs:boolean"/>
<xs:attribute name="type" use="required"/>
</xs:complexType>
</xs:schema>

View File

@@ -69,7 +69,7 @@ public class XMLTransferReportWriter
this.writer.startPrefixMapping(PREFIX, TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI); this.writer.startPrefixMapping(PREFIX, TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI);
// Start Transfer Manifest // uri, name, prefix // Start Transfer Manifest // uri, name, prefix
this.writer.startElement(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferReportModel.LOCALNAME_TRANSFER_REPORT, TransferReportModel.LOCALNAME_TRANSFER_REPORT, EMPTY_ATTRIBUTES); this.writer.startElement(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferReportModel.LOCALNAME_TRANSFER_REPORT, PREFIX + ":" + TransferReportModel.LOCALNAME_TRANSFER_REPORT, EMPTY_ATTRIBUTES);
} }
/** /**
@@ -78,7 +78,7 @@ public class XMLTransferReportWriter
public void endTransferReport() throws SAXException public void endTransferReport() throws SAXException
{ {
// End Transfer Manifest // End Transfer Manifest
writer.endElement(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferReportModel.LOCALNAME_TRANSFER_REPORT, TransferReportModel.LOCALNAME_TRANSFER_REPORT); writer.endElement(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferReportModel.LOCALNAME_TRANSFER_REPORT, PREFIX + ":" + TransferReportModel.LOCALNAME_TRANSFER_REPORT);
writer.endPrefixMapping(PREFIX); writer.endPrefixMapping(PREFIX);
writer.endDocument(); writer.endDocument();
} }