You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by se...@apache.org on 2012/01/24 19:31:07 UTC

svn commit: r1235400 [14/30] - in /incubator/openmeetings/trunk/singlewebapp: WebContent/WEB-INF/ WebContent/WEB-INF/red5-services/ src/META-INF/ src/app/org/openmeetings/app/batik/beans/ src/app/org/openmeetings/app/conference/whiteboard/ src/app/org/...

Modified: incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/OpenXGHttpClient.java
URL: http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/OpenXGHttpClient.java?rev=1235400&r1=1235399&r2=1235400&view=diff
==============================================================================
--- incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/OpenXGHttpClient.java (original)
+++ incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/OpenXGHttpClient.java Tue Jan 24 18:30:48 2012
@@ -1,561 +1,579 @@
-package org.openmeetings.app.sip.xmlrpc;
-
-import java.io.InputStream;
-import java.nio.charset.Charset;
-import java.util.Date;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpVersion;
-import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.RequestEntity;
-import org.apache.commons.httpclient.protocol.Protocol;
-import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
-import org.openmeetings.app.data.basic.Configurationmanagement;
-import org.openmeetings.app.persistence.beans.basic.Configuration;
-import org.openmeetings.app.persistence.beans.sip.OpenXGReturnObject;
-import org.openmeetings.app.persistence.beans.user.UserSipData;
-import org.openmeetings.app.remote.red5.ScopeApplicationAdapter;
-import org.openmeetings.app.sip.xmlrpc.custom.OpenXGCustomXMLMarshall;
-import org.openmeetings.app.sip.xmlrpc.custom.dao.OpenXGReturnObjectDaoImpl;
-import org.openmeetings.utils.crypt.MD5;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class OpenXGHttpClient {
-
-	private static final Logger log = Red5LoggerFactory.getLogger(
-			OpenXGHttpClient.class, ScopeApplicationAdapter.webAppRootKey);
-	@Autowired
-	private Configurationmanagement cfgManagement;
-	@Autowired
-	private OpenXGReturnObjectDaoImpl openXGReturnObjectDao;
-
-	public String digest_calculate(Object[] params) throws Exception {
-		String stringToMd5 = "";
-
-		for (int i = 0; i < params.length; i++) {
-			stringToMd5 += params[i];
-		}
-
-		return MD5.do_checksum(stringToMd5);
-
-	}
-
-	public void openSIPgUserCreateTest() {
-		try {
-
-			String first_name = "Matti";
-			String middle_i = "X";
-			String last_name = "Virtanen";
-			String email = "test@test.de";
-			String password = "password";
-
-			this.openSIPgUserCreateUser(first_name,
-					middle_i, last_name, email, password, "test");
-
-		} catch (Exception err) {
-
-			log.error("[openSIPgUserCreateTest]", err);
-
-		}
-	}
-
-	/**
-	 * 
-	 * Creates a SIP User using the RPC Methods of openXG
-	 * 
-	 * @param first_name
-	 * @param middle_i
-	 * @param last_name
-	 * @param email
-	 * @param password
-	 * @return
-	 */
-	public UserSipData openSIPgUserCreateUser(String first_name,
-			String middle_i, String last_name, String email, String login,
-			String password) {
-		try {
-
-			// Check if the OpenXG Gateway is enabled in general
-			Configuration sip_openxg_enable = cfgManagement.getConfKey(3L,
-					"sip.openxg.enable");
-
-			if (sip_openxg_enable == null
-					|| !sip_openxg_enable.getConf_value().equals("yes")) {
-				log.debug("SIP is disabled");
-				return null;
-			}
-
-			// client_id and client_secret
-			Configuration openxg_client_id = cfgManagement.getConfKey(3L,
-					"openxg.client.id");
-			Configuration openxg_client_secret = cfgManagement.getConfKey(3L,
-					"openxg.client.secret");
-			if (openxg_client_id == null || openxg_client_secret == null) {
-				throw new Exception(
-						"openxg.client.id or openxg.client.secret missing in Configuration table");
-			}
-			String client_id = openxg_client_id.getConf_value();
-			String client_secret = openxg_client_secret.getConf_value();
-
-			// domain
-			Configuration openxg_client_domain = cfgManagement.getConfKey(3L,
-					"openxg.client.domain");
-			if (openxg_client_domain == null) {
-				throw new Exception(
-						"openxg.client.domain missing in Configuration table");
-			}
-			String domain = openxg_client_domain.getConf_value();
-
-			// openxg_community_code
-			Configuration openxg_community_code = cfgManagement.getConfKey(3L,
-					"openxg.community.code");
-			if (openxg_community_code == null) {
-				throw new Exception(
-						"openxg.community.code missing in Configuration table");
-			}
-			String community_code = openxg_community_code.getConf_value();
-
-			// language_code
-			Configuration openxg_language_code = cfgManagement.getConfKey(3L,
-					"openxg.language.code");
-			if (openxg_language_code == null) {
-				throw new Exception(
-						"openxg.language.code missing in Configuration table");
-			}
-			String language_code = openxg_language_code.getConf_value();
-
-			// adminid
-			Configuration openxg_adminid = cfgManagement.getConfKey(3L,
-					"openxg.adminid");
-			if (openxg_adminid == null) {
-				throw new Exception(
-						"openxg.adminid missing in Configuration table");
-			}
-			String adminid = openxg_adminid.getConf_value();
-
-			// sip_language_phonecode, for example +358, is important as port of
-			// the
-			// number/login for the SIP-User via the applet
-			Configuration sip_language_phonecode = cfgManagement.getConfKey(3L,
-					"sip.language.phonecode");
-
-			if (sip_language_phonecode == null) {
-				throw new Exception(
-						"No sip.language.phonecode set in Configuration");
-			}
-
-			// Calculate the number in national format
-			Configuration sip_phonerange_start = cfgManagement.getConfKey(3L,
-					"sip.phonerange.start");
-			Configuration sip_phonerange = cfgManagement.getConfKey(3L,
-					"sip.phonerange");
-			Configuration sip_phonerange_currentindex = cfgManagement
-					.getConfKey(3L, "sip.phonerange.currentindex");
-			if (sip_phonerange_start == null || sip_phonerange == null
-					|| sip_phonerange_currentindex == null) {
-				throw new Exception(
-						"sip.phonerange.start, sip.phonerange or sip.phonerange.currentindex missing in Configuration table");
-			}
-
-			// Long sipPhoneRangeStart =
-			// Long.parseLong(sip_phonerange_start.getConf_value());
-			// Long sipPhoneRange =
-			// Long.parseLong(sip_phonerange.getConf_value());
-			// Long sipPhoneRangeCurrentIndex =
-			// Long.parseLong(sip_phonerange_currentindex.getConf_value());
-
-			// Not sure anymore if this is really needed, we don't need a number
-			// in national format
-			// if (sipPhoneRangeCurrentIndex >= sipPhoneRange) {
-			// throw new
-			// Exception("You have no more numbers, you need to allocate more numbers and alter the Configuration value sip.phonerange");
-			// }
-
-			// Long useridAsNumber = sipPhoneRangeStart +
-			// sipPhoneRangeCurrentIndex;
-			//
-			// log.debug("(sip_phonerange_start.getConf_value().length()) "+(sip_phonerange_start.getConf_value().length()+1));
-			//
-			// //The userid == the Number allocated in National Format!
-			// //The userid is calculated on the number of available numbers in
-			// the range
-			// String userid =
-			// String.format("%0"+(sip_phonerange_start.getConf_value().length())+"d",
-			// useridAsNumber);
-
-			String userid = login;
-
-			// sipPhoneRangeCurrentIndex++;
-			// sip_phonerange_currentindex.setConf_value(""+sipPhoneRangeCurrentIndex);
-
-			// cfgManagement.updateConfig(sip_phonerange_currentindex);
-
-			String digest = this.digest_calculate(new Object[] { client_id,
-					userid, domain, first_name, middle_i, last_name, password,
-					community_code, language_code, email, adminid,
-					client_secret });
-
-			// Get the XML-String representative
-			String stringToPost = OpenXGCustomXMLMarshall.getInstance()
-					.openSIPgUserCreate(client_id, digest, userid, domain,
-							first_name, middle_i, last_name, password,
-							community_code, language_code, email, adminid);
-
-			OpenXGReturnObject openXGReturnObject = this
-					.openSIPgPost(stringToPost);
-
-			openXGReturnObject.setMethodName("OpenSIPg.UserCreate");
-
-			openXGReturnObjectDao.addOpenXGReturnObject(
-					openXGReturnObject);
-
-			log.debug(" Status_code " + openXGReturnObject.getStatus_code());
-			log.debug(" Status_string " + openXGReturnObject.getStatus_string());
-
-			if (openXGReturnObject.getStatus_code().equals("200")) {
-
-				// Add User URI
-				String digestURI = this.digest_calculate(new Object[] {
-						client_id, userid, domain, adminid, client_secret });
-
-				// Get the XML-String representative
-				String stringToPostURI = OpenXGCustomXMLMarshall.getInstance()
-						.openSIPgURIUserIDAdd(client_id, digestURI, userid,
-								domain, adminid);
-
-				OpenXGReturnObject openXGReturnObjectURI = this
-						.openSIPgPost(stringToPostURI);
-
-				openXGReturnObjectURI.setMethodName("OpenSIPg.URIUserIDAdd");
-
-				openXGReturnObjectDao.addOpenXGReturnObject(
-						openXGReturnObjectURI);
-
-				log.debug(" openXGReturnObjectURI Status Code "
-						+ openXGReturnObjectURI.getStatus_code());
-				log.debug(" openXGReturnObjectURI Status String "
-						+ openXGReturnObjectURI.getStatus_string());
-
-				UserSipData userSipData = new UserSipData();
-
-				// userSipData.setUsername(sip_language_phonecode.getConf_value()
-				// + useridAsNumber);
-				userSipData.setUsername(userid);
-				userSipData.setUserpass(password);
-				userSipData.setAuthId(userid);
-
-				return userSipData;
-
-			} else {
-
-				throw new Exception(
-						"Could not add SIP User - Gateway response Error Code: "
-								+ openXGReturnObject.getStatus_code()
-								+ " Message: "
-								+ openXGReturnObject.getStatus_string());
-
-			}
-
-		} catch (Exception err) {
-
-			log.error("[openSIPgUserCreateTest]", err);
-
-		}
-
-		return null;
-	}
-
-	public OpenXGReturnObject openSIPgCreateConference() {
-		try {
-
-			// Check if the OpenXG Gateway is enabled in general
-			Configuration sip_openxg_enable = cfgManagement.getConfKey(3L,
-					"sip.openxg.enable");
-
-			if (sip_openxg_enable == null
-					|| !sip_openxg_enable.getConf_value().equals("yes")) {
-				log.debug("SIP is disabled");
-				return null;
-			}
-
-			// client_id and client_secret
-			Configuration openxg_client_id = cfgManagement.getConfKey(3L,
-					"openxg.client.id");
-			Configuration openxg_client_secret = cfgManagement.getConfKey(3L,
-					"openxg.client.secret");
-			if (openxg_client_id == null || openxg_client_secret == null) {
-				throw new Exception(
-						"openxg.client.id or openxg.client.secret missing in Configuration table");
-			}
-			String client_id = openxg_client_id.getConf_value();
-			String client_secret = openxg_client_secret.getConf_value();
-
-			// domain
-			Configuration openxg_client_domain = cfgManagement.getConfKey(3L,
-					"openxg.client.domain");
-			if (openxg_client_domain == null) {
-				throw new Exception(
-						"openxg.client.domain missing in Configuration table");
-			}
-			String domain = openxg_client_domain.getConf_value();
-
-			// language_code
-			Configuration openxg_language_code = cfgManagement.getConfKey(3L,
-					"openxg.language.code");
-			if (openxg_language_code == null) {
-				throw new Exception(
-						"openxg.language.code missing in Configuration table");
-			}
-			String language_code = openxg_language_code.getConf_value();
-
-			// adminid
-			Configuration openxg_adminid = cfgManagement.getConfKey(3L,
-					"openxg.adminid");
-			if (openxg_adminid == null) {
-				throw new Exception(
-						"openxg.adminid missing in Configuration table");
-			}
-			String adminid = openxg_adminid.getConf_value();
-
-			Date d = new Date();
-			long starttime = d.getTime() / 1000;
-
-			long endTime = (d.getTime() / 1000) + (60 * 60);
-
-			// "0", "2147483647",
-
-			// permanent conferences
-			starttime = 0;
-			endTime = 2147483647;
-
-			String digest = this.digest_calculate(new Object[] { client_id,
-					"067201101", domain, "" + starttime, "" + endTime,
-					language_code, adminid, client_secret });
-
-			Configuration openxg_wrapper_url = cfgManagement.getConfKey(3L,
-					"openxg.wrapper.url");
-
-			if (openxg_wrapper_url == null) {
-				throw new Exception(
-						"No openxg.wrapper.url set in Configuration");
-			}
-
-			String strURL = openxg_wrapper_url.getConf_value();
-
-			// Prepare HTTP post
-			PostMethod post = new PostMethod(strURL);
-			post.addRequestHeader("User-Agent", "OpenSIPg XML_RPC Client");
-
-			// Get the XML-String representative
-			String stringToPost = OpenXGCustomXMLMarshall.getInstance()
-					.openSIPgCreateConference(client_id, digest, "067201101",
-							domain, "" + starttime, "" + endTime,
-							language_code, adminid);
-
-			OpenXGReturnObject openXGReturnObject = this
-					.openSIPgPost(stringToPost);
-
-			openXGReturnObject.setMethodName("OpenSIPg.UserConferenceAdd");
-
-			openXGReturnObjectDao.addOpenXGReturnObject(
-					openXGReturnObject);
-
-			return openXGReturnObject;
-
-		} catch (Exception err) {
-
-			log.error("[openSIPgUserCreate]", err);
-
-		}
-
-		return null;
-	}
-
-	public OpenXGReturnObject openSIPgPost(String stringToPost) {
-		try {
-
-			Configuration openxg_wrapper_url = cfgManagement.getConfKey(3L,
-					"openxg.wrapper.url");
-
-			if (openxg_wrapper_url == null) {
-				throw new Exception(
-						"No openxg.wrapper.url set in Configuration");
-			}
-
-			String strURL = openxg_wrapper_url.getConf_value();
-
-			// Prepare HTTP post
-			PostMethod post = new PostMethod(strURL);
-			post.addRequestHeader("User-Agent", "OpenSIPg XML_RPC Client");
-
-			// log.debug(stringToPost);
-
-			RequestEntity entity = new ByteArrayRequestEntity(
-					stringToPost.getBytes(Charset.forName("ISO-8859-1")));
-
-			// Prepare HTTP post
-
-			post.getParams().setContentCharset("ISO-8859-1");
-			post.getParams().setVersion(HttpVersion.HTTP_1_0);
-
-			// Request content will be retrieved directly
-			// from the input stream
-			post.setRequestEntity(entity);
-
-			Protocol easyhttps = new Protocol("https",
-					(ProtocolSocketFactory) new EasySSLProtocolSocketFactory(),
-					443);
-			Protocol.registerProtocol("https", easyhttps);
-
-			// Get HTTP client
-			HttpClient httpclient = new HttpClient();
-
-			// Execute request
-			int result = httpclient.executeMethod(post);
-
-			// Display status code
-			log.debug("Response status code: " + result);
-
-			if (result == 200) {
-
-				log.debug("parseReturnBody " + post.getResponseBodyAsString());
-
-				OpenXGReturnObject oIG = this.parseOpenXGReturnBody(post
-						.getResponseBodyAsStream());
-
-				log.debug("oIG 1 " + oIG.getStatus_code());
-				log.debug("oIG 2 " + oIG.getStatus_string());
-
-				return oIG;
-
-			} else {
-
-				throw new Exception(
-						"Could not connect to OpenXG, check the URL for the Configuration");
-
-			}
-
-		} catch (Exception err) {
-
-			log.error("[openSIPgUserCreate]", err);
-
-		}
-
-		return null;
-	}
-
-	/**
-	 * 
-	 * @param inputStream
-	 * @return
-	 */
-	public OpenXGReturnObject parseOpenXGReturnBody(InputStream inputStream) {
-		try {
-
-			OpenXGReturnObject openXGReturnObject = new OpenXGReturnObject();
-
-			// log.debug("parseReturnBody "+inputStream);
-
-			DocumentBuilderFactory factory = DocumentBuilderFactory
-					.newInstance();
-			factory.setValidating(false);
-			factory.setNamespaceAware(false);
-
-			// get a builder to create a DOM document
-			DocumentBuilder builder = factory.newDocumentBuilder();
-
-			Document document = builder.parse(inputStream);
-
-			NodeList members = document.getElementsByTagName("member");
-
-			// log.debug("members LENGTH "+members.getLength());
-
-			for (int i = 0; i < members.getLength(); i++) {
-				Element member = (Element) members.item(i);
-
-				NodeList name = member.getElementsByTagName("name");
-
-				// log.debug("Name "+name.item(0).getNodeName());
-
-				Node nameTextNode = name.item(0).getFirstChild();
-
-				log.debug("getNodeValue " + nameTextNode.getNodeValue());
-
-				if (nameTextNode.getNodeValue().equals("status_code")) {
-
-					NodeList string = member.getElementsByTagName("string");
-
-					// log.debug("Value "+string.item(0).getNodeName());
-
-					Node valueTextNode = string.item(0).getFirstChild();
-
-					// log.debug("Value "+valueTextNode.getNodeValue());
-
-					openXGReturnObject.setStatus_code(valueTextNode
-							.getNodeValue());
-
-				} else if (nameTextNode.getNodeValue().equals("status_string")) {
-
-					NodeList string = member.getElementsByTagName("string");
-
-					// log.debug("Value "+string.item(0).getNodeName());
-
-					Node valueTextNode = string.item(0).getFirstChild();
-
-					// log.debug("Value "+valueTextNode.getNodeValue());
-
-					openXGReturnObject.setStatus_string(valueTextNode
-							.getNodeValue());
-
-				} else if (nameTextNode.getNodeValue().equals(
-						"conference_number")) {
-
-					NodeList string = member.getElementsByTagName("string");
-
-					// log.debug("Value "+string.item(0).getNodeName());
-
-					Node valueTextNode = string.item(0).getFirstChild();
-
-					// log.debug("Value "+valueTextNode.getNodeValue());
-
-					openXGReturnObject.setConferenceNumber(valueTextNode
-							.getNodeValue());
-
-				} else if (nameTextNode.getNodeValue().equals("conference_pin")) {
-
-					NodeList string = member.getElementsByTagName("string");
-
-					// log.debug("Value "+string.item(0).getNodeName());
-
-					Node valueTextNode = string.item(0).getFirstChild();
-
-					// log.debug("Value "+valueTextNode.getNodeValue());
-
-					openXGReturnObject.setConferencePin(valueTextNode
-							.getNodeValue());
-
-				}
-
-			}
-
-			return openXGReturnObject;
-
-		} catch (Exception err) {
-
-			log.error("[parseOpenXGReturnBody]", err);
-
-		}
-		return null;
-	}
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.openmeetings.app.sip.xmlrpc;
+
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.Date;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpVersion;
+import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+import org.apache.commons.httpclient.protocol.Protocol;
+import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
+import org.openmeetings.app.data.basic.Configurationmanagement;
+import org.openmeetings.app.persistence.beans.basic.Configuration;
+import org.openmeetings.app.persistence.beans.sip.OpenXGReturnObject;
+import org.openmeetings.app.persistence.beans.user.UserSipData;
+import org.openmeetings.app.remote.red5.ScopeApplicationAdapter;
+import org.openmeetings.app.sip.xmlrpc.custom.OpenXGCustomXMLMarshall;
+import org.openmeetings.app.sip.xmlrpc.custom.dao.OpenXGReturnObjectDaoImpl;
+import org.openmeetings.utils.crypt.MD5;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class OpenXGHttpClient {
+
+	private static final Logger log = Red5LoggerFactory.getLogger(
+			OpenXGHttpClient.class, ScopeApplicationAdapter.webAppRootKey);
+	@Autowired
+	private Configurationmanagement cfgManagement;
+	@Autowired
+	private OpenXGReturnObjectDaoImpl openXGReturnObjectDao;
+
+	public String digest_calculate(Object[] params) throws Exception {
+		String stringToMd5 = "";
+
+		for (int i = 0; i < params.length; i++) {
+			stringToMd5 += params[i];
+		}
+
+		return MD5.do_checksum(stringToMd5);
+
+	}
+
+	public void openSIPgUserCreateTest() {
+		try {
+
+			String first_name = "Matti";
+			String middle_i = "X";
+			String last_name = "Virtanen";
+			String email = "test@test.de";
+			String password = "password";
+
+			this.openSIPgUserCreateUser(first_name,
+					middle_i, last_name, email, password, "test");
+
+		} catch (Exception err) {
+
+			log.error("[openSIPgUserCreateTest]", err);
+
+		}
+	}
+
+	/**
+	 * 
+	 * Creates a SIP User using the RPC Methods of openXG
+	 * 
+	 * @param first_name
+	 * @param middle_i
+	 * @param last_name
+	 * @param email
+	 * @param password
+	 * @return
+	 */
+	public UserSipData openSIPgUserCreateUser(String first_name,
+			String middle_i, String last_name, String email, String login,
+			String password) {
+		try {
+
+			// Check if the OpenXG Gateway is enabled in general
+			Configuration sip_openxg_enable = cfgManagement.getConfKey(3L,
+					"sip.openxg.enable");
+
+			if (sip_openxg_enable == null
+					|| !sip_openxg_enable.getConf_value().equals("yes")) {
+				log.debug("SIP is disabled");
+				return null;
+			}
+
+			// client_id and client_secret
+			Configuration openxg_client_id = cfgManagement.getConfKey(3L,
+					"openxg.client.id");
+			Configuration openxg_client_secret = cfgManagement.getConfKey(3L,
+					"openxg.client.secret");
+			if (openxg_client_id == null || openxg_client_secret == null) {
+				throw new Exception(
+						"openxg.client.id or openxg.client.secret missing in Configuration table");
+			}
+			String client_id = openxg_client_id.getConf_value();
+			String client_secret = openxg_client_secret.getConf_value();
+
+			// domain
+			Configuration openxg_client_domain = cfgManagement.getConfKey(3L,
+					"openxg.client.domain");
+			if (openxg_client_domain == null) {
+				throw new Exception(
+						"openxg.client.domain missing in Configuration table");
+			}
+			String domain = openxg_client_domain.getConf_value();
+
+			// openxg_community_code
+			Configuration openxg_community_code = cfgManagement.getConfKey(3L,
+					"openxg.community.code");
+			if (openxg_community_code == null) {
+				throw new Exception(
+						"openxg.community.code missing in Configuration table");
+			}
+			String community_code = openxg_community_code.getConf_value();
+
+			// language_code
+			Configuration openxg_language_code = cfgManagement.getConfKey(3L,
+					"openxg.language.code");
+			if (openxg_language_code == null) {
+				throw new Exception(
+						"openxg.language.code missing in Configuration table");
+			}
+			String language_code = openxg_language_code.getConf_value();
+
+			// adminid
+			Configuration openxg_adminid = cfgManagement.getConfKey(3L,
+					"openxg.adminid");
+			if (openxg_adminid == null) {
+				throw new Exception(
+						"openxg.adminid missing in Configuration table");
+			}
+			String adminid = openxg_adminid.getConf_value();
+
+			// sip_language_phonecode, for example +358, is important as port of
+			// the
+			// number/login for the SIP-User via the applet
+			Configuration sip_language_phonecode = cfgManagement.getConfKey(3L,
+					"sip.language.phonecode");
+
+			if (sip_language_phonecode == null) {
+				throw new Exception(
+						"No sip.language.phonecode set in Configuration");
+			}
+
+			// Calculate the number in national format
+			Configuration sip_phonerange_start = cfgManagement.getConfKey(3L,
+					"sip.phonerange.start");
+			Configuration sip_phonerange = cfgManagement.getConfKey(3L,
+					"sip.phonerange");
+			Configuration sip_phonerange_currentindex = cfgManagement
+					.getConfKey(3L, "sip.phonerange.currentindex");
+			if (sip_phonerange_start == null || sip_phonerange == null
+					|| sip_phonerange_currentindex == null) {
+				throw new Exception(
+						"sip.phonerange.start, sip.phonerange or sip.phonerange.currentindex missing in Configuration table");
+			}
+
+			// Long sipPhoneRangeStart =
+			// Long.parseLong(sip_phonerange_start.getConf_value());
+			// Long sipPhoneRange =
+			// Long.parseLong(sip_phonerange.getConf_value());
+			// Long sipPhoneRangeCurrentIndex =
+			// Long.parseLong(sip_phonerange_currentindex.getConf_value());
+
+			// Not sure anymore if this is really needed, we don't need a number
+			// in national format
+			// if (sipPhoneRangeCurrentIndex >= sipPhoneRange) {
+			// throw new
+			// Exception("You have no more numbers, you need to allocate more numbers and alter the Configuration value sip.phonerange");
+			// }
+
+			// Long useridAsNumber = sipPhoneRangeStart +
+			// sipPhoneRangeCurrentIndex;
+			//
+			// log.debug("(sip_phonerange_start.getConf_value().length()) "+(sip_phonerange_start.getConf_value().length()+1));
+			//
+			// //The userid == the Number allocated in National Format!
+			// //The userid is calculated on the number of available numbers in
+			// the range
+			// String userid =
+			// String.format("%0"+(sip_phonerange_start.getConf_value().length())+"d",
+			// useridAsNumber);
+
+			String userid = login;
+
+			// sipPhoneRangeCurrentIndex++;
+			// sip_phonerange_currentindex.setConf_value(""+sipPhoneRangeCurrentIndex);
+
+			// cfgManagement.updateConfig(sip_phonerange_currentindex);
+
+			String digest = this.digest_calculate(new Object[] { client_id,
+					userid, domain, first_name, middle_i, last_name, password,
+					community_code, language_code, email, adminid,
+					client_secret });
+
+			// Get the XML-String representative
+			String stringToPost = OpenXGCustomXMLMarshall.getInstance()
+					.openSIPgUserCreate(client_id, digest, userid, domain,
+							first_name, middle_i, last_name, password,
+							community_code, language_code, email, adminid);
+
+			OpenXGReturnObject openXGReturnObject = this
+					.openSIPgPost(stringToPost);
+
+			openXGReturnObject.setMethodName("OpenSIPg.UserCreate");
+
+			openXGReturnObjectDao.addOpenXGReturnObject(
+					openXGReturnObject);
+
+			log.debug(" Status_code " + openXGReturnObject.getStatus_code());
+			log.debug(" Status_string " + openXGReturnObject.getStatus_string());
+
+			if (openXGReturnObject.getStatus_code().equals("200")) {
+
+				// Add User URI
+				String digestURI = this.digest_calculate(new Object[] {
+						client_id, userid, domain, adminid, client_secret });
+
+				// Get the XML-String representative
+				String stringToPostURI = OpenXGCustomXMLMarshall.getInstance()
+						.openSIPgURIUserIDAdd(client_id, digestURI, userid,
+								domain, adminid);
+
+				OpenXGReturnObject openXGReturnObjectURI = this
+						.openSIPgPost(stringToPostURI);
+
+				openXGReturnObjectURI.setMethodName("OpenSIPg.URIUserIDAdd");
+
+				openXGReturnObjectDao.addOpenXGReturnObject(
+						openXGReturnObjectURI);
+
+				log.debug(" openXGReturnObjectURI Status Code "
+						+ openXGReturnObjectURI.getStatus_code());
+				log.debug(" openXGReturnObjectURI Status String "
+						+ openXGReturnObjectURI.getStatus_string());
+
+				UserSipData userSipData = new UserSipData();
+
+				// userSipData.setUsername(sip_language_phonecode.getConf_value()
+				// + useridAsNumber);
+				userSipData.setUsername(userid);
+				userSipData.setUserpass(password);
+				userSipData.setAuthId(userid);
+
+				return userSipData;
+
+			} else {
+
+				throw new Exception(
+						"Could not add SIP User - Gateway response Error Code: "
+								+ openXGReturnObject.getStatus_code()
+								+ " Message: "
+								+ openXGReturnObject.getStatus_string());
+
+			}
+
+		} catch (Exception err) {
+
+			log.error("[openSIPgUserCreateTest]", err);
+
+		}
+
+		return null;
+	}
+
+	public OpenXGReturnObject openSIPgCreateConference() {
+		try {
+
+			// Check if the OpenXG Gateway is enabled in general
+			Configuration sip_openxg_enable = cfgManagement.getConfKey(3L,
+					"sip.openxg.enable");
+
+			if (sip_openxg_enable == null
+					|| !sip_openxg_enable.getConf_value().equals("yes")) {
+				log.debug("SIP is disabled");
+				return null;
+			}
+
+			// client_id and client_secret
+			Configuration openxg_client_id = cfgManagement.getConfKey(3L,
+					"openxg.client.id");
+			Configuration openxg_client_secret = cfgManagement.getConfKey(3L,
+					"openxg.client.secret");
+			if (openxg_client_id == null || openxg_client_secret == null) {
+				throw new Exception(
+						"openxg.client.id or openxg.client.secret missing in Configuration table");
+			}
+			String client_id = openxg_client_id.getConf_value();
+			String client_secret = openxg_client_secret.getConf_value();
+
+			// domain
+			Configuration openxg_client_domain = cfgManagement.getConfKey(3L,
+					"openxg.client.domain");
+			if (openxg_client_domain == null) {
+				throw new Exception(
+						"openxg.client.domain missing in Configuration table");
+			}
+			String domain = openxg_client_domain.getConf_value();
+
+			// language_code
+			Configuration openxg_language_code = cfgManagement.getConfKey(3L,
+					"openxg.language.code");
+			if (openxg_language_code == null) {
+				throw new Exception(
+						"openxg.language.code missing in Configuration table");
+			}
+			String language_code = openxg_language_code.getConf_value();
+
+			// adminid
+			Configuration openxg_adminid = cfgManagement.getConfKey(3L,
+					"openxg.adminid");
+			if (openxg_adminid == null) {
+				throw new Exception(
+						"openxg.adminid missing in Configuration table");
+			}
+			String adminid = openxg_adminid.getConf_value();
+
+			Date d = new Date();
+			long starttime = d.getTime() / 1000;
+
+			long endTime = (d.getTime() / 1000) + (60 * 60);
+
+			// "0", "2147483647",
+
+			// permanent conferences
+			starttime = 0;
+			endTime = 2147483647;
+
+			String digest = this.digest_calculate(new Object[] { client_id,
+					"067201101", domain, "" + starttime, "" + endTime,
+					language_code, adminid, client_secret });
+
+			Configuration openxg_wrapper_url = cfgManagement.getConfKey(3L,
+					"openxg.wrapper.url");
+
+			if (openxg_wrapper_url == null) {
+				throw new Exception(
+						"No openxg.wrapper.url set in Configuration");
+			}
+
+			String strURL = openxg_wrapper_url.getConf_value();
+
+			// Prepare HTTP post
+			PostMethod post = new PostMethod(strURL);
+			post.addRequestHeader("User-Agent", "OpenSIPg XML_RPC Client");
+
+			// Get the XML-String representative
+			String stringToPost = OpenXGCustomXMLMarshall.getInstance()
+					.openSIPgCreateConference(client_id, digest, "067201101",
+							domain, "" + starttime, "" + endTime,
+							language_code, adminid);
+
+			OpenXGReturnObject openXGReturnObject = this
+					.openSIPgPost(stringToPost);
+
+			openXGReturnObject.setMethodName("OpenSIPg.UserConferenceAdd");
+
+			openXGReturnObjectDao.addOpenXGReturnObject(
+					openXGReturnObject);
+
+			return openXGReturnObject;
+
+		} catch (Exception err) {
+
+			log.error("[openSIPgUserCreate]", err);
+
+		}
+
+		return null;
+	}
+
+	public OpenXGReturnObject openSIPgPost(String stringToPost) {
+		try {
+
+			Configuration openxg_wrapper_url = cfgManagement.getConfKey(3L,
+					"openxg.wrapper.url");
+
+			if (openxg_wrapper_url == null) {
+				throw new Exception(
+						"No openxg.wrapper.url set in Configuration");
+			}
+
+			String strURL = openxg_wrapper_url.getConf_value();
+
+			// Prepare HTTP post
+			PostMethod post = new PostMethod(strURL);
+			post.addRequestHeader("User-Agent", "OpenSIPg XML_RPC Client");
+
+			// log.debug(stringToPost);
+
+			RequestEntity entity = new ByteArrayRequestEntity(
+					stringToPost.getBytes(Charset.forName("ISO-8859-1")));
+
+			// Prepare HTTP post
+
+			post.getParams().setContentCharset("ISO-8859-1");
+			post.getParams().setVersion(HttpVersion.HTTP_1_0);
+
+			// Request content will be retrieved directly
+			// from the input stream
+			post.setRequestEntity(entity);
+
+			Protocol easyhttps = new Protocol("https",
+					(ProtocolSocketFactory) new EasySSLProtocolSocketFactory(),
+					443);
+			Protocol.registerProtocol("https", easyhttps);
+
+			// Get HTTP client
+			HttpClient httpclient = new HttpClient();
+
+			// Execute request
+			int result = httpclient.executeMethod(post);
+
+			// Display status code
+			log.debug("Response status code: " + result);
+
+			if (result == 200) {
+
+				log.debug("parseReturnBody " + post.getResponseBodyAsString());
+
+				OpenXGReturnObject oIG = this.parseOpenXGReturnBody(post
+						.getResponseBodyAsStream());
+
+				log.debug("oIG 1 " + oIG.getStatus_code());
+				log.debug("oIG 2 " + oIG.getStatus_string());
+
+				return oIG;
+
+			} else {
+
+				throw new Exception(
+						"Could not connect to OpenXG, check the URL for the Configuration");
+
+			}
+
+		} catch (Exception err) {
+
+			log.error("[openSIPgUserCreate]", err);
+
+		}
+
+		return null;
+	}
+
+	/**
+	 * 
+	 * @param inputStream
+	 * @return
+	 */
+	public OpenXGReturnObject parseOpenXGReturnBody(InputStream inputStream) {
+		try {
+
+			OpenXGReturnObject openXGReturnObject = new OpenXGReturnObject();
+
+			// log.debug("parseReturnBody "+inputStream);
+
+			DocumentBuilderFactory factory = DocumentBuilderFactory
+					.newInstance();
+			factory.setValidating(false);
+			factory.setNamespaceAware(false);
+
+			// get a builder to create a DOM document
+			DocumentBuilder builder = factory.newDocumentBuilder();
+
+			Document document = builder.parse(inputStream);
+
+			NodeList members = document.getElementsByTagName("member");
+
+			// log.debug("members LENGTH "+members.getLength());
+
+			for (int i = 0; i < members.getLength(); i++) {
+				Element member = (Element) members.item(i);
+
+				NodeList name = member.getElementsByTagName("name");
+
+				// log.debug("Name "+name.item(0).getNodeName());
+
+				Node nameTextNode = name.item(0).getFirstChild();
+
+				log.debug("getNodeValue " + nameTextNode.getNodeValue());
+
+				if (nameTextNode.getNodeValue().equals("status_code")) {
+
+					NodeList string = member.getElementsByTagName("string");
+
+					// log.debug("Value "+string.item(0).getNodeName());
+
+					Node valueTextNode = string.item(0).getFirstChild();
+
+					// log.debug("Value "+valueTextNode.getNodeValue());
+
+					openXGReturnObject.setStatus_code(valueTextNode
+							.getNodeValue());
+
+				} else if (nameTextNode.getNodeValue().equals("status_string")) {
+
+					NodeList string = member.getElementsByTagName("string");
+
+					// log.debug("Value "+string.item(0).getNodeName());
+
+					Node valueTextNode = string.item(0).getFirstChild();
+
+					// log.debug("Value "+valueTextNode.getNodeValue());
+
+					openXGReturnObject.setStatus_string(valueTextNode
+							.getNodeValue());
+
+				} else if (nameTextNode.getNodeValue().equals(
+						"conference_number")) {
+
+					NodeList string = member.getElementsByTagName("string");
+
+					// log.debug("Value "+string.item(0).getNodeName());
+
+					Node valueTextNode = string.item(0).getFirstChild();
+
+					// log.debug("Value "+valueTextNode.getNodeValue());
+
+					openXGReturnObject.setConferenceNumber(valueTextNode
+							.getNodeValue());
+
+				} else if (nameTextNode.getNodeValue().equals("conference_pin")) {
+
+					NodeList string = member.getElementsByTagName("string");
+
+					// log.debug("Value "+string.item(0).getNodeName());
+
+					Node valueTextNode = string.item(0).getFirstChild();
+
+					// log.debug("Value "+valueTextNode.getNodeValue());
+
+					openXGReturnObject.setConferencePin(valueTextNode
+							.getNodeValue());
+
+				}
+
+			}
+
+			return openXGReturnObject;
+
+		} catch (Exception err) {
+
+			log.error("[parseOpenXGReturnBody]", err);
+
+		}
+		return null;
+	}
+
+}

Modified: incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/custom/OpenXGCustomXMLMarshall.java
URL: http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/custom/OpenXGCustomXMLMarshall.java?rev=1235400&r1=1235399&r2=1235400&view=diff
==============================================================================
--- incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/custom/OpenXGCustomXMLMarshall.java (original)
+++ incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/custom/OpenXGCustomXMLMarshall.java Tue Jan 24 18:30:48 2012
@@ -1,250 +1,268 @@
-package org.openmeetings.app.sip.xmlrpc.custom;
-
-import org.openmeetings.app.remote.red5.ScopeApplicationAdapter;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-
-/**
- * 
- * @author swagner
- *
- * This class takes a Bean and marshalls it into XML the way OpenXG wants it
- *
- */
-public class OpenXGCustomXMLMarshall {
-	
-	private static final Logger log = Red5LoggerFactory.getLogger(OpenXGCustomXMLMarshall.class, ScopeApplicationAdapter.webAppRootKey);
-
-	private static OpenXGCustomXMLMarshall instance = null;
-
-	public static synchronized OpenXGCustomXMLMarshall getInstance() {
-		if (instance == null) {
-			log.debug("instance created");
-			instance = new OpenXGCustomXMLMarshall();
-		}
-		return instance;
-	}
-	
-	public String openSIPgUserCreate(String client_id, String digest, String userid, String domain, 
-			String first_name, String middle_i, String last_name, String password, String community_code, 
-			String language_code, String email, String adminid) {
-		
-		String stringToPost = "<?xml version=\"1.0\" ?>"+ 
-								"<methodCall>"+ 
-								"	<methodName>OpenSIPg.UserCreate</methodName>"+ 
-								"	<params>"+ 
-								"		<param>"+ 
-								"			<value>"+ 
-								"				<struct>"+ 
-								"					<member>"+ 
-								"						<name>client_id</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ client_id +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>digest</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ digest +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>userid</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ userid +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>domain</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ domain +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>first_name</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ first_name +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>middle_i</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ middle_i +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>last_name</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ last_name +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>password</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ password +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>community_code</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ community_code +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>language_code</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ language_code +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>email</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ email +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>adminid</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ adminid +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"				</struct>"+ 
-								"			</value>"+ 
-								"		</param>"+ 
-								"	</params>"+ 
-								"</methodCall>";
-		
-		return stringToPost;
-	}
-	
-	public String openSIPgURIUserIDAdd(String client_id, String digest, 
-			String userid, String domain, 
-			String adminid) {
-		
-//		  $params = array(client_id=>$client_id, digest=>$digest, userid=>$userid,
-//				  domain=>$domain, adminid=>$adminid);
-		
-		String stringToPost = "<?xml version=\"1.0\" ?>"+ 
-								"<methodCall>"+ 
-								"	<methodName>OpenSIPg.URIUserIDAdd</methodName>"+ 
-								"	<params>"+ 
-								"		<param>"+ 
-								"			<value>"+ 
-								"				<struct>"+ 
-								"					<member>"+ 
-								"						<name>client_id</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ client_id +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>digest</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ digest +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>userid</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ userid +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>domain</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ domain +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>adminid</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ adminid +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"				</struct>"+ 
-								"			</value>"+ 
-								"		</param>"+ 
-								"	</params>"+ 
-								"</methodCall>";
-		
-		return stringToPost;								
-		
-	}
-	
-	
-	public String openSIPgCreateConference(String client_id, String digest, 
-							String userid, String domain, 
-							String start_stamp, String stop_stamp, 
-							String language_code, String adminid) {
-		
-		
-//		$params = array(client_id=>$client_id, digest=>$digest, userid=>$userid,
-//				  domain=>$domain, start_stamp=>$start_stamp,
-//				  stop_stamp=>$stop_stamp, language_code=>$language_code,
-//				  adminid=>$adminid);
-		
-		String stringToPost = "<?xml version=\"1.0\" ?>"+ 
-								"<methodCall>"+ 
-								"	<methodName>OpenSIPg.UserConferenceAdd</methodName>"+ 
-								"	<params>"+ 
-								"		<param>"+ 
-								"			<value>"+ 
-								"				<struct>"+ 
-								"					<member>"+ 
-								"						<name>client_id</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ client_id +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>digest</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ digest +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>userid</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ userid +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>domain</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ domain +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>start_stamp</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ start_stamp +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>stop_stamp</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ stop_stamp +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>language_code</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ language_code +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"					<member>"+ 
-								"						<name>adminid</name>"+ 
-								"						<value>"+ 
-								"							<string>"+ adminid +"</string>"+ 
-								"						</value>"+ 
-								"					</member>"+ 
-								"				</struct>"+ 
-								"			</value>"+ 
-								"		</param>"+ 
-								"	</params>"+ 
-								"</methodCall>";
-		
-		return stringToPost;
-	}
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.openmeetings.app.sip.xmlrpc.custom;
+
+import org.openmeetings.app.remote.red5.ScopeApplicationAdapter;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+
+/**
+ * 
+ * @author swagner
+ *
+ * This class takes a Bean and marshalls it into XML the way OpenXG wants it
+ *
+ */
+public class OpenXGCustomXMLMarshall {
+	
+	private static final Logger log = Red5LoggerFactory.getLogger(OpenXGCustomXMLMarshall.class, ScopeApplicationAdapter.webAppRootKey);
+
+	private static OpenXGCustomXMLMarshall instance = null;
+
+	public static synchronized OpenXGCustomXMLMarshall getInstance() {
+		if (instance == null) {
+			log.debug("instance created");
+			instance = new OpenXGCustomXMLMarshall();
+		}
+		return instance;
+	}
+	
+	public String openSIPgUserCreate(String client_id, String digest, String userid, String domain, 
+			String first_name, String middle_i, String last_name, String password, String community_code, 
+			String language_code, String email, String adminid) {
+		
+		String stringToPost = "<?xml version=\"1.0\" ?>"+ 
+								"<methodCall>"+ 
+								"	<methodName>OpenSIPg.UserCreate</methodName>"+ 
+								"	<params>"+ 
+								"		<param>"+ 
+								"			<value>"+ 
+								"				<struct>"+ 
+								"					<member>"+ 
+								"						<name>client_id</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ client_id +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>digest</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ digest +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>userid</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ userid +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>domain</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ domain +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>first_name</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ first_name +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>middle_i</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ middle_i +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>last_name</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ last_name +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>password</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ password +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>community_code</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ community_code +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>language_code</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ language_code +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>email</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ email +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>adminid</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ adminid +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"				</struct>"+ 
+								"			</value>"+ 
+								"		</param>"+ 
+								"	</params>"+ 
+								"</methodCall>";
+		
+		return stringToPost;
+	}
+	
+	public String openSIPgURIUserIDAdd(String client_id, String digest, 
+			String userid, String domain, 
+			String adminid) {
+		
+//		  $params = array(client_id=>$client_id, digest=>$digest, userid=>$userid,
+//				  domain=>$domain, adminid=>$adminid);
+		
+		String stringToPost = "<?xml version=\"1.0\" ?>"+ 
+								"<methodCall>"+ 
+								"	<methodName>OpenSIPg.URIUserIDAdd</methodName>"+ 
+								"	<params>"+ 
+								"		<param>"+ 
+								"			<value>"+ 
+								"				<struct>"+ 
+								"					<member>"+ 
+								"						<name>client_id</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ client_id +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>digest</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ digest +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>userid</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ userid +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>domain</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ domain +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>adminid</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ adminid +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"				</struct>"+ 
+								"			</value>"+ 
+								"		</param>"+ 
+								"	</params>"+ 
+								"</methodCall>";
+		
+		return stringToPost;								
+		
+	}
+	
+	
+	public String openSIPgCreateConference(String client_id, String digest, 
+							String userid, String domain, 
+							String start_stamp, String stop_stamp, 
+							String language_code, String adminid) {
+		
+		
+//		$params = array(client_id=>$client_id, digest=>$digest, userid=>$userid,
+//				  domain=>$domain, start_stamp=>$start_stamp,
+//				  stop_stamp=>$stop_stamp, language_code=>$language_code,
+//				  adminid=>$adminid);
+		
+		String stringToPost = "<?xml version=\"1.0\" ?>"+ 
+								"<methodCall>"+ 
+								"	<methodName>OpenSIPg.UserConferenceAdd</methodName>"+ 
+								"	<params>"+ 
+								"		<param>"+ 
+								"			<value>"+ 
+								"				<struct>"+ 
+								"					<member>"+ 
+								"						<name>client_id</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ client_id +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>digest</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ digest +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>userid</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ userid +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>domain</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ domain +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>start_stamp</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ start_stamp +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>stop_stamp</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ stop_stamp +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>language_code</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ language_code +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"					<member>"+ 
+								"						<name>adminid</name>"+ 
+								"						<value>"+ 
+								"							<string>"+ adminid +"</string>"+ 
+								"						</value>"+ 
+								"					</member>"+ 
+								"				</struct>"+ 
+								"			</value>"+ 
+								"		</param>"+ 
+								"	</params>"+ 
+								"</methodCall>";
+		
+		return stringToPost;
+	}
+
+}

Modified: incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/custom/OpenXGResponseParser.java
URL: http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/custom/OpenXGResponseParser.java?rev=1235400&r1=1235399&r2=1235400&view=diff
==============================================================================
--- incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/custom/OpenXGResponseParser.java (original)
+++ incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/custom/OpenXGResponseParser.java Tue Jan 24 18:30:48 2012
@@ -1,9 +1,27 @@
-package org.openmeetings.app.sip.xmlrpc.custom;
-
-import org.apache.xerces.parsers.SAXParser;
-
-public class OpenXGResponseParser extends SAXParser {
-
-	
-	
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.openmeetings.app.sip.xmlrpc.custom;
+
+import org.apache.xerces.parsers.SAXParser;
+
+public class OpenXGResponseParser extends SAXParser {
+
+	
+	
+}

Modified: incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/custom/dao/OpenXGReturnObjectDaoImpl.java
URL: http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/custom/dao/OpenXGReturnObjectDaoImpl.java?rev=1235400&r1=1235399&r2=1235400&view=diff
==============================================================================
--- incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/custom/dao/OpenXGReturnObjectDaoImpl.java (original)
+++ incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/custom/dao/OpenXGReturnObjectDaoImpl.java Tue Jan 24 18:30:48 2012
@@ -1,32 +1,50 @@
-package org.openmeetings.app.sip.xmlrpc.custom.dao;
-
-import java.util.Date;
-
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-
-import org.openmeetings.app.persistence.beans.sip.OpenXGReturnObject;
-import org.openmeetings.app.remote.red5.ScopeApplicationAdapter;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.springframework.transaction.annotation.Transactional;
-
-@Transactional
-public class OpenXGReturnObjectDaoImpl {
-
-	private static final Logger log = Red5LoggerFactory.getLogger(OpenXGReturnObjectDaoImpl.class, ScopeApplicationAdapter.webAppRootKey);
-	@PersistenceContext
-	private EntityManager em;
-	
-	public String addOpenXGReturnObject(OpenXGReturnObject openXGReturnObject) {
-	try {
-		
-		openXGReturnObject.setInserted(new Date());
-		
-		em.merge(openXGReturnObject);
-	} catch (Exception ex2) {
-		log.error("[addOpenXGReturnObject]: ",ex2);
-	}
-	return null;
-}
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.openmeetings.app.sip.xmlrpc.custom.dao;
+
+import java.util.Date;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.openmeetings.app.persistence.beans.sip.OpenXGReturnObject;
+import org.openmeetings.app.remote.red5.ScopeApplicationAdapter;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+public class OpenXGReturnObjectDaoImpl {
+
+	private static final Logger log = Red5LoggerFactory.getLogger(OpenXGReturnObjectDaoImpl.class, ScopeApplicationAdapter.webAppRootKey);
+	@PersistenceContext
+	private EntityManager em;
+	
+	public String addOpenXGReturnObject(OpenXGReturnObject openXGReturnObject) {
+	try {
+		
+		openXGReturnObject.setInserted(new Date());
+		
+		em.merge(openXGReturnObject);
+	} catch (Exception ex2) {
+		log.error("[addOpenXGReturnObject]: ",ex2);
+	}
+	return null;
+}
+}

Modified: incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/test/OpenXGClient.java
URL: http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/test/OpenXGClient.java?rev=1235400&r1=1235399&r2=1235400&view=diff
==============================================================================
--- incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/test/OpenXGClient.java (original)
+++ incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/test/OpenXGClient.java Tue Jan 24 18:30:48 2012
@@ -1,162 +1,180 @@
-package org.openmeetings.app.sip.xmlrpc.test;
-
-import java.net.URL;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.xmlrpc.client.XmlRpcClient;
-import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
-import org.openmeetings.app.remote.red5.ScopeApplicationAdapter;
-import org.openmeetings.app.sip.xmlrpc.OpenXGHttpClient;
-import org.openmeetings.utils.crypt.MD5;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-
-public class OpenXGClient {
-
-	private static final Logger log = Red5LoggerFactory.getLogger(
-			OpenXGHttpClient.class, ScopeApplicationAdapter.webAppRootKey);
-
-	private static OpenXGClient instance = null;
-
-	public static synchronized OpenXGClient getInstance() {
-		if (instance == null) {
-			instance = new OpenXGClient();
-		}
-		return instance;
-	}
-
-	public void testConnection() {
-		try {
-
-			log.debug("Test Connection");
-
-			// // Create a trust manager that does not validate certificate
-			// chains
-			// TrustManager[] trustAllCerts = new TrustManager[] {
-			// new X509TrustManager() {
-			// public X509Certificate[] getAcceptedIssuers() {
-			// return null;
-			// }
-			//
-			// public void checkClientTrusted(X509Certificate[] certs, String
-			// authType) {
-			// // Trust always
-			// }
-			//
-			// public void checkServerTrusted(X509Certificate[] certs, String
-			// authType) {
-			// // Trust always
-			// }
-			// }
-			// };
-			//
-			// // Install the all-trusting trust manager
-			// SSLContext sc = SSLContext.getInstance("SSL");
-			// // Create empty HostnameVerifier
-			// HostnameVerifier hv = new HostnameVerifier() {
-			// public boolean verify(String arg0, SSLSession arg1) {
-			// return true;
-			// }
-			// };
-			//
-			// sc.init(null, trustAllCerts, new java.security.SecureRandom());
-			// HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
-			// HttpsURLConnection.setDefaultHostnameVerifier(hv);
-			//
-			XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
-			//
-			// log.debug("config User Agent "+config.getUserAgent());
-
-			// XmlRpc.setDriver(uk.co.wilson.xml.MinML);
-			// //XmlRpc.setDriver(driver)
-			// uk.co.wilson.xml.MinML.xmlinfo = true;
-			//
-
-			config.setUserAgent("OpenSIPg XML_RPC Client");
-			config.setEncoding("ISO-8859-1");
-
-			config.setGzipCompressing(false);
-
-			config.setServerURL(new URL(
-					"http://85.134.48.179/manager/xml_rpc_server.php"));
-			XmlRpcClient client = new XmlRpcClient();
-
-			client.setConfig(config);
-
-			client.setXmlWriterFactory(new OpenXGXmlWriterFactory());
-
-			String client_id = "user_admin";
-			String client_secret = "******";
-
-			String userid = "067201101";
-			String domain = "voipt3.multi.fi";
-			String first_name = "Matti";
-			String middle_i = "X";
-			String last_name = "Virtanen";
-			String password = "password";
-			String community_code = "999";
-			String language_code = "fi";
-			String email = "matti@sucks.com";
-			String adminid = "matti";
-
-			String digest = this.digest_calculate(new Object[] { client_id,
-					userid, domain, first_name, middle_i, last_name, password,
-					community_code, language_code, email, adminid,
-					client_secret });
-
-			// $digest = digest_calculate($client_id, $userid, $domain,
-			// $adminid, $client_secret);
-			// $params = array(client_id=>$client_id, digest=>$digest,
-			// userid=>$userid,
-			// domain=>$domain, adminid=>$adminid);
-
-			log.debug(digest);
-
-			// function user_info($userid, $domain, $adminid, &$error)
-			Object[] params = new Object[] { client_id, digest, userid, domain,
-					first_name, middle_i, last_name, password, community_code,
-					language_code, email, adminid };
-
-			// Object[] struct = new Object[]{params};
-
-			Object result = client.execute("OpenSIPg.UserCreate", params);
-
-			if (result != null) {
-				log.debug(result.getClass().getName());
-
-				if (result instanceof Map) {
-
-					@SuppressWarnings("rawtypes")
-					Map mapResults = (Map) result;
-
-					for (@SuppressWarnings("rawtypes")
-					Iterator iter = mapResults.keySet().iterator(); iter
-							.hasNext();) {
-
-						Object key = iter.next();
-						log.debug("-- key " + key + " value "
-								+ mapResults.get(key));
-
-					}
-
-				}
-			}
-
-		} catch (Exception err) {
-			log.error("[testConnection]", err);
-		}
-	}
-
-	public String digest_calculate(Object[] params) throws Exception {
-		String stringToMd5 = "";
-
-		for (int i = 0; i < params.length; i++) {
-			stringToMd5 += params[i];
-		}
-
-		return MD5.do_checksum(stringToMd5);
-
-	}
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.openmeetings.app.sip.xmlrpc.test;
+
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.xmlrpc.client.XmlRpcClient;
+import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
+import org.openmeetings.app.remote.red5.ScopeApplicationAdapter;
+import org.openmeetings.app.sip.xmlrpc.OpenXGHttpClient;
+import org.openmeetings.utils.crypt.MD5;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+
+public class OpenXGClient {
+
+	private static final Logger log = Red5LoggerFactory.getLogger(
+			OpenXGHttpClient.class, ScopeApplicationAdapter.webAppRootKey);
+
+	private static OpenXGClient instance = null;
+
+	public static synchronized OpenXGClient getInstance() {
+		if (instance == null) {
+			instance = new OpenXGClient();
+		}
+		return instance;
+	}
+
+	public void testConnection() {
+		try {
+
+			log.debug("Test Connection");
+
+			// // Create a trust manager that does not validate certificate
+			// chains
+			// TrustManager[] trustAllCerts = new TrustManager[] {
+			// new X509TrustManager() {
+			// public X509Certificate[] getAcceptedIssuers() {
+			// return null;
+			// }
+			//
+			// public void checkClientTrusted(X509Certificate[] certs, String
+			// authType) {
+			// // Trust always
+			// }
+			//
+			// public void checkServerTrusted(X509Certificate[] certs, String
+			// authType) {
+			// // Trust always
+			// }
+			// }
+			// };
+			//
+			// // Install the all-trusting trust manager
+			// SSLContext sc = SSLContext.getInstance("SSL");
+			// // Create empty HostnameVerifier
+			// HostnameVerifier hv = new HostnameVerifier() {
+			// public boolean verify(String arg0, SSLSession arg1) {
+			// return true;
+			// }
+			// };
+			//
+			// sc.init(null, trustAllCerts, new java.security.SecureRandom());
+			// HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
+			// HttpsURLConnection.setDefaultHostnameVerifier(hv);
+			//
+			XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
+			//
+			// log.debug("config User Agent "+config.getUserAgent());
+
+			// XmlRpc.setDriver(uk.co.wilson.xml.MinML);
+			// //XmlRpc.setDriver(driver)
+			// uk.co.wilson.xml.MinML.xmlinfo = true;
+			//
+
+			config.setUserAgent("OpenSIPg XML_RPC Client");
+			config.setEncoding("ISO-8859-1");
+
+			config.setGzipCompressing(false);
+
+			config.setServerURL(new URL(
+					"http://85.134.48.179/manager/xml_rpc_server.php"));
+			XmlRpcClient client = new XmlRpcClient();
+
+			client.setConfig(config);
+
+			client.setXmlWriterFactory(new OpenXGXmlWriterFactory());
+
+			String client_id = "user_admin";
+			String client_secret = "******";
+
+			String userid = "067201101";
+			String domain = "voipt3.multi.fi";
+			String first_name = "Matti";
+			String middle_i = "X";
+			String last_name = "Virtanen";
+			String password = "password";
+			String community_code = "999";
+			String language_code = "fi";
+			String email = "matti@sucks.com";
+			String adminid = "matti";
+
+			String digest = this.digest_calculate(new Object[] { client_id,
+					userid, domain, first_name, middle_i, last_name, password,
+					community_code, language_code, email, adminid,
+					client_secret });
+
+			// $digest = digest_calculate($client_id, $userid, $domain,
+			// $adminid, $client_secret);
+			// $params = array(client_id=>$client_id, digest=>$digest,
+			// userid=>$userid,
+			// domain=>$domain, adminid=>$adminid);
+
+			log.debug(digest);
+
+			// function user_info($userid, $domain, $adminid, &$error)
+			Object[] params = new Object[] { client_id, digest, userid, domain,
+					first_name, middle_i, last_name, password, community_code,
+					language_code, email, adminid };
+
+			// Object[] struct = new Object[]{params};
+
+			Object result = client.execute("OpenSIPg.UserCreate", params);
+
+			if (result != null) {
+				log.debug(result.getClass().getName());
+
+				if (result instanceof Map) {
+
+					@SuppressWarnings("rawtypes")
+					Map mapResults = (Map) result;
+
+					for (@SuppressWarnings("rawtypes")
+					Iterator iter = mapResults.keySet().iterator(); iter
+							.hasNext();) {
+
+						Object key = iter.next();
+						log.debug("-- key " + key + " value "
+								+ mapResults.get(key));
+
+					}
+
+				}
+			}
+
+		} catch (Exception err) {
+			log.error("[testConnection]", err);
+		}
+	}
+
+	public String digest_calculate(Object[] params) throws Exception {
+		String stringToMd5 = "";
+
+		for (int i = 0; i < params.length; i++) {
+			stringToMd5 += params[i];
+		}
+
+		return MD5.do_checksum(stringToMd5);
+
+	}
+
+}

Modified: incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/test/OpenXGWrapperClient.java
URL: http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/test/OpenXGWrapperClient.java?rev=1235400&r1=1235399&r2=1235400&view=diff
==============================================================================
--- incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/test/OpenXGWrapperClient.java (original)
+++ incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/test/OpenXGWrapperClient.java Tue Jan 24 18:30:48 2012
@@ -1,110 +1,128 @@
-package org.openmeetings.app.sip.xmlrpc.test;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.openmeetings.app.remote.red5.ScopeApplicationAdapter;
-import org.openmeetings.utils.crypt.MD5;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-
-
-public class OpenXGWrapperClient {
-	
-	private static final Logger log = Red5LoggerFactory.getLogger(OpenXGWrapperClient.class, ScopeApplicationAdapter.webAppRootKey);
-
-	private static OpenXGWrapperClient instance = null;
-
-	public static synchronized OpenXGWrapperClient getInstance() {
-		if (instance == null) {
-			instance = new OpenXGWrapperClient();
-		}
-		return instance;
-	}
-	
-	/**
-	 * Only for Testing
-	 */
-	public void testConnection() {
-		
-		String userid = "****";
-		String domain = "****";
-		String first_name = "****";
-		String middle_i = "****";
-		String last_name = "****";
-		String password = "****";
-		String community_code = "****";
-		String language_code = "****";
-		String email = "****";
-		String adminid = "****";
-		
-		String client_id = "****";
-		String client_secret = "*****";
-		
-		this.createUser(client_id, client_secret, userid, domain, first_name, middle_i, 
-					last_name, password, community_code, 
-					language_code, email, adminid);
-	}
-	
-	public void createUser(String client_id, String client_secret, 
-			String userid, String domain, String first_name, String middle_i,  
-			String last_name, String password, String community_code, 
-			String language_code, String email, String adminid
-			) {
-		try {
-			
-			log.debug("Test Connection");
-			
-			// Get target URL
-	        String strURL = "http://127.0.0.1:5080/rpc_client/rpc_gateway_wrapper.php";
-	        
-	        // Prepare HTTP post
-	        PostMethod post = new PostMethod(strURL);
-	        
-	        post.setParameter("userid", userid);
-	        
-	        post.setParameter("domain", domain);
-	        post.setParameter("first_name", first_name);
-	        post.setParameter("middle_i", middle_i);
-	        post.setParameter("last_name", last_name);
-	        post.setParameter("password", password);
-	        post.setParameter("community_code", community_code);
-	        post.setParameter("language_code", language_code);
-	        post.setParameter("email", email);
-	        post.setParameter("adminid", adminid);
-	        post.setParameter("action", "OpenSIPg.UserCreate");
-	        
-	        String digest = this.digest_calculate(new Object[]{client_id, userid, domain,
-					 first_name, middle_i, last_name,
-					 password, community_code,
-					 language_code, email, adminid,
-					 client_secret});
-	        
-	        post.setParameter("digest", digest);
-	        
-	        // Get HTTP client
-	        HttpClient httpclient = new HttpClient();
-	        // Execute request
-            int result = httpclient.executeMethod(post);
-            // Display status code
-            System.out.println("Response status code: " + result);
-            // Display response
-            System.out.println("Response body: ");
-            System.out.println(post.getResponseBodyAsString());
-			
-		} catch (Exception err) {
-			log.error("[testConnection]",err);
-		}
-	}
-	
-	public String digest_calculate(Object[] params) throws Exception {
-		String stringToMd5 = "";
-		
-		for (int i=0;i<params.length;i++) {
-			stringToMd5 += params[i];
-		}
-		
-		return MD5.do_checksum(stringToMd5);
-		
-	}
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.openmeetings.app.sip.xmlrpc.test;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.openmeetings.app.remote.red5.ScopeApplicationAdapter;
+import org.openmeetings.utils.crypt.MD5;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+
+
+public class OpenXGWrapperClient {
+	
+	private static final Logger log = Red5LoggerFactory.getLogger(OpenXGWrapperClient.class, ScopeApplicationAdapter.webAppRootKey);
+
+	private static OpenXGWrapperClient instance = null;
+
+	public static synchronized OpenXGWrapperClient getInstance() {
+		if (instance == null) {
+			instance = new OpenXGWrapperClient();
+		}
+		return instance;
+	}
+	
+	/**
+	 * Only for Testing
+	 */
+	public void testConnection() {
+		
+		String userid = "****";
+		String domain = "****";
+		String first_name = "****";
+		String middle_i = "****";
+		String last_name = "****";
+		String password = "****";
+		String community_code = "****";
+		String language_code = "****";
+		String email = "****";
+		String adminid = "****";
+		
+		String client_id = "****";
+		String client_secret = "*****";
+		
+		this.createUser(client_id, client_secret, userid, domain, first_name, middle_i, 
+					last_name, password, community_code, 
+					language_code, email, adminid);
+	}
+	
+	public void createUser(String client_id, String client_secret, 
+			String userid, String domain, String first_name, String middle_i,  
+			String last_name, String password, String community_code, 
+			String language_code, String email, String adminid
+			) {
+		try {
+			
+			log.debug("Test Connection");
+			
+			// Get target URL
+	        String strURL = "http://127.0.0.1:5080/rpc_client/rpc_gateway_wrapper.php";
+	        
+	        // Prepare HTTP post
+	        PostMethod post = new PostMethod(strURL);
+	        
+	        post.setParameter("userid", userid);
+	        
+	        post.setParameter("domain", domain);
+	        post.setParameter("first_name", first_name);
+	        post.setParameter("middle_i", middle_i);
+	        post.setParameter("last_name", last_name);
+	        post.setParameter("password", password);
+	        post.setParameter("community_code", community_code);
+	        post.setParameter("language_code", language_code);
+	        post.setParameter("email", email);
+	        post.setParameter("adminid", adminid);
+	        post.setParameter("action", "OpenSIPg.UserCreate");
+	        
+	        String digest = this.digest_calculate(new Object[]{client_id, userid, domain,
+					 first_name, middle_i, last_name,
+					 password, community_code,
+					 language_code, email, adminid,
+					 client_secret});
+	        
+	        post.setParameter("digest", digest);
+	        
+	        // Get HTTP client
+	        HttpClient httpclient = new HttpClient();
+	        // Execute request
+            int result = httpclient.executeMethod(post);
+            // Display status code
+            System.out.println("Response status code: " + result);
+            // Display response
+            System.out.println("Response body: ");
+            System.out.println(post.getResponseBodyAsString());
+			
+		} catch (Exception err) {
+			log.error("[testConnection]",err);
+		}
+	}
+	
+	public String digest_calculate(Object[] params) throws Exception {
+		String stringToMd5 = "";
+		
+		for (int i=0;i<params.length;i++) {
+			stringToMd5 += params[i];
+		}
+		
+		return MD5.do_checksum(stringToMd5);
+		
+	}
+
+}

Modified: incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/test/OpenXGXmlWriterFactory.java
URL: http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/test/OpenXGXmlWriterFactory.java?rev=1235400&r1=1235399&r2=1235400&view=diff
==============================================================================
--- incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/test/OpenXGXmlWriterFactory.java (original)
+++ incubator/openmeetings/trunk/singlewebapp/src/app/org/openmeetings/app/sip/xmlrpc/test/OpenXGXmlWriterFactory.java Tue Jan 24 18:30:48 2012
@@ -1,50 +1,68 @@
-package org.openmeetings.app.sip.xmlrpc.test;
-
-import java.io.BufferedWriter;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-
-import org.apache.ws.commons.serialize.XMLWriter;
-import org.apache.xmlrpc.XmlRpcException;
-import org.apache.xmlrpc.common.XmlRpcStreamConfig;
-import org.apache.xmlrpc.serializer.XmlWriterFactory;
-import org.openmeetings.app.remote.red5.ScopeApplicationAdapter;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.xml.sax.ContentHandler;
-
-
-
-public class OpenXGXmlWriterFactory implements XmlWriterFactory {
-	
-	private static final Logger log = Red5LoggerFactory.getLogger(OpenXGXmlWriterFactory.class, ScopeApplicationAdapter.webAppRootKey);
-	
-	protected XMLWriter newXmlWriter() {
-		return new OpenXgXmlWriter();
-	}
-
-	public ContentHandler getXmlWriter(XmlRpcStreamConfig pConfig, OutputStream pStream)
-			throws XmlRpcException {
-		XMLWriter xw = newXmlWriter();
-		xw.setDeclarating(true);
-		String enc = pConfig.getEncoding();
-		if (enc == null) {
-			enc = XmlRpcStreamConfig.UTF8_ENCODING;
-		}
-		xw.setEncoding(enc);
-		xw.setIndenting(false);
-		xw.setFlushing(true);
-		
-		log.debug(":: getXmlWriter ::");
-		
-		try {
-			xw.setWriter(new BufferedWriter(new OutputStreamWriter(pStream, enc)));
-		} catch (UnsupportedEncodingException e) {
-			throw new XmlRpcException(0, "Unsupported encoding: " + enc + e);
-		}
-		return xw;
-	}
-
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.openmeetings.app.sip.xmlrpc.test;
+
+import java.io.BufferedWriter;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.ws.commons.serialize.XMLWriter;
+import org.apache.xmlrpc.XmlRpcException;
+import org.apache.xmlrpc.common.XmlRpcStreamConfig;
+import org.apache.xmlrpc.serializer.XmlWriterFactory;
+import org.openmeetings.app.remote.red5.ScopeApplicationAdapter;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.xml.sax.ContentHandler;
+
+
+
+public class OpenXGXmlWriterFactory implements XmlWriterFactory {
+	
+	private static final Logger log = Red5LoggerFactory.getLogger(OpenXGXmlWriterFactory.class, ScopeApplicationAdapter.webAppRootKey);
+	
+	protected XMLWriter newXmlWriter() {
+		return new OpenXgXmlWriter();
+	}
+
+	public ContentHandler getXmlWriter(XmlRpcStreamConfig pConfig, OutputStream pStream)
+			throws XmlRpcException {
+		XMLWriter xw = newXmlWriter();
+		xw.setDeclarating(true);
+		String enc = pConfig.getEncoding();
+		if (enc == null) {
+			enc = XmlRpcStreamConfig.UTF8_ENCODING;
+		}
+		xw.setEncoding(enc);
+		xw.setIndenting(false);
+		xw.setFlushing(true);
+		
+		log.debug(":: getXmlWriter ::");
+		
+		try {
+			xw.setWriter(new BufferedWriter(new OutputStreamWriter(pStream, enc)));
+		} catch (UnsupportedEncodingException e) {
+			throw new XmlRpcException(0, "Unsupported encoding: " + enc + e);
+		}
+		return xw;
+	}
+
+
+}