Examples of CommunicationsException


Examples of com.cosmo.comm.CommunicationsException

         transport.sendMessage(msg, msg.getAllRecipients());
         transport.close();
      }
      catch (MessagingException ex)
      {
         throw new CommunicationsException("ERROR sending email message. " + ex.getMessage(), ex);
      }
      catch (UnsupportedEncodingException ex)
      {
         throw new CommunicationsException("ERROR encoding mail address (mail: " + this.fromAddress + ", name: " + this.fromName + "). " + ex.getMessage(), ex);
      }
   }
View Full Code Here

Examples of org.jivesoftware.openfire.sip.tester.comm.CommunicationsException

        catch (SipSecurityException exc) {
            // tell the others we couldn't register
            sipManCallback.fireUnregistered(((FromHeader) clientTransaction
                    .getRequest().getHeader(FromHeader.NAME)).getAddress()
                    .toString());
            sipManCallback.fireCommunicationsError(new CommunicationsException(
                    "Authorization failed!", exc));
        }
        catch (Exception exc) {
            // tell the others we couldn't register
            sipManCallback.fireUnregistered(((FromHeader) clientTransaction
                    .getRequest().getHeader(FromHeader.NAME)).getAddress()
                    .toString());
            sipManCallback.fireCommunicationsError(new CommunicationsException(
                    "Failed to resend a request "
                            + "after a security challenge!", exc));
        }
    }
View Full Code Here

Examples of org.jivesoftware.openfire.sip.tester.comm.CommunicationsException

                requestURI = sipManCallback.addressFactory.createSipURI(null,
                        registrarAddress);
            }
            catch (ParseException ex) {

                throw new CommunicationsException("Bad registrar address:"
                        + registrarAddress, ex);
            }
            catch (NullPointerException ex) {
                // Do not throw an exc, we should rather silently notify the
                // user
                // throw new CommunicationsException("A registrar address was
                // not specified!", ex);
                sipManCallback.fireUnregistered(fromAddress.getURI().toString()
                        + " (registrar not specified)");
                return;
            }

            requestURI.setPort(registrarPort);
            try {
                requestURI.setTransportParam(registrarTransport);
            }
            catch (ParseException ex) {
                throw new CommunicationsException(registrarTransport
                        + " is not a valid transport!", ex);
            }
            // Call ID Header
            CallIdHeader callIdHeader = sipManCallback.sipProvider
                    .getNewCallId();
            // CSeq Header
            CSeqHeader cSeqHeader = null;
            try {
                cSeqHeader = sipManCallback.headerFactory.createCSeqHeader(1,
                        Request.REGISTER);
            }
            catch (ParseException ex) {
                // Should never happen

                Log.error("register", ex);

            }
            catch (InvalidArgumentException ex) {
                // Should never happen

                Log.error("register", ex);

            }
            // To Header
            ToHeader toHeader = null;
            try {
                toHeader = sipManCallback.headerFactory.createToHeader(
                        fromAddress, null);
            }
            catch (ParseException ex) {
                // throw was missing - reported by Eero Vaarnas
                throw new CommunicationsException(
                        "Could not create a To header " + "for address:"
                                + fromHeader.getAddress(), ex);
            }
            // User Agent Header
            UserAgentHeader uaHeader = null;
            ArrayList<String> userAgentList = new ArrayList<String>();
            userAgentList.add(SIPConfig.getStackName());

            try {
                uaHeader = sipManCallback.headerFactory
                        .createUserAgentHeader(userAgentList);
            }
            catch (ParseException ex) {
                // throw was missing - reported by Eero Vaarnas
                throw new CommunicationsException(
                        "Could not create a To header " + "for address:"
                                + fromHeader.getAddress(), ex);
            }
            // Via Headers
            ArrayList viaHeaders = sipManCallback.getLocalViaHeaders();
            // MaxForwardsHeader
            MaxForwardsHeader maxForwardsHeader = sipManCallback
                    .getMaxForwardsHeader();
            // Request
            Request request = null;
            try {
                request = sipManCallback.messageFactory.createRequest(
                        requestURI, Request.REGISTER, callIdHeader, cSeqHeader,
                        fromHeader, toHeader, viaHeaders, maxForwardsHeader);
                request.setHeader(uaHeader);
            }
            catch (ParseException ex) {

                // throw was missing - reported by Eero Vaarnas
                throw new CommunicationsException(
                        "Could not create the register request!", ex);
            }
            // Expires Header
            ExpiresHeader expHeader = null;
            for (int retry = 0; retry < 2; retry++) {
                try {
                    expHeader = sipManCallback.headerFactory
                            .createExpiresHeader(expires);
                }
                catch (InvalidArgumentException ex) {
                    if (retry == 0) {
                        expires = 3600;
                        continue;
                    }
                    throw new CommunicationsException(
                            "Invalid registrations expiration parameter - "
                                    + expires, ex);
                }
            }
            request.addHeader(expHeader);
            // Contact Header should contain IP - bug report - Eero Vaarnas
            ContactHeader contactHeader = sipManCallback
                    .getRegistrationContactHeader();
            request.addHeader(contactHeader);
            // Transaction
            ClientTransaction regTrans = null;
            try {
                regTrans = sipManCallback.sipProvider
                        .getNewClientTransaction(request);
            }
            catch (TransactionUnavailableException ex) {
                // throw was missing - reported by Eero Vaarnas
                throw new CommunicationsException(
                        "Could not create a register transaction!\n"
                                + "Check that the Registrar address is correct!");
            }
            try {
                regTrans.sendRequest();
            }
            // we sometimes get a null pointer exception here so catch them all
            catch (Exception ex) {

                // throw was missing - reported by Eero Vaarnas
                throw new CommunicationsException(
                        "Could not send out the register request!", ex);
            }
            this.registerRequest = request;
        }
        catch (Exception e) {
View Full Code Here

Examples of org.jivesoftware.openfire.sip.tester.comm.CommunicationsException

            isUnregistering = true;

            Request registerRequest = getRegisterRequest();
            if (this.registerRequest == null) {

                throw new CommunicationsException(
                        "Couldn't find the initial register request");
            }
            Request unregisterRequest = (Request) registerRequest.clone();
            try {
                unregisterRequest.getExpires().setExpires(0);
                CSeqHeader cSeqHeader = (CSeqHeader) unregisterRequest
                        .getHeader(CSeqHeader.NAME);
                // [issue 1] - increment registration cseq number
                // reported by - Roberto Tealdi <roby.tea@tin.it>
                cSeqHeader
                        .setSequenceNumber(cSeqHeader.getSequenceNumber() + 1);

            }
            catch (InvalidArgumentException ex) {

                // Shouldn't happen
                throw new CommunicationsException(
                        "Unable to set Expires Header", ex);
            }
            ClientTransaction unregisterTransaction = null;
            try {
                unregisterTransaction = sipManCallback.sipProvider
                        .getNewClientTransaction(unregisterRequest);
            }
            catch (TransactionUnavailableException ex) {

                throw new CommunicationsException(
                        "Unable to create a unregister transaction", ex);
            }
            try {
                sipManCallback
                        .fireUnregistering(sipManCallback.currentlyUsedURI);
                unregisterTransaction.sendRequest();
            }
            catch (SipException ex) {

                throw new CommunicationsException(
                        "Failed to send unregister request", ex);
            }
        }
        catch (Exception e) {
View Full Code Here

Examples of org.jivesoftware.openfire.sip.tester.comm.CommunicationsException

                    register(registrarAddress, registrarPort, transport,
                            expires);
            }
            catch (CommunicationsException ex) {
                sipManCallback
                        .fireCommunicationsError(new CommunicationsException(
                                "Failed to reRegister", ex));
            }
        }
View Full Code Here

Examples of org.jivesoftware.openfire.sip.tester.comm.CommunicationsException

            messageFactory = sipFactory.createMessageFactory();
        }
        catch (PeerUnavailableException ex) {
            Log.error("start", ex);

            throw new CommunicationsException(
                    "Could not create factories!", ex);
        }

        try {
            sipStack = sipFactory.createSipStack(System.getProperties());
            ((SipCommRouter) sipStack.getRouter())
                    .setOutboundProxy(SIPConfig.getOutboundProxy());
        }
        catch (PeerUnavailableException ex) {
            Log.error("start", ex);

            throw new CommunicationsException(
                    "Cannot connect!\n"
                            + "Cannot reach proxy.\nCheck your connection."
                            + "(Syntax:<proxy_address:port/transport>)", ex);
        }

        try {
            boolean successfullyBound = false;
            while (!successfullyBound) {
                try {

                    publicIpAddress = new InetSocketAddress(localAddress, localPort);
                    listeningPoint = sipStack.createListeningPoint(
                            localPort, transport);
                }
                catch (InvalidArgumentException ex) {
                    // choose another port between 1024 and 65000

                    localPort = (int) ((65000 - 1024) * Math.random()) + 1024;
                    try {
                        Thread.sleep(1000);
                    }
                    catch (Exception e) {
                        // Do Nothing
                    }

                    continue;
                }
                successfullyBound = true;
            }
        }
        catch (TransportNotSupportedException ex) {
            throw new CommunicationsException(
                    "Transport "
                            + transport
                            + " is not suppported by the stack!\n Try specifying another"
                            + " transport in Mais property files.\n", ex);
        }
        try {
            sipProvider = sipStack.createSipProvider(listeningPoint);
        }
        catch (ObjectInUseException ex) {
            Log.error("start", ex);

            throw new CommunicationsException(
                    "Could not create factories!\n", ex);
        }
        try {
            sipProvider.addSipListener(this);
        }
        catch (TooManyListenersException exc) {
            throw new CommunicationsException(
                    "Could not register SipManager as a sip listener!", exc);
        }

        sipSecurityManager.setHeaderFactory(headerFactory);
        sipSecurityManager.setTransactionCreator(sipProvider);
View Full Code Here

Examples of org.jivesoftware.openfire.sip.tester.comm.CommunicationsException

        if (sipStack == null)
            return;

        if (tries >= SipManager.RETRY_OBJECT_DELETES)
            throw new CommunicationsException(
                    "Failed to delete the sipProvider!");

        if (sipStack == null)
            return;

        // Delete RI ListeningPoint
        for (tries = 0; tries < SipManager.RETRY_OBJECT_DELETES; tries++) {
            try {
                sipStack.deleteListeningPoint(listeningPoint);
            }
            catch (ObjectInUseException ex) {
                // Log.debug("Retrying delete of riListeningPoint!");
                SipManager.sleep(SipManager.RETRY_OBJECT_DELETES_AFTER);
                continue;
            }
            break;
        }

        if (sipStack != null) {

            for (Iterator<SipProvider> it = sipStack.getSipProviders(); it.hasNext();) {
                SipProvider element = it.next();
                try {
                    sipStack.deleteSipProvider(element);
                }
                catch (Exception e) {
                    // Do nothing
                }
            }
        }
        if (tries >= SipManager.RETRY_OBJECT_DELETES)
            throw new CommunicationsException(
                    "Failed to delete a listeningPoint!");

        listeningPoint = null;
        addressFactory = null;
        messageFactory = null;
View Full Code Here

Examples of org.jivesoftware.openfire.sip.tester.comm.CommunicationsException

            notImplemented = messageFactory.createResponse(
                    Response.NOT_IMPLEMENTED, request);
            attachToTag(notImplemented, serverTransaction.getDialog());
        }
        catch (ParseException ex) {
            fireCommunicationsError(new CommunicationsException(
                    "Failed to create a NOT_IMPLEMENTED response to a "
                            + request.getMethod() + " request!", ex));
            return;
        }
        try {
            serverTransaction.sendResponse(notImplemented);
        }
        catch (SipException ex) {
            fireCommunicationsError(new CommunicationsException(
                    "Failed to create a NOT_IMPLEMENTED response to a "
                            + request.getMethod() + " request!", ex));
        }
    }
View Full Code Here

Examples of org.jivesoftware.openfire.sip.tester.comm.CommunicationsException

            fromHeader = headerFactory.createFromHeader(fromAddress,
                    Integer.toString(hashCode()));

        }
        catch (ParseException ex) {
            throw new CommunicationsException(
                    "A ParseException occurred while creating From Header!",
                    ex);
        }
        return fromHeader;
    }
View Full Code Here

Examples of org.jivesoftware.openfire.sip.tester.comm.CommunicationsException

            contactHeader = headerFactory
                    .createContactHeader(contactAddress);

        }
        catch (ParseException ex) {
            throw new CommunicationsException(
                    "A ParseException occurred while creating From Header!",
                    ex);
        }
        return contactHeader;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.