本文整理汇总了Java中org.xmpp.packet.PacketError.Condition类的典型用法代码示例。如果您正苦于以下问题:Java Condition类的具体用法?Java Condition怎么用?Java Condition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Condition类属于org.xmpp.packet.PacketError包,在下文中一共展示了Condition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: setUp
import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
/**
* Initialize the used packet-errors.
*/
@Before
public void setUp() {
stanzaError = new PacketError(Condition.not_acceptable);
applicationError = new PacketError(
Condition.undefined_condition,
Type.modify,
ERROR_TEXT,
"en");
}
开发者ID:igniterealtime,项目名称:tinder,代码行数:13,代码来源:PacketErrorApplicationConditionTest.java
示例17: process
import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
public void process(IQ packet) throws UnauthorizedException,
PacketException {
// sanitize the input
if (packet == null) {
throw new IllegalArgumentException(
"Argument 'packet' cannot be null.");
}
final String xmlns;
final Element child = (packet).getChildElement();
if (child != null) {
xmlns = child.getNamespaceURI();
}
else {
xmlns = null;
}
if (xmlns == null) {
// No namespace defined.
Log.debug("Cannot process this stanza, as it has no namespace:"
+ packet.toXML());
final IQ error = IQ.createResultIQ(packet);
error.setError(Condition.bad_request);
parent.sendPacket(error);
return;
}
// done sanitizing, start processing.
final Element remove = packet.getChildElement().element("remove");
if (remove != null) {
// User wants to unregister. =(
// this.convinceNotToLeave() ... kidding.
handleDeregister(packet);
}
else {
// handle the request
switch (packet.getType()) {
case get:
// client requests registration form
getRegistrationForm(packet);
break;
case set:
// client is providing (filled out) registration form
setRegistrationForm(packet);
break;
default:
// ignore result and error stanzas.
break;
}
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:55,代码来源:RegistrationHandler.java
示例18: handleIQRequest
import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
/**
* Handles IQ requests. This method throws an IllegalArgumentException if an IQ stanza is supplied that is not a request (if the stanza
* is not of type 'get' or 'set'). This method will either throw an Exception, or return a non-null IQ stanza of type 'error' or
* 'result', as XMPP Core specifies that <strong>all</strong> IQ request stanza's (type 'get' or 'set') MUST be replied to.
*
* @param iq
* The IQ stanza that forms the request.
* @return The response to the request.
*/
private IQ handleIQRequest(IQ iq) {
final IQ replyPacket; // 'final' to ensure that it is set.
if (iq == null) {
throw new IllegalArgumentException("Argument 'iq' cannot be null.");
}
final IQ.Type type = iq.getType();
if (type != IQ.Type.get && type != IQ.Type.set) {
throw new IllegalArgumentException("Argument 'iq' must be of type 'get' or 'set'");
}
final Element childElement = iq.getChildElement();
if (childElement == null) {
replyPacket = IQ.createResultIQ(iq);
replyPacket.setError(new PacketError(Condition.bad_request, org.xmpp.packet.PacketError.Type.modify,
"IQ stanzas of type 'get' and 'set' MUST contain one and only one child element (RFC 3920 section 9.2.3)."));
return replyPacket;
}
final String namespace = childElement.getNamespaceURI();
if (namespace == null) {
replyPacket = IQ.createResultIQ(iq);
replyPacket.setError(Condition.feature_not_implemented);
return replyPacket;
}
if (namespace.equals(NAMESPACE_JABBER_IQ_SEARCH)) {
replyPacket = handleSearchRequest(iq);
} else if (namespace.equals(IQDiscoInfoHandler.NAMESPACE_DISCO_INFO)) {
replyPacket = handleDiscoInfo(iq);
} else if (namespace.equals(IQDiscoItemsHandler.NAMESPACE_DISCO_ITEMS)) {
replyPacket = IQ.createResultIQ(iq);
replyPacket.setChildElement("query", IQDiscoItemsHandler.NAMESPACE_DISCO_ITEMS);
} else {
// don't known what to do with this.
replyPacket = IQ.createResultIQ(iq);
replyPacket.setError(Condition.feature_not_implemented);
}
return replyPacket;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:52,代码来源:SearchPlugin.java
示例19: handlegetPassword
import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
private void handlegetPassword(IQ packet) {
if (!packet.getType().equals(IQ.Type.set)) {
throw new IllegalArgumentException(
"This method only accepts 'set' typed IQ stanzas as an argument.");
}
IQ resultIQ ;
Session session = sessionManager.getSession(packet.getFrom());
Element query = packet.getChildElement();//("query");
String email = query.elementText("email");
String username = query.elementText("username");
if(username == null || username.equals("") || email == null || email.equals("")) {
final IQ errorgetPassword = IQ.createResultIQ(packet);
errorgetPassword.setError(Condition.bad_request);
session.process(errorgetPassword);
}
User user = null;
try {
user = userManager.getUser(username);
String newpassword = StringUtils.randomString(8);
//StringUtils.class
user.setPassword(newpassword);
//randomString
try {
EmailService.getInstance().sendMessage(username, email, "G3Chat", EmailService.getInstance().getUsername(), "reset password", "your password is:" + newpassword + ",please update your password\n Magicont Technology Inc.", null);
} catch (Exception e) {
resultIQ = IQ.createResultIQ(packet);
resultIQ.setError(PacketError.Condition.item_not_found);
}
resultIQ = IQ.createResultIQ(packet);
} catch (UserNotFoundException e1) {
resultIQ = IQ.createResultIQ(packet);
resultIQ.setError(PacketError.Condition.bad_request);
}
session.process(resultIQ);
}
开发者ID:coodeer,项目名称:g3server,代码行数:48,代码来源:IQRouter.java
示例20: handleIQRequest
import org.xmpp.packet.PacketError.Condition; //导入依赖的package包/类
/**
* Handles IQ requests. This method throws an IllegalArgumentException if an
* IQ stanza is supplied that is not a request (if the stanza is not of type
* 'get' or 'set'). This method will either throw an Exception, or return a
* non-null IQ stanza of type 'error' or 'result', as XMPP Core specifies
* that <strong>all</strong> IQ request stanza's (type 'get' or 'set') MUST
* be replied to.
*
* @param iq
* The IQ stanza that forms the request.
* @return The response to the request.
*/
private IQ handleIQRequest(IQ iq) {
final IQ replyPacket; // 'final' to ensure that it is set.
if (iq == null) {
throw new IllegalArgumentException("Argument 'iq' cannot be null.");
}
final IQ.Type type = iq.getType();
if (type != IQ.Type.get && type != IQ.Type.set) {
throw new IllegalArgumentException(
"Argument 'iq' must be of type 'get' or 'set'");
}
final Element childElement = iq.getChildElement();
if (childElement == null) {
replyPacket = IQ.createResultIQ(iq);
replyPacket
.setError(new PacketError(
Condition.bad_request,
org.xmpp.packet.PacketError.Type.modify,
"IQ stanzas of type 'get' and 'set' MUST contain one and only one child element (RFC 3920 section 9.2.3)."));
return replyPacket;
}
final String namespace = childElement.getNamespaceURI();
if (namespace == null) {
replyPacket = IQ.createResultIQ(iq);
replyPacket.setError(Condition.feature_not_implemented);
return replyPacket;
}
if (namespace.equals(NAMESPACE_JABBER_IQ_SEARCH)) {
replyPacket = handleSearchRequest(iq);
} else if (namespace.equals(IQDiscoInfoHandler.NAMESPACE_DISCO_INFO)) {
replyPacket = handleDiscoInfo(iq);
} else if (namespace.equals(IQDiscoItemsHandler.NAMESPACE_DISCO_ITEMS)) {
replyPacket = IQ.createResultIQ(iq);
replyPacket.setChildElement("query",
IQDiscoItemsHandler.NAMESPACE_DISCO_ITEMS);
} else {
// don't known what to do with this.
replyPacket = IQ.createResultIQ(iq);
replyPacket.setError(Condition.feature_not_implemented);
}
return replyPacket;
}
开发者ID:coodeer,项目名称:g3server,代码行数:60,代码来源:SearchPlugin.java
注:本文中的org.xmpp.packet.PacketError.Condition类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论