本文整理汇总了Java中org.xmpp.packet.PacketError.Condition方法的典型用法代码示例。如果您正苦于以下问题:Java PacketError.Condition方法的具体用法?Java PacketError.Condition怎么用?Java PacketError.Condition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xmpp.packet.PacketError
的用法示例。
在下文中一共展示了PacketError.Condition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendErrorPacket
import org.xmpp.packet.PacketError; //导入方法依赖的package包/类
/**
* 将错误数据包发送给原始发件人
*
* @param originalPacket
* @param condition
*/
private void sendErrorPacket(IQ originalPacket,
PacketError.Condition condition) {
if (IQ.Type.error == originalPacket.getType()) {
log.error("不能回答一个IQ错误到另一个IQ错误: " + originalPacket);
return;
}
IQ reply = IQ.createResultIQ(originalPacket);
reply.setChildElement(originalPacket.getChildElement().createCopy());
reply.setError(condition);
try {
PacketDeliverer.deliver(reply);
} catch (Exception e) {
// Ignore
}
}
示例2: toPacketError
import org.xmpp.packet.PacketError; //导入方法依赖的package包/类
/**
* Convert a FederationError instance to a PacketError. This may return
* <undefined-condition> if the incoming error can't be understood.
*
* @param error the incoming error
* @return a generated PacketError instance
* @throws IllegalArgumentException if the OK error code is given
*/
private static PacketError toPacketError(FederationError error) {
Preconditions.checkArgument(error.getErrorCode() != FederationError.Code.OK);
String tag = error.getErrorCode().name().toLowerCase().replace('_', '-');
PacketError.Condition condition;
try {
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;
}
示例3: sendErrorPacket
import org.xmpp.packet.PacketError; //导入方法依赖的package包/类
/**
* Senda the error packet to the original sender
*/
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);
return;
}
IQ reply = IQ.createResultIQ(originalPacket);
reply.setChildElement(originalPacket.getChildElement().createCopy());
reply.setError(condition);
try {
PacketDeliverer.deliver(reply);
} catch (Exception e) {
// Ignore
}
}
示例4: sendErrorPacket
import org.xmpp.packet.PacketError; //导入方法依赖的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);
}
示例5: queueRequest
import org.xmpp.packet.PacketError; //导入方法依赖的package包/类
/**
* Adds the request to a queue in the workgroup. If the workgroup is closed or the request
* does not pass a filter then the request will be rejected and this method will return false.
*
* @param request the request to add to a queue of this wokrgroup.
* @return true if the request was added to a queue.
*/
public boolean queueRequest(UserRequest request) {
// Retrieve routing manager
RoutingManager routingManager = RoutingManager.getInstance();
// Check if they require referer validation.
boolean contains = containsValidReferer(request);
if (!contains) {
return false;
}
if (getStatus() != Workgroup.Status.OPEN) {
return false;
}
// Check if the request may be accepted by the workgroup
PacketError.Condition error = requestFilterFactory.getFilter().filter(request);
if (error == null) {
synchronized (routingManager) {
// Add the request to the best queue of the workgroup
routingManager.routeRequest(this, request);
return true;
}
}
return false;
}
示例6: sendErrorPacket
import org.xmpp.packet.PacketError; //导入方法依赖的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);
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;
}
try {
// Route the error packet to the original sender of the IQ.
PacketDeliverer.deliver(reply);
} catch (Exception e) {
// Ignore
}
}
示例7: sendErrorPacket
import org.xmpp.packet.PacketError; //导入方法依赖的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);
return;
}
IQ reply = IQ.createResultIQ(originalPacket);
reply.setChildElement(originalPacket.getChildElement().createCopy());
reply.setError(condition);
try {
// Route the error packet to the original sender
PacketDeliverer.deliver(reply);
} catch (Exception e) {
// Ignore
}
}
示例8: sendErrorPacket
import org.xmpp.packet.PacketError; //导入方法依赖的package包/类
/**
* Generate a conflict packet to indicate that the nickname being requested/used is already in
* use by another user.
*
* @param packet the packet to be bounced.
*/
void sendErrorPacket(IQ packet, PacketError.Condition error, Element pubsubError) {
IQ reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(error);
if (pubsubError != null) {
// Add specific pubsub error if available
reply.getError().getElement().add(pubsubError);
}
router.route(reply);
}
示例9: sendErrorPacket
import org.xmpp.packet.PacketError; //导入方法依赖的package包/类
/**
* Sends an IQ error with the specified condition to the sender of the original
* IQ packet.
*
* @param packet the packet to be bounced.
* @param extraError application specific error or null if none.
* @param error the error.
*/
private void sendErrorPacket(Route packet, PacketError.Condition error, Element extraError) {
Route reply = new Route(packet.getStreamID());
reply.setID(packet.getID());
reply.setFrom(packet.getTo());
reply.setTo(packet.getFrom());
reply.setError(error);
if (extraError != null) {
// Add specific application error if available
reply.getError().getElement().add(extraError);
}
deliver(reply);
}
示例10: getSubsriptionError
import org.xmpp.packet.PacketError; //导入方法依赖的package包/类
@Override
public PacketError.Condition getSubsriptionError() {
return PacketError.Condition.not_allowed;
}
示例11: getSubsriptionError
import org.xmpp.packet.PacketError; //导入方法依赖的package包/类
@Override
public PacketError.Condition getSubsriptionError() {
return PacketError.Condition.not_authorized;
}
示例12: filter
import org.xmpp.packet.PacketError; //导入方法依赖的package包/类
public PacketError.Condition filter(Request request) {
return null;
}
示例13: getSubsriptionError
import org.xmpp.packet.PacketError; //导入方法依赖的package包/类
@Override
public PacketError.Condition getSubsriptionError() {
// Return nothing since users can always subscribe to the node
return null;
}
示例14: getSubsriptionError
import org.xmpp.packet.PacketError; //导入方法依赖的package包/类
@Override
public PacketError.Condition getSubsriptionError() {
return PacketError.Condition.not_authorized;
}
示例15: getSubsriptionError
import org.xmpp.packet.PacketError; //导入方法依赖的package包/类
/**
* Returns the error condition that should be returned to the subscriber when
* subscription is not allowed.
*
* @return the error condition that should be returned to the subscriber when
* subscription is not allowed.
*/
public abstract PacketError.Condition getSubsriptionError();