List of usage examples for org.dom4j Namespace Namespace
public Namespace(String prefix, String uri)
From source file:com.zimbra.soap.util.WsdlGenerator.java
License:Open Source License
public static Document makeWsdlDoc(List<WsdlInfoForNamespace> nsInfos, String serviceName, String targetNamespace) { Namespace nsSvc = new Namespace(svcPrefix, targetNamespace); final QName svcTypes = QName.get("types", nsWsdl); Document document = DocumentHelper.createDocument(); Map<WsdlServiceInfo, Element> bindElems = Maps.newTreeMap(); Map<WsdlServiceInfo, Element> portTypeElems = Maps.newTreeMap(); Element root = document.addElement(QName.get("definitions", nsWsdl)); root.add(nsSvc);//w w w.ja va2s. c o m for (WsdlInfoForNamespace wsdlNsInfo : nsInfos) { root.add(wsdlNsInfo.getXsdNamespace()); } root.add(nsZimbra); root.add(nsSoap); root.add(nsXsd); root.add(nsWsdl); root.addAttribute("targetNamespace", targetNamespace); root.addAttribute("name", serviceName); addWsdlTypesElement(root, svcTypes, nsInfos); for (WsdlInfoForNamespace wsdlNsInfo : nsInfos) { WsdlServiceInfo svcInfo = wsdlNsInfo.getSvcInfo(); if (!portTypeElems.containsKey(svcInfo)) { // wsdl:definitions/wsdl:portType Element portTypeElem = DocumentHelper.createElement(portType); portTypeElem.addAttribute("name", svcInfo.getPortTypeName()); portTypeElems.put(svcInfo, portTypeElem); } if (!bindElems.containsKey(svcInfo)) { // wsdl:definitions/wsdl:binding Element bindingElem = DocumentHelper.createElement(wsdlBinding); bindingElem.addAttribute("name", svcInfo.getBindingName()); bindingElem.addAttribute("type", svcPrefix + ":" + svcInfo.getPortTypeName()); // wsdl:definitions/wsdl:binding/soap:binding Element soapBindElem = bindingElem.addElement(soapBinding); soapBindElem.addAttribute("transport", "http://schemas.xmlsoap.org/soap/http"); soapBindElem.addAttribute("style", "document"); bindElems.put(svcInfo, bindingElem); } } for (WsdlInfoForNamespace wsdlNsInfo : nsInfos) { WsdlServiceInfo svcInfo = wsdlNsInfo.getSvcInfo(); for (String requestName : wsdlNsInfo.getRequests()) { String rootName = requestName.substring(0, requestName.length() - 7); String responseName = rootName + "Response"; String reqOpName = requestName.substring(0, 1).toLowerCase() + requestName.substring(1); String reqMsgName = wsdlNsInfo.getTag() + requestName + "Message"; String respMsgName = wsdlNsInfo.getTag() + responseName + "Message"; addWsdlRequestAndResponseMessageElements(root, wsdlNsInfo, reqMsgName, respMsgName, requestName, responseName); addWsdlPortTypeOperationElements(portTypeElems.get(svcInfo), reqMsgName, respMsgName, reqOpName); addWsdlBindingOperationElements(bindElems.get(svcInfo), wsdlNsInfo, reqOpName, rootName); } } addWsdlSoapHdrContextMessageElement(root); for (Entry<WsdlServiceInfo, Element> entry : portTypeElems.entrySet()) { root.add(entry.getValue()); } for (Entry<WsdlServiceInfo, Element> entry : bindElems.entrySet()) { root.add(entry.getValue()); } Set<WsdlServiceInfo> svcSet = Sets.newHashSet(); for (WsdlInfoForNamespace wsdlNsInfo : nsInfos) { WsdlServiceInfo svcInfo = wsdlNsInfo.getSvcInfo(); if (!svcSet.contains(svcInfo)) { svcSet.add(svcInfo); addWsdlServiceElement(root, svcInfo); } } return document; }
From source file:com.zimbra.soap.util.WsdlInfoForNamespace.java
License:Open Source License
public WsdlInfoForNamespace(String xsdNs, WsdlServiceInfo svcInfo, Iterable<String> requests) { this.xsdNamespaceString = xsdNs; this.svcInfo = svcInfo; this.requests = Lists.newArrayList(requests); this.xsdPrefix = xsdNs.replaceFirst("urn:", ""); this.tag = xsdPrefix.replaceFirst("zimbra", ""); this.xsdNamespace = new Namespace(getXsdPrefix(), this.getXsdNamespaceString()); }
From source file:de.innovationgate.wgpublisher.webtml.actions.TMLAction.java
License:Open Source License
public static TMLAction buildActionFromScriptModule(WGCSSJSModule mod, ObjectStrategy defaultObjectStrategy) throws TMLActionException, WGAPIException { String code = mod.getCode().trim(); TMLAction action = null;/*w w w . j av a 2s . c o m*/ // See if code is surrounded by <tml:action> Tag. Parse it out to get // flags if (code.startsWith("<tml:action")) { List<String> codelines = WGUtils.deserializeCollection(code, "\n"); if (codelines.size() < 2) { throw new TMLActionException( "Too few lines for action script module. A script module that begins with <tml:action> must a) have this tag on a separate line and b) end with </tml:action> on a separate line"); } // Take first and last line of code and try to parse them as XML String actionXML = ACTION_XML_PREFIX + ((String) codelines.get(0)) + ((String) codelines.get(codelines.size() - 1)) + ACTION_XML_SUFFIX; String actionCode = ""; if (codelines.size() >= 3) { actionCode = WGUtils.serializeCollection(codelines.subList(1, codelines.size() - 1), "\n"); } // Parse out action flags boolean master = false; boolean async = false; boolean debounce = true; int timeout = RhinoExpressionEngine.DEFAULT_SCRIPTTIMEOUT; try { Document actionDOM = DocumentHelper.parseText(actionXML); Element actionElement = actionDOM.getRootElement() .element(new QName("action", new Namespace("tml", "urn:webtml"))); master = WGUtils.stringToBoolean(actionElement.attributeValue("master", "false")); async = WGUtils.stringToBoolean(actionElement.attributeValue("async", "false")); debounce = WGUtils.stringToBoolean(actionElement.attributeValue("debounce", "true")); try { timeout = Integer.parseInt(actionElement.attributeValue("timeout", new Integer(RhinoExpressionEngine.DEFAULT_SCRIPTTIMEOUT).toString())); } catch (NumberFormatException e) { throw new TMLActionException( "Unparseable action timeout: " + actionElement.attributeValue("timeout")); } action = new TMLAction(actionCode, master, async, debounce, ORIGIN_SCRIPT_MODULE); action.setTimeout(timeout); } catch (DocumentException e) { throw new TMLActionException("Unable to build action from script module", e); } } // No tag surrounds the action code. Take the code unmodified else { action = new TMLAction(code, false, false, true, ORIGIN_SCRIPT_MODULE); } if (action != null) { action.setDesignReference(new DesignResourceReference(mod)); action.setModuleDate(mod.getLastModified()); action.setID(action.getModuleDatabase() + "/" + action.getModuleName()); // Determine object strategy: May be modified by strategy determined on module. ObjectStrategy objectStrategy = defaultObjectStrategy; String determinedObjectStrategyStr = (String) mod .getExtensionData(RhinoExpressionEngine.EXTDATA_OBJECTSTRATEGY); if (determinedObjectStrategyStr != null) { objectStrategy = ObjectStrategy.valueOf(determinedObjectStrategyStr); } action.setObjectStrategy(objectStrategy); // Determine name of eventually included object from original filename String sourceFileName = mod.getSourceFileName(); if (sourceFileName != null) { String objectName = DesignDirectory.getTMLScriptObjectName(sourceFileName); action.setObjectName(objectName); } } return action; }
From source file:de.saar.coli.salsa.reiter.framenet.Frame.java
License:Open Source License
public Element exportToSalsaTiger() { Namespace ns = new Namespace("fd", "http://www.clt-st.de/framenet/frame-database"); Element elem = new DefaultElement("frame", ns); elem.add(new FlyweightAttribute("name", this.getName(), ns)); for (FrameElement fe : this.frameElements()) { Element fee = new DefaultElement("element", ns); fee.add(new FlyweightAttribute("name", fe.getName(), ns)); fee.add(new FlyweightAttribute("optional", String.valueOf(!fe.isCore()), ns)); elem.add(fee);//www. ja v a 2 s. c o m } return elem; }
From source file:dk.nsi.stamdata.replication.webservice.AtomFeedWriter.java
License:Mozilla Public License
public <T extends View> org.w3c.dom.Document write(Class<T> viewClass, List<T> records) throws IOException { checkNotNull(viewClass);/*w w w . j a v a2 s . c om*/ checkNotNull(records); String entityName = Views.getViewPath(viewClass); try { Document document = DocumentHelper.createDocument(); document.setXMLEncoding("utf-8"); // Start the feed. Element feed = document.addElement("atom:feed", ATOM_NS); // Get the namespace of the view class. String viewNS = viewClass.getPackage().getAnnotation(XmlSchema.class).namespace(); Namespace namespace = new Namespace(null, viewNS); document.getRootElement().add(namespace); writeFeedMetadata(entityName, feed); // Write each record as an ATOM entry. Marshaller marshaller = viewXmlHelper.createMarshaller(viewClass); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); marshaller.setProperty(Marshaller.JAXB_ENCODING, STREAM_ENCODING); for (Object record : records) { View view = (View) record; writeEntry(feed, entityName, view, marshaller); } return convertToW3C(document); } catch (Exception e) { throw new IOException("Failed while writing ATOM feed.", e); } }
From source file:edu.ucsd.library.dams.api.DAMSAPIServlet.java
private Identifier createOrLookupUser(TripleStore es, String user) throws TripleStoreException, IOException { Identifier uid = null;/*from ww w. j av a2 s. c o m*/ if (!StringUtils.isBlank(user)) { // lookup the user from the event triplestore String query = "SELECT ?sub WHERE { ?sub <" + rdfNS + "type> ?type . ?type <" + rdfNS + "label> '\"mads:PersonalName\"' . " + "?sub <" + madsNS + "authoritativeLabel> ?val . FILTER ( lcase( ?val ) = lcase('\"" + user + "\"'))}"; BindingIterator it = es.sparqlSelect(query); if (it.hasNext()) uid = Identifier.publicURI(it.nextBinding().get("sub")); else { // mint ARK for the new user String minterURL = idMinters.get(minterDefault) + "1"; String userARK = HttpUtil.get(minterURL); userARK = userARK.replaceAll(".*/", "").trim(); uid = userID = Identifier.publicURI(idNS + userARK); Namespace madsNamespace = new Namespace("mads", madsNS); Namespace rdfNamespace = new Namespace("rdf", rdfNS); Element rdf = createRdfRootElement(); Element name = rdf.addElement(new QName("PersonalName", madsNamespace)); name.addAttribute(new QName("about", rdfNamespace), uid.getId()); addTextElement(name, "authoritativeLabel", madsNamespace, user); Element el = addElement(name, "elementList", madsNamespace); el.addAttribute(new QName("parseType", rdfNamespace), "Collection"); Element ne = addElement(el, "NameElement", madsNamespace); addTextElement(ne, "elementValue", madsNamespace, user); // add the user record to the event triplestore InputStream in = new ByteArrayInputStream(rdf.getDocument().asXML().getBytes()); Map info = objectEdit(userARK, true, in, null, null, null, null, es, es, null); in.close(); int statusCode = (int) info.get("statusCode"); if (statusCode != 201) throw new TripleStoreException( "Error status code" + statusCode + ": " + (String) info.get("message")); } } return uid; }
From source file:edu.ucsd.library.dams.api.DAMSAPIServlet.java
private Element createRdfRootElement() { // setup document rdf root element Document doc = new DocumentFactory().createDocument(); Element rdf = addElement(doc, "RDF", new Namespace("rdf", rdfNS)); doc.setRootElement(rdf);//ww w . java 2 s .co m rdf.add(new Namespace("mads", madsNS)); rdf.add(new Namespace("rdf", rdfNS)); rdf.add(new Namespace("dams", prNS)); return rdf; }
From source file:edu.vt.middleware.ldap.dsml.Dsmlv1.java
License:Open Source License
/** * This will take the results of a prior LDAP query and convert it to a DSML * <code>Document</code>.//from w w w.jav a 2 s . com * * @param result <code>LdapResult</code> * * @return <code>Document</code> */ public Document createDsml(final LdapResult result) { final Namespace ns = new Namespace("dsml", "http://www.dsml.org/DSML"); final Document doc = DocumentHelper.createDocument(); final Element dsmlElement = doc.addElement(new QName("dsml", ns)); final Element entriesElement = dsmlElement.addElement(new QName("directory-entries", ns)); // build document object from result if (result != null) { for (LdapEntry le : result.getEntries()) { final Element entryElement = this.createDsmlEntry(new QName("entry", ns), le, ns); entriesElement.add(entryElement); } } return doc; }
From source file:edu.vt.middleware.ldap.dsml.Dsmlv2.java
License:Open Source License
/** * This will take the results of a prior LDAP query and convert it to a DSML * <code>Document</code>.//from w ww.j a v a 2 s . c o m * * @param result <code>LdapResult</code> * * @return <code>Document</code> */ public Document createDsml(final LdapResult result) { final Namespace ns = new Namespace("", "urn:oasis:names:tc:DSML:2:0:core"); final Document doc = DocumentHelper.createDocument(); final Element dsmlElement = doc.addElement(new QName("batchResponse", ns)); final Element entriesElement = dsmlElement.addElement(new QName("searchResponse", ns)); // build document object from results if (result != null) { for (LdapEntry le : result.getEntries()) { final Element entryElement = this.createDsmlEntry(new QName("searchResultEntry", ns), le, ns); entriesElement.add(entryElement); } } final Element doneElement = entriesElement.addElement(new QName("searchResultDone", ns)); final Element codeElement = doneElement.addElement(new QName("resultCode", ns)); codeElement.addAttribute("code", "0"); return doc; }
From source file:eml.studio.server.oozie.workflow.ActionNodeDef.java
License:Open Source License
/** * the detail xml configurations goes here, this will be called in append2XML * @param action//from ww w. ja va 2 s . com */ public void generateActionXML(Element action) { Namespace xmlns = new Namespace("", "uri:oozie:shell-action:0.2"); // root namespace uri QName qName = QName.get("shell", xmlns); // your root element's name Element shell = action.addElement(qName); // action.appendChild( shell ); generateElement(shell, "job-tracker", "${jobTracker}"); generateElement(shell, "name-node", "${nameNode}"); Element configuration = shell.addElement("configuration"); createProperty(configuration, "mapred.job.queue.name", "${queueName}"); createProperty(configuration, "mapreduce.map.memeory.mb", "10240"); if (program.isScriptProgram()) { //?? generateElement(shell, "exec", "./" + widgetId + ".startup"); } else { generateElement(shell, "exec", "./run.sh"); } command2XMLforShell(shell); if (program.isScriptProgram()) { generateElement(shell, "file", "${appPath}/" + widgetId + ".startup"); generateElement(shell, "file", "${appPath}/" + widgetId + ".script"); } else generateElement(shell, "file", "${nameNode}/" + program.getPath() + "/run.sh"); shell.addElement("capture-output"); }