Example usage for org.apache.commons.configuration Configuration subset

List of usage examples for org.apache.commons.configuration Configuration subset

Introduction

In this page you can find the example usage for org.apache.commons.configuration Configuration subset.

Prototype

Configuration subset(String prefix);

Source Link

Document

Return a decorator Configuration containing every key from the current Configuration that starts with the specified prefix.

Usage

From source file:org.mobicents.servlet.sip.restcomm.http.security.Realm.java

private SimpleRole getRole(final String role) {
    if (roles != null) {
        return roles.get(role);
    } else {/*from   w w w.  java2 s.  co  m*/
        synchronized (this) {
            if (roles == null) {
                roles = new HashMap<String, SimpleRole>();
                final ServiceLocator services = ServiceLocator.getInstance();
                final Configuration configuration = services.get(Configuration.class);
                loadSecurityRoles(configuration.subset("security-roles"));
            }
        }
        return roles.get(role);
    }
}

From source file:org.restcomm.connect.commons.push.PushNotificationServerHelper.java

public PushNotificationServerHelper(final ActorSystem actorSystem, final Configuration configuration) {
    this.dispatcher = actorSystem.dispatchers().lookup("restcomm-blocking-dispatcher");

    final Configuration runtime = configuration.subset("runtime-settings");
    this.pushNotificationServerEnabled = runtime.getBoolean("push-notification-server-enabled", false);
    if (this.pushNotificationServerEnabled) {
        this.pushNotificationServerUrl = runtime.getString("push-notification-server-url");
        this.pushNotificationServerDelay = runtime.getLong("push-notification-server-delay");
    }/*from   ww  w  . j av  a2 s .c  o m*/
}

From source file:org.restcomm.connect.dao.mybatis.MybatisDaoManager.java

@Override
public void configure(final Configuration configuration, Configuration daoManagerConfiguration) {
    this.configuration = daoManagerConfiguration.subset("dao-manager");
    this.amazonS3Configuration = configuration.subset("amazon-s3");
    this.runtimeConfiguration = configuration.subset("runtime-settings");
}

From source file:org.restcomm.connect.http.filters.FileCacheServlet.java

/**
 * Process the actual request./*from  w  w  w .java 2  s  .com*/
 *
 * @param request The request to be processed.
 * @param response The response to be created.
 * @param content Whether the request body should be written (GET) or not
 * (HEAD).
 * @throws IOException If something fails at I/O level.
 */
private void processRequest(HttpServletRequest request, HttpServletResponse response, boolean content)
        throws IOException {
    // Validate the requested file ------------------------------------------------------------

    // Get requested file by path info.
    String requestedFile = request.getPathInfo();
    if (logger.isDebugEnabled()) {
        logger.debug("Requested path:" + requestedFile);
    }

    // Check if file is actually supplied to the request URL.
    if (requestedFile == null) {
        logger.debug("No file requested, return 404.");
        // Do your thing if the file is not supplied to the request URL.
        // Throw an exception, or send 404, or show default/warning page, or just ignore it.
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
        return;
    }

    Configuration rootConfiguration = (Configuration) request.getServletContext()
            .getAttribute(Configuration.class.getName());
    Configuration runtimeConfiguration = rootConfiguration.subset("runtime-settings");

    String basePath = runtimeConfiguration.getString("cache-path");
    int bufferSize = runtimeConfiguration.getInteger("cache-buffer-size", DEFAULT_BUFFER_SIZE);
    long expireTime = runtimeConfiguration.getLong("cache-expire-time", DEFAULT_EXPIRE_TIME);

    // URL-decode the file name (might contain spaces and on) and prepare file object.
    String fDecodedPath = URLDecoder.decode(requestedFile, "UTF-8");
    File file = new File(basePath, fDecodedPath);

    // Check if file actually exists in filesystem.
    if (!file.exists()) {
        logger.debug("Requested file not found, return 404.");
        // Do your thing if the file appears to be non-existing.
        // Throw an exception, or send 404, or show default/warning page, or just ignore it.
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
        return;
    }

    // Prepare some variables. The ETag is an unique identifier of the file.
    String fileName = file.getName();
    long length = file.length();
    long lastModified = file.lastModified();
    String eTag = fileName + "_" + length + "_" + lastModified;
    long expires = System.currentTimeMillis() + expireTime;

    // Validate request headers for caching ---------------------------------------------------
    // If-None-Match header should contain "*" or ETag. If so, then return 304.
    String ifNoneMatch = request.getHeader("If-None-Match");
    if (ifNoneMatch != null && matches(ifNoneMatch, eTag)) {
        logger.debug("IfNoneMatch/Etag not matching, return 304.");
        response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
        response.setHeader("ETag", eTag); // Required in 304.
        response.setDateHeader("Expires", expires); // Postpone cache with 1 week.
        return;
    }

    // If-Modified-Since header should be greater than LastModified. If so, then return 304.
    // This header is ignored if any If-None-Match header is specified.
    long ifModifiedSince = request.getDateHeader("If-Modified-Since");
    if (ifNoneMatch == null && ifModifiedSince != -1 && ifModifiedSince + 1000 > lastModified) {
        logger.debug("IfModifiedSince not matching, return 304.");
        response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
        response.setHeader("ETag", eTag); // Required in 304.
        response.setDateHeader("Expires", expires); // Postpone cache with 1 week.
        return;
    }

    // Validate request headers for resume ----------------------------------------------------
    // If-Match header should contain "*" or ETag. If not, then return 412.
    String ifMatch = request.getHeader("If-Match");
    if (ifMatch != null && !matches(ifMatch, eTag)) {
        logger.debug("ifMatch not matching, return 412.");
        response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
        return;
    }

    // If-Unmodified-Since header should be greater than LastModified. If not, then return 412.
    long ifUnmodifiedSince = request.getDateHeader("If-Unmodified-Since");
    if (ifUnmodifiedSince != -1 && ifUnmodifiedSince + 1000 <= lastModified) {
        logger.debug("ifUnmodifiedSince not matching, return 412.");
        response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
        return;
    }

    // Prepare and initialize response --------------------------------------------------------
    // Get content type by file name and content disposition.
    String contentType = getServletContext().getMimeType(fileName);
    String disposition = "inline";

    // If content type is unknown, then set the default value.
    // For all content types, see: http://www.w3schools.com/media/media_mimeref.asp
    // To add new content types, add new mime-mapping entry in web.xml.
    if (contentType == null) {
        contentType = "application/octet-stream";
    }

    // If content type is text, expand content type with the one and right character encoding.
    if (contentType.startsWith("text")) {
        contentType += ";charset=UTF-8";
    } // Else, expect for images, determine content disposition. If content type is supported by
      // the browser, then set to inline, else attachment which will pop a 'save as' dialogue.
    else if (!contentType.startsWith("image")) {
        String accept = request.getHeader("Accept");
        disposition = accept != null && accepts(accept, contentType) ? "inline" : "attachment";
    }

    // Initialize response.
    response.reset();
    response.setBufferSize(bufferSize);
    response.setHeader("Content-Disposition", disposition + ";filename=\"" + fileName + "\"");
    response.setHeader("Accept-Ranges", "bytes");
    response.setHeader("ETag", eTag);
    response.setDateHeader("Last-Modified", lastModified);
    response.setDateHeader("Expires", expires);

    // Send requested file (part(s)) to client ------------------------------------------------
    // Prepare streams.
    FileInputStream input = null;
    OutputStream output = null;

    if (content) {
        logger.debug("Content requested,streaming.");
        // Open streams.
        input = new FileInputStream(file);
        output = response.getOutputStream();
        long streamed = stream(input, output, bufferSize);
        if (logger.isDebugEnabled()) {
            logger.debug("Bytes streamed:" + streamed);
        }
    }

}

From source file:org.restcomm.connect.interpreter.SmsInterpreter.java

public SmsInterpreter(final ActorRef service, final Configuration configuration, final DaoManager storage,
        final Sid accountId, final String version, final URI url, final String method, final URI fallbackUrl,
        final String fallbackMethod) {
    super();/*from  ww  w .jav a2  s.c  o  m*/
    final ActorRef source = self();
    this.system = context().system();
    uninitialized = new State("uninitialized", null, null);
    acquiringLastSmsRequest = new State("acquiring last sms event", new AcquiringLastSmsEvent(source), null);
    downloadingRcml = new State("downloading rcml", new DownloadingRcml(source), null);
    downloadingFallbackRcml = new State("downloading fallback rcml", new DownloadingFallbackRcml(source), null);
    ready = new State("ready", new Ready(source), null);
    redirecting = new State("redirecting", new Redirecting(source), null);
    creatingSmsSession = new State("creating sms session", new CreatingSmsSession(source), null);
    sendingSms = new State("sending sms", new SendingSms(source), null);
    waitingForSmsResponses = new State("waiting for sms responses", new WaitingForSmsResponses(source), null);
    sendingEmail = new State("sending Email", new SendingEmail(source), null);
    finished = new State("finished", new Finished(source), null);
    // Initialize the transitions for the FSM.
    final Set<Transition> transitions = new HashSet<Transition>();
    transitions.add(new Transition(uninitialized, acquiringLastSmsRequest));
    transitions.add(new Transition(acquiringLastSmsRequest, downloadingRcml));
    transitions.add(new Transition(acquiringLastSmsRequest, finished));
    transitions.add(new Transition(acquiringLastSmsRequest, sendingEmail));
    transitions.add(new Transition(downloadingRcml, ready));
    transitions.add(new Transition(downloadingRcml, downloadingFallbackRcml));
    transitions.add(new Transition(downloadingRcml, finished));
    transitions.add(new Transition(downloadingRcml, sendingEmail));
    transitions.add(new Transition(downloadingFallbackRcml, ready));
    transitions.add(new Transition(downloadingFallbackRcml, finished));
    transitions.add(new Transition(downloadingFallbackRcml, sendingEmail));
    transitions.add(new Transition(ready, redirecting));
    transitions.add(new Transition(ready, creatingSmsSession));
    transitions.add(new Transition(ready, waitingForSmsResponses));
    transitions.add(new Transition(ready, sendingEmail));
    transitions.add(new Transition(ready, finished));
    transitions.add(new Transition(redirecting, ready));
    transitions.add(new Transition(redirecting, creatingSmsSession));
    transitions.add(new Transition(redirecting, finished));
    transitions.add(new Transition(redirecting, sendingEmail));
    transitions.add(new Transition(redirecting, waitingForSmsResponses));
    transitions.add(new Transition(creatingSmsSession, sendingSms));
    transitions.add(new Transition(creatingSmsSession, waitingForSmsResponses));
    transitions.add(new Transition(creatingSmsSession, sendingEmail));
    transitions.add(new Transition(creatingSmsSession, finished));
    transitions.add(new Transition(sendingSms, ready));
    transitions.add(new Transition(sendingSms, redirecting));
    transitions.add(new Transition(sendingSms, creatingSmsSession));
    transitions.add(new Transition(sendingSms, waitingForSmsResponses));
    transitions.add(new Transition(sendingSms, sendingEmail));
    transitions.add(new Transition(sendingSms, finished));
    transitions.add(new Transition(waitingForSmsResponses, waitingForSmsResponses));
    transitions.add(new Transition(waitingForSmsResponses, sendingEmail));
    transitions.add(new Transition(waitingForSmsResponses, finished));
    transitions.add(new Transition(sendingEmail, ready));
    transitions.add(new Transition(sendingEmail, redirecting));
    transitions.add(new Transition(sendingEmail, creatingSmsSession));
    transitions.add(new Transition(sendingEmail, waitingForSmsResponses));
    transitions.add(new Transition(sendingEmail, finished));
    // Initialize the FSM.
    this.fsm = new FiniteStateMachine(uninitialized, transitions);
    // Initialize the runtime stuff.
    this.service = service;
    this.downloader = downloader();
    this.storage = storage;
    this.emailconfiguration = configuration.subset("smtp-service");
    this.runtime = configuration.subset("runtime-settings");
    this.configuration = configuration.subset("sms-aggregator");
    this.accountId = accountId;
    this.version = version;
    this.url = url;
    this.method = method;
    this.fallbackUrl = fallbackUrl;
    this.fallbackMethod = fallbackMethod;
    this.sessions = new HashMap<Sid, ActorRef>();
    this.normalizeNumber = runtime.getBoolean("normalize-numbers-for-outbound-calls");
}

