Package org.apache.vysper.xml.fragment

Examples of org.apache.vysper.xml.fragment.Attribute


                       
                        logger.debug("Relaying message to all room occupants");
                        for(Occupant occupent : room.getOccupants()) {
                            logger.debug("Relaying message to  {}", occupent);
                            List<Attribute> replaceAttributes = new ArrayList<Attribute>();
                            replaceAttributes.add(new Attribute("from", roomAndSendingNick.getFullQualifiedName()));
                            replaceAttributes.add(new Attribute("to", occupent.getJid().getFullQualifiedName()));
                           
                            relayStanza(occupent.getJid(),
                                    StanzaBuilder.createClone(stanza, true, replaceAttributes).build(),
                                    serverRuntimeContext);
                           
                        }
                       
                        // add to discussion history
                        room.getHistory().append(stanza, sendingOccupant);
                    } else {
                        return createMessageErrorStanza(room.getJID(), from, stanza.getID(), StanzaErrorType.MODIFY, StanzaErrorCondition.FORBIDDEN, stanza);
                    }
                } else {
                    return createMessageErrorStanza(room.getJID(), from, stanza.getID(), StanzaErrorType.MODIFY, StanzaErrorCondition.NOT_ACCEPTABLE, stanza);
                }
            } else {
                return createMessageErrorStanza(moduleDomain, from, stanza.getID(), StanzaErrorType.MODIFY, StanzaErrorCondition.ITEM_NOT_FOUND, stanza);
            }
        } else if(type == null  || type == MessageStanzaType.CHAT || type == MessageStanzaType.NORMAL) {
            // private message
            logger.debug("Received direct message to {}", roomWithNickJid);
            Room room = conference.findRoom(roomJid);
            if(room != null) {
                Occupant sendingOccupant = room.findOccupantByJID(from);
               
                // sender must be participant in room
                    if(roomWithNickJid.isResourceSet()) {
                        if(sendingOccupant != null) {
                            // got resource, private message for occupant
                            Occupant receivingOccupant = room.findOccupantByNick(roomWithNickJid.getResource());
                           
                            // must be sent to an existing occupant in the room
                            if(receivingOccupant != null) {
                               
                                Entity roomAndSendingNick = new EntityImpl(room.getJID(), sendingOccupant.getName());
                                logger.debug("Relaying message to  {}", receivingOccupant);
                                List<Attribute> replaceAttributes = new ArrayList<Attribute>();
                                replaceAttributes.add(new Attribute("from", roomAndSendingNick.getFullQualifiedName()));
                                replaceAttributes.add(new Attribute("to", receivingOccupant.getJid().getFullQualifiedName()));
                               
                                relayStanza(receivingOccupant.getJid(),
                                        StanzaBuilder.createClone(stanza, true, replaceAttributes).build(),
                                        serverRuntimeContext);
                            } else {
View Full Code Here


        List<Attribute> attributes = new ArrayList<Attribute>();
        XMLAttributes xmlAttributes = elementEvent.attributes;
        for (int i = 0; i < xmlAttributes.getLength(); i++) {
            String qName = xmlAttributes.getQName(i);
            String value = xmlAttributes.getValue(i);
            attributes.add(new Attribute(qName, value));
        }
        return attributes;
    }
View Full Code Here

                createFragments(message));
    }
   
    private static List<Attribute> createAttributes(StatusCode code) {
        List<Attribute> attributes = new ArrayList<Attribute>();
        if(code != null) attributes.add(new Attribute("code", Integer.toString(code.code())));
        return attributes;
    }
View Full Code Here

                createFragments(reason));
    }
   
    private static List<Attribute> createAttributes(Entity from, Entity to) {
        List<Attribute> attributes = new ArrayList<Attribute>();
        if(to != null) attributes.add(new Attribute("to", to.getFullQualifiedName()));
        if(from != null) attributes.add(new Attribute("from", from.getFullQualifiedName()));
        return attributes;
    }
View Full Code Here

        super(NamespaceURIs.XEP0045_MUC, ELEMENT_HISTORY, null, createAttributes(maxstanzas, maxchars, seconds, since), null);
    }

    private static List<Attribute> createAttributes(Integer maxstanzas, Integer maxchars, Integer seconds, Calendar since) {
        List<Attribute> attributes = new ArrayList<Attribute>();
        if(maxstanzas != null) attributes.add(new Attribute(ATTRIBUTE_MAXSTANZAS, maxstanzas.toString()));
        if(maxchars != null) attributes.add(new Attribute(ATTRIBUTE_MAXCHARS, maxchars.toString()));
        if(seconds != null) attributes.add(new Attribute(ATTRIBUTE_SECONDS, seconds.toString()));
        if(since != null) attributes.add(new Attribute(ATTRIBUTE_SINCE, DateTimeProfile.getInstance().getDateTimeInUTC(since.getTime())));
        return attributes;
    }
