mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge DM-DM_deployment to HEAD
17716 : Copied alfresco/HEAD to alfresco/BRANCHES/DEV/BRIAN/DM-DM_deployment. 17721 : Moved alfresco/BRANCHES/DEV/BRIAN/DM-DM_deployment to alfresco/BRANCHES/DEV/DM-DM_deployment. 17809 : Bare Bones of TransferService. 17813 : more bones 17824 : bootstrap of the transfer spaces 17826 : Added username, path, and a getter for the password. 17832 : createTransferTarget, getTransferTargets() working. 17836 : transfer target - duplicate name detection - delete transfer target by name - get transfer target by name - TransferException added along with transfer-service.properties 17840 : transfer target - enable / disable - update properties 17851 : Added the notion of a transmitter for the transfer service, and an HttpClient implementation of it. 17852 : Added the web script needed for the receiving end of a transfer, along with a command processor for clients to check availability of the service and credentials. 17856 : Added a Mockito-based test for HttpClientTransmitterImpl 17857 : Corrected javadoc for test class 17858 : Added test for overriding SSL socket factory 17859 : Wired up the transfer service to the transfer transmitter. 17896 : Rework to spring for app:transferDefinitions it's now app:transfer_definitio - Add throws clauses to TransferService - Bare bones of interface for begin and sendManifest 17944 : Work in progress on manifest file 17947 : added parent and child associations to the snapshot. 17956 : Now has the parent path implemented and introduces the TransferManifestNodeFactory. 17965 : Added content, MLText and collections. 17978 : addition of source and target peer associations. 17982 : Fixing parentNode information. 18008 : XML Manifest Reader checkpoint. (Still incomplete but lots working) 18040 : ParentPath is transmitted, fixes for source and target assocs. 18048 : SAIL-30: Initial commit of functionality for begin, sendManifest, and sendContent parts of the transfer process 18049 : Fix for parse of Locale type. 18054 : Added TransferManifestNodeHelper and more tests 18066 : Work in progress check in - Implemented the content chunker - sketched out more interfaces on TransferTransmitter. - Please note that the chunker is not yet connected to the manifest file, that will come next. r18069 : Wired up manifest reader to content chunker. r18089 : Fiest cut of callback interface for review. r18091 : added hashCode implementation which was missing from ContentData r18095 : Start of the server-side commit. Note that this is an interim commit - not tested. r18096 : Initial entry of a ContentData implementation of HttpClient's "Part" r18155 : Work in progress check in. TransferEvent - incomplete HttpClientTransmitter - first cut complete (not tested) Server side - first cut complete (not tested) 18156 : TransferMessage missing from last check in. 18166 : check in command processors 18167 : Work primarily on the transfer commit operation 18170 : corrected spring errors. 18176 : Further testing and fixing of transfer commit 18206 : Work in progress. 18236 : Work in progress - generally adding debug logging and sorting out exception handlers. 18240 : Fix to call "end" correctly after exception is thrown with "commit" 18242 : Aligning the manifest part names. 18243 : PostSnapshot calls the correct method on the receiver service. 18267 : First node has transferred. 18274 : Fixing abort to call end, debug statements, formatting code brackest 18275 : First code to handle updates. Also improved error messages passed back to client 18289 : Checked in work in progress. Content upload not working. 18290 : Update to ensure file type. 18300 : Added more log output and some of the error messages. 18301 : Work in progress 18302 : Added log output 18307 : Added a noddy transfer action 18315 : Sprint 2 complete - transfer and update one node. 18354 : Now the manifest file has deleted nodes. - Adding copyright headers 18384 : Plumbing for unit tests on one box. 18416 : First end to end unit test working. (one node create and update) 18421 : Added path based update test and many send test. 18458 : Added the functionality to transfer deleted and restored nodes. 18481 : Implementation of transferAsync 18491 : SAIL-32, SAIL-35 - Added node crawler for DM-DM Transfer F6 and F9. 18620 : Basic transfer report implementation git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18858 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,596 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have received a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.transfer.manifest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.repo.transfer.PathHelper;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.MLText;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.NamespaceException;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ISO8601DateFormat;
|
||||
import org.alfresco.util.ISO9075;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.Locator;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* SAX XML Content Handler to read a transfer manifest XML Stream and
|
||||
* delegate processing to the specified TransferManifestProcessor
|
||||
*
|
||||
* @author Mark Rogers
|
||||
*/
|
||||
public class XMLTransferManifestReader extends DefaultHandler implements ContentHandler, NamespacePrefixResolver
|
||||
{
|
||||
private TransferManifestProcessor processor;
|
||||
|
||||
/**
|
||||
* These are the namespaces used within the document - there may be a different mapping to
|
||||
* the namespaces of the Data Dictionary.
|
||||
*/
|
||||
// Map<String, String> documentNamespaces = new HashMap<String, String>();
|
||||
|
||||
final String TRANSFER_URI = ManifestModel.TRANSFER_MODEL_1_0_URI;
|
||||
final String XMLNS_URI = "http://www.w3.org/XML/1998/namespace";
|
||||
LinkedList<HashMap<String, String>> namespaces = new LinkedList<HashMap<String, String>>();
|
||||
|
||||
public XMLTransferManifestReader(TransferManifestProcessor snapshotProcessor)
|
||||
{
|
||||
this.processor = snapshotProcessor;
|
||||
|
||||
// prefix to uri map
|
||||
HashMap<String, String> namespace = new HashMap<String, String>();
|
||||
namespace.put("xmlns", XMLNS_URI);
|
||||
namespaces.add(namespace);
|
||||
}
|
||||
|
||||
public void startDocument() throws SAXException
|
||||
{
|
||||
processor.startTransferManifest();
|
||||
}
|
||||
|
||||
public void endDocument() throws SAXException
|
||||
{
|
||||
processor.endTransferManifest();
|
||||
}
|
||||
|
||||
public void characters(char[] ch, int start, int length) throws SAXException
|
||||
{
|
||||
if(buffer != null)
|
||||
{
|
||||
buffer.append(ch, start, length);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Current State of the parser
|
||||
*/
|
||||
private StringBuffer buffer;
|
||||
private Map<String, Object>props = new HashMap<String, Object>();
|
||||
|
||||
/**
|
||||
* Start Element
|
||||
*/
|
||||
public void startElement(String uri, String localName, String prefixName, Attributes atts)
|
||||
throws SAXException
|
||||
{
|
||||
QName elementQName = QName.resolveToQName(this, prefixName);
|
||||
|
||||
HashMap<String, String> namespace = new HashMap<String, String>();
|
||||
namespaces.addFirst(namespace);
|
||||
|
||||
/**
|
||||
* Look for any namespace attributes
|
||||
*/
|
||||
for(int i = 0; i < atts.getLength(); i++)
|
||||
{
|
||||
QName attributeQName = QName.resolveToQName(this, atts.getQName(i));
|
||||
if(attributeQName.getNamespaceURI().equals(XMLNS_URI))
|
||||
{
|
||||
namespace.put(attributeQName.getLocalName(), atts.getValue(i));
|
||||
}
|
||||
}
|
||||
|
||||
if(elementQName == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(elementQName.getNamespaceURI().equals(TRANSFER_URI));
|
||||
{
|
||||
// This is one of the transfer manifest elements
|
||||
String elementName = elementQName.getLocalName();
|
||||
|
||||
// Simple and stupid parser for now
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_TRANSFER_MAINIFEST))
|
||||
{
|
||||
// Good we got this
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_TRANSFER_HEADER))
|
||||
{
|
||||
TransferManifestHeader header = new TransferManifestHeader();
|
||||
props.put("header", header);
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_DELETED_NODE))
|
||||
{
|
||||
TransferManifestDeletedNode node = new TransferManifestDeletedNode();
|
||||
NodeRef nodeRef = new NodeRef(atts.getValue("", "nodeRef"));
|
||||
node.setNodeRef(nodeRef);
|
||||
props.put("node", node);
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_NODE))
|
||||
{
|
||||
TransferManifestNormalNode node = new TransferManifestNormalNode();
|
||||
NodeRef nodeRef = new NodeRef(atts.getValue("", "nodeRef"));
|
||||
QName type = QName.createQName(atts.getValue("", "nodeType"));
|
||||
node.setNodeRef(nodeRef);
|
||||
node.setType(type);
|
||||
props.put("node", node);
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_ASPECTS))
|
||||
{
|
||||
TransferManifestNormalNode node = (TransferManifestNormalNode)props.get("node");
|
||||
node.setAspects(new HashSet<QName>());
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_ASPECT))
|
||||
{
|
||||
buffer = new StringBuffer();
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_PROPERTIES))
|
||||
{
|
||||
TransferManifestNormalNode node = (TransferManifestNormalNode)props.get("node");
|
||||
HashMap<QName, Serializable>properties = new HashMap<QName, Serializable>();
|
||||
node.setProperties(properties);
|
||||
props.put("properties", properties);
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_PROPERTY))
|
||||
{
|
||||
QName name = QName.createQName(atts.getValue("", "name"));
|
||||
props.put("name", name);
|
||||
props.remove("values");
|
||||
props.remove("mltext");
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_HEADER_CREATED_DATE))
|
||||
{
|
||||
buffer = new StringBuffer();
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_PARENT_ASSOCS))
|
||||
{
|
||||
TransferManifestNormalNode node = (TransferManifestNormalNode)props.get("node");
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_CHILD_ASSOCS))
|
||||
{
|
||||
TransferManifestNormalNode node = (TransferManifestNormalNode)props.get("node");
|
||||
node.setChildAssocs(new ArrayList<ChildAssociationRef>());
|
||||
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_CHILD_ASSOC))
|
||||
{
|
||||
buffer = new StringBuffer();
|
||||
NodeRef to = new NodeRef(atts.getValue("", "to"));
|
||||
QName type = QName.createQName(atts.getValue("", "type"));
|
||||
Boolean isPrimary = Boolean.parseBoolean(atts.getValue("", "isPrimary"));
|
||||
|
||||
props.put("to", to);
|
||||
props.put("type", type);
|
||||
props.put("isPrimary", isPrimary);
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_PARENT_ASSOC))
|
||||
{
|
||||
buffer = new StringBuffer();
|
||||
NodeRef from = new NodeRef(atts.getValue("", "from"));
|
||||
QName type = QName.createQName(atts.getValue("", "type"));
|
||||
Boolean isPrimary = Boolean.parseBoolean(atts.getValue("", "isPrimary"));
|
||||
props.put("from", from);
|
||||
props.put("type", type);
|
||||
props.put("isPrimary", isPrimary);
|
||||
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_TARGET_ASSOCS))
|
||||
{
|
||||
TransferManifestNormalNode node = (TransferManifestNormalNode)props.get("node");
|
||||
List<AssociationRef> assocs = new ArrayList<AssociationRef>();
|
||||
node.setTargetAssocs(assocs);
|
||||
props.put("assocs", assocs);
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_SOURCE_ASSOCS))
|
||||
{
|
||||
TransferManifestNormalNode node = (TransferManifestNormalNode)props.get("node");
|
||||
List<AssociationRef> assocs = new ArrayList<AssociationRef>();
|
||||
node.setSourceAssocs(assocs);
|
||||
props.put("assocs", assocs);
|
||||
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_ASSOC))
|
||||
{
|
||||
NodeRef source = new NodeRef(atts.getValue("", "source"));
|
||||
NodeRef target = new NodeRef(atts.getValue("", "target"));
|
||||
QName type = QName.createQName(atts.getValue("", "type"));
|
||||
props.put("source", source);
|
||||
props.put("target", target);
|
||||
props.put("type", type);
|
||||
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_PRIMARY_PARENT))
|
||||
{
|
||||
buffer = new StringBuffer();
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_VALUES))
|
||||
{
|
||||
Collection<Serializable> values = new ArrayList<Serializable>();
|
||||
props.put("values", values);
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_VALUE))
|
||||
{
|
||||
buffer = new StringBuffer();
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_MLVALUE))
|
||||
{
|
||||
MLText mltext = (MLText)props.get("mlvalues");
|
||||
if(mltext == null)
|
||||
{
|
||||
mltext = new MLText();
|
||||
props.put("mlvalues", mltext);
|
||||
}
|
||||
String strLocale = (String)atts.getValue("", "locale");
|
||||
Locale locale = I18NUtil.parseLocale(strLocale);
|
||||
props.put("locale", locale);
|
||||
buffer = new StringBuffer();
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_CONTENT_HEADER))
|
||||
{
|
||||
String contentURL = (String)atts.getValue("", "contentURL");
|
||||
String mimetype = (String)atts.getValue("", "mimetype");
|
||||
String strLocale = (String)atts.getValue("", "locale");
|
||||
Locale locale = I18NUtil.parseLocale(strLocale);
|
||||
String encoding = (String)atts.getValue("", "encoding");
|
||||
String sizeStr = (String)atts.getValue("", "size");
|
||||
Long size = Long.valueOf(sizeStr);
|
||||
ContentData contentHeader = new ContentData(contentURL, mimetype, size.longValue(), encoding, locale);
|
||||
props.put("contentHeader", contentHeader);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // startElement
|
||||
|
||||
/**
|
||||
* End Element
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void endElement(String uri, String localName, String prefixName) throws SAXException
|
||||
{
|
||||
namespaces.removeFirst();
|
||||
|
||||
QName elementQName = QName.resolveToQName(this, prefixName);
|
||||
|
||||
if(elementQName == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(elementQName.getNamespaceURI().equals(TRANSFER_URI));
|
||||
{
|
||||
// This is one of the transfer manifest elements
|
||||
String elementName = elementQName.getLocalName();
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_TRANSFER_MAINIFEST))
|
||||
{
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_TRANSFER_HEADER))
|
||||
{
|
||||
TransferManifestHeader header = (TransferManifestHeader)props.get("header");
|
||||
// User to process the header
|
||||
processor.processTransferManifiestHeader(header);
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_NODE))
|
||||
{
|
||||
TransferManifestNormalNode node = (TransferManifestNormalNode)props.get("node");
|
||||
processor.processTransferManifestNode(node);
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_DELETED_NODE))
|
||||
{
|
||||
TransferManifestDeletedNode node = (TransferManifestDeletedNode)props.get("node");
|
||||
processor.processTransferManifestNode(node);
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_ASPECTS))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_ASPECT))
|
||||
{
|
||||
TransferManifestNormalNode node = (TransferManifestNormalNode)props.get("node");
|
||||
node.getAspects().add(QName.createQName(buffer.toString()));
|
||||
buffer = null;
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_PROPERTIES))
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_PROPERTY))
|
||||
{
|
||||
TransferManifestNormalNode node = (TransferManifestNormalNode)props.get("node");
|
||||
QName name = (QName)props.get("name");
|
||||
Serializable value = (Serializable)props.get("value");
|
||||
node.getProperties().put(name, value);
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_HEADER_CREATED_DATE))
|
||||
{
|
||||
TransferManifestHeader header = (TransferManifestHeader)props.get("header");
|
||||
header.setCreatedDate(ISO8601DateFormat.parse(buffer.toString()));
|
||||
buffer = null;
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_PARENT_ASSOCS))
|
||||
{
|
||||
// No-op
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_CHILD_ASSOCS))
|
||||
{
|
||||
// No-op
|
||||
}
|
||||
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_CHILD_ASSOC))
|
||||
{
|
||||
String value = buffer.toString();
|
||||
QName name = QName.createQName(value);
|
||||
NodeRef to = (NodeRef)props.get("to");
|
||||
QName type = (QName) props.get("type");
|
||||
Boolean isPrimary = (Boolean)props.get("isPrimary");
|
||||
TransferManifestNormalNode node = (TransferManifestNormalNode)props.get("node");
|
||||
|
||||
ChildAssociationRef childAssociationRef = new ChildAssociationRef(type, node.getNodeRef(), name, to, isPrimary, -1);
|
||||
node.getChildAssocs().add(childAssociationRef);
|
||||
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_PARENT_ASSOC))
|
||||
{
|
||||
String value = buffer.toString();
|
||||
QName name = QName.createQName(value);
|
||||
NodeRef from = (NodeRef)props.get("from");
|
||||
QName type = (QName) props.get("type");
|
||||
Boolean isPrimary = (Boolean)props.get("isPrimary");
|
||||
TransferManifestNode node = (TransferManifestNode)props.get("node");
|
||||
|
||||
ChildAssociationRef childAssociationRef = new ChildAssociationRef(type, from, name, node.getNodeRef(), isPrimary, -1);
|
||||
|
||||
if (TransferManifestNormalNode.class.isAssignableFrom(node.getClass()))
|
||||
{
|
||||
TransferManifestNormalNode normalNode = (TransferManifestNormalNode)node;
|
||||
List<ChildAssociationRef> parents = normalNode.getParentAssocs();
|
||||
if (parents == null)
|
||||
{
|
||||
parents = new ArrayList<ChildAssociationRef>();
|
||||
normalNode.setParentAssocs(parents);
|
||||
}
|
||||
parents.add(childAssociationRef);
|
||||
}
|
||||
if (isPrimary)
|
||||
{
|
||||
node.setPrimaryParentAssoc(childAssociationRef);
|
||||
}
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_TARGET_ASSOCS))
|
||||
{
|
||||
//TransferManifestNode node = (TransferManifestNode)props.get("node");
|
||||
//node.getTargetAssocs().add((AssociationRef)props.get("assoc"));
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_SOURCE_ASSOCS))
|
||||
{
|
||||
//TransferManifestNode node = (TransferManifestNode)props.get("node");
|
||||
//node.getSourceAssocs().add((AssociationRef)props.get("assoc"));
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_ASSOC))
|
||||
{
|
||||
NodeRef source = (NodeRef)props.get("source");
|
||||
NodeRef target = (NodeRef)props.get("target");
|
||||
QName type = (QName) props.get("type");
|
||||
List<AssociationRef> assocs = (List<AssociationRef>)props.get("assocs");
|
||||
AssociationRef assoc = new AssociationRef(source, type, target);
|
||||
assocs.add(assoc);
|
||||
props.put("assoc", new AssociationRef(source, type, target));
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_PRIMARY_PATH))
|
||||
{
|
||||
TransferManifestNode node = (TransferManifestNode)props.get("node");
|
||||
String value = buffer.toString();
|
||||
Path path = PathHelper.stringToPath(value);
|
||||
node.setParentPath(path);
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_VALUES))
|
||||
{
|
||||
props.put("value", props.get("values"));
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_VALUE))
|
||||
{
|
||||
Collection<Serializable> values = (Collection<Serializable>)props.get("values");
|
||||
String value = buffer.toString();
|
||||
|
||||
if(values != null)
|
||||
{
|
||||
values.add(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
props.put("value", value);
|
||||
}
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_MLVALUE))
|
||||
{
|
||||
MLText mltext = (MLText)props.get("mlvalues");
|
||||
Locale locale = (Locale)props.get("locale");
|
||||
String value = buffer.toString();
|
||||
mltext.addValue(locale, value);
|
||||
props.put("value", mltext);
|
||||
|
||||
}
|
||||
if(elementName.equals(ManifestModel.LOCALNAME_ELEMENT_CONTENT_HEADER))
|
||||
{
|
||||
TransferManifestNode node = (TransferManifestNode)props.get("node");
|
||||
ContentData data = (ContentData)props.get("contentHeader");
|
||||
props.put("value", data);
|
||||
}
|
||||
}
|
||||
} // end element
|
||||
|
||||
|
||||
|
||||
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
|
||||
{
|
||||
//NO-OP
|
||||
}
|
||||
|
||||
public void processingInstruction(String target, String data) throws SAXException
|
||||
{
|
||||
//NO-OP
|
||||
}
|
||||
|
||||
public void setDocumentLocator(Locator locator)
|
||||
{
|
||||
//NO-OP
|
||||
}
|
||||
|
||||
public void skippedEntity(String name) throws SAXException
|
||||
{
|
||||
//NO-OP
|
||||
}
|
||||
|
||||
public void startPrefixMapping(String prefix, String uri) throws SAXException
|
||||
{
|
||||
HashMap<String, String> namespace = namespaces.get(0);
|
||||
// prefix is key, URI is value
|
||||
namespace.put(prefix, uri);
|
||||
}
|
||||
|
||||
public void endPrefixMapping(String prefix) throws SAXException
|
||||
{
|
||||
HashMap<String, String> namespace = namespaces.get(0);
|
||||
// prefix is key, URI is value
|
||||
namespace.remove(prefix);
|
||||
}
|
||||
|
||||
// Namespace Prefix Resolver implementation below
|
||||
|
||||
/**
|
||||
* lookup the prefix for a URI e.g. TRANSFER_URI for xfer
|
||||
*/
|
||||
public String getNamespaceURI(String prefix) throws NamespaceException
|
||||
{
|
||||
for(HashMap<String, String> namespace : namespaces)
|
||||
{
|
||||
String uri = namespace.get(prefix);
|
||||
if(uri != null)
|
||||
{
|
||||
return uri;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri
|
||||
* @return the prefix
|
||||
*/
|
||||
public Collection<String> getPrefixes(String namespaceURI) throws NamespaceException
|
||||
{
|
||||
Collection<String> prefixes = new HashSet<String>();
|
||||
|
||||
for(HashMap<String, String> namespace : namespaces)
|
||||
{
|
||||
for(Entry<String, String> entry : namespace.entrySet())
|
||||
{
|
||||
if (namespaceURI.equals(entry.getValue()))
|
||||
{
|
||||
prefixes.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return prefixes;
|
||||
}
|
||||
|
||||
public Collection<String> getPrefixes()
|
||||
{
|
||||
Collection<String> prefixes = new HashSet<String>();
|
||||
|
||||
for(HashMap<String, String> namespace : namespaces)
|
||||
{
|
||||
prefixes.addAll(namespace.keySet());
|
||||
}
|
||||
|
||||
return prefixes;
|
||||
}
|
||||
|
||||
public Collection<String> getURIs()
|
||||
{
|
||||
Collection<String> uris = new HashSet<String>();
|
||||
|
||||
for(HashMap<String, String> namespace : namespaces)
|
||||
{
|
||||
uris.addAll(namespace.values());
|
||||
}
|
||||
|
||||
return uris;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user