From source file:org.restcomm.connect.interpreter.SubVoiceInterpreter.java

public SubVoiceInterpreter(final Configuration configuration, final Sid account, final Sid phone,
        final String version, final URI url, final String method, final URI fallbackUrl,
        final String fallbackMethod, final URI statusCallback, final String statusCallbackMethod,
        final String emailAddress, final ActorRef callManager, final ActorRef conferenceManager,
        final ActorRef sms, final DaoManager storage, final Boolean hangupOnEnd) {
    super();//from  w ww . j  a va 2 s  . c o m
    source = self();
    downloadingRcml = new State("downloading rcml", new DownloadingRcml(source), null);
    ready = new State("ready", new Ready(source), null);
    notFound = new State("notFound", new NotFound(source), null);
    rejecting = new State("rejecting", new Rejecting(source), null);
    finished = new State("finished", new Finished(source), null);

    transitions.add(new Transition(acquiringAsrInfo, finished));
    transitions.add(new Transition(acquiringSynthesizerInfo, finished));
    transitions.add(new Transition(acquiringCallInfo, downloadingRcml));
    transitions.add(new Transition(acquiringCallInfo, finished));
    transitions.add(new Transition(downloadingRcml, ready));
    transitions.add(new Transition(downloadingRcml, notFound));
    transitions.add(new Transition(downloadingRcml, hangingUp));
    transitions.add(new Transition(downloadingRcml, finished));
    transitions.add(new Transition(ready, faxing));
    transitions.add(new Transition(ready, pausing));
    transitions.add(new Transition(ready, checkingCache));
    transitions.add(new Transition(ready, caching));
    transitions.add(new Transition(ready, synthesizing));
    transitions.add(new Transition(ready, rejecting));
    transitions.add(new Transition(ready, redirecting));
    transitions.add(new Transition(ready, processingGatherChildren));
    transitions.add(new Transition(ready, creatingRecording));
    transitions.add(new Transition(ready, creatingSmsSession));
    transitions.add(new Transition(ready, hangingUp));
    transitions.add(new Transition(ready, finished));
    transitions.add(new Transition(pausing, ready));
    transitions.add(new Transition(pausing, finished));
    transitions.add(new Transition(rejecting, finished));
    transitions.add(new Transition(faxing, ready));
    transitions.add(new Transition(faxing, finished));
    transitions.add(new Transition(caching, finished));
    transitions.add(new Transition(playing, ready));
    transitions.add(new Transition(playing, finished));
    transitions.add(new Transition(synthesizing, finished));
    transitions.add(new Transition(redirecting, ready));
    transitions.add(new Transition(redirecting, finished));
    transitions.add(new Transition(creatingRecording, finished));
    transitions.add(new Transition(finishRecording, ready));
    transitions.add(new Transition(finishRecording, finished));
    transitions.add(new Transition(processingGatherChildren, finished));
    transitions.add(new Transition(gathering, finished));
    transitions.add(new Transition(finishGathering, finished));
    transitions.add(new Transition(creatingSmsSession, finished));
    transitions.add(new Transition(sendingSms, ready));
    transitions.add(new Transition(sendingSms, finished));
    transitions.add(new Transition(hangingUp, finished));

    // Initialize the FSM.
    this.fsm = new FiniteStateMachine(uninitialized, transitions);
    // Initialize the runtime stuff.
    this.accountId = account;
    this.phoneId = phone;
    this.version = version;
    this.url = url;
    this.method = method;
    this.fallbackUrl = fallbackUrl;
    this.fallbackMethod = fallbackMethod;
    this.viStatusCallback = statusCallback;
    this.viStatusCallbackMethod = statusCallbackMethod;
    this.emailAddress = emailAddress;
    this.configuration = configuration;
    this.callManager = callManager;
    //        this.asrService = asr(configuration.subset("speech-recognizer"));
    //        this.faxService = fax(configuration.subset("fax-service"));
    this.smsService = sms;
    this.smsSessions = new HashMap<Sid, ActorRef>();
    this.storage = storage;
    //        this.synthesizer = tts(configuration.subset("speech-synthesizer"));
    final Configuration runtime = configuration.subset("runtime-settings");
    //        String path = runtime.getString("cache-path");
    //        if (!path.endsWith("/")) {
    //            path = path + "/";
    //        }
    //        path = path + accountId.toString();
    //        cachePath = path;
    //        String uri = runtime.getString("cache-uri");
    //        if (!uri.endsWith("/")) {
    //            uri = uri + "/";
    //        }
    //        try {
    //            uri = UriUtils.resolve(new URI(uri)).toString();
    //        } catch (URISyntaxException e) {
    //            logger.error("URISyntaxException while trying to resolve Cache URI: "+e);
    //        }
    //        uri = uri + accountId.toString();
    //        this.cache = cache(path, uri);
    this.downloader = downloader();
    this.hangupOnEnd = hangupOnEnd;
}

From source file:org.restcomm.connect.interpreter.VoiceInterpreter.java

public VoiceInterpreter(final Configuration configuration, final Sid account, final Sid phone,
        final String version, final URI url, final String method, final URI fallbackUrl,
        final String fallbackMethod, final URI viStatusCallback, final String statusCallbackMethod,
        final String referTarget, final String transferor, final String transferee, final String emailAddress,
        final ActorRef callManager, final ActorRef conferenceManager, final ActorRef bridgeManager,
        final ActorRef sms, final DaoManager storage, final ActorRef monitoring, final String rcml,
        final boolean asImsUa, final String imsUaLogin, final String imsUaPassword) {
    super();//from ww w. j  a  v  a2  s .  c om
    final ActorRef source = self();
    downloadingRcml = new State("downloading rcml", new DownloadingRcml(source), null);
    downloadingFallbackRcml = new State("downloading fallback rcml", new DownloadingFallbackRcml(source), null);
    initializingCall = new State("initializing call", new InitializingCall(source), null);
    // initializedCall = new State("initialized call", new InitializedCall(source), new PostInitializedCall(source));
    ready = new State("ready", new Ready(source), null);
    notFound = new State("notFound", new NotFound(source), null);
    rejecting = new State("rejecting", new Rejecting(source), null);
    startDialing = new State("start dialing", new StartDialing(source), null);
    processingDialChildren = new State("processing dial children", new ProcessingDialChildren(source), null);
    acquiringOutboundCallInfo = new State("acquiring outbound call info", new AcquiringOutboundCallInfo(source),
            null);
    forking = new State("forking", new Forking(source), null);
    // joiningCalls = new State("joining calls", new JoiningCalls(source), null);
    this.creatingBridge = new State("creating bridge", new CreatingBridge(source), null);
    this.initializingBridge = new State("initializing bridge", new InitializingBridge(source), null);
    this.bridging = new State("bridging", new Bridging(source), null);
    bridged = new State("bridged", new Bridged(source), null);
    finishDialing = new State("finish dialing", new FinishDialing(source), null);
    acquiringConferenceInfo = new State("acquiring conference info", new AcquiringConferenceInfo(source), null);
    joiningConference = new State("joining conference", new JoiningConference(source), null);
    conferencing = new State("conferencing", new Conferencing(source), null);
    finishConferencing = new State("finish conferencing", new FinishConferencing(source), null);
    finished = new State("finished", new Finished(source), null);
    /*
     * dialing = new State("dialing", null, null); bridging = new State("bridging", null, null); conferencing = new
     * State("conferencing", null, null);
     */
    transitions.add(new Transition(acquiringAsrInfo, finished));
    transitions.add(new Transition(acquiringSynthesizerInfo, finished));
    transitions.add(new Transition(acquiringCallInfo, initializingCall));
    transitions.add(new Transition(acquiringCallInfo, downloadingRcml));
    transitions.add(new Transition(acquiringCallInfo, finished));
    transitions.add(new Transition(acquiringCallInfo, ready));
    transitions.add(new Transition(initializingCall, downloadingRcml));
    transitions.add(new Transition(initializingCall, ready));
    transitions.add(new Transition(initializingCall, finishDialing));
    transitions.add(new Transition(initializingCall, hangingUp));
    transitions.add(new Transition(initializingCall, finished));
    transitions.add(new Transition(downloadingRcml, ready));
    transitions.add(new Transition(downloadingRcml, notFound));
    transitions.add(new Transition(downloadingRcml, downloadingFallbackRcml));
    transitions.add(new Transition(downloadingRcml, hangingUp));
    transitions.add(new Transition(downloadingRcml, finished));
    transitions.add(new Transition(downloadingFallbackRcml, ready));
    transitions.add(new Transition(downloadingFallbackRcml, hangingUp));
    transitions.add(new Transition(downloadingFallbackRcml, finished));
    transitions.add(new Transition(downloadingFallbackRcml, notFound));
    transitions.add(new Transition(ready, initializingCall));
    transitions.add(new Transition(ready, faxing));
    transitions.add(new Transition(ready, sendingEmail));
    transitions.add(new Transition(ready, pausing));
    transitions.add(new Transition(ready, checkingCache));
    transitions.add(new Transition(ready, caching));
    transitions.add(new Transition(ready, synthesizing));
    transitions.add(new Transition(ready, rejecting));
    transitions.add(new Transition(ready, redirecting));
    transitions.add(new Transition(ready, processingGatherChildren));
    transitions.add(new Transition(ready, creatingRecording));
    transitions.add(new Transition(ready, creatingSmsSession));
    transitions.add(new Transition(ready, startDialing));
    transitions.add(new Transition(ready, hangingUp));
    transitions.add(new Transition(ready, finished));
    transitions.add(new Transition(pausing, ready));
    transitions.add(new Transition(pausing, finished));
    transitions.add(new Transition(rejecting, finished));
    transitions.add(new Transition(faxing, ready));
    transitions.add(new Transition(faxing, finished));
    transitions.add(new Transition(sendingEmail, ready));
    transitions.add(new Transition(sendingEmail, finished));
    transitions.add(new Transition(sendingEmail, finishDialing));
    transitions.add(new Transition(checkingCache, caching));
    transitions.add(new Transition(checkingCache, conferencing));
    transitions.add(new Transition(caching, finished));
    transitions.add(new Transition(caching, conferencing));
    transitions.add(new Transition(caching, finishConferencing));
    transitions.add(new Transition(playing, ready));
    transitions.add(new Transition(playing, finishConferencing));
    transitions.add(new Transition(playing, finished));
    transitions.add(new Transition(synthesizing, finished));
    transitions.add(new Transition(redirecting, ready));
    transitions.add(new Transition(redirecting, finished));
    transitions.add(new Transition(creatingRecording, finished));
    transitions.add(new Transition(finishRecording, ready));
    transitions.add(new Transition(finishRecording, finished));
    transitions.add(new Transition(processingGatherChildren, finished));
    transitions.add(new Transition(gathering, finished));
    transitions.add(new Transition(finishGathering, ready));
    transitions.add(new Transition(finishGathering, finishGathering));
    transitions.add(new Transition(finishGathering, finished));
    transitions.add(new Transition(creatingSmsSession, finished));
    transitions.add(new Transition(sendingSms, ready));
    transitions.add(new Transition(sendingSms, startDialing));
    transitions.add(new Transition(sendingSms, finished));
    transitions.add(new Transition(startDialing, processingDialChildren));
    transitions.add(new Transition(startDialing, acquiringConferenceInfo));
    transitions.add(new Transition(startDialing, faxing));
    transitions.add(new Transition(startDialing, sendingEmail));
    transitions.add(new Transition(startDialing, pausing));
    transitions.add(new Transition(startDialing, checkingCache));
    transitions.add(new Transition(startDialing, caching));
    transitions.add(new Transition(startDialing, synthesizing));
    transitions.add(new Transition(startDialing, redirecting));
    transitions.add(new Transition(startDialing, processingGatherChildren));
    transitions.add(new Transition(startDialing, creatingRecording));
    transitions.add(new Transition(startDialing, creatingSmsSession));
    transitions.add(new Transition(startDialing, startDialing));
    transitions.add(new Transition(startDialing, hangingUp));
    transitions.add(new Transition(startDialing, finished));
    transitions.add(new Transition(processingDialChildren, processingDialChildren));
    transitions.add(new Transition(processingDialChildren, forking));
    transitions.add(new Transition(processingDialChildren, hangingUp));
    transitions.add(new Transition(processingDialChildren, finished));
    transitions.add(new Transition(forking, acquiringOutboundCallInfo));
    transitions.add(new Transition(forking, finishDialing));
    transitions.add(new Transition(forking, hangingUp));
    transitions.add(new Transition(forking, finished));
    transitions.add(new Transition(forking, ready));
    // transitions.add(new Transition(acquiringOutboundCallInfo, joiningCalls));
    transitions.add(new Transition(acquiringOutboundCallInfo, hangingUp));
    transitions.add(new Transition(acquiringOutboundCallInfo, finished));
    transitions.add(new Transition(acquiringOutboundCallInfo, creatingBridge));
    transitions.add(new Transition(creatingBridge, initializingBridge));
    transitions.add(new Transition(creatingBridge, finishDialing));
    transitions.add(new Transition(initializingBridge, bridging));
    transitions.add(new Transition(initializingBridge, hangingUp));
    transitions.add(new Transition(bridging, bridged));
    transitions.add(new Transition(bridging, finishDialing));
    transitions.add(new Transition(bridged, finishDialing));
    transitions.add(new Transition(bridged, finished));
    transitions.add(new Transition(finishDialing, ready));
    transitions.add(new Transition(finishDialing, faxing));
    transitions.add(new Transition(finishDialing, sendingEmail));
    transitions.add(new Transition(finishDialing, pausing));
    transitions.add(new Transition(finishDialing, checkingCache));
    transitions.add(new Transition(finishDialing, caching));
    transitions.add(new Transition(finishDialing, synthesizing));
    transitions.add(new Transition(finishDialing, redirecting));
    transitions.add(new Transition(finishDialing, processingGatherChildren));
    transitions.add(new Transition(finishDialing, creatingRecording));
    transitions.add(new Transition(finishDialing, creatingSmsSession));
    transitions.add(new Transition(finishDialing, startDialing));
    transitions.add(new Transition(finishDialing, hangingUp));
    transitions.add(new Transition(finishDialing, finished));
    transitions.add(new Transition(finishDialing, initializingCall));
    transitions.add(new Transition(acquiringConferenceInfo, joiningConference));
    transitions.add(new Transition(acquiringConferenceInfo, hangingUp));
    transitions.add(new Transition(acquiringConferenceInfo, finished));
    transitions.add(new Transition(joiningConference, conferencing));
    transitions.add(new Transition(joiningConference, hangingUp));
    transitions.add(new Transition(joiningConference, finished));
    transitions.add(new Transition(conferencing, finishConferencing));
    transitions.add(new Transition(conferencing, hangingUp));
    transitions.add(new Transition(conferencing, finished));
    transitions.add(new Transition(conferencing, checkingCache));
    transitions.add(new Transition(conferencing, caching));
    transitions.add(new Transition(conferencing, playing));
    transitions.add(new Transition(conferencing, startDialing));
    transitions.add(new Transition(conferencing, creatingSmsSession));
    transitions.add(new Transition(conferencing, sendingEmail));
    transitions.add(new Transition(finishConferencing, ready));
    transitions.add(new Transition(finishConferencing, faxing));
    transitions.add(new Transition(finishConferencing, sendingEmail));
    transitions.add(new Transition(finishConferencing, pausing));
    transitions.add(new Transition(finishConferencing, checkingCache));
    transitions.add(new Transition(finishConferencing, caching));
    transitions.add(new Transition(finishConferencing, synthesizing));
    transitions.add(new Transition(finishConferencing, redirecting));
    transitions.add(new Transition(finishConferencing, processingGatherChildren));
    transitions.add(new Transition(finishConferencing, creatingRecording));
    transitions.add(new Transition(finishConferencing, creatingSmsSession));
    transitions.add(new Transition(finishConferencing, startDialing));
    transitions.add(new Transition(finishConferencing, hangingUp));
    transitions.add(new Transition(finishConferencing, finished));
    transitions.add(new Transition(hangingUp, finished));
    transitions.add(new Transition(hangingUp, finishConferencing));
    transitions.add(new Transition(hangingUp, finishDialing));
    transitions.add(new Transition(uninitialized, finished));
    transitions.add(new Transition(notFound, finished));
    // Initialize the FSM.
    this.fsm = new FiniteStateMachine(uninitialized, transitions);
    // Initialize the runtime stuff.
    this.accountId = account;
    this.phoneId = phone;
    this.version = version;
    this.url = url;
    this.method = method;
    this.fallbackUrl = fallbackUrl;
    this.fallbackMethod = fallbackMethod;
    this.viStatusCallback = viStatusCallback;
    this.viStatusCallbackMethod = statusCallbackMethod;
    this.referTarget = referTarget;
    this.transferor = transferor;
    this.transferee = transferee;
    this.emailAddress = emailAddress;
    this.configuration = configuration;
    this.callManager = callManager;
    this.conferenceManager = conferenceManager;
    this.bridgeManager = bridgeManager;
    this.smsService = sms;
    this.smsSessions = new HashMap<Sid, ActorRef>();
    this.storage = storage;
    final Configuration runtime = configuration.subset("runtime-settings");
    playMusicForConference = Boolean.parseBoolean(runtime.getString("play-music-for-conference", "false"));
    this.enable200OkDelay = this.configuration.subset("runtime-settings").getBoolean("enable-200-ok-delay",
            false);
    this.downloader = downloader();
    this.monitoring = monitoring;
    this.rcml = rcml;
    this.asImsUa = asImsUa;
    this.imsUaLogin = imsUaLogin;
    this.imsUaPassword = imsUaPassword;
}

From source file:org.restcomm.connect.sms.SmsService.java

public SmsService(final Configuration configuration, final SipFactory factory, final DaoManager storage,
        final ServletContext servletContext) {
    super();/*from  ww  w.j av a  2s  .  co m*/
    this.system = context().system();
    this.configuration = configuration;
    final Configuration runtime = configuration.subset("runtime-settings");
    this.authenticateUsers = runtime.getBoolean("authenticate");
    this.servletConfig = (ServletConfig) configuration.getProperty(ServletConfig.class.getName());
    this.sipFactory = factory;
    this.storage = storage;
    this.servletContext = servletContext;
    monitoringService = (ActorRef) servletContext.getAttribute(MonitoringService.class.getName());
    // final Configuration runtime = configuration.subset("runtime-settings");
    // TODO this.useTo = runtime.getBoolean("use-to");
    patchForNatB2BUASessions = runtime.getBoolean("patch-for-nat-b2bua-sessions", true);

    extensions = ExtensionController.getInstance().getExtensions(ExtensionType.SmsService);
    if (logger.isInfoEnabled()) {
        logger.info("SmsService extensions: " + (extensions != null ? extensions.size() : "0"));
    }
}

From source file:org.restcomm.connect.sms.SmsSession.java

public SmsSession(final Configuration configuration, final SipFactory factory, final SipURI transport,
        final DaoManager storage, final ActorRef monitoringService, final ServletContext servletContext) {
    super();//from   w w  w .j av a  2  s.  c o  m
    this.configuration = configuration;
    this.smsConfiguration = configuration.subset("sms-aggregator");
    this.factory = factory;
    this.observers = new ArrayList<ActorRef>();
    this.transport = transport;
    this.attributes = new HashMap<String, Object>();
    this.storage = storage;
    this.monitoringService = monitoringService;
    this.servletContext = servletContext;
    this.smppActivated = Boolean
            .parseBoolean(this.configuration.subset("smpp").getString("[@activateSmppConnection]", "false"));
    if (smppActivated) {
        smppMessageHandler = (ActorRef) servletContext.getAttribute(SmppMessageHandler.class.getName());
    }
    String defaultHost = transport.getHost();
    this.externalIP = this.configuration.subset("runtime-settings").getString("external-ip");
    if (externalIP == null || externalIP.isEmpty() || externalIP.equals(""))
        externalIP = defaultHost;

    this.tlvSet = new TlvSet();
    if (!this.configuration.subset("outbound-sms").isEmpty()) {
        //TODO: handle arbitrary keys instead of just TAG_DEST_NETWORK_ID
        try {
            String valStr = this.configuration.subset("outbound-sms").getString("destination_network_id");
            this.tlvSet.addOptionalParameter(new Tlv(SmppConstants.TAG_DEST_NETWORK_ID,
                    ByteArrayUtil.toByteArray(Integer.parseInt(valStr))));
        } catch (Exception e) {
            logger.error("Error while parsing tlv configuration " + e);
        }
    }
}

From source file:org.restcomm.connect.telephony.Call.java

public Call(final SipFactory factory, final ActorRef mediaSessionController, final Configuration configuration,
        final URI statusCallback, final String statusCallbackMethod, final List<String> statusCallbackEvent,
        Map<String, ArrayList<String>> headers) {
    super();//from  w ww . j av  a2  s .  com
    final ActorRef source = self();
    this.system = context().system();
    this.statusCallback = statusCallback;
    this.statusCallbackMethod = statusCallbackMethod;
    this.statusCallbackEvent = statusCallbackEvent;
    if (statusCallback != null) {
        downloader = downloader();
    }

    this.extensionHeaders = new HashMap<String, ArrayList<String>>();
    if (headers != null) {
        this.extensionHeaders = headers;
    }

    // States for the FSM
    this.uninitialized = new State("uninitialized", null, null);
    this.initializing = new State("initializing", new Initializing(source), null);
    this.waitingForAnswer = new State("waiting for answer", new WaitingForAnswer(source), null);
    this.queued = new State("queued", new Queued(source), null);
    this.ringing = new State("ringing", new Ringing(source), null);
    this.failingBusy = new State("failing busy", new FailingBusy(source), null);
    this.busy = new State("busy", new Busy(source), null);
    this.notFound = new State("not found", new NotFound(source), null);
    //This time the --new Canceling(source)-- is an ActionOnState. Overloaded constructor is used here
    this.canceling = new State("canceling", new Canceling(source));
    this.canceled = new State("canceled", new Canceled(source), null);
    this.failingNoAnswer = new State("failing no answer", new FailingNoAnswer(source), null);
    this.noAnswer = new State("no answer", new NoAnswer(source), null);
    this.dialing = new State("dialing", new Dialing(source), null);
    this.updatingMediaSession = new State("updating media session", new UpdatingMediaSession(source), null);
    this.inProgress = new State("in progress", new InProgress(source), null);
    this.joining = new State("joining", new Joining(source), null);
    this.leaving = new State("leaving", new Leaving(source), null);
    this.stopping = new State("stopping", new Stopping(source), null);
    this.completed = new State("completed", new Completed(source), null);
    this.failed = new State("failed", new Failed(source), null);
    this.inDialogRequest = new State("InDialogRequest", new InDialogRequest(source), null);

    // Transitions for the FSM
    final Set<Transition> transitions = new HashSet<Transition>();
    transitions.add(new Transition(this.uninitialized, this.ringing));
    transitions.add(new Transition(this.uninitialized, this.queued));
    transitions.add(new Transition(this.uninitialized, this.canceled));
    transitions.add(new Transition(this.uninitialized, this.completed));
    transitions.add(new Transition(this.queued, this.canceled));
    transitions.add(new Transition(this.queued, this.initializing));
    transitions.add(new Transition(this.ringing, this.busy));
    transitions.add(new Transition(this.ringing, this.notFound));
    transitions.add(new Transition(this.ringing, this.canceling));
    transitions.add(new Transition(this.ringing, this.canceled));
    transitions.add(new Transition(this.ringing, this.failingNoAnswer));
    transitions.add(new Transition(this.ringing, this.failingBusy));
    transitions.add(new Transition(this.ringing, this.noAnswer));
    transitions.add(new Transition(this.ringing, this.initializing));
    transitions.add(new Transition(this.ringing, this.updatingMediaSession));
    transitions.add(new Transition(this.ringing, this.completed));
    transitions.add(new Transition(this.ringing, this.stopping));
    transitions.add(new Transition(this.ringing, this.failed));
    transitions.add(new Transition(this.initializing, this.canceling));
    transitions.add(new Transition(this.initializing, this.dialing));
    transitions.add(new Transition(this.initializing, this.failed));
    transitions.add(new Transition(this.initializing, this.inProgress));
    transitions.add(new Transition(this.initializing, this.waitingForAnswer));
    transitions.add(new Transition(this.initializing, this.stopping));
    transitions.add(new Transition(this.waitingForAnswer, this.inProgress));
    transitions.add(new Transition(this.waitingForAnswer, this.joining));
    transitions.add(new Transition(this.waitingForAnswer, this.canceling));
    transitions.add(new Transition(this.waitingForAnswer, this.completed));
    transitions.add(new Transition(this.waitingForAnswer, this.stopping));
    transitions.add(new Transition(this.dialing, this.canceling));
    transitions.add(new Transition(this.dialing, this.stopping));
    transitions.add(new Transition(this.dialing, this.failingBusy));
    transitions.add(new Transition(this.dialing, this.ringing));
    transitions.add(new Transition(this.dialing, this.failed));
    transitions.add(new Transition(this.dialing, this.failingNoAnswer));
    transitions.add(new Transition(this.dialing, this.noAnswer));
    transitions.add(new Transition(this.dialing, this.updatingMediaSession));
    transitions.add(new Transition(this.inProgress, this.stopping));
    transitions.add(new Transition(this.inProgress, this.joining));
    transitions.add(new Transition(this.inProgress, this.leaving));
    transitions.add(new Transition(this.inProgress, this.failed));
    transitions.add(new Transition(this.inProgress, this.inDialogRequest));
    transitions.add(new Transition(this.joining, this.inProgress));
    transitions.add(new Transition(this.joining, this.stopping));
    transitions.add(new Transition(this.joining, this.failed));
    transitions.add(new Transition(this.leaving, this.inProgress));
    transitions.add(new Transition(this.leaving, this.stopping));
    transitions.add(new Transition(this.leaving, this.failed));
    transitions.add(new Transition(this.leaving, this.completed));
    transitions.add(new Transition(this.canceling, this.canceled));
    transitions.add(new Transition(this.canceling, this.completed));
    transitions.add(new Transition(this.failingBusy, this.busy));
    transitions.add(new Transition(this.failingNoAnswer, this.noAnswer));
    transitions.add(new Transition(this.failingNoAnswer, this.canceling));
    transitions.add(new Transition(this.updatingMediaSession, this.inProgress));
    transitions.add(new Transition(this.updatingMediaSession, this.failed));
    transitions.add(new Transition(this.stopping, this.completed));
    transitions.add(new Transition(this.stopping, this.failed));
    transitions.add(new Transition(this.failed, this.completed));
    transitions.add(new Transition(this.completed, this.stopping));
    transitions.add(new Transition(this.completed, this.failed));

    // FSM
    this.fsm = new FiniteStateMachine(this.uninitialized, transitions);

    // SIP runtime stuff.
    this.factory = factory;

    // Conferencing
    this.conferencing = false;

    // Media Session Control runtime stuff.
    this.msController = mediaSessionController;
    this.fail = false;

    // Initialize the runtime stuff.
    this.id = Sid.generate(Sid.Type.CALL);
    this.instanceId = RestcommConfiguration.getInstance().getMain().getInstanceId();
    this.created = DateTime.now();
    this.observers = Collections.synchronizedList(new ArrayList<ActorRef>());
    this.receivedBye = false;

    // Media Group runtime stuff
    this.liveCallModification = false;
    this.recording = false;
    this.configuration = configuration;
    final Configuration runtime = this.configuration.subset("runtime-settings");
    this.disableSdpPatchingOnUpdatingMediaSession = runtime
            .getBoolean("disable-sdp-patching-on-updating-mediasession", false);
    this.enable200OkDelay = runtime.getBoolean("enable-200-ok-delay", false);
    if (!runtime.subset("ims-authentication").isEmpty()) {
        final Configuration imsAuthentication = runtime.subset("ims-authentication");
        this.actAsImsUa = imsAuthentication.getBoolean("act-as-ims-ua");
    }
}