View Full Code Here

    }

   
    private static List<Attribute> createAttributes(Entity jid, String nick, Affiliation affiliation, Role role) {
        List<Attribute> attributes = new ArrayList<Attribute>();
        if(jid != null) attributes.add(new Attribute("jid", jid.getFullQualifiedName()));
        if(nick != null) attributes.add(new Attribute("nick", nick));
        if(affiliation != null) attributes.add(new Attribute("affiliation", affiliation.toString()));
        if(role != null) attributes.add(new Attribute("role", role.toString()));
        return attributes;
    }
View Full Code Here

public class Delay extends XMLElement {

    public Delay(Entity from, Calendar timestamp) {
        super(NamespaceURIs.URN_XMPP_DELAY, "delay", null, Arrays.asList(
            new NamespaceAttribute(NamespaceURIs.URN_XMPP_DELAY),
            new Attribute("from", from.getFullQualifiedName()),
            new Attribute("stamp", DateTimeProfile.getInstance().getDateTimeInUTC(timestamp.getTime()))
            ), null);
    }
View Full Code Here

            if (itemElement == null) throw new XMLSemanticError("missing item node");
        } catch (XMLSemanticError xmlSemanticError) {
            throw new RosterBadRequestException("roster set needs a single item node.");
        }

        Attribute attributeJID = itemElement.getAttribute("jid");
        if (attributeJID == null || attributeJID.getValue() == null) throw new RosterBadRequestException("missing 'jid' attribute on item node");

        XMLElementVerifier verifier = itemElement.getVerifier();
        String name = verifier.attributePresent("name") ? itemElement.getAttribute("name").getValue() : null;
        if (name != null && name.length() > RosterConfiguration.ROSTER_ITEM_NAME_MAX_LENGTH) {
            throw new RosterNotAcceptableException("roster name too long: " + name.length());
        }

        SubscriptionType subscription = verifier.attributePresent("subscription") ? SubscriptionType.valueOf(itemElement.getAttribute("subscription").getValue().toUpperCase()) : SubscriptionType.NONE;
        if (!parseSubscriptionTypes && subscription != SubscriptionType.REMOVE) subscription = SubscriptionType.NONE; // roster remove is always tolerated

        AskSubscriptionType askSubscriptionType = AskSubscriptionType.NOT_SET;
        if (parseSubscriptionTypes) {
            askSubscriptionType = verifier.attributePresent("ask") ? AskSubscriptionType.valueOf("ASK_" + itemElement.getAttribute("ask").getValue().toUpperCase()) : AskSubscriptionType.NOT_SET;
        }

        String contactJid = attributeJID.getValue();
        Entity contact;
        try {
            contact = EntityImpl.parse(contactJid);
        } catch (EntityFormatException e) {
            throw new RosterNotAcceptableException("jid cannot be parsed: " + contactJid);
View Full Code Here

     * Creates a XMLElement like this <delete node="nodeName"/>
     * @param nodeName the value for the node attribute
     * @return the XMLElement for inclusion in the delete notification.
     */
    private XMLElement createDeleteElement(String nodeName) {
        return new XMLElement(null, "delete", null, new Attribute[] {new Attribute("node", nodeName)}, (XMLFragment[])null);
    }
View Full Code Here

    public ResponseStanzaContainer execute(Stanza anyStanza, ServerRuntimeContext serverRuntimeContext, boolean isOutboundStanza, SessionContext sessionContext, SessionStateHolder sessionStateHolder) {
        XMPPCoreStanza stanza = XMPPCoreStanza.getWrapper(anyStanza);
        if (stanza == null) throw new IllegalArgumentException("can only handle core XMPP stanzas (iq, message, presence)");

        // type="error" is common to all stanza, check here some prerequisites
        Attribute typeAttribute = stanza.getAttribute("type");
        XMPPCoreStanza xmppCoreStanza = XMPPCoreStanza.getWrapper(stanza);
        if (xmppCoreStanza != null && typeAttribute != null)
        {
            String errorDescription = null;
            String type = typeAttribute.getValue();
            if (IQStanzaType.ERROR.value().equals(type)) {
                // assure, result contains zero or one element
                // rfc3920/9.2.3/7.
                if (!stanza.getVerifier().subElementPresent("error")) {
                    errorDescription = "stanza of type error must include an 'error' child";
View Full Code Here

TOP

Related Classes of org.apache.vysper.xml.fragment.Attribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.