@Override public String toString() { return element.asXML(); }
/** * Sets the payload included when publishing the item. A published item may or may not * have a payload. Transient nodes that are configured to not broadcast payloads may allow * published items to have no payload. * * @param payload the payload included when publishing the item or <tt>null</tt> * if none was found. */ void setPayload(Element payload) { this.payload = payload; // Update XML representation of the payload if (payload == null) { payloadXML = null; } else { payloadXML = payload.asXML(); } }
public String asXML() { return document.getRootElement().asXML(); }
@Override public String getAvailableStreamFeatures() { StringBuilder sb = new StringBuilder(200); for (Element element : getAvailableStreamFeaturesElements()) { sb.append(element.asXML()); } return sb.toString(); }
/** * @see org.jivesoftware.openfire.vcard.DefaultVCardProvider#createVCard(java.lang.String, org.dom4j.Element) */ @Override public Element createVCard(String username, Element vCardElement) throws AlreadyExistsException { if (LOG.isDebugEnabled()) { LOG.debug("createvcard:" + vCardElement.asXML()); } return super.createVCard(username, vCardElement); }
/** * Returns a string with the valid SASL mechanisms available for the specified session. If * the session's connection is not secured then only include the SASL mechanisms that don't * require TLS. * * @param session The current session * * @return a string with the valid SASL mechanisms available for the specified session. */ public static String getSASLMechanisms( LocalSession session ) { if ( session instanceof ClientSession ) { return getSASLMechanismsElement( (ClientSession) session ).asXML(); } else if ( session instanceof LocalIncomingServerSession ) { return getSASLMechanismsElement( (LocalIncomingServerSession) session ).asXML(); } else { Log.debug( "Unable to determine SASL mechanisms that are applicable to session '{}'. Unrecognized session type.", session ); return ""; } }
/** * Updated the existing privacy list in the database. * * @param username the username of the user that updated a privacy list. * @param list the PrivacyList to update in the database. */ public void updatePrivacyList(String username, PrivacyList list) { Connection con = null; PreparedStatement pstmt = null; try { con = DbConnectionManager.getConnection(); pstmt = con.prepareStatement(UPDATE_PRIVACY_LIST); pstmt.setInt(1, (list.isDefault() ? 1 : 0)); pstmt.setString(2, list.asElement().asXML()); pstmt.setString(3, username); pstmt.setString(4, list.getName()); pstmt.executeUpdate(); } catch (Exception e) { Log.error("Error updating privacy list: " + list.getName() + " of username: " + username, e); } finally { DbConnectionManager.closeConnection(pstmt, con); } databaseContainsPrivacyLists.set(true); }
/** * Creates and saves the new privacy list to the database. * * @param username the username of the user that created a new privacy list. * @param list the PrivacyList to save. */ public void createPrivacyList(String username, PrivacyList list) { Connection con = null; PreparedStatement pstmt = null; try { con = DbConnectionManager.getConnection(); pstmt = con.prepareStatement(INSERT_PRIVACY_LIST); pstmt.setString(1, username); pstmt.setString(2, list.getName()); pstmt.setInt(3, (list.isDefault() ? 1 : 0)); pstmt.setString(4, list.asElement().asXML()); pstmt.executeUpdate(); } catch (Exception e) { Log.error("Error adding privacy list: " + list.getName() + " of username: " + username, e); } finally { DbConnectionManager.closeConnection(pstmt, con); } databaseContainsPrivacyLists.set(true); }
@Override boolean processUnknowPacket(Element doc) { String tag = doc.getName(); if ("route".equals(tag)) { // Process stanza wrapped by the route packet processRoute(new Route(doc)); return true; } else if ("handshake".equals(tag)) { if (!((LocalConnectionMultiplexerSession) session).authenticate(doc.getStringValue())) { Log.debug( "Closing session that failed to authenticate: {}", session ); session.close(); } return true; } else if ("error".equals(tag) && "stream".equals(doc.getNamespacePrefix())) { Log.debug( "Closing session because of received stream error {}. Affected session: {}", doc.asXML(), session ); session.close(); return true; } return false; }
LOG.debug("updatevcard:" + vCard.asXML());
protected String createEmptyBody(boolean terminate) { final Element body = DocumentHelper.createElement( QName.get( "body", "http://jabber.org/protocol/httpbind" ) ); if (terminate) { body.addAttribute("type", "terminate"); } body.addAttribute("ack", String.valueOf(getLastAcknowledged())); return body.asXML(); }
private String getAvailablePluginsUpdateRequest() { Element xmlRequest = docFactory.createDocument().addElement("available"); // Add locale so we can get current name and description of plugins Element locale = xmlRequest.addElement("locale"); locale.addText(JiveGlobals.getLocale().toString()); return xmlRequest.asXML(); }
@Override public Element createVCard(String username, Element vCardElement) throws AlreadyExistsException { if (loadVCard(username) != null) { // The user already has a vCard throw new AlreadyExistsException("Username " + username + " already has a vCard"); } if ( JiveGlobals.getBooleanProperty( PhotoResizer.PROPERTY_RESIZE_ON_CREATE, PhotoResizer.PROPERTY_RESIZE_ON_CREATE_DEFAULT ) ) { PhotoResizer.resizeAvatar( vCardElement ); } Connection con = null; PreparedStatement pstmt = null; try { con = DbConnectionManager.getConnection(); pstmt = con.prepareStatement(INSERT_PROPERTY); pstmt.setString(1, username); pstmt.setString(2, vCardElement.asXML()); pstmt.executeUpdate(); } catch (SQLException e) { Log.error("Error creating vCard for username: " + username, e); } finally { DbConnectionManager.closeConnection(pstmt, con); } return vCardElement; }
@Override public Element updateVCard(String username, Element vCardElement) throws NotFoundException { if (loadVCard(username) == null) { // The user does not have a vCard throw new NotFoundException("Username " + username + " does not have a vCard"); } if ( JiveGlobals.getBooleanProperty( PhotoResizer.PROPERTY_RESIZE_ON_CREATE, PhotoResizer.PROPERTY_RESIZE_ON_CREATE_DEFAULT ) ) { PhotoResizer.resizeAvatar( vCardElement ); } Connection con = null; PreparedStatement pstmt = null; try { con = DbConnectionManager.getConnection(); pstmt = con.prepareStatement(UPDATE_PROPERTIES); pstmt.setString(1, vCardElement.asXML()); pstmt.setString(2, username); pstmt.executeUpdate(); } catch (SQLException e) { Log.error("Error updating vCard of username: " + username, e); } finally { DbConnectionManager.closeConnection(pstmt, con); } return vCardElement; }
protected static String createErrorBody(String type, String condition) { final Element body = DocumentHelper.createElement( QName.get( "body", "http://jabber.org/protocol/httpbind" ) ); body.addAttribute("type", type); body.addAttribute("condition", condition); return body.asXML(); }
private void sendPacketError(Element stanza, PacketError.Condition condition) { Element reply = stanza.createCopy(); reply.addAttribute("type", "error"); reply.addAttribute("to", stanza.attributeValue("from")); reply.addAttribute("from", stanza.attributeValue("to")); reply.add(new PacketError(condition).getElement()); deliver(reply.asXML()); }
private String createSessionRestartResponse() { final Element response = DocumentHelper.createElement( QName.get( "body", "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); } return response.asXML(); }
private String getServerUpdateRequest() { XMPPServer server = XMPPServer.getInstance(); Element xmlRequest = docFactory.createDocument().addElement("version"); // Add current openfire version Element openfire = xmlRequest.addElement("openfire"); openfire.addAttribute("current", server.getServerInfo().getVersion().getVersionString()); return xmlRequest.asXML(); }
@Override public void writeExternal(ObjectOutput out) throws IOException { ExternalizableUtil.getInstance().writeSerializable(out, userJID); ExternalizableUtil.getInstance().writeSafeUTF(out, name); ExternalizableUtil.getInstance().writeBoolean(out, isDefault); ExternalizableUtil.getInstance().writeSafeUTF(out, asElement().asXML()); }
private static String createSessionCreationResponse(HttpSession session) throws DocumentException { Element response = DocumentHelper.createElement( QName.get( "body", "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())); } Element features = response.addElement("stream:features"); for (Element feature : session.getAvailableStreamFeaturesElements()) { features.add(feature); } return response.asXML(); }