Commit 64e320a2 by amir

first time in the sea?

parent 1710293b
Pipeline #89 skipped in 0 seconds
Showing with 4862 additions and 0 deletions
/build/
/bin/
.gradle
.settings
.idea
.lck
.project
.classpath
gradle/
group 'com.ipgallery.common'
version '1.0.0'
apply plugin: 'java'
apply plugin: 'maven-publish'
sourceCompatibility = 1.8
repositories {
//mavenCentral()
maven { url "http://172.16.1.132:8081/repository/internal" }
maven { url "http://mandubian-mvn.googlecode.com/svn/trunk/mandubian-mvn/repository" }
}
dependencies {
compile 'com.fasterxml.jackson.core:jackson-databind:2.2.3'
compile 'com.github.stephenc.eaio-uuid:uuid:3.4.0'
compile 'redis.clients:jedis:2.4.2'
compile 'com.ipgallery.common:utils:1.0.0'
compile group: 'org.springframework', name: 'spring-web', version: '3.2.6.RELEASE'
compile group: 'com.google.code.gson', name: 'gson', version: '2.2.2'
compile 'redis.clients:jedis:2.4.2'
compile group: 'commons-net', name: 'commons-net', version: '3.3'
compile group: 'org.apache.cxf', name: 'cxf-rt-frontend-jaxrs', version: '2.6.9'
compile 'es.arcadiaconsulting.javapns:javapns:2.2-json'
compile group: 'com.mortennobel', name: 'java-image-scaling', version: '0.8.5'
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
publishing {
publications {
repositories.maven {
url 'http://172.16.1.132:8081/repository/internal'
credentials {
username "admin"
password "giptmgr1"
}
}
mavenJava(MavenPublication) {
//artifactId 'group-service'
from components.java
}
}
}
\ No newline at end of file
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
rootProject.name = 'mcz-core'
package mcz.core.beans;
import java.io.Serializable;
import java.util.List;
import mcz.core.defs.Enums.EnumChatAttendeeStatus;
import mcz.core.defs.Enums.EnumNetworkConnection;
import mcz.core.util.security.SecurityUtil;
public class ChatAttendee extends MczBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 8914005202746698695L;
public static final String URI = "uri";
public static final String IMAGE_LINK_MEMBER = "imageLink";
public static final String LAST_TIMESTAMP = "lastUpdateTimestamp";
public static final String NETWORK_CONNECTION = "networkConnection";
public static final String CHATROOM_NAME = "chatRoomName";
public static final String CHATROOM_ID = "chatRoomId";
public static final String STATUS = "status";
private Long lastUpdateTimestamp;
private EnumNetworkConnection networkConnection;
private String uri;
private String chatRoomName;
private String imageLink;
private String chatRoomId;
private EnumChatAttendeeStatus status;
public Long getLastUpdateTimestamp() {
return lastUpdateTimestamp;
}
public void setLastUpdateTimestamp(Long lastUpdateTimestamp) {
this.lastUpdateTimestamp = lastUpdateTimestamp;
}
public EnumNetworkConnection getNetworkConnection() {
return networkConnection;
}
public void setNetworkConnection(EnumNetworkConnection networkConnection) {
this.networkConnection = networkConnection;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getChatRoomName() {
return chatRoomName;
}
public void setChatRoomName(String chatRoomName) {
this.chatRoomName = chatRoomName;
}
public String getImageLink() {
return imageLink;
}
public void setImageLink(String imageLink) {
this.imageLink = imageLink;
}
public String getChatRoomId() {
return chatRoomId;
}
public void setChatRoomId(String chatRoomId) {
this.chatRoomId = chatRoomId;
}
public EnumChatAttendeeStatus getStatus() {
return status;
}
public void setStatus(EnumChatAttendeeStatus status) {
this.status = status;
}
public static String createChatRoomId(List<ChatAttendee> chatAttendees) {
String chatRoomId = null;
if (chatAttendees != null && chatAttendees.size() > 0) {
ChatAttendee chatAttendee = chatAttendees.get(0);
String networkConnection = chatAttendee.getNetworkConnection().name();
String uri = chatAttendee.getUri();
if (networkConnection != null && uri != null) {
StringBuffer sb = new StringBuffer();
sb.append(chatAttendee.getNetworkConnection().name()).append(chatAttendee.getUri()).append(String.valueOf(System.currentTimeMillis()));
chatRoomId = SecurityUtil.encodeBase64(sb.toString().getBytes());
}
if (chatRoomId != null) {
for (ChatAttendee chatAttnd : chatAttendees) {
if (chatAttnd != null) {
chatAttnd.setChatRoomId(chatRoomId);
}
}
}
}
return chatRoomId;
}
public boolean isDeleted()
{
return (EnumChatAttendeeStatus.E_DELETED.equals(getStatus()));
}
@Override
public String toString() {
String imageLink = (this.getImageLink() != null && this.getImageLink().length() > 0 ) ? this.getImageLink() : "";
StringBuffer strBuff = new StringBuffer();
strBuff.append("[ ChatAttendee: ");
strBuff.append(", LastUpdateTimestamp: " + this.getLastUpdateTimestamp());
strBuff.append(", NetworkConnection: " + this.getNetworkConnection().name());
strBuff.append(", Uri: " + this.getUri());
strBuff.append(", ChatRoomName: " + this.getChatRoomName());
strBuff.append(", ImageLink: " + imageLink);
strBuff.append(", ChatRoomId: " + this.getChatRoomId());
strBuff.append(", Status: " + this.getStatus().name());
strBuff.append("]");
return strBuff.toString();
}
@Override
public String getBeanId() {
StringBuffer strBuff = new StringBuffer();
strBuff.append(this.getNetworkConnection().name()).append("!&!");
strBuff.append(this.getChatRoomName()).append("!&!");
strBuff.append(this.getChatRoomId());
return strBuff.toString();
}
@Override
public boolean equals(Object obj) {
boolean equals;
if(this == obj) {
equals = true;
} else if ((obj == null) || (obj.getClass() != this.getClass())) {
equals = false;
} else { // object must be ChatAttendee at this point
ChatAttendee chatAttendee = (ChatAttendee)obj;
equals = (this.getNetworkConnection() == chatAttendee.getNetworkConnection() || (this.getNetworkConnection() != null && this.getNetworkConnection().equals(chatAttendee.getNetworkConnection())) || (chatAttendee.getNetworkConnection() != null && chatAttendee.getNetworkConnection().equals(this.getNetworkConnection()))) &&
(this.getUri() == chatAttendee.getUri() || (this.getUri() != null && this.getUri().equals(chatAttendee.getUri())) || (chatAttendee.getUri() != null && chatAttendee.getUri().equals(this.getUri()))) &&
(this.getChatRoomId() == chatAttendee.getChatRoomId() || (this.getChatRoomId() != null && this.getChatRoomId().equals(chatAttendee.getChatRoomId())) || (chatAttendee.getChatRoomId() != null && chatAttendee.getChatRoomId().equals(this.getChatRoomId())));
}
return equals;
}
@Override
public int hashCode() {
int hash = 7;
hash = 31 * hash + (null != this.getNetworkConnection() ? this.getNetworkConnection().name().hashCode() : 0);
hash = 31 * hash + (null != this.getUri() ? this.getUri().hashCode() : 0);
hash = 31 * hash + (null != this.getChatRoomId() ? this.getChatRoomId().hashCode() : 0);
return hash;
}
}
package mcz.core.beans;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import mcz.core.util.SocialNetworkServersMap;
public enum ConfParameter
{
ANN_SERVER_DOMAIN(
"172.16.1.196:5060",
"IP Address of the announcement server. This is the domain part of the sip uri that will be used when sending the SIP INVITE message to the ann. server"),
DEFAULT_SERVER_ADDRESS(
"192.168.200.7",
"IP Address for default SIP server used to handle SIP messages sent from MCZ, for example S-CSCF or a softswitch."),
DEFAULT_SERVER_REALM(
"",
"optional - the realm of the default server, could be IP Address or a domain name, this will be the in the host part of the request URI."),
DEFAULT_CLIENT_DOMAIN(
"62.90.108.70",
"optional - could be IP Address or a domain name, this will be the in the host part of the request URI for the mcz web client."),
SPEED_DIAL_PREFIX_MAX_LENGTH(
"3",
"A number specifying the exact length of the dialed number used for contact's speed-dial. Used to identify that an incoming call is a call to a contact's speed dial"),
TIMER_EXPIRES("70000", "Expiration of register"),
TIMER_WAIT("20000", "The time to wait for a connection command"),
TIMER_TEAR_DOWN("4000",
"the timeout to wait for tear down process in click to dial"),
TIMER_SEQUENTIAL("20000",
"the timeout to wait for a target to answer until moving to the next target"),
PUSH_SESSIONS_CHECK_TIMER("1000",
"the timeout to wait before checking a push session state"),
ANNOUNCEMENTS(createDefaultAnnouncements(),
"mapping from error resp to announcement to play."),
NETWORK_PREFIXES(
createDefaultNetworkPrefixes(),
"Speed dial prefixes used when a subscriber wishes to call a contact to a direct network, for example to call his contacts Skype."),
CTD_ANNOUNCEMENT("Calling.wav;repeat=forever",
"the announcement to play in click to dial."),
SOCIAL_NETWORKS_SERVERS(
createDefaultSocialServers(),
"Every social network(skype/gtalk/etc) has a unique server (host:port) to send/recieve calls from."),
IS_USE_ANNOUNCEMENT_IN_WEB_CALLS(
"false",
"Control click-to-dial feature. Sets which 3pcc logic to use when setting up a call; if set to true, announcements server will be used. Otherwise, a simple 3pcc call flow will be used (Flow 1 of RFC 3725)"),
SKIN("generic",
// TODO need to add a list of options - iterate over the sub-classes of
// Skin, for each call it's .getName() method and add the resulting string
// to this description
"The type of skin used for web pages."),
IS_REGISTER_DEVICE_BY_DEFAULT(
"false",
"If true, when a subscriber adds a new device, that device is considered registered (as if SIP REGISTER already arrived). The SIP domain used for the device is the default server."),
SERVER_PRESENCE_TIME(
"60000",
"In milliseconds, Sleep time of: MCLPresenceServlet <CheckContactUserProfileTask>"),
CLIENT_PRESENCE_TIME(
"30000",
"In milliseconds, Interval time of: updatePresenceInfo <initiated in: ContactsTest.jsp>"),
CLIENT_NET_CONN_STATE_TIME(
"30000",
"In milliseconds, Interval time of: updateNetworksConnectionStatus, updateNetworksConnectionStatusOfLoginDiv <initiated in: ContactsTest.jsp, loginDiv.jsp>"),
LAST_ACCESSED_EXPIRATION_TIME(
"3600",
"In seconds, how long to save the last accessed resource like user-profile/contact"),
IS_ACTIVITY_LOGGED("true", "Deprecated"),
NEXT_RESOURCE_ID(
"1",
"Please do not change. A number specifying the next available resource name for user pictures (pictures uploaded by user). Changing this value may cause user pictures to be lost, and may expose user pictures to other users"),
MCTEL_URI(
"http://172.16.1.186:7001/mclogic/index.html",
"when mcweb wants to start a 3pcc call, this is the uri it will turn to in order to initialize the call"),
TERM_ROLE_PREFIX("", "Terminating prefix in SIP ROUTE header (INVITE)"),
VIDEO_SERVER_IP("172.16.1.48", "IP Server of Video Server"),
EXTERNAL_PRESENCE_SERVER_ADDRESS("",
"Address of an external sip presence server to publish presence event to"),
FACEBOOK_APP_ALIAS("ipgallerymcz",
"Alias for facebook app defined in facebook app page"),
REGISTERED_SUBSCRIBERS_LIMIT("0",
"Maximum limit of registered subscribers in application"),
P_CHARGING_VECTOR_ORIG_IOI("",
"The P-Charging-Vector originating inter operator id"),
P_CHARGING_ADDRESS_CCF("",
"The P-Charging-Function-Addresses charging collection function"),
P_CHARGING_ADDRESS_ECF("",
"The P-Charging-Function-Addresses event collection function"),
SYSTEM_MSG_TICKER_TEXT("", "system wide messages"),
ONLINE_SUBMODEL_POLLING_TIME("2000",
"In milliseconds, runtime polling of subscriber data"),
ONLINE_CHAT_POLLING_TIME("1000", "In milliseconds, chatPollingTimeout"),
ONLINE_LOG_TO_CONSOLE("false", "use console log");
private Object defaultValue;
private String description;
/**
* @param defaultValue
* the default value used when creating the parameter in the dao
* @param description
* a user friendly text that describes the meaning of this
* parameter
*/
private ConfParameter(Object defaultValue, String description)
{
this.defaultValue = defaultValue;
this.description = description;
}
private static Map<String, String> createDefaultAnnouncements()
{
SortedMap<String, String> map = new TreeMap<String, String>();
map.put("486", "UserBusy.wav");
map.put("404", "NotFound.wav");
return map;
}
private static Map<String, String> createDefaultNetworkPrefixes()
{
SortedMap<String, String> map = new TreeMap<String, String>();
map.put("1", "GTALK");
map.put("2", "FACEBOOK");
map.put("3", "SIP");
map.put("4", "MOBILE");
map.put("5", "LANDLINE");
map.put("6", "MCZ");
return map;
}
private static SocialNetworkServersMap createDefaultSocialServers()
{
SocialNetworkServersMap snsMap = new SocialNetworkServersMap();
snsMap.initMaps();
return snsMap;
}
public Object getDefaultValue()
{
return defaultValue;
}
/**
* @return a user friendly text that describes the meaning of this parameter
*/
public String getDescription()
{
return description;
}
}
package mcz.core.beans;
import java.lang.reflect.Type;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
public class ContactAdapter implements JsonSerializer<Contact>{
private static Gson gson = new GsonBuilder()
.registerTypeAdapter(UserProfile.class, new UserProfileAdapter())
.create();
@Override
public JsonElement serialize(Contact contact, Type arg1,JsonSerializationContext arg2) {
JsonObject obj = new JsonObject();
obj.addProperty("id", contact.getBeanId());
obj.addProperty("name", contact.getName() == null ? "" : contact.getName());
obj.addProperty("isFavorite", contact.isFavorite() ? "true" : "false");
obj.addProperty("deleted", contact.getDeleted() ? "true" : "false");
obj.addProperty("speedDial", contact.getSpeedDial() == null ? "" : contact.getSpeedDial());
obj.addProperty("imageLink", contact.getImageLink() == null ? "" : contact.getImageLink());
obj.addProperty("imagePath", contact.getImagePath() == null ? "" : contact.getImagePath());
obj.add("userProfiles",gson.toJsonTree(contact.getUserProfiles()));
obj.add("contactGroupsInfo",gson.toJsonTree(contact.getContactGroupsInfo()));
return obj;
}
}
package mcz.core.beans;
import java.lang.reflect.Type;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
//import com.google.gson.Gson;
//import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
public class ContactAdapterHeadInfo implements JsonSerializer<Contact>{
private static Gson gson = new GsonBuilder().registerTypeAdapter(UserProfile.class, new UserProfileAdapterHeadInfo()).create();
@Override
public JsonElement serialize(Contact contact, Type arg1,JsonSerializationContext arg2) {
JsonObject obj = new JsonObject();
obj.addProperty("name", contact.getName() == null ? "" : contact.getName());
obj.addProperty("imageLink", contact.getImageLink() == null ? "" : contact.getImageLink());
obj.addProperty("favorite", contact.isFavorite() ? "true" : "false");
obj.addProperty("speedDial", contact.getSpeedDial() == null ? "" : contact.getSpeedDial());
obj.addProperty("lastUpdateTimestamp", contact.getLastUpdateTimestamp());
obj.add("ups",gson.toJsonTree(contact.getUserProfiles()));
return obj;
}
}
\ No newline at end of file
package mcz.core.beans;
import java.lang.reflect.Type;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
public class ContactDetailsAdapterHeadInfo implements JsonSerializer<Contact>{
private static Gson gson = new GsonBuilder()
.registerTypeAdapter(UserProfile.class, new UserProfileAdapterHeadInfo())
.create();
@Override
public JsonElement serialize(Contact contact, Type arg1,JsonSerializationContext arg2) {
JsonObject obj = new JsonObject();
obj.addProperty("userID", contact.getBeanId());
//obj.addProperty("name", contact.getName() == null ? "" : contact.getName());
//obj.addProperty("isFavorite", contact.isFavorite() ? "true" : "false");
//obj.addProperty("image", contact.getImageLink() == null ? "" : contact.getImageLink());
obj.add("ups",gson.toJsonTree(contact.getUserProfiles()));
return obj;
}
}
\ No newline at end of file
package mcz.core.beans;
/**
* Listener that handles events coming from DAO methods
*/
public interface DaoListener {
/**
* This method is called when the Dao implementation encounters an error while trying to execute a method.
* Implementation of this method must never throw an exception. Exception that is thrown from this method may be discarded.
*
* @param errMsg a user friendly description of the error that occoured. May be null.
* @param e an exception relating to the error that occoured. May be null.
*/
public void handleError(String errMsg, Exception e);
}
package mcz.core.beans;
import utils.common.Log4jHandler;
public class DaoLogWriter implements DaoListener {
private static final Log4jHandler logger = new Log4jHandler(DaoLogWriter.class.getName());
@Override
public void handleError(String errMsg, Exception e) {
if (e == null) {
logger.severe(errMsg);
} else {
logger.fatal("Exception during dao operation", e);
}
}
}
package mcz.core.beans;
import java.io.Serializable;
public class GroupChatMember implements Serializable {
/**
*
*/
private static final long serialVersionUID = -712436463392699331L;
public static final String C_STATUS = "status";
public static final String C_URI = "uri";
public static final String C_MEMBER_NAME = "memberName";
public static final String C_IMAGE_LINK = "imageLink";
public static final String C_CALLER = "caller";
private String status;
private String uri;
private String memberName;
private String imageLink;
private Boolean caller;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getMemberName() {
return memberName;
}
public void setMemberName(String memberName) {
this.memberName = memberName;
}
public String getImageLink() {
return imageLink;
}
public void setImageLink(String imageLink) {
this.imageLink = imageLink;
}
public Boolean getCaller() {
return caller;
}
public void setCaller(Boolean caller) {
this.caller = caller;
}
}
package mcz.core.beans;
import java.io.Serializable;
import java.util.Comparator;
import java.util.SortedSet;
import java.util.TreeSet;
import mcz.core.defs.Enums.EnumGroupOfContactsColor;
import mcz.core.defs.Enums.EnumGroupOfContactsIcon;
public class GroupOfContacts extends MczBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = -5661023956979194100L;
private String userName;
private String groupName;
private String description;
private EnumGroupOfContactsColor color = EnumGroupOfContactsColor.E_DEFAULT;
private EnumGroupOfContactsIcon imageLink = EnumGroupOfContactsIcon.E_GROUP;
SortedSet<Contact> contacts = new TreeSet<Contact>(new Comparator<Contact> () {
@Override
public int compare(Contact contact1, Contact contact2) {
return
contact1.getName().compareTo(
contact2.getName());
}
});
//private List<Contact> contacts = new ArrayList<Contact>(0);
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public EnumGroupOfContactsColor getColor() {
return color;
}
public void setColor(EnumGroupOfContactsColor color) {
this.color = color;
}
public EnumGroupOfContactsIcon getImageLink() {
return imageLink;
}
public void setImageLink(EnumGroupOfContactsIcon imageLink) {
this.imageLink = imageLink;
}
public SortedSet<Contact> getContacts() {
return contacts;
}
public void setContacts(SortedSet<Contact> contacts) {
this.contacts = contacts;
}
public String toString() {
StringBuffer strBuff = new StringBuffer();
strBuff.append("[ GroupOfContacts: ");
strBuff.append("UserName: " + this.getUserName());
strBuff.append(", GroupName: " + this.getGroupName());
strBuff.append(", Description: " + this.getDescription());
strBuff.append(", Color: " + this.getColor());
strBuff.append(", ImageLink: " + this.getImageLink());
strBuff.append("]");
return strBuff.toString();
}
@Override
public String getBeanId() {
StringBuffer strBuff = new StringBuffer();
strBuff.append(this.getUserName()).append("!&!");
strBuff.append(this.getGroupName());
return strBuff.toString();
}
@Override
public boolean equals(Object obj) {
boolean equals;
if(this == obj) {
equals = true;
} else if ((obj == null) || (obj.getClass() != this.getClass())) {
equals = false;
} else { // object must be GroupOfContacts at this point
GroupOfContacts groupOfContacts = (GroupOfContacts)obj;
equals =
// userNames equals
( (this.getUserName() == groupOfContacts.getUserName()) || ((this.getUserName() != null && groupOfContacts.getUserName() != null) && (this.getUserName().equals(groupOfContacts.getUserName()))) )
&&
// groupNames equals
( (this.getGroupName() == groupOfContacts.getGroupName()) || ((this.getGroupName() != null && groupOfContacts.getGroupName() != null) && (this.getGroupName().equals(groupOfContacts.getGroupName()))) );
}
return equals;
}
@Override
public int hashCode() {
int hash = 7;
hash = 31 * hash + (null != this.getUserName() ? this.getUserName().hashCode() : 0);
hash = 31 * hash + (null != this.getGroupName() ? this.getGroupName().hashCode() : 0);
return hash;
}
}
package mcz.core.beans;
import java.io.Serializable;
public class ImContact implements Serializable {
private static final long serialVersionUID = 3559418670791212054L;
String firstName;
String lastName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("First Name: " + firstName + ";");
buffer.append("Last Name: " + lastName);
return buffer.toString();
}
}
package mcz.core.beans;
public class ImportedUserProfile extends UserProfile {
private static final long serialVersionUID = -2308307403621440385L;
private String profilePhotoLink;
/**
* @return url for an image associated with this user profile in the originating
* network. This picture is usually the contact's picture.
*/
public String getProfilePhotoLink() {
return profilePhotoLink;
}
public void setProfilePhotoLink(String photoLink) {
this.profilePhotoLink = photoLink;
}
@Override
public String toString() {
return
"[ImportedUseProfile with UserProfile " + super.toString() +
", img link " + getProfilePhotoLink() + "]";
}
}
package mcz.core.beans;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
public class InMemoryContacts {
private List<ImContact> contacts;
public InMemoryContacts() {}
@Autowired
public InMemoryContacts(List<ImContact> contacts) {
this.contacts = contacts;
}
public List<ImContact> getContacts() {
return contacts;
}
public void setContacts(List<ImContact> contacts) {
this.contacts = contacts;
}
}
package mcz.core.beans;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
public class InMemorySubscribers {
private List<Subscriber> subscribers;
public InMemorySubscribers() {}
@Autowired
public InMemorySubscribers(List<Subscriber> subscribers) {
this.subscribers = subscribers;
}
public List<Subscriber> getSubscribers() {
return subscribers;
}
public void setSubscribers(List<Subscriber> subscribers) {
this.subscribers = subscribers;
}
}
package mcz.core.beans;
import java.util.Collection;
import java.util.Iterator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import mcz.core.util.Common;
/**
* Super class for all MCZ beans
*/
public abstract class MczBean {
/**
* Use only from client side.
*
* For example (In jsp or html page):
* <a href="<%=request.getContextPath() %>/contactPage.htm?contactId=${contact.id}" rel="external">
*
* @return
*/
@JsonIgnore
public String getId() {
String beanId = getBeanId();
String id = null;
if (beanId != null && beanId.length() > 0) {
id = Common.encodeURL(beanId);
}
return id;
}
/**
* Use only from server side.
*
* For example : (In Controller or Servlet class):
* return "redirect:contactPage.htm?contactId="+contact.getBeanId();
*
* @return a unique identifier for this bean in the scope of it's container
*/
@JsonIgnore
public abstract String getBeanId();
/**
* returns if this object equals another object, in the scope of their containers.
* 2 objects may still be equal although they are contained in different containers
* @param obj
* @return true if the objects equals, false otherwise.
*/
@Override
public boolean equals(Object obj) {
boolean isEqual = false;
if (obj != null && obj instanceof MczBean) {
MczBean mBean = (MczBean)obj;
isEqual = getId().equals(mBean.getId());
}
return isEqual;
}
@Override
public int hashCode() {
return getId().hashCode();
}
/**
* Scans the given collection searching for a bean with the specified id.
* @param collection
* @param id
* @return the first bean with the given id, or null if none is found.
*/
protected static MczBean findMczBean(Collection<? extends MczBean> collection, String id) {
MczBean bean = null;
if (id != null) {
String encodeID = Common.encodeURL(id);
for (MczBean beanCandidate : collection) {
if (beanCandidate != null && beanCandidate.getId().equals(encodeID)) {
bean = beanCandidate;
break;
}
}
}
return bean;
}
protected static MczBean removeMczBean(Collection<? extends MczBean> collection, String id) {
Iterator<? extends MczBean> iter = collection.iterator();
MczBean deletedBean = null;
if (id != null) {
String encodeID = Common.encodeURL(id);
for (; iter.hasNext();) {
MczBean bean = iter.next();
if (bean.getId().equals(encodeID)) {
deletedBean = bean;
iter.remove();
break;
}
}
}
return deletedBean;
}
}
package mcz.core.beans;
import java.io.Serializable;
import mcz.core.defs.Enums.EnumPresenceMode;
/**
* Data object that describes the presence info of a user profile or subscriber. For example online, away, etc...
* presence info also includes a user string (for example "in the office")
*/
public class PresenceInfo extends MczBean implements Serializable {
private static final long serialVersionUID = -2976798044385534806L;
private boolean acceptAudio = false;
private boolean acceptVideo = false;
private boolean acceptChat = false;
private boolean acceptMessage = false;
private EnumPresenceMode mode = EnumPresenceMode.E_OFFLINE;
private String status = "";
private String resourceId = null;
private Long lastPresenceTimestamp = null;
/**
* @return true if this object represent an online status in MCZ context, false otherwise.
*/
public boolean isOnline() {
if (mode == EnumPresenceMode.E_ONLINE || mode == EnumPresenceMode.E_AWAY || mode == EnumPresenceMode.E_DND) {
return true;
}
else {
return false;
}
}
public boolean isAcceptAudio() {
return acceptAudio;
}
public void setAcceptAudio(boolean acceptAudio) {
this.acceptAudio = acceptAudio;
}
public boolean isAcceptVideo() {
return acceptVideo;
}
public void setAcceptVideo(boolean acceptVideo) {
this.acceptVideo = acceptVideo;
}
public boolean isAcceptChat() {
return acceptChat;
}
public void setAcceptChat(boolean acceptChat) {
this.acceptChat = acceptChat;
}
public boolean isAcceptMessage() {
return acceptMessage;
}
public void setAcceptMessage(boolean acceptMessage) {
this.acceptMessage = acceptMessage;
}
/**
* @return the presence status (online, away, offline, etc...)
*/
public EnumPresenceMode getMode() {
return mode;
}
public void setMode(EnumPresenceMode mode) {
this.mode = mode;
}
/**
* @return text the user entered to describe his presence (e.g. "in the office", "happy birthday", ...)
*/
public String getStatus() {
return this.status;
}
public void setStatus(String status) {
this.status = status;
}
public String getResourceId() {
return resourceId;
}
public void setResourceId(String resourceId) {
this.resourceId = resourceId;
}
@Override
public String getBeanId() {
return getStatus() + getMode().ordinal();
}
public Long getLastPresenceTimestamp()
{
return lastPresenceTimestamp;
}
public void setLastPresenceTimestamp(Long lastPresenceTimestamp)
{
this.lastPresenceTimestamp = lastPresenceTimestamp;
}
@Override
public String toString() {
return "[PresenceInfo " + getMode().toString() + ", status " + getStatus() + "]";
}
}
package mcz.core.beans;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.node.ObjectNode;
import mcz.core.util.Common;
public class RestResponse
{
public boolean success = true;
public String error = null;
public JsonNode objectNode = null;
@JsonIgnore
private ObjectMapper objMapper;
@JsonCreator
public RestResponse(@JsonProperty("success")boolean success,
@JsonProperty("error")String error,
@JsonProperty("respObject")JsonNode objectNode) {
super();
this.success = success;
this.error = error;
this.objectNode = objectNode;
}
public void prepare(ObjectMapper objMapper) { this.objMapper = objMapper; }
public ObjectMapper getObjectMapper() { return objMapper; }
public boolean isSuccess () { return success; }
public String getError() { return error; }
public String getRawString() {
if (objectNode != null) {
return objectNode.toString();
}
return null;
}
/**
* getting the object map
* @param objMapper
* @return
*/
public JsonNode getRootNode() { return objectNode; }
/**
* get node by name
* @param name
* @return
*/
public JsonNode getNode(String name) {
if (objectNode != null) {
return objectNode.path(name);
}
return null;
}
public String getParamString(String name) {
if (objectNode != null) {
JsonNode jn = objectNode.get(name);
if (jn!=null && !jn.isMissingNode() && jn.isTextual()) {
return jn.asText(); //(arg0)Common.removeSigns(jn.toString(), '"', '"');
}
}
return null;
}
public Long getParamLong(String name) {
if (objectNode != null) {
JsonNode jn = objectNode.path(name);
if (jn!=null && !jn.isMissingNode() && jn.isNumber()) {
return new Long(jn.longValue());
}
}
return null;
}
public Integer getParamInt(String name) {
if (objectNode != null) {
JsonNode jn = objectNode.path(name);
if (jn!=null && !jn.isMissingNode() && jn.isNumber()) {
return new Integer(jn.intValue());
}
}
return null;
}
public Boolean getParamBool(String name) {
if (objectNode != null) {
JsonNode jn = objectNode.path(name);
if (jn!=null && !jn.isMissingNode() && jn.isBoolean()) {
return new Boolean(jn.booleanValue());
}
}
return null;
}
public Object getObject(String name, Class<?> objClass) {
ObjectReader objectReader = objMapper.reader(objClass);
if (objectNode != null && objMapper != null) {
JsonNode jn = objectNode.path(name);
if (jn!=null && !jn.isMissingNode()) {
try {
return objectReader.readValue(jn);
} catch (Exception e) {
}
}
}
return null;
}
public Object getNodeAsObject(JsonNode jn, Class<?> objClass) {
ObjectReader objectReader = objMapper.reader(objClass);
if (jn!=null && !jn.isMissingNode() && objMapper != null) {
try {
return objectReader.readValue(jn);
} catch (Exception e) {
}
}
return null;
}
public String toJsonString() {
ObjectNode nodeObj = objMapper.createObjectNode();
nodeObj.put("success", success);
nodeObj.put("error", error);
nodeObj.put("objectNode", objectNode);
return nodeObj.toString();
}
}
package mcz.core.beans;
import java.lang.reflect.Type;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
public class UserProfileAdapter implements JsonSerializer<UserProfile>{
@Override
public JsonElement serialize(UserProfile userProfile, Type arg1,
JsonSerializationContext arg2) {
// TODO Auto-generated method stub
JsonObject obj = new JsonObject();
JsonObject presenceObj = new JsonObject();
obj.addProperty("id", userProfile.getBeanId());
obj.addProperty("name", userProfile.getName() == null ? "" : userProfile.getName());
obj.addProperty("profileUser", userProfile.getProfileUser() == null ? "" : userProfile.getProfileUser());
obj.addProperty("networkConnection", userProfile.getNetworkConnection().toString() == null ? "" : userProfile.getNetworkConnection().toString());
obj.addProperty("isDefaultForCall", userProfile.isDefaultForCall() ? "true" : "false");
obj.addProperty("isDefaultForChat", userProfile.isDefaultForChat() ? "true" : "false");
presenceObj.addProperty("acceptAudio", String.valueOf(userProfile.getPresenceInfo().isAcceptAudio()) == null ? "" : String.valueOf(userProfile.getPresenceInfo().isAcceptAudio()));
presenceObj.addProperty("acceptVideo", String.valueOf(userProfile.getPresenceInfo().isAcceptVideo()) == null ? "" : String.valueOf(userProfile.getPresenceInfo().isAcceptVideo()));
presenceObj.addProperty("acceptChat", String.valueOf(userProfile.getPresenceInfo().isAcceptChat()) == null ? "" : String.valueOf(userProfile.getPresenceInfo().isAcceptChat()));
presenceObj.addProperty("acceptMessage", String.valueOf(userProfile.getPresenceInfo().isAcceptMessage()) == null ? "" : String.valueOf(userProfile.getPresenceInfo().isAcceptMessage()));
presenceObj.addProperty("mode",userProfile.getPresenceInfo().getMode().toString() == null ? "" : userProfile.getPresenceInfo().getMode().toString());
presenceObj.addProperty("status",userProfile.getPresenceInfo().getStatus() == null ? "" : userProfile.getPresenceInfo().getStatus());
presenceObj.addProperty("lastUpdateTS",userProfile.getPresenceInfo().getLastPresenceTimestamp() == null ? 0 : userProfile.getPresenceInfo().getLastPresenceTimestamp());
obj.add("pressenceInfo",presenceObj);
return obj;
}
}
package mcz.core.beans;
import java.lang.reflect.Type;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
/*
* build a json that contains only a minimal fields for supporting the main contact list page
*/
public class UserProfileAdapterHeadInfo implements JsonSerializer<UserProfile>{
@Override
public JsonElement serialize(UserProfile userProfile, Type arg1,
JsonSerializationContext arg2) {
JsonObject obj = new JsonObject();
//obj.addProperty("cId", userProfile.getName()); // we plant the contact's id here !!!
obj.addProperty("uId", userProfile.getBeanId());
obj.addProperty("pu", userProfile.getProfileUser() == null ? "" : userProfile.getProfileUser());
obj.addProperty("netConn", userProfile.getNetworkConnection().toString() == null ? "" : userProfile.getNetworkConnection().toString());
//obj.addProperty("isAud", String.valueOf(userProfile.getPresenceInfo().isAcceptAudio()) == null ? "" : String.valueOf(userProfile.getPresenceInfo().isAcceptAudio()));
//obj.addProperty("isVid", String.valueOf(userProfile.getPresenceInfo().isAcceptVideo()) == null ? "" : String.valueOf(userProfile.getPresenceInfo().isAcceptVideo()));
//obj.addProperty("isCht", String.valueOf(userProfile.getPresenceInfo().isAcceptChat()) == null ? "" : String.valueOf(userProfile.getPresenceInfo().isAcceptChat()));
//obj.addProperty("isMsg", String.valueOf(userProfile.getPresenceInfo().isAcceptMessage()) == null ? "" : String.valueOf(userProfile.getPresenceInfo().isAcceptMessage()));
return obj;
}
}
\ No newline at end of file
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mcz.core.beans;
/**
*
* @author amir
*/
public class Video {
private String title;
private String url;
public Video(String name, String url) {
this.setTitle(name);
this.setUrl(url);
}
public Video() {
// TODO Auto-generated constructor stub
}
/**
* @param title the title to set
*/
public void setTitle(String title) {
this.title = title;
}
/**
* @return the title
*/
public String getTitle() {
return title;
}
/**
* @param uri the url to set
*/
public void setUrl(String url) {
this.url = url;
}
/**
* @return the url
*/
public String getUrl() {
return url;
}
}
package mcz.core.beans.activities;
import java.io.Serializable;
import mcz.core.beans.MczBean;
import mcz.core.defs.Enums.EnumActivityDirection;
import mcz.core.defs.Enums.EnumNetworkConnection;
import mcz.core.util.Common;
/**
* An instance of the class describes a single activity, be that outgoing call, incoming IM, etc...
*/
public abstract class Activity extends MczBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = -8411990963762285336L;
private String source;
private String dest;
private String userName;
private String contactName;
private String contactId;
protected boolean success = false;
private Long creationTime = null;
private Long startTime = null;
private Long endTime = null;
private EnumActivityDirection direction;
private EnumNetworkConnection networkConnection = EnumNetworkConnection.E_NO_NETWORK;
public Long getCreationTime()
{
return creationTime;
}
public void setCreationTime(Long creationTime)
{
this.creationTime = creationTime;
}
/**
* @return the activity start time in milliseconds since epoch, or null if there is none.
*/
public Long getStartTime()
{
return startTime;
}
public void setStartTime(Long startTime)
{
this.startTime = startTime;
}
/**
* @return the activity end time in milliseconds since epoch, or null if there is none.
*/
public Long getEndTime()
{
return endTime;
}
public void setEndTime(Long endTime)
{
this.endTime = endTime;
}
public Boolean isSuccess()
{
return success;
}
public void setSuccess(Boolean success)
{
this.success = success;
}
public String getDest()
{
return dest;
}
public void setDest(String dest)
{
this.dest = Common.extractUserPartFromSipUri(dest);
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getContactName() {
return contactName;
}
public void setContactName(String contactName) {
this.contactName = contactName;
}
public String getContactId() {
return contactId;
}
public void setContactId(String contactId) {
this.contactId = contactId;
}
public EnumActivityDirection getDirection()
{
return direction;
}
public void setDirection(EnumActivityDirection direction)
{
this.direction = direction;
}
public String getSource()
{
return source;
}
public void setSource(String source)
{
this.source = Common.extractUserPartFromSipUri(source);
}
public EnumNetworkConnection getNetworkConnection() {
return networkConnection;
}
public void setNetworkConnection(EnumNetworkConnection networkConnection) {
this.networkConnection = networkConnection;
}
@Override
public String toString() {
return "[ Activity: [ source: " + getSource() +
" dest: " + getDest() +
" userName: " + getUserName() +
" contactName: " + getContactName() +
" creationTime: " + getCreationTime() +
" startTime: " + getStartTime() +
" endTime: " + getEndTime() +
" type: " + getTypeName() +
" networkConnection: " + getNetworkConnection().name() +
" direction: " + getDirection().name() +
" success: " + isSuccess().toString() +
" ] ]";
}
@Override
public String getBeanId() {
return getUserName() + "!&!" +
getSource() + "!&!" +
getDest() + "!&!" +
getTypeName() + "!&!" +
getDirection() + "!&!" +
getCreationTime();
}
/**
* @return a user friendly name describing the type of this device ("Call" or "Chat")
*/
public abstract String getTypeName();
}
package mcz.core.beans.activities;
import java.io.Serializable;
import mcz.core.defs.Constants;
import mcz.core.defs.Enums.EnumSessionTDCause;
public class ActivityCall extends Activity implements Serializable {
/**
*
*/
private static final long serialVersionUID = -9071458337738003985L;
EnumSessionTDCause tdCause = EnumSessionTDCause.E_NORMAL_CLEAR;
@Override
public String toString() {
return "[ActivityCall " + super.toString() + "]";
}
@Override
public String getTypeName() {
return Constants.C_CALL;
}
public EnumSessionTDCause getTdCause()
{
return tdCause;
}
public void setTdCause(EnumSessionTDCause tdCause)
{
this.tdCause = tdCause;
}
}
package mcz.core.beans.activities;
import java.io.Serializable;
import mcz.core.defs.Constants;
import mcz.core.defs.Enums.EnumChatContentType;
import mcz.core.defs.Enums.EnumImdnDeliveryStatus;
public class ActivityChat extends Activity implements Serializable {
/**
*
*/
private static final long serialVersionUID = 6866758320993248546L;
private String content = null;
private String chatRoomId = null;
private EnumChatContentType chatContentType = null;
private Long chatContentSize = 0L;
private String chatContentFileLink = null;
private String chatContentThumbnailLink = null;
private String imdnMsgId = null; /// for imdn purpose
private EnumImdnDeliveryStatus deliveryStatus = null;
/**
* @return the contents of the chat message this activity is assoicated with
*/
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getChatRoomId() {
return chatRoomId;
}
public void setChatRoomId(String chatRoomId) {
this.chatRoomId = chatRoomId;
}
public EnumChatContentType getChatContentType() {
return chatContentType;
}
public void setChatContentType(EnumChatContentType chatContentType) {
this.chatContentType = chatContentType;
}
public Long getChatContentSize() {
return chatContentSize;
}
public void setChatContentSize(Long chatContentSize) {
this.chatContentSize = chatContentSize;
}
public String getChatContentFileLink() {
return chatContentFileLink;
}
public void setChatContentFileLink(String chatContentFileLink) {
this.chatContentFileLink = chatContentFileLink;
}
public String getChatContentThumbnailLink() {
return chatContentThumbnailLink;
}
public void setChatContentThumbnailLink(String chatContentThumbnailLink) {
this.chatContentThumbnailLink = chatContentThumbnailLink;
}
@Override
public String getBeanId() {
if (getImdnMsgId() != null)
return super.getBeanId() + getImdnMsgId();
else
return super.getBeanId();
}
@Override
public String getTypeName() {
return Constants.C_CHAT;
}
public String getImdnMsgId()
{
return imdnMsgId;
}
public void setImdnMsgId(String imdnMsgId)
{
this.imdnMsgId = imdnMsgId;
}
public EnumImdnDeliveryStatus getDeliveryStatus()
{
return deliveryStatus;
}
public void setDeliveryStatus(EnumImdnDeliveryStatus deliveryStatus)
{
this.deliveryStatus = deliveryStatus;
}
}
package mcz.core.beans.activities;
public class SmsContent {
public String source;
public String destination;
public String message;
public String date;
public SmsContent(String source, String destination, String message, String date)
{
this.source = source;
this.destination = destination;
this.message = message;
this.date = date;
}
public String toString()
{
String res = date + " : " + message;
return res;
}
}
package mcz.core.beans.credentials;
import java.io.Serializable;
import mcz.core.beans.MczBean;
import mcz.core.defs.Enums.EnumNetworkConnectorState;
import mcz.core.defs.Enums.EnumNetworkConnection;
/**
* Represents credential information needed for social network connection
*/
public abstract class Credential extends MczBean implements Serializable {
private static final long serialVersionUID = 3L;
private String userName;
private EnumNetworkConnectorState networkConnectorState;
private String gatewayAddress;
/**
* @return the id used for the social network
*/
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public EnumNetworkConnectorState getNetworkConnectorState() {
return networkConnectorState;
}
public void setNetworkConnectorState(EnumNetworkConnectorState networkConnectorState) {
this.networkConnectorState = networkConnectorState;
}
public String getGatewayAddress() {
return gatewayAddress;
}
public void setGatewayAddress(String gatewayAddress) {
this.gatewayAddress = gatewayAddress;
}
@Override
public String getBeanId() {
return getClass().getSimpleName();
}
@Override
public String toString() {
return "[" + getNetworkConnection() + " username " + getUserName() + "]";
}
@Override
public boolean equals(Object obj) {
Credential cred = (Credential)obj;
if ( cred.getUserName().equals(this.getUserName()) &&
cred.getNetworkConnection().equals(this.getNetworkConnection()) )
return true;
return false;
}
/**
* @return the corresponding enum value associated with this credential
*/
public abstract EnumNetworkConnection getNetworkConnection();
}
\ No newline at end of file
package mcz.core.beans.credentials;
import mcz.core.defs.Enums.EnumNetworkConnection;
/**
* Login details for Facebook
*/
public class CredentialFacebook extends CredentialPasswordBased {
/**
*
*/
private static final long serialVersionUID = 5200272365379667233L;
@Override
public EnumNetworkConnection getNetworkConnection() {
return EnumNetworkConnection.E_FACEBOOK;
}
}
package mcz.core.beans.credentials;
import mcz.core.defs.Enums.EnumNetworkConnection;
/**
* Login details for Google Talk
*/
public class CredentialGtalk extends CredentialPasswordBased {
/**
*
*/
private static final long serialVersionUID = -6907168088453188107L;
@Override
public EnumNetworkConnection getNetworkConnection() {
return EnumNetworkConnection.E_GTALK;
}
}
package mcz.core.beans.credentials;
import mcz.core.defs.Enums.EnumNetworkConnection;
public class CredentialOther extends Credential {
/**
*
*/
private static final long serialVersionUID = 2895577599748443439L;
EnumNetworkConnection networkConnection = EnumNetworkConnection.E_NO_NETWORK;
public CredentialOther()
{
}
public CredentialOther(EnumNetworkConnection networkConnection)
{
this.networkConnection = networkConnection;
}
@Override
public EnumNetworkConnection getNetworkConnection() {
// TODO oded - Just a workaround - should be fixed when all "other"
// networks should be supported
return networkConnection;
}
}
package mcz.core.beans.credentials;
/**
* Credentials that has both username & password
*/
public abstract class CredentialPasswordBased extends Credential {
/**
*
*/
private static final long serialVersionUID = -8296966420657559564L;
private String password;
private String connectionErrorReason = null;
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getConnectionErrorReason() {
return connectionErrorReason;
}
public void setConnectionErrorReason(String connectionErrorReason) {
this.connectionErrorReason = connectionErrorReason;
}
@Override
public String getBeanId() {
return super.getBeanId() + getPassword();
}
}
package mcz.core.beans.credentials;
import mcz.core.defs.Enums.EnumNetworkConnection;
public class CredentialRenren extends CredentialPasswordBased
{
/**
*
*/
private static final long serialVersionUID = 1065391353231928339L;
@Override
public EnumNetworkConnection getNetworkConnection(){
return EnumNetworkConnection.E_RENREN;
}
}
package mcz.core.beans.credentials;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import utils.common.Log4jHandler;
import mcz.core.beans.Dao;
import mcz.core.beans.Subscriber;
import mcz.core.defs.Enums.EnumNetworkConnection;
import mcz.core.defs.Enums.EnumNetworkConnectorState;
import mcz.core.util.security.SecurityUtil;
/**
* Container class that holds all social sites credentials for a subscriber.
* An object of this class is also responsible to synchronize the credentials of a subscriber with the connection
* objects that actually communicate with the social network
*/
public class Credentials implements Serializable {
private static final long serialVersionUID = -5114742067088246213L;
private static final Log4jHandler logger = new Log4jHandler(Credentials.class.getName());
public static final String NETWORK_CONNECTION = "networkConnection";
public static final String USER_NAME = "userName";
public static final String NETWORK_CONNECTOR_STATE = "networkConnectorState";
public static final String GATEWAY_ADDRESS = "gatewayAddress";
public static final String PASSWORD = "password";
public static final String CONNECTION_ERROR_REASON = "connectionErrorReason";
private Map<EnumNetworkConnection, Credential> credentials = null;
//private Map<EnumNetworkConnection, SocialNetworkConnection> connections = null;
private Subscriber sub = null;
public Credentials(Subscriber sub) {
this.credentials = new HashMap<EnumNetworkConnection, Credential>();
//this.connections = new HashMap<EnumNetworkConnection, SocialNetworkConnection>();
this.sub = sub;
}
public Credentials() {
this.credentials = new HashMap<EnumNetworkConnection, Credential>();
}
public int size() {
return credentials.size();
}
public static Class<? extends Credential> valueOf(EnumNetworkConnection networkConnection) {
Class<? extends Credential> cls = null;
switch(networkConnection) {
case E_FACEBOOK:
cls = CredentialFacebook.class;
break;
case E_GTALK:
cls = CredentialGtalk.class;
break;
case E_RENREN:
cls = CredentialRenren.class;
break;
case E_SIP:
case E_MCZ_APP:
cls = CredentialOther.class;
break;
default:
break;
}
return cls;
}
/**
* Adds the given credential to this collection. If a credential of this type already exist, it overrides the existing entry
* @param credential
* @return false if failed to add the new credential (old credential will be removed regardless), true otherwise
*/
public boolean addCredential(Credential credential, Dao dao) {
EnumNetworkConnection networkConnection = credential.getNetworkConnection();
credentials.put(networkConnection, credential);
//logger.info("credentials added " + credential);
// if ( dao != null ){
// conn = NetworkConnectionsHandler.GetConnection(sub,networkConnection);
// if (conn == null && !(networkConnection.equals(EnumNetworkConnection.E_NO_NETWORK)) ) {
// //logger.info("Adding a new connection object for " + type);
// conn = NetworkConnectionsHandler.CreateConnection(sub,networkConnection, credential, dao);
// } else if (conn != null) {
// //logger.info("Connection object already exists " + conn);
// conn.setCredential(credential);
// }
// }
return true;
}
public Credential get(EnumNetworkConnection networkConnection) {
return credentials.get(networkConnection);
}
// public SocialNetworkConnection getConnection(EnumNetworkConnection networkConnection) {
// return NetworkConnectionsHandler.GetConnection(sub, networkConnection);
//// return connections.get(networkConnection);
// }
public Collection<Credential> getCredentialValues()
{
return credentials.values();
}
public Credential removeCredenital(EnumNetworkConnection networkConnection) {
Credential removedCredential = credentials.get(networkConnection);
credentials.remove(networkConnection);
// if (removedCredential != null && NetworkConnectionsHandler.GetConnection(sub,networkConnection) != null)
// {
// //logger.info("Removed credential - disconnecting and removing connection.");
//
// SocialNetworkConnection snc = null;
// try
// {
// snc = NetworkConnectionsHandler.GetConnection(sub, networkConnection);
// if (snc != null)
// snc.Disconnect();
// } catch (Exception e)
// {
// logger.severe("Failed to disconnect " + snc +" :" + e.getLocalizedMessage());
// }
//
// //NetworkConnectionsHandler.DeleteConnection(sub, networkConnection);
// }
return removedCredential;
}
/**
* given a list of social network types, retrieves only the credential that <b>are not</b> in the given list
* @param updatedCredentialTypes
* @return see method description
*/
public Iterable<Credential> getOthers(Collection<EnumNetworkConnection> excludingTypes) {
Set<Credential> otherCredentials = new HashSet<Credential>();
for (EnumNetworkConnection networkConnection : EnumNetworkConnection.values()) {
if (! excludingTypes.contains(networkConnection)) {
Credential credential = get(networkConnection);
if (credential != null ) {
otherCredentials.add(get(networkConnection));
}
}
}
return otherCredentials;
}
/**
* @return true if there is at least one credential defined, false otherwise
*/
public boolean hasCredential() {
return credentials.size() > 0;
}
// public Collection<SocialNetworkConnection> getDefinedConnections() {
// return NetworkConnectionsHandler.GetValues(sub);
// //return connections.values();
// }
@Override
public String toString() {
StringBuilder strBuilder = new StringBuilder("[Credentials ");
if (credentials.size() > 0) {
for (Credential credential : credentials.values()) {
strBuilder.append(String.valueOf(credential)).append(", ");
}
strBuilder.delete(strBuilder.length() - 2, strBuilder.length());
} else {
strBuilder.append("<no credentials>");
}
strBuilder.append("]");
return strBuilder.toString();
}
}
package mcz.core.beans.deviceinstances;
import java.io.Serializable;
import mcz.core.beans.ConfParameter;
import mcz.core.beans.Dao;
import mcz.core.beans.MczBean;
import mcz.core.defs.Enums;
import mcz.core.defs.Enums.EnumDeviceState;
import mcz.core.defs.Enums.EnumImMode;
import mcz.core.defs.Enums.EnumMobileAppStatus;
import mcz.core.defs.Enums.EnumMobilePhoneOS;
import mcz.core.defs.Enums.EnumNetworkConnection;
public class DeviceInstance extends MczBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 20187334304264781L;
private final static String IM_MODE;
private static EnumImMode eImMode;
static {
IM_MODE = System.getProperty("config.system.im.mode");
eImMode = EnumImMode.resolveImMode(IM_MODE);
if(eImMode == null)
eImMode = EnumImMode.E_SIP_MODE;
}
private EnumNetworkConnection networkConnection;
private String publicId;
private String instanceId;
private String contactUri;
private EnumDeviceState devState;
private String token;
private EnumMobilePhoneOS mobileOS;
private EnumMobileAppStatus appStatus;
private Long lastRegisterTimestamp;
private Long lastUpdateTimestamp;
private Float geoLatitude;
private Float geoLongitude;
private Long geoTimestamp;
private String customerId;
public EnumNetworkConnection getNetworkConnection() {
return networkConnection;
}
public void setNetworkConnection(EnumNetworkConnection networkConnection) {
this.networkConnection = networkConnection;
}
public String getPublicId() {
return publicId;
}
public void setPublicId(String publicId) {
this.publicId = publicId;
}
public String getInstanceId() {
return instanceId;
}
public void setInstanceId(String instanceId) {
this.instanceId = instanceId;
}
public String getContactUri() {
return contactUri;
}
public void setContactUri(String contactUri) {
this.contactUri = contactUri;
}
public EnumDeviceState getDevState() {
return devState;
}
public void setDevState(EnumDeviceState devState) {
this.devState = devState;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public EnumMobilePhoneOS getMobileOS() {
return mobileOS;
}
public void setMobileOS(EnumMobilePhoneOS mobileOS) {
this.mobileOS = mobileOS;
}
public EnumMobileAppStatus getAppStatus() {
return appStatus;
}
public void setAppStatus(EnumMobileAppStatus appStatus) {
this.appStatus = appStatus;
}
public Long getLastRegisterTimestamp() {
return lastRegisterTimestamp;
}
public void setLastRegisterTimestamp(Long lastRegisterTimestamp) {
this.lastRegisterTimestamp = lastRegisterTimestamp;
}
public Long getLastUpdateTimestamp() {
return lastUpdateTimestamp;
}
public void setLastUpdateTimestamp(Long lastUpdateTimestamp) {
this.lastUpdateTimestamp = lastUpdateTimestamp;
}
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
public Float getGeoLatitude() {
return geoLatitude;
}
public void setGeoLatitude(Float geoLatitude) {
this.geoLatitude = geoLatitude;
}
public Float getGeoLongitude() {
return geoLongitude;
}
public void setGeoLongitude(Float geoLongitude) {
this.geoLongitude = geoLongitude;
}
public Long getGeoTimestamp() {
return geoTimestamp;
}
public void setGeoTimestamp(Long geoTimestamp) {
this.geoTimestamp = geoTimestamp;
}
/**
* @return the default sip contact uri
* for this device. The default uri uses the default server address from
* the configuration. This is used when a device is registered but is missing a contact uri (for example a fixed line device
* that never sends a SIP REGISTER)
*/
public String getDefaultContactUri(Dao dao) {
/*
* if the contact uri is not null then taking the contact uri
* please note: in comcast we only took the user part and add the default
* realm as the host part
*
* if contact uri is null then concating the public id with the default realm
*/
if (getContactUri() != null && getContactUri().length() > 0) {
// where available - use the device's known contact uri
return getContactUri();
} else {
// use the default realm if exists else use the default server address
String uriHost = dao.getValue(ConfParameter.DEFAULT_SERVER_REALM);
if (uriHost.isEmpty()) {
uriHost = dao.getValue(ConfParameter.DEFAULT_SERVER_ADDRESS);
}
return new String("sip:" + getPublicId() + "@" + uriHost);
}
}
public boolean hasPushService() {
if (mobileOS != null && token != null && token.length() > 0) {
switch (mobileOS) {
case E_IOS:
case E_ANDROID:
return true;
default:
return false;
}
}
return false;
}
@Override
public String toString() {
return "[DeviceInstance Network Connection " + getNetworkConnection().name() + ", public Id " + getPublicId() + ", instance Id " + getInstanceId() + ", contact uri " + getContactUri() + ", " + (isAvailable() ? "" : "not ") + "registered]";
}
public boolean isAvailable() {
boolean available = false;
switch(eImMode) {
case E_SIP_MODE:
case E_MIXED_MODE:
available = getDevState() != null && EnumDeviceState.E_REGISTERED.equals(getDevState());
if (getNetworkConnection() != null && EnumNetworkConnection.E_MCZ_APP.equals(getNetworkConnection())) {
available = available && getAppStatus() != null && EnumMobileAppStatus.E_APP_ONLINE.equals(getAppStatus());
}
break;
case E_HTTP_MODE:
if (getNetworkConnection() != null && EnumNetworkConnection.E_MCZ_APP.equals(getNetworkConnection())) {
available = getAppStatus() != null && EnumMobileAppStatus.E_APP_ONLINE.equals(getAppStatus());
}
break;
}
return available;
}
@Override
public String getBeanId() {
String beanId = null;
StringBuffer sb = null;
if (getNetworkConnection() != null && getPublicId() != null && getPublicId().length() > 0) {
sb = new StringBuffer();
sb.append(getNetworkConnection().name());
sb.append(getPublicId());
if (getInstanceId() != null && getInstanceId().length() > 0) {
sb.append(getInstanceId());
}
}
if (sb != null) {
beanId = sb.toString();
}
return beanId;
}
}
package mcz.core.beans.devices;
import java.io.Serializable;
import mcz.core.beans.ConfParameter;
import mcz.core.beans.Dao;
import mcz.core.beans.MczBean;
import mcz.core.defs.Enums.EnumNetworkConnection;
/**
* Data object representing a device owned by the subscriber, which can be used for outgoing or incoming call
*/
public abstract class Device extends MczBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = -8116617257302270885L;
private boolean isRegistered;
private String name;
private String publicId;
private String contactUri;
private Long lastRegisterTimestamp;
/**
* @return the url to the image representing this type of device (cellular phone, fixed phone, etc...) for gui purposes
*/
public abstract String getTypeIconUrl();
/**
* @return a user friendly name describing the NetworkConnection of this device ("Cellular", "fixed phone", ...)
*/
public abstract String getNetworkConnectionName();
/**
* @return the Network Connection enum
*/
public abstract EnumNetworkConnection getNetworkConnection();
/**
* @return user friendly name of the device such as "Home phone", "My work skype", etc...
*/
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/**
* The straight-forward way to register a device is when a SIP REGISTER is recieved in MCZ application.
* However, using configuration a device might be created as registered (This is used for devices that send no SIP REGISTER,
* such as fixed line phone, or mobile phone). In this case this method will return true, but contactUri() method will return
* the default server as uri
* @return true if the device is considered registered.
*/
public boolean isRegistered() {
return isRegistered;
}
public void setIsRegistered(boolean isRegistered) {
this.isRegistered = isRegistered;
}
public String getPublicId() {
return publicId;
}
public void setPublicId(String publicId) {
this.publicId = publicId;
}
/**
* If you need to know whether or not the returned contact uri is the default server or no, you can
* compare it to the returned value of the {@link #getDefaultContactUri()}.
* @return this device's sip contact uri if available. If not available, returns the default sip contact uri. This method
* never returns null or an empty string.
* @see #isRegistered()
* @see #getDefaultContactUri()
*/
public String getContactUri() {
return contactUri;
}
public void setContactUri(String contactUri) {
this.contactUri = contactUri;
}
@Override
public String getBeanId() {
return getDeviceId(getNetworkConnection().name(),getPublicId());
}
public static String getDeviceId (String deviceType, String publicId) {
return (deviceType + publicId)
.replace(' ', '_')
.replace('+', '_').replace('.', '_').replace('@', '_').replace("'","_").replace("\"","_");
}
/**
* @return the default sip contact uri
* for this device. The default uri uses the default server address from
* the configuration. This is used when a device is registered but is missing a contact uri (for example a fixed line device
* that never sends a SIP REGISTER)
*/
public String getDefaultContactUri(Dao dao) {
/*
* if the contact uri is not null then taking the contact uri
* please note: in comcast we only took the user part and add the default
* realm as the host part
*
* if contact uri is null then concating the public id with the default realm
*/
if (getContactUri() != null && getContactUri().length() > 0)
{
// where available - use the device's known contact uri
return getContactUri();
} else
{
// use the default realm if exists else use the default server address
String uriHost = dao.getValue(ConfParameter.DEFAULT_SERVER_REALM);
if (uriHost.isEmpty())
uriHost = dao.getValue(ConfParameter.DEFAULT_SERVER_ADDRESS);
return new String("sip:" + getPublicId() + "@" + uriHost);
}
}
public Long getLastRegisterTimestamp()
{
return lastRegisterTimestamp;
}
public void setLastRegisterTimestamp(Long lastRegisterTimestamp)
{
this.lastRegisterTimestamp = lastRegisterTimestamp;
}
@Override
public String toString() {
return "[Device Network Connection " + getNetworkConnectionName() + ", name " + getName() + ", public Id " + getPublicId() + ", contact uri " + getContactUri() + ", " + (isRegistered? "": "not ") + "registered]";
}
public boolean isAvailable() {
return isRegistered();
}
}
\ No newline at end of file
package mcz.core.beans.devices;
import mcz.core.defs.Enums.EnumNetworkConnection;
public class EmailDevice extends Device {
/**
*
*/
private static final long serialVersionUID = 2544478749924098392L;
@Override
public String getTypeIconUrl() {
return "icon-mail";
}
@Override
public String getNetworkConnectionName() {
return EnumNetworkConnection.E_MAIL.getName();
}
@Override
public EnumNetworkConnection getNetworkConnection()
{
return EnumNetworkConnection.E_MAIL;
}
}
package mcz.core.beans.devices;
import mcz.core.defs.Enums.EnumNetworkConnection;
public class GtalkDevice extends Device {
/**
*
*/
private static final long serialVersionUID = -419019425229336411L;
@Override
public String getTypeIconUrl() {
return "icon-mail";
}
@Override
public String getNetworkConnectionName() {
return EnumNetworkConnection.E_GTALK.getName();
}
@Override
public EnumNetworkConnection getNetworkConnection()
{
return EnumNetworkConnection.E_GTALK;
}
}
package mcz.core.beans.devices;
import mcz.core.defs.Enums.EnumNetworkConnection;;
public class LandlineDevice extends Device {
/**
*
*/
private static final long serialVersionUID = 2263031934423019646L;
@Override
public String getTypeIconUrl() {
return "icon-landline";
}
@Override
public String getNetworkConnectionName() {
return EnumNetworkConnection.E_LANDLINE.getName();
}
@Override
public EnumNetworkConnection getNetworkConnection()
{
return EnumNetworkConnection.E_LANDLINE;
}
}
package mcz.core.beans.devices;
import mcz.core.defs.Enums.EnumNetworkConnection;
import mcz.core.defs.Enums.EnumMobileAppStatus;
import mcz.core.defs.Enums.EnumMobilePhoneOS;
public class MczAppDevice extends Device {
/**
*
*/
private static final long serialVersionUID = 6438673242971457901L;
private String token;
private EnumMobilePhoneOS mobileOS;
private EnumMobileAppStatus appStatus = EnumMobileAppStatus.E_APP_OFFLINE;
private Float geoLatitude = null;
private Float geoLongitude = null;
private Long geoTimestamp = null;
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public boolean hasPushService()
{
if (mobileOS != null && token != null)
{
switch (mobileOS)
{
case E_IOS:
case E_ANDROID:
return true;
default:
return false;
}
}
return false;
}
public EnumMobilePhoneOS getMobileOS()
{
return mobileOS;
}
public void setMobileOS(EnumMobilePhoneOS mobileOS)
{
this.mobileOS = mobileOS;
}
public EnumMobileAppStatus getAppStatus()
{
return appStatus;
}
public void setAppStatus(EnumMobileAppStatus appStatus)
{
this.appStatus = appStatus;
}
public Float getGeoLatitude() {
return geoLatitude;
}
public void setGeoLatitude(Float geoLatitude) {
this.geoLatitude = geoLatitude;
}
public Float getGeoLongitude() {
return geoLongitude;
}
public void setGeoLongitude(Float geoLongitude) {
this.geoLongitude = geoLongitude;
}
public Long getGeoTimestamp() {
return geoTimestamp;
}
public void setGeoTimestamp(Long geoTimestamp) {
this.geoTimestamp = geoTimestamp;
}
public void setAppStatusOnline() { this.appStatus = EnumMobileAppStatus.E_APP_ONLINE; }
public void setAppStatusOffline() { this.appStatus = EnumMobileAppStatus.E_APP_OFFLINE; }
@Override
public String getTypeIconUrl() {
return "icon-browser";
}
@Override
public String getNetworkConnectionName() {
return EnumNetworkConnection.E_MCZ_APP.getName();
}
@Override
public EnumNetworkConnection getNetworkConnection()
{
return EnumNetworkConnection.E_MCZ_APP;
}
@Override
public boolean isAvailable() {
return getAppStatus().equals(EnumMobileAppStatus.E_APP_ONLINE) && isRegistered();
}
}
\ No newline at end of file
package mcz.core.beans.devices;
import mcz.core.defs.Enums.EnumNetworkConnection;
public class MobileDevice extends Device {
/**
*
*/
private static final long serialVersionUID = 7296504228902056070L;
@Override
public String getTypeIconUrl() {
return "icon-mobile";
}
@Override
public String getNetworkConnectionName() {
return EnumNetworkConnection.E_MOBILE.getName();
}
@Override
public EnumNetworkConnection getNetworkConnection()
{
return EnumNetworkConnection.E_MOBILE;
}
}
package mcz.core.beans.devices;
import mcz.core.defs.Enums.EnumNetworkConnection;
public class SipDevice extends Device {
/**
*
*/
private static final long serialVersionUID = 2646202526526001980L;
@Override
public String getTypeIconUrl() {
return "icon-browser";
}
@Override
public String getNetworkConnectionName() {
return EnumNetworkConnection.E_SIP.getName();
}
@Override
public EnumNetworkConnection getNetworkConnection()
{
return EnumNetworkConnection.E_SIP;
}
}
package mcz.core.beans.devices;
import mcz.core.defs.Enums.EnumNetworkConnection;
public class TvDevice extends Device {
/**
*
*/
private static final long serialVersionUID = -731868909828554670L;
@Override
public String getTypeIconUrl() {
return "icon-browser";
}
@Override
public String getNetworkConnectionName() {
return EnumNetworkConnection.E_TV.getName();
}
@Override
public EnumNetworkConnection getNetworkConnection()
{
return EnumNetworkConnection.E_TV;
}
}
/**
*
*/
package mcz.core.beans.groups;
import java.util.HashMap;
import java.util.Map;
/**
* @author user
*
*/
public class GroupFactory {
private static GroupFactory instance = null;
static Map<String, PublicGroup> groups = new HashMap<String, PublicGroup>();
protected GroupFactory() {
createGroup("ALL");
}
public static GroupFactory getInstance() {
if(instance == null) {
instance = new GroupFactory();
}
return instance;
}
public static PublicGroup getGroup(String title) {
if (groups.containsKey(title)) {
return groups.get(title);
}
createGroup(title);
return groups.get(title);
}
private static void createGroup(String title) {
if (!(groups.containsKey(title)))
{
PublicGroup g = new PublicGroup();
g.setTitle(title);
groups.put(title, g);
}
}
}
/**
*
*/
package mcz.core.beans.groups;
import java.util.Observable;
/**
* @author user
*
*/
public class GroupObservable extends Observable {
/**
*
*/
public GroupObservable() {
super();
}
@Override
public void notifyObservers(Object arg) {
setChanged();
super.notifyObservers(arg);
}
}
/**
*
*/
package mcz.core.beans.groups;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import mcz.core.beans.MczBean;
import mcz.core.beans.Subscriber;
/**
* @author user
*
*/
public class PublicGroup extends MczBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1068049434005773253L;
private VideoMessage vmsg = null;
private String title;
private String description;
private GroupObservable observable;
private Map<String, VideoMessage> subMap;
public PublicGroup() {
observable = new GroupObservable();
subMap = new HashMap<String, VideoMessage>();
}
/* (non-Javadoc)
* @see mcz.beans.MczBean#getId()
*/
@Override
public String getBeanId() {
// TODO Auto-generated method stub
return "PublicGroup";
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
public synchronized void addSuggestedVideo(VideoMessage vm) {
this.vmsg = vm;
//this.observable.notifyObservers(vm);
for(Object key : subMap.keySet()) {
if (!vm.getSubscriber().getUserName().equals(key))
subMap.put((String)key, vm);
}
}
public VideoMessage getSuggestedVideo(Subscriber sub) {
VideoMessage vm = subMap.get(sub.getUserName());
subMap.put(sub.getUserName(), null);
return vm;
}
public void removeContent(VideoMessage video) {
this.vmsg = null;
}
public void addToMap(Subscriber subscriber)
{
String name = subscriber.getUserName();
if (!subMap.containsKey(name))
{
subMap.put(name, null);
}
}
public void addObserver(Subscriber subscriber) {
this.observable.addObserver(subscriber);
}
public void removeObserver(Subscriber subscriber) {
this.observable.deleteObserver(subscriber);
}
}
/**
*
*/
package mcz.core.beans.groups;
import java.io.Serializable;
import java.util.Date;
import mcz.core.beans.MczBean;
import mcz.core.beans.Subscriber;
import mcz.core.beans.tv.Content;
/**
* @author user
*
*/
public class VideoMessage extends MczBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 5138657665815478225L;
private Content content;
private Date publishTime;
private Subscriber subscriber;
public VideoMessage(Content content) {
this.content = content;
this.publishTime = new Date();
}
public VideoMessage(Content content, Date publishTime, Subscriber subscriber ) {
this.content = content;
this.publishTime = publishTime;
this.subscriber = subscriber;
}
/**
* Copy constructor.
*/
public VideoMessage(VideoMessage msg) {
this(msg.getContent(), msg.getPublishTime(), msg.getSubscriber());
}
/* (non-Javadoc)
* @see mcz.beans.MczBean#getId()
*/
@Override
public String getBeanId() {
// TODO Auto-generated method stub
return null;
}
public void setContent(Content content) {
this.content = content;
}
public Content getContent() {
return content;
}
public void setPublishTime(Date publishTime) {
this.publishTime = publishTime;
}
public Date getPublishTime() {
return publishTime;
}
public void setSubscriber(Subscriber subscriber) {
this.subscriber = subscriber;
}
public Subscriber getSubscriber() {
return subscriber;
}
}
package mcz.core.beans.ons;
import java.io.Serializable;
import mcz.core.defs.Enums.EnumActiveService;
public class OnsFindMeMode extends OnsMode implements Serializable {
/**
*
*/
private static final long serialVersionUID = -6707105319963091941L;
@Override
public String toGuiString() {
return "Find Me";
}
@Override
public EnumActiveService getServiceType()
{
return EnumActiveService.E_FIND_ME_HERE;
}
}
package mcz.core.beans.ons;
import java.io.Serializable;
import mcz.core.defs.Enums.EnumActiveService;
public class OnsFollowMeMode extends OnsMode implements Serializable {
/**
*
*/
private static final long serialVersionUID = 7014751587158839231L;
private int timeout;
@Override
public int getTimeout() {
return timeout;
}
@Override
public void setTimeout(int timeout) {
this.timeout = timeout;
}
@Override
public boolean equals(Object obj) {
boolean isEquals = super.equals(obj);
if (isEquals == true && obj instanceof OnsFollowMeMode) {
OnsFollowMeMode mode = (OnsFollowMeMode)obj;
isEquals = (mode.getTimeout() == getTimeout());
}
return isEquals;
}
@Override
public int hashCode() {
return super.hashCode() ^ getTimeout();
}
@Override
public String toGuiString() {
return "Follow Me";
}
@Override
public EnumActiveService getServiceType()
{
return EnumActiveService.E_FOLLOW_ME;
}
}
package mcz.core.beans.ons;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import mcz.core.beans.MczBean;
import mcz.core.beans.devices.Device;
import mcz.core.defs.Enums.EnumActiveService;
/**
* Describes the subscriber configuration for a single mode of his One Number service. Each mode have associated "active" devices
*/
public abstract class OnsMode extends MczBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = -5865679854300727088L;
private List<Device> devices = new LinkedList<Device>();
public abstract EnumActiveService getServiceType();
/**
* @return the devices associated with this mode. This is a list of active devices. The order of the device is significant.
*/
public List<Device> getDevices() {
return devices;
}
@Override
public String getBeanId() {
return getClass().getSimpleName();
}
/**
* @return a user friendly name describing this mode. e.g. "Sim Ring", "Find me", etc.
*/
public abstract String toGuiString();
@Override
public String toString() {
StringBuilder strBuild = new StringBuilder("[" + getClass().getSimpleName() + " with devices [");
for (Device device : getDevices()) {
strBuild.append(device.toString()).append(", ");
}
strBuild.deleteCharAt(strBuild.length() - 1);
strBuild.deleteCharAt(strBuild.length() - 2);
strBuild.append("] ]");
return strBuild.toString();
}
public int getTimeout() {
return 0;
}
public void setTimeout(int timeout) {
}
}
\ No newline at end of file
package mcz.core.beans.ons;
import java.io.Serializable;
import mcz.core.defs.Enums.EnumActiveService;
public class OnsSimRingMode extends OnsMode implements Serializable {
/**
*
*/
private static final long serialVersionUID = 4208210865450792091L;
@Override
public String toGuiString() {
return "Sim Ring";
}
@Override
public EnumActiveService getServiceType()
{
return EnumActiveService.E_SIM_RING;
}
}
package mcz.core.beans.presence;
import java.io.Serializable;
import java.util.List;
import mcz.core.defs.Enums.EnumBuddiesMsgOpCode;
public class BuddiesMessage implements Serializable {
/**
*
*/
private static final long serialVersionUID = 3000802670140363697L;
private EnumBuddiesMsgOpCode opCode;
private List<Buddy> buddies;
private BuddyOwner buddyOwner;
int destQueueNum;
public BuddiesMessage() {
}
public BuddiesMessage(int destQueueNum) {
this.destQueueNum = destQueueNum;
}
public EnumBuddiesMsgOpCode getOpCode() {
return opCode;
}
public void setOpCode(EnumBuddiesMsgOpCode opCode) {
this.opCode = opCode;
}
public List<Buddy> getBuddies() {
return buddies;
}
public void setBuddies(List<Buddy> buddies) {
this.buddies = buddies;
}
public BuddyOwner getBuddyOwner() {
return buddyOwner;
}
public void setBuddyOwner(BuddyOwner buddyOwner) {
this.buddyOwner = buddyOwner;
}
public int getDestQueueNum() {
return destQueueNum;
}
public void setDestQueueNum(int destQueueNum) {
this.destQueueNum = destQueueNum;
}
}
package mcz.core.beans.presence;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import mcz.core.beans.MczBean;
import mcz.core.defs.Enums.EnumBuddyBeanType;
import mcz.core.defs.Enums.EnumNetworkConnection;
import mcz.core.defs.Enums.EnumPresenceMode;
import mcz.core.util.Common;
public class Buddy extends MczBean implements Serializable, BuddyBean {
/**
*
*/
private static final long serialVersionUID = -5633619950090782721L;
private String userId;
private String userName;
private EnumNetworkConnection networkConnection = EnumNetworkConnection.E_NO_NETWORK;
private String imageUrl;
private EnumPresenceMode mode = EnumPresenceMode.E_UNKNOWN;
private String status;
private String resourceId;
private boolean acceptAudio = false;
private boolean acceptVideo = false;
List<PresentitySubscription> presentitySubscriptions = new ArrayList<PresentitySubscription>(0);
public Buddy() {
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public EnumNetworkConnection getNetworkConnection() {
return networkConnection;
}
public void setNetworkConnection(EnumNetworkConnection networkConnection) {
this.networkConnection = networkConnection;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public EnumPresenceMode getMode() {
return mode;
}
public void setMode(EnumPresenceMode mode) {
this.mode = mode;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public boolean isAcceptAudio() {
return acceptAudio;
}
public void setAcceptAudio(boolean acceptAudio) {
this.acceptAudio = acceptAudio;
}
public boolean isAcceptVideo() {
return acceptVideo;
}
public void setAcceptVideo(boolean acceptVideo) {
this.acceptVideo = acceptVideo;
}
public String getResourceId() {
return resourceId;
}
public void setResourceId(String resourceId) {
this.resourceId = resourceId;
}
public List<PresentitySubscription> getPresentitySubscriptions() {
return presentitySubscriptions;
}
public void setPresentitySubscriptions(
List<PresentitySubscription> presentitySubscriptions) {
this.presentitySubscriptions = presentitySubscriptions;
}
@Override
public String toString() {
StringBuffer strBuff = new StringBuffer();
strBuff.append("[ Buddy: ");
strBuff.append("UserId: " + this.getUserId());
strBuff.append(", UserName: " + this.getUserName());
strBuff.append(", NetworkConnection: " + this.getNetworkConnection().name());
strBuff.append(", ImageUrl: " + this.getImageUrl());
strBuff.append(", Mode: " + this.getMode().name());
strBuff.append(", Status: " + this.getStatus());
strBuff.append(", ResourceId: " + this.getResourceId());
strBuff.append("]");
return strBuff.toString();
}
@Override
public String getBeanId() {
StringBuffer strBuff = new StringBuffer();
strBuff.append(this.getUserId()).append("!&!");
strBuff.append(this.getUserName()).append("!&!");
strBuff.append(this.getNetworkConnection().name()).append("!&!");
strBuff.append(this.getImageUrl()).append("!&!");
strBuff.append(this.getMode().name()).append("!&!");
strBuff.append(this.getStatus());
return strBuff.toString();
}
@Override
public boolean equals(Object obj) {
boolean equals;
if(this == obj) {
equals = true;
} else if ((obj == null) || (obj.getClass() != this.getClass())) {
equals = false;
} else { // object must be Buddy at this point
Buddy buddy = (Buddy)obj;
equals = (this.getNetworkConnection() == buddy.getNetworkConnection() || (this.getNetworkConnection() != null && this.getNetworkConnection().equals(buddy.getNetworkConnection())) || (buddy.getNetworkConnection() != null && buddy.getNetworkConnection().equals(this.getNetworkConnection()))) &&
(this.getUserId() == buddy.getUserId() || (this.getUserId() != null && this.getUserId().equals(buddy.getUserId())) || (buddy.getUserId() != null && buddy.getUserId().equals(this.getUserId())));
}
return equals;
}
@Override
public int hashCode() {
int hash = 7;
hash = 31 * hash + (null != this.getNetworkConnection() ? this.getNetworkConnection().hashCode() : 0);
hash = 31 * hash + (null != this.getUserId() ? this.getUserId().hashCode() : 0);
return hash;
}
@Override
public int getHashedKey() {
return Common.abs((getUserId() + getNetworkConnection().name()).hashCode());
}
@Override
public EnumBuddyBeanType getType() {
return EnumBuddyBeanType.E_BUDDY;
}
}
package mcz.core.beans.presence;
import mcz.core.defs.Enums.EnumBuddyBeanType;
public interface BuddyBean {
public int getHashedKey();
public EnumBuddyBeanType getType();
}
package mcz.core.beans.presence;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import mcz.core.beans.MczBean;
import mcz.core.defs.Enums.EnumBuddyBeanType;
import mcz.core.defs.Enums.EnumNetworkConnection;
import mcz.core.util.Common;
public class BuddyOwner extends MczBean implements Serializable, BuddyBean {
/**
*
*/
private static final long serialVersionUID = -1242371816224809443L;
private String userId;
private String userName;
private EnumNetworkConnection networkConnection = EnumNetworkConnection.E_NO_NETWORK;
List<Buddy> buddies = new ArrayList<Buddy>(0);
public BuddyOwner() {
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public EnumNetworkConnection getNetworkConnection() {
return networkConnection;
}
public void setNetworkConnection(EnumNetworkConnection networkConnection) {
this.networkConnection = networkConnection;
}
public List<Buddy> getBuddies() {
return buddies;
}
public void setBuddies(List<Buddy> buddies) {
this.buddies = buddies;
}
public String toString() {
StringBuffer strBuff = new StringBuffer();
strBuff.append("[ BuddyOwner: ");
strBuff.append("UserId: " + this.getUserId());
strBuff.append(", UserName: " + this.getUserName());
strBuff.append(", NetworkConnection: " + this.getNetworkConnection().name());
strBuff.append("]");
return strBuff.toString();
}
@Override
public String getBeanId() {
StringBuffer strBuff = new StringBuffer();
strBuff.append(this.getUserId()).append("!&!");
strBuff.append(this.getUserName()).append("!&!");
strBuff.append(this.getNetworkConnection().name());
return strBuff.toString();
}
@Override
public boolean equals(Object obj) {
boolean equals;
if(this == obj) {
equals = true;
} else if ((obj == null) || (obj.getClass() != this.getClass())) {
equals = false;
} else { // object must be BuddyOwner at this point
BuddyOwner buddyOwner = (BuddyOwner)obj;
equals = (this.getNetworkConnection() == buddyOwner.getNetworkConnection() || (this.getNetworkConnection() != null && this.getNetworkConnection().equals(buddyOwner.getNetworkConnection())) || (buddyOwner.getNetworkConnection() != null && buddyOwner.getNetworkConnection().equals(this.getNetworkConnection()))) &&
(this.getUserId() == buddyOwner.getUserId() || (this.getUserId() != null && this.getUserId().equals(buddyOwner.getUserId())) || (buddyOwner.getUserId() != null && buddyOwner.getUserId().equals(this.getUserId())));
}
return equals;
}
@Override
public int hashCode() {
int hash = 7;
hash = 31 * hash + (null != this.getNetworkConnection() ? this.getNetworkConnection().hashCode() : 0);
hash = 31 * hash + (null != this.getUserId() ? this.getUserId().hashCode() : 0);
return hash;
}
@Override
public int getHashedKey() {
return Common.abs((getUserId() + getNetworkConnection().name()).hashCode() + 1);
}
@Override
public EnumBuddyBeanType getType() {
return EnumBuddyBeanType.E_BUDDY_OWNER;
}
}
package mcz.core.beans.presence;
import java.io.Serializable;
import mcz.core.beans.MczBean;
public class PresentitySubscription extends MczBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = -5690025310912895591L;
private String watcherUri;
private String route;
private Long expires;
public PresentitySubscription() {
}
public String getWatcherUri() {
return watcherUri;
}
public void setWatcherUri(String watcherUri) {
this.watcherUri = watcherUri;
}
public String getRoute() {
return route;
}
public void setRoute(String route) {
this.route = route;
}
public Long getExpires() {
return expires;
}
public void setExpires(Long expires) {
this.expires = expires;
}
@Override
public String toString() {
StringBuffer strBuff = new StringBuffer();
strBuff.append("[ Presentity Subscription: ");
strBuff.append("WatcherUri: " + this.getWatcherUri());
strBuff.append(", Route: " + this.getRoute());
strBuff.append(", Expires: " + this.getExpires().toString());
strBuff.append(" ]");
return strBuff.toString();
}
@Override
public String getBeanId() {
StringBuffer strBuff = new StringBuffer();
strBuff.append(this.getWatcherUri()).append("!&!");
strBuff.append(this.getRoute()).append("!&!");
strBuff.append(this.getExpires().toString());
return strBuff.toString();
}
@Override
public boolean equals(Object obj) {
boolean equals;
if(this == obj) {
equals = true;
} else if ((obj == null) || (obj.getClass() != this.getClass())) {
equals = false;
} else { // object must be PresentitySubscription at this point
PresentitySubscription presentitySubscription = (PresentitySubscription)obj;
equals = (this.getWatcherUri() == presentitySubscription.getWatcherUri() || (this.getWatcherUri() != null && this.getWatcherUri().equals(presentitySubscription.getWatcherUri())) || (presentitySubscription.getWatcherUri() != null && presentitySubscription.getWatcherUri().equals(this.getWatcherUri())));
}
return equals;
}
@Override
public int hashCode() {
int hash = 7;
hash = 31 * hash + (null != this.getWatcherUri() ? this.getWatcherUri().hashCode() : 0);
return hash;
}
}
package mcz.core.beans.profiles;
import java.io.Serializable;
import java.util.List;
public class Brands implements Serializable{
public static class Brand {
private String name;
private String path;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
}
private static final long serialVersionUID = 4519238880636198119L;
List<Brand> brands;
public List<Brand> getBrands() {
return brands;
}
public void setBrands(List<Brand> brands) {
this.brands = brands;
}
}
\ No newline at end of file
package mcz.core.beans.profiles;
import java.io.Serializable;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore;
import mcz.core.beans.MczBean;
public class ClientProfile extends MczBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 140808237379694959L;
private String carrier;
private String applicationHostURL;
private String sipHostIP;
private String sipHostPort;
private boolean useIMS;
private boolean useStun;
private String stunHostIP;
private String stunHostPort;
private List<String> transportType;
private String domain;
private List<String> connectivityType;
private List<String> activeAudioCodecs;
private List<String> availableAudioCodecs;
private List<String> activeVideoCodecs;
private List<String> availableVideoCodecs;
private String brand;
private String wsServers;
private String stunServers;
private String turnServers;
private Long lastProfileUpdate;
@JsonIgnore
public String getCarrier() {
return carrier;
}
@JsonIgnore
public void setCarrier(String carrier) {
this.carrier = carrier;
}
@JsonIgnore
public String getApplicationHostURL() {
return applicationHostURL;
}
@JsonIgnore
public void setApplicationHostURL(String applicationHostURL) {
this.applicationHostURL = applicationHostURL;
}
@JsonIgnore
public String getSipHostIP() {
return sipHostIP;
}
public void setSipHostIP(String sipHostIP) {
this.sipHostIP = sipHostIP;
}
@JsonIgnore
public String getSipHostPort() {
return sipHostPort;
}
@JsonIgnore
public void setSipHostPort(String sipHostPort) {
this.sipHostPort = sipHostPort;
}
@JsonIgnore
public boolean isUseIMS() {
return useIMS;
}
public void setUseIMS(boolean useIMS) {
this.useIMS = useIMS;
}
@JsonIgnore
public boolean isUseStun() {
return useStun;
}
@JsonIgnore
public void setUseStun(boolean useStun) {
this.useStun = useStun;
}
@JsonIgnore
public String getStunHostIP() {
return stunHostIP;
}
public void setStunHostIP(String stunHostIP) {
this.stunHostIP = stunHostIP;
}
@JsonIgnore
public String getStunHostPort() {
return stunHostPort;
}
@JsonIgnore
public void setStunHostPort(String stunHostPort) {
this.stunHostPort = stunHostPort;
}
@JsonIgnore
public List<String> getTransportType() {
return transportType;
}
@JsonIgnore
public void setTransportType(List<String> transportType) {
this.transportType = transportType;
}
@JsonIgnore
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
@JsonIgnore
public List<String> getConnectivityType() {
return connectivityType;
}
@JsonIgnore
public void setConnectivityType(List<String> connectivityType) {
this.connectivityType = connectivityType;
}
@JsonIgnore
public List<String> getActiveAudioCodecs() {
return activeAudioCodecs;
}
@JsonIgnore
public void setActiveAudioCodecsList(List<String> activeAudioCodecs) {
this.activeAudioCodecs = activeAudioCodecs;
}
@JsonIgnore
public List<String> getAvailableAudioCodecs() {
return availableAudioCodecs;
}
@JsonIgnore
public void setAvailableAudioCodecsList(List<String> availableAudioCodecs) {
this.availableAudioCodecs = availableAudioCodecs;
}
@JsonIgnore
public List<String> getActiveVideoCodecs() {
return activeVideoCodecs;
}
@JsonIgnore
public void setActiveVideoCodecsList(List<String> activeVideoCodecs) {
this.activeVideoCodecs = activeVideoCodecs;
}
@JsonIgnore
public List<String> getAvailableVideoCodecs() {
return availableVideoCodecs;
}
@JsonIgnore
public void setAvailableVideoCodecsList(List<String> availableVideoCodecs) {
this.availableVideoCodecs = availableVideoCodecs;
}
@JsonIgnore
public String getBrand() {
return brand;
}
@JsonIgnore
public void setBrand(String brand) {
this.brand = brand;
}
@JsonIgnore
public String getWebsocketServerUrl() {
return wsServers;
}
@JsonIgnore
public void setWebsocketServerUrl(String wsServers) {
this.wsServers = wsServers;
}
@JsonIgnore
public String getStunServers() {
return stunServers;
}
@JsonIgnore
public void setStunServers(String stunServers) {
this.stunServers = stunServers;
}
@JsonIgnore
public String getTurnServers() {
return turnServers;
}
@JsonIgnore
public void setTurnServers(String turnServers) {
this.turnServers = turnServers;
}
@JsonIgnore
public Long getLastProfileUpdate() {
return lastProfileUpdate;
}
@JsonIgnore
public void setLastProfileUpdate(Long lastProfileUpdate) {
this.lastProfileUpdate = lastProfileUpdate;
}
@Override
@JsonIgnore
public String toString() {
return "[ClientProfile carrier " + this.getCarrier() + "\n" +
", applicationHostURL " + this.getApplicationHostURL() + "\n" +
", sipHostIP " + this.getSipHostIP() + "\n" +
", sipHostPort " + this.getSipHostPort() + "\n" +
", useIMS " + this.isUseIMS() + "\n" +
", useStun " + this.isUseStun() + "\n" +
", stunHostIP " + this.getStunHostIP() + "\n" +
", stunHostPort " + this.getStunHostPort() + "\n" +
", transportType " + this.getTransportType().get(0) + "\n" +
", domain " + this.getDomain() + "\n" +
", connectivityType " + this.getConnectivityType().get(0) + "\n" +
", activeAudioCodecs " + this.getActiveAudioCodecs() + "\n" +
", availableAudioCodecs " + this.getAvailableAudioCodecs() + "\n" +
", activeVideoCodecs " + this.getActiveVideoCodecs() + "\n" +
", availableVideoCodecs " + this.getAvailableVideoCodecs() + "\n" +
", brand " + this.getBrand() + "\n" +
", websocketServerUrl " + this.getWebsocketServerUrl() + "\n" +
", stunServers " + this.getStunServers() + "\n" +
", turnServers " + this.getTurnServers() + "\n" +
", lastProfileUpdate " + this.getLastProfileUpdate() + "\n" +
"]";
}
@Override
@JsonIgnore
public String getBeanId() {
return this.getCarrier();
}
}
/**
*
*/
package mcz.core.beans.tv;
import java.io.Serializable;
import java.util.EnumMap;
import java.util.Map;
import mcz.core.beans.MczBean;
import mcz.core.util.ScreenTarget;
/**
* @author user
*
*/
public class Content extends MczBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = -8110323755021040357L;
private Map<ScreenTarget, PhysicalContent> physicalContents = new EnumMap<ScreenTarget, PhysicalContent>(ScreenTarget.class);
private Metadata metadata;
/*
* (non-Javadoc)
*
* @see mcz.beans.MczBean#getId()
*/
@Override
public String getBeanId() {
// TODO Auto-generated method stub
return Integer.toString(metadata.getContentId());
}
/**
* @param physicalContnet the physicalContnet to set
*/
public void setPhysicalContnets(Map<ScreenTarget, PhysicalContent> physicalContnet) {
this.physicalContents = physicalContnet;
}
/**
* @return the physicalContents
*/
public Map<ScreenTarget, PhysicalContent> getPhysicalContnets() {
return this.physicalContents;
}
public void addPhysicalContnet(PhysicalContent content) {
this.physicalContents.put(content.getDecodingInfo().getTarget(), content);
}
public void removeContent(PhysicalContent content) {
this.physicalContents.remove(content);
}
public Metadata getMetadata() {
return this.metadata;
}
public void setMetadata(Metadata metadata) {
this.metadata = metadata;
}
}
/**
*
*/
package mcz.core.beans.tv;
import java.io.Serializable;
import mcz.core.beans.MczBean;
import mcz.core.util.ScreenTarget;
/**
* @author user
*
*/
public class DecodingInfo extends MczBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = -4242746650785248280L;
private ScreenTarget target;
/*
* (non-Javadoc)
*
* @see mcz.beans.MczBean#getId()
*/
@Override
public String getBeanId() {
// TODO Auto-generated method stub
return Integer.toString(target.ordinal());
}
public ScreenTarget getTarget() {
return this.target;
}
public void setTarget(ScreenTarget target) {
this.target = target;
}
}
/**
*
*/
package mcz.core.beans.tv;
import java.io.Serializable;
import java.util.EnumMap;
import java.util.HashSet;
import java.util.Set;
import mcz.core.beans.MczBean;
import mcz.core.tv.data.TvData;
import mcz.core.util.Category;
import mcz.core.util.ScreenTarget;
import com.google.gson.Gson;
/**
* @author user
*
*/
public class Epg extends MczBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 7091196829464657L;
private Set<TvChannel> channels = new HashSet<TvChannel>();
/* (non-Javadoc)
* @see mcz.beans.MczBean#getId()
*/
@Override
public String getBeanId() {
// TODO Auto-generated method stub
return "EPG";
}
/**
* @param channels the channels to set
*/
public void setChannels(Set<TvChannel> channels) {
this.channels = channels;
}
/**
* @return the channels
*/
public Set<TvChannel> getChannels() {
return channels;
}
public void addChannel(TvChannel channel) {
this.channels.add(channel);
}
public void removeChannel(TvChannel channel) {
this.channels.remove(channel);
}
public static String toJson(Epg epg) {
Gson gson = new Gson();
return gson.toJson(epg);
}
/*
public Object clone(){
try{
Epg cloned = (Epg)super.clone();
cloned.channels = (HashSet<TvChannel>)this.channels.clone();
return cloned;
}
catch(CloneNotSupportedException e){
System.out.println(e);
return null;
}
}
*/
public void setUp() {
DecodingInfo decodingInfo = new DecodingInfo();
decodingInfo.setTarget(ScreenTarget.Tv);
PhysicalContent pcontent = new PhysicalContent();
pcontent.setContentId(1);
pcontent.setDecodingInfo(decodingInfo);
pcontent.setUri("htttp://pcontact.mp4");
Metadata md = new Metadata();
md.setContentId(1);
HashSet<Category> cat = new HashSet<Category>();
cat.add(Category.News);
cat.add(Category.Sports);
md.setCategories(cat);
md.setDirector("director");
md.setProducer("producer");
md.setFavorite(true);
//md.setSuggested(4);
HashSet<String> act = new HashSet<String>();
act.add("actor1");
act.add("actor2");
act.add("actor3");
md.setDuration(100);
md.setDescription("description.....");
md.setTitle("title");
md.setThumbnail("http://humbnail.jpg");
md.setActors(act);
Content cont = new Content();
EnumMap<ScreenTarget, PhysicalContent> pc = new EnumMap<ScreenTarget, PhysicalContent>(ScreenTarget.class);
pc.put(decodingInfo.getTarget(),pcontent);
cont.setPhysicalContnets(pc);
cont.setMetadata(md);
Program prog = new Program();
prog.setStartTime(0);
prog.setDuration(101);
prog.setChannel(1);
prog.setProgramId(1);
prog.setRecord(true);
TvChannel ch = new TvChannel();
ch.setName("AAA");
ch.setChId(1);
ch.setFavorite(true);
ch.setLogo("http://channel_logo.png");
prog.setContent(cont);
ch.addProgram(prog);
addChannel(ch);
}
public static void main(String [ ] args) {
Epg epg;// = new Epg();
//epg.setUp();
TvData t = new TvData();
epg = t.createEpgFromUrl("http://videoserver/tv/tvData.json");
//System.out.println(toJson(epg));
Gson gson = new Gson();
//return gson.toJson(epg)
//System.out.println(gson.toJson(t.getScheduledRecording()));
System.out.println(gson.toJson(t.getContents().values()));
}
}
/**
*
*/
package mcz.core.beans.tv;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import mcz.core.beans.MczBean;
import mcz.core.util.Category;
/**
* @author user
*
*/
public class Metadata extends MczBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = -7817093226123334414L;
private String director;
private String producer;
private Set<String> actors = new HashSet<String>();
private Set<Category> categories = new HashSet<Category>();
private int contentId;
private int duration;
private String description;
private String title;
//private int suggested;
private boolean favorite = false;
private String thumbnail;
/*
* (non-Javadoc)
*
* @see mcz.beans.MczBean#getId()
*/
@Override
public String getBeanId() {
// TODO Auto-generated method stub
return Integer.toString(this.getContentId()); }
/**
* @param director
* the director to set
*/
public void setDirector(String director) {
this.director = director;
}
/**
* @return the director
*/
public String getDirector() {
return director;
}
public void setProducer(String producer) {
this.producer = producer;
}
public String getProducer() {
return producer;
}
public void setActors(Set<String> actors) {
this.actors = actors;
}
public Set<String> getActors() {
return actors;
}
public void setContentId(int contentId) {
this.contentId = contentId;
}
public int getContentId() {
return contentId;
}
public void setCategories(Set<Category> categories) {
this.categories = categories;
}
public Set<Category> getCategories() {
return categories;
}
public void setDuration(int duration) {
this.duration = duration;
}
public int getDuration() {
return duration;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description the description to set
*/
public void setDescription(String description) {
this.description = description;
}
/**
* @return the title
*/
public String getTitle() {
return title;
}
/**
* @param title the title to set
*/
public void setTitle(String title) {
this.title = title;
}
/*
public void setSuggested(int suggested) {
this.suggested = suggested;
}
public int getSuggested() {
return suggested;
}
*/
public void setFavorite(boolean favorite) {
this.favorite = favorite;
}
public boolean isFavorite() {
return favorite;
}
/**
* @return the thumbnail
*/
public String getThumbnail() {
return thumbnail;
}
/**
* @param thumbnail the thumbnail to set
*/
public void setThumbnail(String thumbnail) {
this.thumbnail = thumbnail;
}
}
/**
*
*/
package mcz.core.beans.tv;
import java.io.Serializable;
import mcz.core.beans.MczBean;
/**
* @author user
*
*/
public class PhysicalContent extends MczBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = -6035796656210375348L;
private String uri;
private int contentId;
private DecodingInfo decodingInfo;
/* (non-Javadoc)
* @see mcz.beans.MczBean#getId()
*/
@Override
public String getBeanId() {
// TODO Auto-generated method stub
return Integer.toString(this.getContentId());
}
public void setUri(String uri) {
this.uri = uri;
}
public String getUri() {
return uri;
}
public void setContentId(int contentId) {
this.contentId = contentId;
}
public int getContentId() {
return contentId;
}
public void setDecodingInfo(DecodingInfo decodingInfo) {
this.decodingInfo = decodingInfo;
}
public DecodingInfo getDecodingInfo() {
return decodingInfo;
}
}
/**
*
*/
package mcz.core.beans.tv;
import java.io.Serializable;
import mcz.core.beans.MczBean;
/**
* @author Dan Stavy
*
*/
public class Program extends MczBean implements Serializable, Comparable<Program> {
/**
*
*/
private static final long serialVersionUID = -8269307613795814683L;
private int programId;
private int chId;
private int startTime;
//private int offsetTime;
private int duration;
private Content content;
private boolean record;
/* (non-Javadoc)
* @see mcz.beans.MczBean#getId()
*/
@Override
public String getBeanId() {
// TODO Auto-generated method stub
return "program";
}
/*
// duration has to be set before
public void setOffsetTime() {
int endTime = startTime + duration;
Date date = new Date(); // given date
Calendar calendar = GregorianCalendar.getInstance(); // creates a new calendar instance
calendar.setTime(date); // assigns calendar to given date
int nowMin = calendar.get(Calendar.HOUR_OF_DAY) + calendar.get(Calendar.MINUTE); // gets hour in 24h format
if (endTime > nowMin) {
this.offsetTime = startTime - nowMin; // program that is running will have minus value
}
else
{
this.offsetTime = 1440 - nowMin + startTime; // 24H - now + program time
}
}
*/
public void setStartTime(int min) {
this.startTime = min;
}
public int getStartTime() {
return startTime;
}
public void setDuration(int duration) {
this.duration = duration;
}
public int getDuration() {
return duration;
}
public void setChannel(int chId) {
this.chId = chId;
}
public int getChannelId() {
return chId;
}
public void setContent(Content content) {
this.content = content;
}
public Content getContent() {
return content;
}
public void setRecord(boolean record) {
this.record = record;
}
public boolean isRecord() {
return record;
}
public void setProgramId(int programId) {
this.programId = programId;
}
public int getProgramId() {
return programId;
}
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(Program o) {
if (this.startTime < (o.startTime)) return -1;
if (this.startTime > (o.startTime)) return 1;
//if (this.programId < o.programId) return 1;
//if (this.programId > o.programId) return -1;
return 0;
}
}
package mcz.core.beans.tv;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.lang.reflect.Type;
import java.util.HashSet;
import java.util.Set;
import mcz.core.beans.MczBean;
import utils.common.Log4jHandler;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
public class StaticChannel extends MczBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 2767614766601027503L;
private static final Log4jHandler logger = new Log4jHandler(StaticChannel.class.getName());
private String name;
private int ChId;
private String logo;
private boolean myChannel;
private Set<Content> contents = new HashSet<Content>();
/*
* (non-Javadoc)
*
* @see mcz.beans.MczBean#getId()
*/
@Override
public String getBeanId() {
// TODO Auto-generated method stub
return getName();
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getLogo() {
return this.logo;
}
public void setLogo(String logo) {
this.logo = logo;
}
public Set<Content> getContents() {
return this.contents;
}
public void setContents(Set<Content> contents) {
this.contents = contents;
}
public void addContent(Content content) {
this.contents.add(content);
}
public void removeContent(Content content) {
this.contents.remove(content);
}
public void setChId(int chId) {
ChId = chId;
}
public int getChId() {
return ChId;
}
public void setMyChannel(boolean myChannel) {
this.myChannel = myChannel;
}
public boolean isMyChannel() {
return myChannel;
}
public static String toJson(StaticChannel ch) {
Gson gson = new Gson();
return gson.toJson(ch.contents);
}
public Set<Content> createEpgFromUrl(String url) {
Gson gson = new Gson();
InputStreamReader in = null;
try {
//URL jf = new URL(url);
//in = new BufferedReader(new InputStreamReader(jf.openStream()));
in = new InputStreamReader(new FileInputStream(url));
//Type ContentType = new TypeToken<Epg>() {}.getType();
Type ContentType = new TypeToken<Set<Content>>() {}.getType();
this.contents = gson.fromJson(in, ContentType);
} catch (FileNotFoundException e) {
logger.info("Could not find TV json files !");
} catch (Exception e) {
logger.info("Could not find TV json files !");
} finally {
if (in != null)
try {
in.close();
} catch (Exception ignored) {}
}
//inflateTvData(epg);
return this.contents;
}
public static void main(String [ ] args) {
//TvData tv = new TvData();
//tv.createEpgFromUrl("http://videoserver/vod/tvData.json");
StaticChannel ch = new StaticChannel();
//Content c = tv.getContent(1);
//Content c2 = tv.createContent(1);
//ch.addContent(c);
//ch.addContent(c2);
ch.createEpgFromUrl("http://videoserver/vod/vod.json");
System.out.println(StaticChannel.toJson(ch));
}
}
package mcz.core.beans.tv;
import java.io.Serializable;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import mcz.core.beans.MczBean;
public class TvChannel extends MczBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 2767614766601027503L;
private String name;
private String logo;
private int ChId;
private boolean favorite;
private boolean myChannel;
private SortedSet<Program> programs = new TreeSet<Program>();
/*
* (non-Javadoc)
*
* @see mcz.beans.MczBean#getId()
*/
@Override
public String getBeanId() {
// TODO Auto-generated method stub
return getName();
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getLogo() {
return this.logo;
}
public void setLogo(String logo) {
this.logo = logo;
}
public Set<Program> getPrograms() {
return this.programs;
}
public void setPrograms(SortedSet<Program> programs) {
this.programs = programs;
}
public void addProgram(Program program) {
this.programs.add(program);
}
public void removeProgram(Program program) {
this.programs.remove(program);
}
public void setChId(int chId) {
ChId = chId;
}
public int getChId() {
return ChId;
}
public void setFavorite(boolean favorite) {
this.favorite = favorite;
}
public boolean isFavorite() {
return favorite;
}
public void setMyChannel(boolean myChannel) {
this.myChannel = myChannel;
}
public boolean isMyChannel() {
return myChannel;
}
}
This diff could not be displayed because it is too large.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment