Package org.xmpp.packet

Examples of org.xmpp.packet.PacketError


    }

    // Check the outgoing packet log.
    assertEquals(1, server2.transport.packets.size());
    Packet errorResponse = server2.transport.packets.peek();
    PacketError error = errorResponse.getError();
    assertNotNull(error);
    assertEquals(TEST_CONDITION, error.getCondition());

    // Assert that the error response does *not* include the original packet.
    assertTrue(errorResponse instanceof IQ);
    IQ errorIQ = (IQ) errorResponse;
    assertEquals(null, errorIQ.getChildElement());
View Full Code Here


      // Look for error condition and invoke the relevant callback.
      Element element = packet.getElement().element("error");
      if (element != null) {
        LOG.fine("Invoking error callback for: " + packet.getID());
        call.callback.error(toFederationError(new PacketError(element)));
      } else {
        if (call.responseType.equals(packet.getClass())) {
          LOG.fine("Invoking normal callback for: " + packet.getID());
          call.callback.run(packet);
        } else {
View Full Code Here

      condition = PacketError.Condition.fromXMPP(tag);
    } catch (IllegalArgumentException e) {
      condition = PacketError.Condition.undefined_condition;
      LOG.warning("Did not understand error condition, defaulting to: " + condition.name());
    }
    PacketError result = new PacketError(condition);
    if (error.hasErrorMessage()) {
      // TODO(thorogood): Hide this behind a flag so we don't always broadcast error cases.
      result.setText(error.getErrorMessage(), "en");
    }
    return result;
  }
View Full Code Here

            return;
        }
        try {
            // Generate a rejection response to the sender
            Message errorResponse = message.createCopy();
            errorResponse.setError(new PacketError(PacketError.Condition.item_not_found,
                    PacketError.Type.continue_processing));
            errorResponse.setFrom(message.getTo());
            errorResponse.setTo(message.getFrom());
            // Send the response
            router.route(errorResponse);
View Full Code Here

        reply = IQ.createResultIQ(packet);

        // Handle Invalid Requests
        if (os == null || (!os.equals("windows") && !os.equals("mac") && !os.equals("linux"))) {
            reply.setChildElement(packet.getChildElement().createCopy());
            reply.setError(new PacketError(PacketError.Condition.not_acceptable));
            sendPacket(reply);
            return;
        }

        Element sparkElement = reply.setChildElement("query", "jabber:iq:spark");
        String client = null;

        // Handle Windows clients
        if (os.equals("windows")) {
            client = JiveGlobals.getProperty("spark.windows.client");
        }
        // Handle Mac clients.
        else if (os.equals("mac")) {
            client = JiveGlobals.getProperty("spark.mac.client");
        }

        // Handle Linux Client.
        else if (os.equals("linux")) {
            client = JiveGlobals.getProperty("spark.linux.client");
        }

        if (client != null) {
            int index = client.indexOf("_");

            // Add version number
            String versionNumber = client.substring(index + 1);
            int indexOfPeriod = versionNumber.indexOf(".");

            versionNumber = versionNumber.substring(0, indexOfPeriod);
            versionNumber = versionNumber.replaceAll("_", ".");

            sparkElement.addElement("version").setText(versionNumber);

            // Add updated time.
            File clientFile = new File(JiveGlobals.getHomeDirectory(), "enterprise/spark/" + client);
            if (!clientFile.exists()) {
                reply.setChildElement(packet.getChildElement().createCopy());
                reply.setError(new PacketError(PacketError.Condition.item_not_found));
                sendPacket(reply);
                return;
            }
            long updatedTime = clientFile.lastModified();
            sparkElement.addElement("updatedTime").setText(Long.toString(updatedTime));

            // Add download url
            String downloadURL = JiveGlobals.getProperty("spark.client.downloadURL");
            String server = XMPPServer.getInstance().getServerInfo().getXMPPDomain();
            downloadURL = downloadURL.replace("127.0.0.1", server);

            sparkElement.addElement("downloadURL").setText(downloadURL + "?client=" + client);

            String displayMessage = JiveGlobals.getProperty("spark.client.displayMessage");
            if (displayMessage != null && displayMessage.trim().length() > 0) {
                sparkElement.addElement("displayMessage").setText(displayMessage);
            }
        }
        else {
            reply.setChildElement(packet.getChildElement().createCopy());
            reply.setError(new PacketError(PacketError.Condition.item_not_found));
            sendPacket(reply);
            return;
        }

        sendPacket(reply);
View Full Code Here

            String extraDomain = doc.attributeValue("name");
            String allowMultiple = doc.attributeValue("allowMultiple");
            if (extraDomain == null || "".equals(extraDomain)) {
                // No new bind domain was specified so return a bad_request error
                Element reply = doc.createCopy();
                reply.add(new PacketError(PacketError.Condition.bad_request).getElement());
                connection.deliverRawText(reply.asXML());
            }
            else if (extraDomain.equals(initialDomain)) {
                // Component is binding initial domain that is already registered
                // Send confirmation that the new domain has been registered
                connection.deliverRawText("<bind/>");
            }
            else if (extraDomain.endsWith(initialDomain)) {
                // Only accept subdomains under the initial registered domain
                if (allowMultiple != null && component.getSubdomains().contains(extraDomain)) {
                    // Domain already in use so return a conflict error
                    Element reply = doc.createCopy();
                    reply.add(new PacketError(PacketError.Condition.conflict).getElement());
                    connection.deliverRawText(reply.asXML());
                }
                else {
                    try {
                        // Get the requested subdomain
                        String subdomain = extraDomain;
                        int index = extraDomain.indexOf(serverName);
                        if (index > -1) {
                            subdomain = extraDomain.substring(0, index -1);
                        }
                        InternalComponentManager.getInstance().addComponent(subdomain, component);
                        // Send confirmation that the new domain has been registered
                        connection.deliverRawText("<bind/>");
                    }
                    catch (ComponentException e) {
                        Log.error("Error binding extra domain: " + extraDomain + " to component: " +
                                component, e);
                        // Return internal server error
                        Element reply = doc.createCopy();
                        reply.add(new PacketError(
                                PacketError.Condition.internal_server_error).getElement());
                        connection.deliverRawText(reply.asXML());
                    }
                }
            }
            else {
                // Return forbidden error since we only allow subdomains of the intial domain
                // to be used by the same external component
                Element reply = doc.createCopy();
                reply.add(new PacketError(PacketError.Condition.forbidden).getElement());
                connection.deliverRawText(reply.asXML());
            }
            return true;
        }
        return false;
