当前位置: 首页>>代码示例>>Java>>正文


Java Condition类代码示例

本文整理汇总了Java中org.xmpp.packet.PacketError.Condition的典型用法代码示例。如果您正苦于以下问题:Java Condition类的具体用法?Java Condition怎么用?Java Condition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Condition类属于org.xmpp.packet.PacketError包,在下文中一共展示了Condition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cancelPendingRequest

import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
/**
 * Retires a pending request.
 *
 * @param from JID that the request was originally sent from.
 * @param to JID that the request was originally sent to.
 * @param namespace IQ namespace to identify request.
 */
public void cancelPendingRequest(JID from, JID to, String namespace) {
    for (IQ request : pendingIQRequests.keySet()) {
        if (request.getTo().equals(to) && request.getFrom().toBareJID().equals(from.toBareJID())) {
            Element child = request.getChildElement();
            if (child != null) {
                String xmlns = child.getNamespaceURI();
                if (xmlns.equals(namespace)) {
                    IQ result = IQ.createResultIQ(request);
                    result.setError(PacketError.Condition.item_not_found);
                    getTransport().sendPacket(result);
                    pendingIQRequests.remove(request);
                    return;
                }
            }
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:25,代码来源:BaseMUCTransport.java

示例2: sendErrorPacket

import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
private void sendErrorPacket(IQ originalPacket, PacketError.Condition condition) {
    if (IQ.Type.error == originalPacket.getType()) {
        Log.error("Cannot reply an IQ error to another IQ error: " + originalPacket.toXML());
        return;
    }
    IQ reply = IQ.createResultIQ(originalPacket);
    reply.setChildElement(originalPacket.getChildElement().createCopy());
    reply.setError(condition);
    // Check if the server was the sender of the IQ
    if (serverName.equals(originalPacket.getFrom().toString())) {
        // Just let the IQ router process the IQ error reply
        handle(reply);
        return;
    }
    // Route the error packet to the original sender of the IQ.
    routingTable.routePacket(reply.getTo(), reply, true);
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:18,代码来源:IQRouter.java

示例3: createErrorResponse

import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
/**
 * Creates an error response for a given IQ request.
 * 
 * @param request
 * @param message
 * @param condition
 * @param type
 * @return
 */
public static IQ createErrorResponse(final IQ request,
        final String message, Condition condition, Type type) {
    final IQ result = request.createCopy();
    result.setID(request.getID());
    result.setFrom(request.getTo());
    result.setTo(request.getFrom());

    PacketError e = new PacketError(condition, type);
    if (message != null) {
        e.setText(message);
    }
    result.setError(e);

    return result;
}
 
开发者ID:abmargb,项目名称:jamppa,代码行数:25,代码来源:XMPPUtils.java

示例4: processPacket

import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
/**
 * @see org.xmpp.component.Component#processPacket(org.xmpp.packet.Packet)
 */
final public void processPacket(final Packet packet) {
	final Packet copy = packet.createCopy();
	
	if (executor == null) {
		
	}
	try {
		executor.execute(new PacketProcessor(copy));
	} catch (RejectedExecutionException ex) {
		log.error("(serving component '" + getName()
				+ "') Unable to process packet! "
				+ "Is the thread pool queue exhausted? "
				+ "Packet dropped in component '" + getName()
				+ "'. Packet that's dropped: " + packet.toXML(), ex);
		// If the original packet was an IQ request, we should return an
		// error.
		if (packet instanceof IQ && ((IQ) packet).isRequest()) {
			final IQ response = IQ.createResultIQ((IQ) packet);
			response.setError(Condition.internal_server_error);
			send(response);
		}
	}
}
 
开发者ID:igniterealtime,项目名称:tinder,代码行数:27,代码来源:AbstractComponent.java

示例5: testValidBehaviorConditionAndNamespace

import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
/**
 * Testing the default behavior of the setter and getter methods, when an
 * application error including a namespace is set.
 */
@Test
public void testValidBehaviorConditionAndNamespace() {
	String appErrorName = "special-application-condition";
	String appNS = "application-ns";
	applicationError.setApplicationCondition(appErrorName, appNS);
	if (!appNS.equals(applicationError.getApplicationConditionNamespaceURI())) {
		fail("Don't get the expected namespace of the application-specific "
				+ "error condition.");
	}
	if (Condition.undefined_condition != applicationError.getCondition()) {
		fail("The application-specific error condition don't have to modify "
				+ "the standard error condition.");
	}
	if (!ERROR_TEXT.equals(applicationError.getText())) {
		fail("The application-specific error condition don't have to modify "
				+ "the text of the packet-error.");
	}
}
 
开发者ID:igniterealtime,项目名称:tinder,代码行数:23,代码来源:PacketErrorApplicationConditionTest.java

示例6: testValidBehaviorReset

import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
/**
 * Verifies the valid behavior of this class, even after a previously set condition is removed.
 */
@Test
public void testValidBehaviorReset() {
	// set error
	String appErrorName = "special-application-condition";
	String appNS = "application-ns";
	applicationError.setApplicationCondition(appErrorName, appNS);
	
	// unset error
	applicationError.setApplicationCondition(null);
	
	// verify that unsetting the error propagated correctly.
	if (applicationError.getApplicationConditionNamespaceURI() != null) {
		fail("Removing the application-specific error condition don't "
				+ "remove the namespace of the application.");
	}
	if (Condition.undefined_condition != applicationError.getCondition()) {
		fail("Removing the application-specific error condition don't have "
				+ "to modify the standard error condition.");
	}
	if (!ERROR_TEXT.equals(applicationError.getText())) {
		fail("Removing the application-specific error condition don't have "
				+ "to modify the text of the packet-error.");
	}
}
 
开发者ID:igniterealtime,项目名称:tinder,代码行数:28,代码来源:PacketErrorApplicationConditionTest.java

示例7: createErrorIQ

import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
/**
 * Create an error IQ from the request using the XMPP error stanza.  The 
 * element, namespace and command are cloned.  The content type is XML.
 * @param iq
 * @param condition
 * @return An IQ MMX error with XMPP error stanza.
 */
public static IQ createErrorIQ(IQ iq, Condition condition) {
  IQ error = IQ.createResultIQ(iq);
  error.setType(IQ.Type.error);
  Element rqtElt = iq.getChildElement();
  Element errElt = error.setChildElement(rqtElt.getName(), 
      rqtElt.getNamespace().getText());
  errElt.addAttribute(Constants.MMX_ATTR_COMMAND, 
      rqtElt.attributeValue(Constants.MMX_ATTR_COMMAND));
  errElt.addAttribute(Constants.MMX_ATTR_CTYPE, "application/xml");
  error.setError(condition);
  return error;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:20,代码来源:IQUtils.java

示例8: expirePendingRequest

import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
/**
 * Expires a pending request.
 *
 * @param request The request that will be expired
 */
public void expirePendingRequest(IQ request) {
    IQ result = IQ.createResultIQ(request);
    result.setError(PacketError.Condition.remote_server_timeout);
    getTransport().sendPacket(result);
    pendingIQRequests.remove(request);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:12,代码来源:BaseMUCTransport.java

示例9: handleDeregister

import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
/**
 * Processes an IQ-register request that is expressing the wish to
 * deregister from a gateway.
 *
 * @param packet the IQ-register stanza.
 */
private void handleDeregister(final IQ packet) {
    final IQ result = IQ.createResultIQ(packet);

    if (packet.getChildElement().elements().size() != 1) {
        Log.debug("Cannot process this stanza - exactly one"
                + " childelement of <remove> expected:" + packet.toXML());
        final IQ error = IQ.createResultIQ(packet);
        error.setError(Condition.bad_request);
        parent.sendPacket(error);
        return;
    }

    final JID from = packet.getFrom();
    final JID to = packet.getTo();

    // Tell the end user the transport went byebye.
    final Presence unavailable = new Presence(Presence.Type.unavailable);
    unavailable.setTo(from);
    unavailable.setFrom(to);
    this.parent.sendPacket(unavailable);

    try {
        deleteRegistration(from);
    }
    catch (UserNotFoundException e) {
        Log.debug("Error cleaning up contact list of: " + from);
        result.setError(Condition.registration_required);
    }
    parent.sendPacket(result);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:37,代码来源:RegistrationHandler.java

示例10: completeRegistration

import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
public void completeRegistration(TransportSession session) {
    final IQ result = IQ.createResultIQ(session.getRegistrationPacket());
    if (!session.getFailureStatus().equals(ConnectionFailureReason.NO_ISSUE)) {
        // Ooh there was a connection issue, we're going to report that back!
        if (session.getFailureStatus().equals(ConnectionFailureReason.USERNAME_OR_PASSWORD_INCORRECT)) {
            result.setError(Condition.not_authorized);
        }
        else if (session.getFailureStatus().equals(ConnectionFailureReason.CAN_NOT_CONNECT)) {
            result.setError(Condition.service_unavailable);
        }
        else if (session.getFailureStatus().equals(ConnectionFailureReason.LOCKED_OUT)) {
            result.setError(Condition.forbidden);
        }
        else {
            result.setError(Condition.undefined_condition);
        }
        result.setType(IQ.Type.error);
    }
    parent.sendPacket(result);

    session.setRegistrationPacket(null);

    // Lets ask them what their presence is, maybe log them in immediately.
    final Presence p = new Presence(Presence.Type.probe);
    p.setTo(session.getJID());
    p.setFrom(parent.getJID());
    parent.sendPacket(p);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:29,代码来源:RegistrationHandler.java

示例11: sendMessage

import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
/**
 * Sends a simple message through he component manager.
 *
 * @param to Who the message is for.
 * @param from Who the message is from.
 * @param msg Message to be send.
 * @param type Type of message to be sent.
 */
public void sendMessage(JID to, JID from, String msg, Message.Type type) {
    Message m = new Message();
    m.setType(type);
    m.setFrom(from);
    m.setTo(to);
    m.setBody(net.sf.kraken.util.StringUtils.removeInvalidXMLCharacters(msg));
    if (msg.length() == 0) {
        Log.debug("Dropping empty message packet.");
        return;
    }
    if (type.equals(Message.Type.chat) || type.equals(Message.Type.normal)) {
        chatStateEventSource.isActive(from, to);
        m.addChildElement("active", NameSpace.CHATSTATES);
        if (JiveGlobals.getBooleanProperty("plugin.gateway.globsl.messageeventing", true)) {
            Element xEvent = m.addChildElement("x", "jabber:x:event");
//            xEvent.addElement("id");
            xEvent.addElement("composing");
        }
    }
    else if (type.equals(Message.Type.error)) {
        // Error responses require error elements, even if we aren't going to do it "right" yet
        // TODO: All -real- error handling
        m.setError(Condition.undefined_condition);
    }
    try {
        TransportSession session = sessionManager.getSession(to);
        if (session.getDetachTimestamp() != 0) {
            // This is a detached session then, so lets store the packet instead of delivering.
            session.storePendingPacket(m);
            return;
        }
    }
    catch (NotFoundException e) {
        // No session?  That's "fine", allow it through, it's probably something from the transport itself.
    }
    sendPacket(m);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:46,代码来源:BaseTransport.java

示例12: routingFailed

import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
/**
 * Notification message indicating that a packet has failed to be routed to the receipient.
 *
 * @param receipient address of the entity that failed to receive the packet.
 * @param packet IQ packet that failed to be sent to the receipient.
 */
public void routingFailed(JID receipient, Packet packet) {
    IQ iq = (IQ) packet;
    // If a route to the target address was not found then try to answer a
    // service_unavailable error code to the sender of the IQ packet
    if (IQ.Type.result != iq.getType() && IQ.Type.error != iq.getType()) {
        Log.info("Packet sent to unreachable address " + packet.toXML());
        sendErrorPacket(iq, PacketError.Condition.service_unavailable);
    }
    else {
        Log.warn("Error or result packet could not be delivered " + packet.toXML());
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:19,代码来源:IQRouter.java

示例13: initReaderAndWriter

import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
private void initReaderAndWriter() throws XMPPException {
    try {
        if (compressionHandler == null) {
            reader = new BufferedReader(new InputStreamReader(
                    socket.getInputStream(), "UTF-8"));
            writer = new BufferedWriter(new OutputStreamWriter(
                    socket.getOutputStream(), "UTF-8"));
        } else {
            try {
                OutputStream os = compressionHandler.getOutputStream(socket
                        .getOutputStream());
                writer = new BufferedWriter(new OutputStreamWriter(os,
                        "UTF-8"));

                InputStream is = compressionHandler.getInputStream(socket
                        .getInputStream());
                reader = new BufferedReader(new InputStreamReader(is,
                        "UTF-8"));
            } catch (Exception e) {
                e.printStackTrace();
                compressionHandler = null;
                reader = new BufferedReader(new InputStreamReader(
                        socket.getInputStream(), "UTF-8"));
                writer = new BufferedWriter(new OutputStreamWriter(
                        socket.getOutputStream(), "UTF-8"));
            }
        }
    } catch (IOException ioe) {
        throw new XMPPException(
                "XMPPError establishing connection with server.",
                new PacketError(Condition.internal_server_error,
                        Type.cancel,
                        "XMPPError establishing connection with server."),
                ioe);
    }

    // If debugging is enabled, we open a window and write out all network
    // traffic.
    initDebugger();
}
 
开发者ID:abmargb,项目名称:jamppa,代码行数:41,代码来源:XMPPConnection.java

示例14: error

import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
/**
 * @param iq
 * @param errorMessage
 * @param logger
 * @return
 */
public static IQ error(IQ iq, String errorMessage, Exception e,
        Logger logger) {
    logger.error(errorMessage, e);
    return XMPPUtils.createErrorResponse(iq, errorMessage,
            Condition.bad_request, Type.modify);
}
 
开发者ID:abmargb,项目名称:jamppa,代码行数:13,代码来源:XMPPUtils.java

示例15: closeQueue

import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
/**
 * Cleans up the queue, by dropping all packets from the queue. Queued IQ
 * stanzas of type <tt>get</tt> and <tt>set</tt> are responded to by a
 * 'recipient-unavailable' error, to indicate that this component is
 * temporarily unavailable.
 */
private void closeQueue() {
	log.debug("Closing queue...");
	/*
	 * This method gets called as part of the Component#shutdown() routine.
	 * If that method gets called, the component has already been removed
	 * from the routing tables. We don't need to worry about new packets to
	 * arrive - there won't be any.
	 */
	executor.shutdown();
	try {
		if (!executor.awaitTermination(2, TimeUnit.SECONDS)) {
			final List<Runnable> wasAwatingExecution = executor
					.shutdownNow();
			for (final Runnable abortMe : wasAwatingExecution) {
				final Packet packet = ((PacketProcessor) abortMe).packet;
				if (packet instanceof IQ) {
					final IQ iq = (IQ) packet;
					if (iq.isRequest()) {
						log.debug("Responding 'service unavailable' to "
								+ "unprocessed stanza: {}", iq.toXML());
						final IQ error = IQ.createResultIQ(iq);
						error.setError(Condition.service_unavailable);
						send(error);
					}
				}
			}
		}
	} catch (InterruptedException e) {
		// ignore, as we're shutting down anyway.
	}
}
 
开发者ID:igniterealtime,项目名称:tinder,代码行数:38,代码来源:AbstractComponent.java


注:本文中的org.xmpp.packet.PacketError.Condition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。