Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Fconnectionroutesms #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package frontlinesms2

import frontlinesms2.camel.routesms.*

import org.apache.camel.Exchange
import org.apache.camel.builder.RouteBuilder
import org.apache.camel.model.RouteDefinition
import frontlinesms2.camel.exception.*

class RoutesmsFconnection extends Fconnection {
private static final String ROUTESMS_URL = "http://121.241.242.114/websms/"
static final configFields = ["name", "username", "password"]
static final defaultValues = []
static String getShortName() { "routesms" }

String username
String password // FIXME maybe encode this rather than storing plaintext
String message
/**
*String type
*String dlr
*String destination
*String source
*String server
*/

static passwords = ['password']

static mapping = {
password column: 'routesms_password'
}

List<RouteDefinition> getRouteDefinitions() {
return new RouteBuilder() {
@Override void configure() {}
List getRouteDefinitions() {
return [from("seda:out-${RoutesmsFconnection.this.id}")
.onException(AuthenticationException, InvalidApiIdException)
.handled(true)
.beanRef('fconnectionService', 'handleDisconnection')
.end()
.setHeader(Fconnection.HEADER_FCONNECTION_ID, simple(ClickatellFconnection.this.id.toString()))
.process(new ClickatellPreProcessor())
.setHeader(Exchange.HTTP_QUERY,
simple('api_id=${header.routesms.apiId}&' +
'user=${header.routesms.username}&' +
'password=${header.routesms.password}&' +
'to=${header.routesms.dst}&' +
'text=${body}'))
.to(ROUTESMS_URL)
.process(new RoutesmsPostProcessor())
.routeId("out-internet-${RoutesmsFconnection.this.id}")]
}
}.routeDefinitions
}
}