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


Java XMPPErrorException类代码示例

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


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

示例1: createNode

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入依赖的package包/类
/**
 * Creates a node with specified configuration.
 * 
 * Note: This is the only way to create a collection node.
 * 
 * @param name The name of the node, which must be unique within the 
 * pubsub service
 * @param config The configuration for the node
 * @return The node that was created
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 * @throws NotConnectedException 
 */
public Node createNode(String name, Form config) throws NoResponseException, XMPPErrorException, NotConnectedException
{
	PubSub request = PubSub.createPubsubPacket(to, Type.set, new NodeExtension(PubSubElementType.CREATE, name), null);
	boolean isLeafNode = true;
	
	if (config != null)
	{
		request.addExtension(new FormNode(FormNodeType.CONFIGURE, config));
		FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName());
		
		if (nodeTypeField != null)
			isLeafNode = nodeTypeField.getValues().get(0).equals(NodeType.leaf.toString());
	}

	// Errors will cause exceptions in getReply, so it only returns
	// on success.
	sendPubsubPacket(con, request);
	Node newNode = isLeafNode ? new LeafNode(con, name) : new CollectionNode(con, name);
	newNode.setTo(to);
	nodeMap.put(newNode.getId(), newNode);
	
	return newNode;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:37,代码来源:PubSubManager.java

示例2: shouldFailIfTargetDoesNotSupportIBB

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入依赖的package包/类
/**
 * Invoking {@link InBandBytestreamManager#establishSession(String)} should
 * throw an exception if the given target does not support in-band
 * bytestream.
 * @throws SmackException 
 * @throws XMPPException 
 */
@Test
public void shouldFailIfTargetDoesNotSupportIBB() throws SmackException, XMPPException {
    InBandBytestreamManager byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);

    try {
        XMPPError xmppError = new XMPPError(
                        XMPPError.Condition.feature_not_implemented);
        IQ errorIQ = IBBPacketUtils.createErrorIQ(targetJID, initiatorJID, xmppError);
        protocol.addResponse(errorIQ);

        // start In-Band Bytestream
        byteStreamManager.establishSession(targetJID);

        fail("exception should be thrown");
    }
    catch (XMPPErrorException e) {
        assertEquals(XMPPError.Condition.feature_not_implemented,
                        e.getXMPPError().getCondition());
    }

}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:29,代码来源:InBandBytestreamManagerTest.java

示例3: setStatus

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入依赖的package包/类
/**
 * Sets the agent's current status with the workgroup. The presence mode affects how offers
 * are routed to the agent. The possible presence modes with their meanings are as follows:<ul>
 * <p/>
 * <li>Presence.Mode.AVAILABLE -- (Default) the agent is available for more chats
 * (equivalent to Presence.Mode.CHAT).
 * <li>Presence.Mode.DO_NOT_DISTURB -- the agent is busy and should not be disturbed.
 * However, special case, or extreme urgency chats may still be offered to the agent.
 * <li>Presence.Mode.AWAY -- the agent is not available and should not
 * have a chat routed to them (equivalent to Presence.Mode.EXTENDED_AWAY).</ul>
 *
 * @param presenceMode the presence mode of the agent.
 * @param status       sets the status message of the presence update.
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 * @throws NotConnectedException 
 * @throws IllegalStateException if the agent is not online with the workgroup.
 */