View Full Code Here

        }
        else {
            // Throw error
            reply = IQ.createResultIQ(packet);
            reply.setChildElement(packet.getChildElement().createCopy());
            reply.setError(new PacketError(PacketError.Condition.item_not_found));
        }


        workgroup.send(reply);
    }
View Full Code Here

        IQ reply = IQ.createResultIQ(packet);
        try {
            if (workgroup.getAgentManager().getAgentSession(packet.getFrom()) == null) {
                reply = IQ.createResultIQ(packet);
                reply.setChildElement(packet.getChildElement().createCopy());
                reply.setError(new PacketError(PacketError.Condition.not_authorized));
                workgroup.send(reply);
                return;
            }
        }
        catch (AgentNotFoundException e) {
            reply = IQ.createResultIQ(packet);
            reply.setChildElement(packet.getChildElement().createCopy());
            reply.setError(new PacketError(PacketError.Condition.not_authorized));
            workgroup.send(reply);
            return;
        }

        // Create session list
View Full Code Here

            JID from = packet.getFrom();
            String bareJID = from.toBareJID();
            if (!isOwner(bareJID, workgroup)) {
                reply = IQ.createResultIQ(packet);
                reply.setChildElement(packet.getChildElement().createCopy());
                reply.setError(new PacketError(PacketError.Condition.forbidden));
                workgroup.send(reply);
                return;
            }

            // Verify that an agent is requesting this information.
            WorkgroupManager workgroupManager = WorkgroupManager.getInstance();
            if (iq.element("makeOwner") != null) {
                String sessionID = iq.element("makeOwner").attributeValue("sessionID");
                final String serviceName = workgroupManager.getMUCServiceName();
                final String roomName = sessionID + "@" + serviceName;
                // final String roomJID = roomName + "/" + workgroup.getJID().getNode();

                IQ iqPacket = new IQ(IQ.Type.set);
                iqPacket.setTo(roomName);
                iqPacket.setFrom(workgroup.getFullJID());

                Element query = iqPacket.setChildElement("query", "http://jabber.org/protocol/muc#owner");
                Element item = query.addElement("item");
                item.addAttribute("affiliation", "owner");
                item.addAttribute("jid", packet.getFrom().toBareJID());
                workgroup.send(iqPacket);
            }


            reply = IQ.createResultIQ(packet);
        }
        catch (Exception e) {
            reply = IQ.createResultIQ(packet);
            reply.setChildElement(packet.getChildElement().createCopy());
            reply.setError(new PacketError(PacketError.Condition.item_not_found));
        }
        workgroup.send(reply);
    }
View Full Code Here

        } catch (AgentNotFoundException e) {
            // Ignore
        }
        if (agentSession == null) {
            reply.setChildElement(packet.getChildElement().createCopy());
            reply.setError(new PacketError(PacketError.Condition.item_not_found));
            send(reply);
            Log.debug("Agent not found while accepting offer");
            return;
        }
        // Answer that the invitation was received and that it is being processed
View Full Code Here

TOP

Related Classes of org.xmpp.packet.PacketError

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.