use of org.asteriskjava.manager.action.OriginateAction in project opennms by OpenNMS.
the class AsteriskOriginator method originateCall.
/**
* Originates a call based on properties set on this bean.
*
* @throws org.opennms.netmgt.asterisk.utils.AsteriskOriginatorException if any.
*/
public void originateCall() throws AsteriskOriginatorException {
OriginateAction originateAction = buildOriginateAction();
LOG.info("Logging in Asterisk manager connection");
try {
m_managerConnection.login();
} catch (final IllegalStateException ise) {
throw new AsteriskOriginatorException("Illegal state logging in Asterisk manager connection", ise);
} catch (final IOException ioe) {
throw new AsteriskOriginatorException("I/O exception logging in Asterisk manager connection", ioe);
} catch (final AuthenticationFailedException afe) {
throw new AsteriskOriginatorException("Authentication failure logging in Asterisk manager connection", afe);
} catch (final TimeoutException toe) {
throw new AsteriskOriginatorException("Timed out logging in Asterisk manager connection", toe);
}
LOG.info("Successfully logged in Asterisk manager connection");
LOG.info("Originating a call to extension {}", m_legAExtension);
LOG.debug(createCallLogMsg());
LOG.debug("Originate action:\n\n{}", originateAction.toString());
ManagerResponse managerResponse = null;
try {
managerResponse = m_managerConnection.sendAction(originateAction);
} catch (final IllegalArgumentException iae) {
m_managerConnection.logoff();
throw new AsteriskOriginatorException("Illegal argument sending originate action", iae);
} catch (final IllegalStateException ise) {
m_managerConnection.logoff();
throw new AsteriskOriginatorException("Illegal state sending originate action", ise);
} catch (final IOException ioe) {
m_managerConnection.logoff();
throw new AsteriskOriginatorException("I/O exception sending originate action", ioe);
} catch (final TimeoutException toe) {
m_managerConnection.logoff();
throw new AsteriskOriginatorException("Timed out sending originate action", toe);
}
LOG.info("Asterisk manager responded: {}", managerResponse.getResponse());
LOG.info("Asterisk manager message: {}", managerResponse.getMessage());
if (managerResponse.getResponse().toLowerCase().startsWith("error")) {
m_managerConnection.logoff();
throw new AsteriskOriginatorException("Got error response sending originate event. Response: " + managerResponse.getResponse() + "; Message: " + managerResponse.getMessage());
}
LOG.info("Logging off Asterisk manager connection");
m_managerConnection.logoff();
LOG.info("Successfully logged off Asterisk manager connection");
}
use of org.asteriskjava.manager.action.OriginateAction in project openmeetings by apache.
the class SipDao method joinToConfCall.
/**
* Perform call to specified phone number and join to conference
*
* @param number
* number to call
* @param r
* room to be connected to the call
*/
public void joinToConfCall(String number, Room r) {
String sipNumber = (r != null && r.getConfno() != null) ? r.getConfno() : null;
if (sipNumber == null) {
log.warn("Failed to get SIP number for room: {}", r);
return;
}
OriginateAction oa = new OriginateAction();
oa.setChannel(String.format("Local/%s@rooms-originate", sipNumber));
oa.setContext("rooms-out");
oa.setExten(number);
oa.setPriority(1);
oa.setTimeout(timeout);
exec(oa);
}
use of org.asteriskjava.manager.action.OriginateAction in project opennms by OpenNMS.
the class AsteriskOriginator method buildOriginateAction.
/**
* Build a complete OriginateAction ready for dispatching.
*
* @return completed OriginateAction, ready to be passed to ManagerConnection.sendAction
* @throws org.opennms.netmgt.asterisk.utils.AsteriskOriginatorException if any of the underlying operations fail
*/
public OriginateAction buildOriginateAction() throws AsteriskOriginatorException {
final OriginateAction action = new OriginateAction();
action.setCallerId(m_callerId);
setLegAChannel(expandPattern(m_legAChannelPattern));
action.setChannel(getLegAChannel());
action.setTimeout(m_dialTimeout);
action.setCallerId(m_callerId);
if (m_legBIsApp) {
action.setApplication(expandPattern(m_legBAppPattern));
action.setData(expandPattern(m_legBAppDataPattern));
} else {
action.setContext(m_legBContext);
action.setExten(m_legBExtension);
action.setPriority(m_legBPriority);
}
action.setVariables(m_channelVars);
return action;
}
Aggregations