public void setStatus(Presence.Mode presenceMode, String status) throws NoResponseException, XMPPErrorException, NotConnectedException {
    if (!online) {
        throw new IllegalStateException("Cannot set status when the agent is not online.");
    }

    if (presenceMode == null) {
        presenceMode = Presence.Mode.available;
    }
    this.presenceMode = presenceMode;

    Presence presence = new Presence(Presence.Type.available);
    presence.setMode(presenceMode);
    presence.setTo(this.getWorkgroupJID());

    if (status != null) {
        presence.setStatus(status);
    }
    presence.addExtension(new MetaData(this.metaData));

    PacketCollector collector = this.connection.createPacketCollectorAndSend(new AndFilter(new StanzaTypeFilter(Presence.class),
            FromMatchesFilter.create(workgroupJID)), presence);

    collector.nextResultOrThrow();
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:43,代码来源:AgentSession.java

示例4: negotiateIncomingStream

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入依赖的package包/类
@Override
InputStream negotiateIncomingStream(Stanza streamInitiation) throws InterruptedException,
                SmackException, XMPPErrorException {
    // build SOCKS5 Bytestream request
    Socks5BytestreamRequest request = new ByteStreamRequest(this.manager,
                    (Bytestream) streamInitiation);

    // always accept the request
    Socks5BytestreamSession session = request.accept();

    // test input stream
    try {
        PushbackInputStream stream = new PushbackInputStream(session.getInputStream());
        int firstByte = stream.read();
        stream.unread(firstByte);
        return stream;
    }
    catch (IOException e) {
        throw new SmackException("Error establishing input stream", e);
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:22,代码来源:Socks5TransferNegotiator.java

示例5: addBookmarkedConference

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入依赖的package包/类
/**
 * Adds or updates a conference in the bookmarks.
 *
 * @param name the name of the conference
 * @param jid the jid of the conference
 * @param isAutoJoin whether or not to join this conference automatically on login
 * @param nickname the nickname to use for the user when joining the conference
 * @param password the password to use for the user when joining the conference
 * @throws XMPPErrorException thrown when there is an issue retrieving the current bookmarks from
 * the server.
 * @throws NoResponseException if there was no response from the server.
 * @throws NotConnectedException 
 */
public void addBookmarkedConference(String name, String jid, boolean isAutoJoin,
        String nickname, String password) throws NoResponseException, XMPPErrorException, NotConnectedException
{
    retrieveBookmarks();
    BookmarkedConference bookmark
            = new BookmarkedConference(name, jid, isAutoJoin, nickname, password);
    List<BookmarkedConference> conferences = bookmarks.getBookmarkedConferences();
    if(conferences.contains(bookmark)) {
        BookmarkedConference oldConference = conferences.get(conferences.indexOf(bookmark));
        if(oldConference.isShared()) {
            throw new IllegalArgumentException("Cannot modify shared bookmark");
        }
        oldConference.setAutoJoin(isAutoJoin);
        oldConference.setName(name);
        oldConference.setNickname(nickname);
        oldConference.setPassword(password);
    }
    else {
        bookmarks.addBookmarkedConference(bookmark);
    }
    privateDataManager.setPrivateData(bookmarks);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:36,代码来源:BookmarkManager.java

示例6: resolveRoom

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入依赖的package包/类
public String resolveRoom(XMPPConnection connection) throws XMPPException, SmackException {
    ObjectHelper.notEmpty(room, "room");

    if (room.indexOf('@', 0) != -1) {
        return room;
    }

    Iterator<String> iterator = MultiUserChat.getServiceNames(connection).iterator();
    if (!iterator.hasNext()) {
        throw new XMPPErrorException("Cannot find Multi User Chat service",
                                     new XMPPError(new XMPPError.Condition("Cannot find Multi User Chat service on connection: " + getConnectionMessage(connection))));
    }

    String chatServer = iterator.next();
    LOG.debug("Detected chat server: {}", chatServer);

    return room + "@" + chatServer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:XmppEndpoint.java

示例7: createIncomingStream

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入依赖的package包/类
@Override
public InputStream createIncomingStream(StreamInitiation initiation) throws XMPPErrorException,
                InterruptedException, SmackException {
    /*
     * SOCKS5 initiation listener must ignore next SOCKS5 Bytestream request with given session
     * ID
     */
    this.manager.ignoreBytestreamRequestOnce(initiation.getSessionID());

    Stanza streamInitiation = initiateIncomingStream(this.connection, initiation);
    return negotiateIncomingStream(streamInitiation);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:13,代码来源:Socks5TransferNegotiator.java

示例8: getDefaultList

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入依赖的package包/类
/**
 * Answer the default privacy list. Returns <code>null</code> if there is no default list.
 * 
 * @return the privacy list of the default list.
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 * @throws NotConnectedException 
 */ 
public PrivacyList getDefaultList() throws NoResponseException, XMPPErrorException, NotConnectedException {
    Privacy privacyAnswer = this.getPrivacyWithListNames();
    String listName = privacyAnswer.getDefaultName();
    if (StringUtils.isNullOrEmpty(listName)) {
        return null;
    }
    boolean isDefaultAndActive = listName.equals(privacyAnswer.getActiveName());
    return new PrivacyList(isDefaultAndActive, true, listName, getPrivacyListItems(listName));
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:18,代码来源:PrivacyListManager.java

示例9: deletePrivacyList

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入依赖的package包/类
/**
 * Remove a privacy list.
 * 
    * @param listName the list that has changed its content.
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 * @throws NotConnectedException 
 */ 
public void deletePrivacyList(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException {
	// The request of the list is an privacy message with an empty list
	Privacy request = new Privacy();
	request.setPrivacyList(listName, new ArrayList<PrivacyItem>());

	// Send the package to the server
	setRequest(request);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:17,代码来源:PrivacyListManager.java

示例10: getName

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入依赖的package包/类
/**
 * Return the agents name.
 *
 * @return - the agents name.
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 * @throws NotConnectedException 
 */
public String getName() throws NoResponseException, XMPPErrorException, NotConnectedException {
    AgentInfo agentInfo = new AgentInfo();
    agentInfo.setType(IQ.Type.get);
    agentInfo.setTo(workgroupJID);
    agentInfo.setFrom(getUser());
    AgentInfo response = (AgentInfo) connection.createPacketCollectorAndSend(agentInfo).nextResultOrThrow();
    return response.getName();
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:17,代码来源:Agent.java

示例11: changePassword

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入依赖的package包/类
/**
 * Changes the password of the currently logged-in account. This operation can only
 * be performed after a successful login operation has been completed. Not all servers
 * support changing passwords; an XMPPException will be thrown when that is the case.
 *
 * @throws IllegalStateException if not currently logged-in to the server.
 * @throws XMPPErrorException if an error occurs when changing the password.
 * @throws NoResponseException if there was no response from the server.
 * @throws NotConnectedException 
 */
public void changePassword(String newPassword) throws NoResponseException, XMPPErrorException, NotConnectedException {
    if (!connection().isSecureConnection() && !allowSensitiveOperationOverInsecureConnection) {
        // TODO throw exception in newer Smack versions
        LOGGER.warning("Changing password over insecure connection. "
                        + "This will throw an exception in future versions of Smack if AccountManager.sensitiveOperationOverInsecureConnection(true) is not set");
    }
    Map<String, String> map = new HashMap<String, String>();
    map.put("username",XmppStringUtils.parseLocalpart(connection().getUser()));
    map.put("password",newPassword);
    Registration reg = new Registration(map);
    reg.setType(IQ.Type.set);
    reg.setTo(connection().getServiceName());
    createPacketCollectorAndSend(reg).nextResultOrThrow();
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:25,代码来源:AccountManager.java

示例12: declineActiveList

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入依赖的package包/类
/**
 * Client declines the use of active lists.
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 * @throws NotConnectedException 
 */ 
public void declineActiveList() throws NoResponseException, XMPPErrorException, NotConnectedException {
	// The request of the list is an privacy message with an empty list
	Privacy request = new Privacy();
	request.setDeclineActiveList(true);
	
	// Send the package to the server
	setRequest(request);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:15,代码来源:PrivacyListManager.java

示例13: getMacros

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入依赖的package包/类
/**
 * Asks the workgroup for it's Global Macros.
 *
 * @param global true to retrieve global macros, otherwise false for personal macros.
 * @return MacroGroup the root macro group.
 * @throws XMPPErrorException if an error occurs while getting information from the server.
 * @throws NoResponseException 
 * @throws NotConnectedException 
 */
public MacroGroup getMacros(boolean global) throws NoResponseException, XMPPErrorException, NotConnectedException {
    Macros request = new Macros();
    request.setType(IQ.Type.get);
    request.setTo(workgroupJID);
    request.setPersonal(!global);

    Macros response = (Macros) connection.createPacketCollectorAndSend(request).nextResultOrThrow();
    return response.getRootGroup();
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:19,代码来源:AgentSession.java

示例14: discoverInfo

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入依赖的package包/类
/**
 * Returns the discovered information of a given XMPP entity addressed by its JID.
 * Use null as entityID to query the server
 * 
 * @param entityID the address of the XMPP entity or null.
 * @return the discovered information.
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 * @throws NotConnectedException 
 */
public DiscoverInfo discoverInfo(String entityID) throws NoResponseException, XMPPErrorException, NotConnectedException {
    if (entityID == null)
        return discoverInfo(null, null);

    // Check if the have it cached in the Entity Capabilities Manager
    DiscoverInfo info = EntityCapsManager.getDiscoverInfoByUser(entityID);

    if (info != null) {
        // We were able to retrieve the information from Entity Caps and
        // avoided a disco request, hurray!
        return info;
    }

    // Try to get the newest node#version if it's known, otherwise null is
    // returned
    EntityCapsManager.NodeVerHash nvh = EntityCapsManager.getNodeVerHashByJid(entityID);

    // Discover by requesting the information from the remote entity
    // Note that wee need to use NodeVer as argument for Node if it exists
    info = discoverInfo(entityID, nvh != null ? nvh.getNodeVer() : null);

    // If the node version is known, store the new entry.
    if (nvh != null) {
        if (EntityCapsManager.verifyDiscoverInfoVersion(nvh.getVer(), nvh.getHash(), info))
            EntityCapsManager.addDiscoverInfoByNode(nvh.getNodeVer(), info);
    }

    return info;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:40,代码来源:ServiceDiscoveryManager.java

示例15: getPrivacyListItems

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入依赖的package包/类
/**
 * Answer the privacy list items under listName with the allowed and blocked permissions.
 * 
 * @param listName the name of the list to get the allowed and blocked permissions.
 * @return a list of privacy items under the list listName.
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 * @throws NotConnectedException 
 */ 
private List<PrivacyItem> getPrivacyListItems(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException  {
    assert StringUtils.isNotEmpty(listName);
    // The request of the list is an privacy message with an empty list
    Privacy request = new Privacy();
    request.setPrivacyList(listName, new ArrayList<PrivacyItem>());
    
    // Send the package to the server and get the answer
    Privacy privacyAnswer = getRequest(request);
    
    return privacyAnswer.getPrivacyList(listName);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:21,代码来源:PrivacyListManager.java


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