List of usage examples for org.dom4j Element addNamespace
Element addNamespace(String prefix, String uri);
From source file:org.jivesoftware.multiplexer.net.http.HttpBindServlet.java
License:Open Source License
private String createErrorBody(String type, String condition) { Element body = DocumentHelper.createElement("body"); body.addNamespace("", "http://jabber.org/protocol/httpbind"); body.addAttribute("type", type); body.addAttribute("condition", condition); return body.asXML(); }
From source file:org.jivesoftware.multiplexer.net.http.HttpBindServlet.java
License:Open Source License
private static String createEmptyBody() { Element body = DocumentHelper.createElement("body"); body.addNamespace("", "http://jabber.org/protocol/httpbind"); return body.asXML(); }
From source file:org.jivesoftware.multiplexer.net.http.HttpSessionManager.java
License:Open Source License
private String createSessionCreationResponse(HttpSession session) throws DocumentException { Element response = DocumentHelper.createElement("body"); response.addNamespace("", "http://jabber.org/protocol/httpbind"); response.addNamespace("stream", "http://etherx.jabber.org/streams"); response.addAttribute("authid", session.getStreamID()); response.addAttribute("sid", session.getStreamID()); response.addAttribute("secure", Boolean.TRUE.toString()); response.addAttribute("requests", String.valueOf(session.getMaxRequests())); response.addAttribute("inactivity", String.valueOf(session.getInactivityTimeout())); response.addAttribute("polling", String.valueOf(session.getMaxPollingInterval())); response.addAttribute("wait", String.valueOf(session.getWait())); if (session.getVersion() >= 1.6) { response.addAttribute("ver", String.valueOf(session.getVersion())); }//from w w w . j a v a 2 s .co m Element features = response.addElement("stream:features"); for (Element feature : session.getAvailableStreamFeaturesElements()) { features.add(feature.createCopy()); } return response.asXML(); }
From source file:org.jivesoftware.openfire.http.HttpBindServlet.java
License:Open Source License
protected static String createErrorBody(String type, String condition) { final Element body = DocumentHelper.createElement("body"); body.addNamespace("", "http://jabber.org/protocol/httpbind"); body.addAttribute("type", type); body.addAttribute("condition", condition); return body.asXML(); }
From source file:org.jivesoftware.openfire.http.HttpSession.java
License:Open Source License
protected String createEmptyBody(boolean terminate) { final Element body = DocumentHelper.createElement("body"); if (terminate) { body.addAttribute("type", "terminate"); }/* w ww . j av a 2 s . co m*/ body.addNamespace("", "http://jabber.org/protocol/httpbind"); body.addAttribute("ack", String.valueOf(getLastAcknowledged())); return body.asXML(); }
From source file:org.jivesoftware.openfire.http.HttpSession.java
License:Open Source License
private String createSessionRestartResponse() { final Element response = DocumentHelper.createElement("body"); response.addNamespace("", "http://jabber.org/protocol/httpbind"); response.addNamespace("stream", "http://etherx.jabber.org/streams"); final Element features = response.addElement("stream:features"); for (Element feature : getAvailableStreamFeaturesElements()) { features.add(feature);/*from ww w .jav a2 s . c o m*/ } return response.asXML(); }
From source file:org.jivesoftware.openfire.http.HttpSessionManager.java
License:Open Source License
private static String createSessionCreationResponse(HttpSession session) throws DocumentException { Element response = DocumentHelper.createElement("body"); response.addNamespace("", "http://jabber.org/protocol/httpbind"); response.addNamespace("stream", "http://etherx.jabber.org/streams"); response.addAttribute("from", session.getServerName()); response.addAttribute("authid", session.getStreamID().getID()); response.addAttribute("sid", session.getStreamID().getID()); response.addAttribute("secure", Boolean.TRUE.toString()); response.addAttribute("requests", String.valueOf(session.getMaxRequests())); response.addAttribute("inactivity", String.valueOf(session.getInactivityTimeout())); response.addAttribute("polling", String.valueOf(session.getMaxPollingInterval())); response.addAttribute("wait", String.valueOf(session.getWait())); if ((session.getMajorVersion() == 1 && session.getMinorVersion() >= 6) || session.getMajorVersion() > 1) { response.addAttribute("hold", String.valueOf(session.getHold())); response.addAttribute("ack", String.valueOf(session.getLastAcknowledged())); response.addAttribute("maxpause", String.valueOf(session.getMaxPause())); response.addAttribute("ver", String.valueOf(session.getMajorVersion()) + "." + String.valueOf(session.getMinorVersion())); }/*from w w w . j a v a 2s. co m*/ Element features = response.addElement("stream:features"); for (Element feature : session.getAvailableStreamFeaturesElements()) { features.add(feature); } return response.asXML(); }
From source file:org.nuxeo.ecm.core.io.impl.ExportedDocumentImpl.java
License:Apache License
protected void readDocumentSchemas(Element element, DocumentModel doc, boolean inlineBlobs) throws IOException { SchemaManager schemaManager = Framework.getLocalService(SchemaManager.class); String[] schemaNames = doc.getSchemas(); for (String schemaName : schemaNames) { Element schemaElement = element.addElement(ExportConstants.SCHEMA_TAG).addAttribute("name", schemaName); Schema schema = schemaManager.getSchema(schemaName); Namespace targetNs = schema.getNamespace(); // If namespace prefix is empty, use schema name if (StringUtils.isEmpty(targetNs.prefix)) { targetNs = new Namespace(targetNs.uri, schema.getName()); }//from w w w .j a va2s . c o m schemaElement.addNamespace(targetNs.prefix, targetNs.uri); DataModel dataModel = doc.getDataModel(schemaName); for (Field field : schema.getFields()) { Object value = dataModel.getData(field.getName().getLocalName()); readProperty(schemaElement, targetNs, field, value, inlineBlobs); } } }
From source file:org.nuxeo.ecm.core.storage.marklogic.MarkLogicStateSerializer.java
License:Apache License
private static void addDefaultNamespaces(Element root) { root.addNamespace("xs", XMLConstants.W3C_XML_SCHEMA_NS_URI); root.addNamespace("xsi", XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI); }
From source file:org.nuxeo.ecm.platform.jbpm.syndication.serializer.SimpleXMLSerializer.java
License:Open Source License
@Override public void serialize(ResultSummary summary, List<DashBoardItem> workItems, String columnsDefinition, List<String> labels, String lang, Response res, HttpServletRequest req) { if (workItems == null) { return;//w w w .jav a2s .c om } QName tasksTag = DocumentFactory.getInstance().createQName(rootTaskNodeName, taskNSPrefix, taskNS); QName taskTag = DocumentFactory.getInstance().createQName(taskNodeName, taskNSPrefix, taskNS); QName taskCategoryTag = DocumentFactory.getInstance().createQName(taskCategoryNodeName, taskNSPrefix, taskNS); org.dom4j.Element rootElem = DocumentFactory.getInstance().createElement(tasksTag); rootElem.addNamespace(taskNSPrefix, taskNS); org.dom4j.Document rootDoc = DocumentFactory.getInstance().createDocument(rootElem); Map<String, List<DashBoardItem>> sortedDashBoardItem = new HashMap<String, List<DashBoardItem>>(); for (DashBoardItem item : workItems) { String category = item.getDirective(); if (category == null) { category = "None"; } if (!sortedDashBoardItem.containsKey(category)) { sortedDashBoardItem.put(category, new ArrayList<DashBoardItem>()); } sortedDashBoardItem.get(category).add(item); } for (String category : sortedDashBoardItem.keySet()) { org.dom4j.Element categoryElem = rootElem.addElement(taskCategoryTag); categoryElem.addAttribute("category", category); for (DashBoardItem item : sortedDashBoardItem.get(category)) { org.dom4j.Element taskElem = categoryElem.addElement(taskTag); taskElem.addAttribute("name", item.getName()); taskElem.addAttribute("directive", item.getDirective()); taskElem.addAttribute("description", item.getDescription()); taskElem.addAttribute("id", item.getId().toString()); taskElem.addAttribute("link", item.getDocumentLink()); if (item.getDueDate() != null) { taskElem.addAttribute("dueDate", DateFormat.getDateInstance().format(item.getDueDate())); } if (item.getStartDate() != null) { taskElem.addAttribute("startDate", DateFormat.getDateInstance().format(item.getStartDate())); } String currentLifeCycle = ""; try { currentLifeCycle = item.getDocument().getCurrentLifeCycleState(); } catch (ClientException e) { log.debug("No LifeCycle found"); } taskElem.addAttribute("currentDocumentLifeCycle", currentLifeCycle); // not thread-safe so don't use a static instance DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); if (item.getDueDate() != null) { taskElem.addAttribute("dueDate", dateFormat.format(item.getDueDate())); } if (item.getStartDate() != null) { taskElem.addAttribute("startDate", dateFormat.format(item.getStartDate())); } if (item.getComment() != null) { taskElem.setText(item.getComment()); } } } QName translationTag = DocumentFactory.getInstance().createQName(translationNodeName, taskNSPrefix, taskNS); org.dom4j.Element translationElem = rootElem.addElement(translationTag); Map<String, String> translatedWords = getTranslationsForWorkflow("en"); for (String key : translatedWords.keySet()) { translationElem.addAttribute(key, translatedWords.get(key)); } res.setEntity(rootDoc.asXML(), MediaType.TEXT_XML); res.getEntity().setCharacterSet(CharacterSet.UTF_8); }