Package org.wso2.carbon.mashup.imwrapper.core

Examples of org.wso2.carbon.mashup.imwrapper.core.IMException


            if (log.isDebugEnabled()) {
                log.debug("Connection disconnected");
            }
        } else {
            log.error("Cannot disconnect cause the connection is not made as yet");
            throw new IMException("Cannot disconnect cause the connection is not made as yet");
        }


    }
View Full Code Here


                log.error(e);
            }
        } while (!loginProcessed);

        if (!loggedIn) {
            throw new IMException(errorMessage);
        }
    }
View Full Code Here

        }
    }

    public void sendMessage(String to, String message) throws IMException {
        if (disconnectCalled) {
            throw new IMException("Unable to send message cause the IM connection is been " +
                    "disconnected");
        }
        if (loginProcessed && loggedIn) {
            final Email email = Email.parseStr(to);
            final String text = message;
            messageCount ++;
            MsnSwitchboard[] switchboards = messenger.getActiveSwitchboards();
            for (MsnSwitchboard switchboard1 : switchboards) {
                if (switchboard1.containContact(email)
                        && switchboard1.getAllContacts().length == 1) {
                    switchboard1.sendText(text);
                    messageCount--;
                    return;
                }
            }

            final Object attachment = new Object();
            messenger.addSwitchboardListener(new MsnSwitchboardAdapter() {

                public void switchboardStarted(MsnSwitchboard switchboard) {
                    if (switchboard.getAttachment() == attachment) {
                        switchboard.inviteContact(email);
                    }
                }

                public void contactJoinSwitchboard(MsnSwitchboard switchboard,
                                                   MsnContact contact) {
                    if (switchboard.getAttachment() == attachment
                            && email.equals(contact.getEmail())) {
                        switchboard.setAttachment(null);
                        messenger.removeSwitchboardListener(this);
                        switchboard.sendText(text);
                        messageCount --;
                    }
                }

            });
            messenger.newSwitchboard(attachment);
        } else {
            log.error("Got to Log in before a message can be sent.");
            throw new IMException("Got to Log in before a message can be sent.");
        }
    }
View Full Code Here

            loggedIn = false;

            // If there were unsent messgaes, probably the messages were sent to non-existing users
            // we throw an exception after disconnection
            if (messageCount > 0) {
                throw new IMException(
                        "There are some messages that were not sent to MSN recipients. " +
                                "The reason could be that these recipients were not online. " +
                                messageCount + " messages were not delivered");
            }
        } else {
            log.error("Cannot disconnect cause the connection is not made as yet");
            throw new IMException("Cannot disconnect cause the connection is not made as yet");
        }
    }
View Full Code Here

    public void login(String userID, String password) throws IMException {
        int index = userID.indexOf("@");
        if (index < 1 || userID.length() == (index + 1)) {
            log.error(
                    "The format of the userID is incorrect. The userID must be of the form userName@jabberServer");
            throw new IMException(
                    "The format of the userID is incorrect. The userID must be of the form userName@jabberServer");
        }
        String username = userID.substring(0, index);
        String serverName = userID.substring(index + 1);
        connection = new XMPPConnection(serverName);
        try {
            connection.connect();
            connection.login(username, password);
        } catch (XMPPException e) {
            loginProcessed = true;
            loggedIn = false;
            log.error(e);
            throw new IMException(e);
        }
        loginProcessed = true;
        loggedIn = true;
    }
View Full Code Here

            chatMessage.setBody(message);
            chatMessage.setType(Message.Type.normal);
            connection.sendPacket(chatMessage);
        } else {
            log.error("Got to Log in before a message can be sent.");
            throw new IMException("Got to Log in before a message can be sent.");
        }
    }
View Full Code Here

            if (log.isDebugEnabled()) {
                log.debug("Connection to jabber server disconnected");
            }
        } else {
            log.error("Cannot disconnect cause the connection is not made as yet");
            throw new IMException("Cannot disconnect cause the connection is not made as yet");
        }
    }
View Full Code Here

        }

        public void run() {
            try {
                MessageContext msgCtx = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
                Event<MessageContext> event = new Event(msgCtx);
                subscriptions = subscriptionManager.getMatchingSubscriptions(event);
            } catch (EventException e) {
                handleException("Matching subscriptions fetching error", e);
            }
View Full Code Here

     * @throws EventException event
     */
    private void processGetStatusRequest(MessageContext mc,
                                         ResponseMessageBuilder messageBuilder)
            throws AxisFault, EventException {
        Subscription subscription =
                SubscriptionMessageBuilder.createGetStatusMessage(mc);
        if (log.isDebugEnabled()) {
            log.debug("GetStatus request recived for SynapseSubscription ID : " +
                    subscription.getId());
        }
        subscription = subscriptionManager.getSubscription(subscription.getId());
        if (subscription != null) {
            if (log.isDebugEnabled()) {
                log.debug("Sending GetStatus responce for SynapseSubscription ID : " +
                        subscription.getId());
            }
            //send the responce
            SOAPEnvelope soapEnvelope = messageBuilder.genGetStatusResponse(subscription);
            dispatchResponse(soapEnvelope, EventingConstants.WSE_GET_STATUS_RESPONSE,
                    mc, false);
View Full Code Here


    public SynapseSubscription() {
        this.setId(UIDGenerator.generateURNString());
        this.setDeliveryMode(EventingConstants.WSE_DEFAULT_DELIVERY_MODE);
        SubscriptionData subscriptionData = new SubscriptionData();
        subscriptionData.setProperty(SynapseEventingConstants.STATIC_ENTRY, "false");
        this.setSubscriptionData(subscriptionData);
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.mashup.imwrapper.core.IMException

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.