ingo@113: /* ingo@113: * Copyright (c) 2011 by Intevation GmbH ingo@113: * ingo@113: * This program is free software under the LGPL (>=v2.1) ingo@113: * Read the file LGPL.txt coming with the software for details ingo@113: * or visit http://www.gnu.org/licenses/ if it does not exist. ingo@113: */ ingo@113: package de.intevation.artifacts.common.utils; ingo@113: ingo@113: import org.w3c.dom.Document; ingo@113: import org.w3c.dom.Element; ingo@113: ingo@113: import de.intevation.artifacts.common.ArtifactNamespaceContext; ingo@113: ingo@113: ingo@113: /** ingo@113: * This class provides methods that help creating the artifact protocol ingo@113: * documents DESCRIBE, FEED, ADVANCE and OUT. ingo@113: * ingo@113: * @author Ingo Weinzierl ingo@113: */ ingo@113: public class ClientProtocolUtils { ingo@113: ingo@113: /** ingo@113: * It should not be necessary to create instances of this class. ingo@113: */ ingo@113: private ClientProtocolUtils() { ingo@113: } ingo@113: ingo@113: ingo@113: /** ingo@113: * This method creates a new CREATE document. ingo@113: * ingo@113: * @return the CREATE document. ingo@113: */ ingo@113: public static Document newCreateDocument(String factory) { ingo@113: Document doc = XMLUtils.newDocument(); ingo@113: ingo@113: XMLUtils.ElementCreator cr = new XMLUtils.ElementCreator( ingo@113: doc, ingo@113: ArtifactNamespaceContext.NAMESPACE_URI, ingo@113: ArtifactNamespaceContext.NAMESPACE_PREFIX); ingo@113: ingo@113: Element action = cr.create("action"); ingo@113: Element type = cr.create("type"); ingo@113: Element fac = cr.create("factory"); ingo@113: ingo@113: type.setAttribute("name", "create"); ingo@113: fac.setAttribute("name", factory); ingo@113: ingo@113: action.appendChild(type); ingo@113: action.appendChild(fac); ingo@113: ingo@113: doc.appendChild(action); ingo@113: ingo@113: return doc; ingo@113: } ingo@113: } ingo@113: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :