-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
push global notification class and updated SMS. SMPP and VOICE to use…
… global notification
- Loading branch information
Showing
15 changed files
with
836 additions
and
574 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?xml version="1.0"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.restcomm</groupId> | ||
<artifactId>restcomm-connect</artifactId> | ||
<version>8.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>restcomm-connect.notification</artifactId> | ||
<name>restcomm-connect.notification</name> | ||
|
||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-log4j12</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>commons-configuration</groupId> | ||
<artifactId>commons-configuration</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.scala-lang</groupId> | ||
<artifactId>scala-library</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.typesafe.akka</groupId> | ||
<artifactId>akka-actor_2.10</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.typesafe.akka</groupId> | ||
<artifactId>akka-slf4j_2.10</artifactId> | ||
</dependency> | ||
|
||
|
||
<dependency> | ||
<groupId>org.restcomm</groupId> | ||
<artifactId>restcomm-connect.dao</artifactId> | ||
<version>${project.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
|
||
|
||
<dependency> | ||
<groupId>org.restcomm</groupId> | ||
<artifactId>restcomm-connect.interpreter</artifactId> | ||
<version>${project.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.mobicents.servlet.sip</groupId> | ||
<artifactId>sip-servlets-spec</artifactId> | ||
<version>${sipservletapi.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.scalatest</groupId> | ||
<artifactId>scalatest_2.9.1</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.typesafe.akka</groupId> | ||
<artifactId>akka-testkit_2.10</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
95 changes: 95 additions & 0 deletions
95
...comm.notification/src/main/java/org/restcomm/connect/notification/GlobalNotification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package org.restcomm.connect.notification; | ||
|
||
import java.net.URI; | ||
import org.apache.commons.configuration.Configuration; | ||
import org.joda.time.DateTime; | ||
import org.restcomm.connect.dao.DaoManager; | ||
import org.restcomm.connect.dao.NotificationsDao; | ||
import org.restcomm.connect.dao.entities.Notification; | ||
import org.restcomm.connect.commons.dao.Sid; | ||
|
||
|
||
|
||
/** | ||
* | ||
* @author charles.roufay | ||
*/ | ||
public class GlobalNotification { | ||
|
||
|
||
public static int getERROR_NOTIFICATION() { | ||
return ERROR_NOTIFICATION; | ||
} | ||
|
||
public static int getWARNING_NOTIFICATION() { | ||
return WARNING_NOTIFICATION; | ||
} | ||
private static final int WARNING_NOTIFICATION = 1; | ||
private static final int ERROR_NOTIFICATION = 0; | ||
private final Sid accountId = new Sid("ACae6e420f425248d6a26948c17a9e2acf"); | ||
|
||
public GlobalNotification(Configuration configuration, DaoManager storage) { | ||
this.runtime = configuration.subset("runtime-settings"); | ||
this.apiVersion = runtime.getString("api-version"); | ||
this.storage = storage; | ||
} | ||
private final String apiVersion; | ||
private final Configuration runtime; | ||
private final DaoManager storage; | ||
private Notification notification = null; | ||
private NotificationsDao notifications = null; | ||
// application data. | ||
//private HttpRequestDescriptor request; | ||
//private HttpResponseDescriptor response; | ||
//notifications.addNotification(notification); | ||
private URI uri = URI.create("http://documentation.telestax.com/connect/api/"); | ||
public void sendNotification(final int errorWarningCode, final int apiErrorCode, final String errorMessage) { | ||
notification = notification(errorWarningCode, apiErrorCode, errorMessage, uri,"","",""); | ||
notifications = storage.getNotificationsDao(); | ||
notifications.addNotification(notification); | ||
} | ||
protected Notification notification(final int errorWarningCode, final int apiErrorCode, | ||
final String errorMessage, | ||
final URI requestUrl, | ||
final String requestMethod, | ||
final String requestVariables, | ||
final String responseHeaders) { | ||
|
||
final Notification.Builder builder = Notification.builder(); | ||
final Sid sid = Sid.generate(Sid.Type.NOTIFICATION); | ||
builder.setSid(sid); | ||
builder.setAccountSid(accountId); | ||
builder.setApiVersion(apiVersion); | ||
builder.setLog(errorWarningCode); | ||
builder.setErrorCode(apiErrorCode); | ||
final String base = runtime.getString("error-dictionary-uri"); | ||
StringBuilder buffer = new StringBuilder(); | ||
buffer.append(base); | ||
if (!base.endsWith("/")) { | ||
buffer.append("/"); | ||
} | ||
buffer.append(apiErrorCode).append(".html"); | ||
final URI info = URI.create(buffer.toString()); | ||
builder.setMoreInfo(info); | ||
builder.setMessageText(errorMessage); | ||
final DateTime now = DateTime.now(); | ||
builder.setMessageDate(now); | ||
builder.setRequestUrl(requestUrl); | ||
builder.setRequestMethod(requestMethod); | ||
builder.setRequestVariables(requestVariables); | ||
builder.setResponseHeaders(responseHeaders); | ||
buffer = new StringBuilder(); | ||
buffer.append("/").append(apiVersion).append("/Accounts/"); | ||
buffer.append(accountId.toString()).append("/Notifications/"); | ||
buffer.append(sid.toString()); | ||
final URI uri = URI.create(buffer.toString()); | ||
builder.setUri(uri); | ||
return builder.build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.