PageRenderTime 26ms CodeModel.GetById 40ms RepoModel.GetById 1ms app.codeStats 0ms

/3rdPartyServices/EnterpriseServices/NetworkingZone/web-app/src/main/java/org/societies/thirdpartyservices/networking/client/NetworkingClientComms.java

https://github.com/societies/SOCIETIES-SCE-Services
Java | 897 lines | 566 code | 156 blank | 175 comment | 75 complexity | b0632568e2509785f9611060f5fdb378 MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0, AGPL-3.0
  1. /**
  2. * Copyright (c) 2011, SOCIETIES Consortium (WATERFORD INSTITUTE OF TECHNOLOGY (TSSG), HERIOT-WATT UNIVERSITY (HWU), SOLUTA.NET
  3. * (SN), GERMAN AEROSPACE CENTRE (Deutsches Zentrum fuer Luft- und Raumfahrt e.V.) (DLR), Zavod za varnostne tehnologije
  4. * informacijske družbe in elektronsko poslovanje (SETCCE), INSTITUTE OF COMMUNICATION AND COMPUTER SYSTEMS (ICCS), LAKE
  5. * COMMUNICATIONS (LAKE), INTEL PERFORMANCE LEARNING SOLUTIONS LTD (INTEL), PORTUGAL TELECOM INOVAÇÃO, SA (PTIN), IBM Corp.,
  6. * INSTITUT TELECOM (ITSUD), AMITEC DIACHYTI EFYIA PLIROFORIKI KAI EPIKINONIES ETERIA PERIORISMENIS EFTHINIS (AMITEC), TELECOM
  7. * ITALIA S.p.a.(TI), TRIALOG (TRIALOG), Stiftelsen SINTEF (SINTEF), NEC EUROPE LTD (NEC))
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
  11. * conditions are met:
  12. *
  13. * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
  16. * disclaimer in the documentation and/or other materials provided with the distribution.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
  19. * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
  20. * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  23. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. package org.societies.thirdpartyservices.networking.client;
  26. import java.util.Arrays;
  27. import java.util.Collections;
  28. import java.util.List;
  29. import org.slf4j.Logger;
  30. import org.slf4j.LoggerFactory;
  31. import org.societies.api.comm.xmpp.datatypes.Stanza;
  32. import org.societies.api.comm.xmpp.datatypes.XMPPInfo;
  33. import org.societies.api.comm.xmpp.exceptions.CommunicationException;
  34. import org.societies.api.comm.xmpp.exceptions.XMPPError;
  35. import org.societies.api.comm.xmpp.interfaces.ICommCallback;
  36. import org.societies.api.comm.xmpp.interfaces.ICommManager;
  37. import org.societies.api.identity.IIdentity;
  38. import org.societies.api.identity.InvalidFormatException;
  39. import org.societies.api.ext3p.networking.MemberDetails;
  40. import org.societies.api.ext3p.networking.NetworkingBean;
  41. import org.societies.api.ext3p.networking.Method;
  42. import org.societies.api.ext3p.networking.NetworkingBeanResult;
  43. import org.societies.api.ext3p.networking.ShareInfo;
  44. import org.societies.api.ext3p.networking.UserDetails;
  45. import org.societies.api.ext3p.networking.ZoneDetails;
  46. import org.societies.api.ext3p.networking.ZoneEvent;
  47. /**
  48. * Comms Client that initiates the remote communication for the networking zone
  49. *
  50. * @author Maria Mannion
  51. *
  52. */
  53. public class NetworkingClientComms implements ICommCallback {
  54. private static final List<String> NAMESPACES = Collections
  55. .unmodifiableList(Arrays
  56. .asList("http://societies.org/api/ext3p/networking"));
  57. private static final List<String> PACKAGES = Collections
  58. .unmodifiableList(Arrays
  59. .asList("org.societies.api.ext3p.networking"));
  60. //TODO : Temporary while testing
  61. private int TEST_TIME_MULTIPLER = 10;
  62. private int WAIT_TIME_SECS = 100;
  63. // PRIVATE VARIABLES
  64. private ICommManager commManager;
  65. private static Logger LOG = LoggerFactory.getLogger(NetworkingClientComms.class);
  66. private NetworkingBeanResult commsResult;
  67. private String netServerID;
  68. // PROPERTIES
  69. public ICommManager getCommManager() {
  70. return commManager;
  71. }
  72. public void setCommManager(ICommManager commManager) {
  73. this.commManager = commManager;
  74. }
  75. public NetworkingClientComms() {
  76. netServerID = new String("networking.societies.local");
  77. }
  78. public NetworkingClientComms(String networkingserver) {
  79. this.netServerID = networkingserver;
  80. }
  81. public void InitService() {
  82. // Registry Netowkring Client with the Comms Manager
  83. if (LOG.isDebugEnabled())
  84. LOG.debug("Registering the Networking Client with the XMPP Communication Manager");
  85. try {
  86. getCommManager().register(this);
  87. } catch (CommunicationException e) {
  88. e.printStackTrace();
  89. }
  90. }
  91. /*
  92. * (non-Javadoc)
  93. *
  94. * @see
  95. * org.societies.api.comm.xmpp.interfaces.ICommCallback#getJavaPackages()
  96. */
  97. @Override
  98. public List<String> getJavaPackages() {
  99. return PACKAGES;
  100. }
  101. /*
  102. * (non-Javadoc)
  103. *
  104. * @see
  105. * org.societies.api.comm.xmpp.interfaces.ICommCallback#getXMLNamespaces()
  106. */
  107. @Override
  108. public List<String> getXMLNamespaces() {
  109. return NAMESPACES;
  110. }
  111. /*
  112. * (non-Javadoc)
  113. *
  114. * @see
  115. * org.societies.api.comm.xmpp.interfaces.ICommCallback#receiveError(org
  116. * .societies.api.comm.xmpp.datatypes.Stanza,
  117. * org.societies.api.comm.xmpp.exceptions.XMPPError)
  118. */
  119. @Override
  120. public void receiveError(Stanza arg0, XMPPError arg1) {
  121. // TODO Auto-generated method stub
  122. }
  123. /*
  124. * (non-Javadoc)
  125. *
  126. * @see
  127. * org.societies.api.comm.xmpp.interfaces.ICommCallback#receiveInfo(org.
  128. * societies.api.comm.xmpp.datatypes.Stanza, java.lang.String,
  129. * org.societies.api.comm.xmpp.datatypes.XMPPInfo)
  130. */
  131. @Override
  132. public void receiveInfo(Stanza arg0, String arg1, XMPPInfo arg2) {
  133. // TODO Auto-generated method stub
  134. }
  135. /*
  136. * (non-Javadoc)
  137. *
  138. * @see
  139. * org.societies.api.comm.xmpp.interfaces.ICommCallback#receiveItems(org
  140. * .societies.api.comm.xmpp.datatypes.Stanza, java.lang.String,
  141. * java.util.List)
  142. */
  143. @Override
  144. public void receiveItems(Stanza arg0, String arg1, List<String> arg2) {
  145. // TODO Auto-generated method stub
  146. }
  147. /*
  148. * (non-Javadoc)
  149. *
  150. * @see
  151. * org.societies.api.comm.xmpp.interfaces.ICommCallback#receiveMessage(org
  152. * .societies.api.comm.xmpp.datatypes.Stanza, java.lang.Object)
  153. */
  154. @Override
  155. public void receiveMessage(Stanza arg0, Object arg1) {
  156. // TODO Auto-generated method stub
  157. }
  158. /*
  159. * (non-Javadoc)
  160. *
  161. * @see
  162. * org.societies.api.comm.xmpp.interfaces.ICommCallback#receiveResult(org
  163. * .societies.api.comm.xmpp.datatypes.Stanza, java.lang.Object)
  164. */
  165. @Override
  166. public void receiveResult(Stanza arg0, Object arg1) {
  167. // TODO Auto-generated method stub
  168. if (arg1 instanceof NetworkingBeanResult){
  169. commsResult = (NetworkingBeanResult) arg1;
  170. }
  171. }
  172. public String getServerCisID() {
  173. // We want to sent all messages for Netowrking Client to the metworking server
  174. // hardcode for now TODO : Read from properties
  175. IIdentity toIdentity = null;
  176. commsResult = null;
  177. try {
  178. toIdentity = getCommManager().getIdManager().fromJid(netServerID);
  179. } catch (InvalidFormatException e1) {
  180. // TODO Auto-generated catch block
  181. e1.printStackTrace();
  182. }
  183. Stanza stanza = new Stanza(toIdentity);
  184. // CREATE MESSAGE BEAN
  185. NetworkingBean netBean = new NetworkingBean();
  186. netBean.setMethod(Method.WHOAREYOU);
  187. try {
  188. getCommManager().sendIQGet(stanza, netBean, this);
  189. } catch (CommunicationException e) {
  190. LOG.warn(e.getMessage());
  191. }
  192. ;
  193. // TYuck, another TODO this properly, for now, wait up to 5 secs
  194. int i= 0;
  195. while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
  196. try {
  197. i++;
  198. Thread.sleep(WAIT_TIME_SECS);
  199. } catch (InterruptedException e) {
  200. // TODO Auto-generated catch block
  201. e.printStackTrace();
  202. }
  203. }
  204. if (commsResult != null)
  205. {
  206. return this.commsResult.getNetworkingCis();
  207. }
  208. return null;
  209. }
  210. public List<String> getZoneCisID() {
  211. // We want to sent all messages for Netowrking Client to the metworking server
  212. // hardcode for now TODO : Read from properties
  213. IIdentity toIdentity = null;
  214. commsResult = null;
  215. try {
  216. toIdentity = getCommManager().getIdManager().fromJid(netServerID);
  217. } catch (InvalidFormatException e1) {
  218. // TODO Auto-generated catch block
  219. e1.printStackTrace();
  220. }
  221. Stanza stanza = new Stanza(toIdentity);
  222. // CREATE MESSAGE BEAN
  223. NetworkingBean netBean = new NetworkingBean();
  224. netBean.setMethod(Method.GET_ZONE_LIST);
  225. try {
  226. getCommManager().sendIQGet(stanza, netBean, this);
  227. } catch (CommunicationException e) {
  228. LOG.warn(e.getMessage());
  229. };
  230. // TYuck, another TODO this properly, for now, wait up to 5 secs
  231. int i= 0;
  232. while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
  233. try {
  234. i++;
  235. Thread.sleep(WAIT_TIME_SECS);
  236. } catch (InterruptedException e) {
  237. // TODO Auto-generated catch block
  238. e.printStackTrace();
  239. }
  240. }
  241. if (commsResult != null)
  242. return this.commsResult.getZones();
  243. return null;
  244. }
  245. public UserDetails getFriendDetails(String friendid)
  246. {
  247. // We want to sent all messages for Netowrking Client to the metworking server
  248. // hardcode for now TODO : Read from properties
  249. IIdentity toIdentity = null;
  250. commsResult = null;
  251. try {
  252. toIdentity = getCommManager().getIdManager().fromJid(netServerID);
  253. } catch (InvalidFormatException e1) {
  254. // TODO Auto-generated catch block
  255. e1.printStackTrace();
  256. }
  257. Stanza stanza = new Stanza(toIdentity);
  258. // CREATE MESSAGE BEAN
  259. NetworkingBean netBean = new NetworkingBean();
  260. netBean.setMethod(Method.GETUSERDETAILS);
  261. netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
  262. netBean.setFrienduserid(friendid);
  263. try {
  264. getCommManager().sendIQGet(stanza, netBean, this);
  265. } catch (CommunicationException e) {
  266. LOG.warn(e.getMessage());
  267. };
  268. // TYuck, another TODO this properly, for now, wait up to 5 secs
  269. int i= 0;
  270. while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
  271. try {
  272. i++;
  273. Thread.sleep(WAIT_TIME_SECS);
  274. } catch (InterruptedException e) {
  275. // TODO Auto-generated catch block
  276. e.printStackTrace();
  277. }
  278. }
  279. if (commsResult != null)
  280. return this.commsResult.getUserDetails();
  281. return null;
  282. }
  283. public UserDetails getMyDetails()
  284. {
  285. // We want to sent all messages for Netowrking Client to the metworking server
  286. // hardcode for now TODO : Read from properties
  287. IIdentity toIdentity = null;
  288. commsResult = null;
  289. try {
  290. toIdentity = getCommManager().getIdManager().fromJid(netServerID);
  291. } catch (InvalidFormatException e1) {
  292. // TODO Auto-generated catch block
  293. e1.printStackTrace();
  294. }
  295. Stanza stanza = new Stanza(toIdentity);
  296. // CREATE MESSAGE BEAN
  297. NetworkingBean netBean = new NetworkingBean();
  298. netBean.setMethod(Method.GETMYDETAILS);
  299. netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
  300. try {
  301. getCommManager().sendIQGet(stanza, netBean, this);
  302. } catch (CommunicationException e) {
  303. LOG.warn(e.getMessage());
  304. };
  305. // TYuck, another TODO this properly, for now, wait up to 5 secs
  306. int i= 0;
  307. while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
  308. try {
  309. i++;
  310. Thread.sleep(WAIT_TIME_SECS);
  311. } catch (InterruptedException e) {
  312. // TODO Auto-generated catch block
  313. e.printStackTrace();
  314. }
  315. }
  316. if (commsResult != null)
  317. return this.commsResult.getUserDetails();
  318. return null;
  319. }
  320. public UserDetails updateMyDetails(UserDetails newDetails)
  321. {
  322. // We want to sent all messages for Netowrking Client to the metworking server
  323. // hardcode for now TODO : Read from properties
  324. IIdentity toIdentity = null;
  325. commsResult = null;
  326. try {
  327. toIdentity = getCommManager().getIdManager().fromJid(netServerID);
  328. } catch (InvalidFormatException e1) {
  329. // TODO Auto-generated catch block
  330. e1.printStackTrace();
  331. }
  332. Stanza stanza = new Stanza(toIdentity);
  333. // CREATE MESSAGE BEAN
  334. NetworkingBean netBean = new NetworkingBean();
  335. netBean.setMethod(Method.UPDATEMYDETAILS);
  336. netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
  337. LOG.info("updateMyDetails : newDetails.getDisplayName() " +newDetails.getDisplayName());
  338. newDetails.setUserid(netBean.getMyuserid());
  339. netBean.setMyDetails(newDetails);
  340. try {
  341. getCommManager().sendIQGet(stanza, netBean, this);
  342. } catch (CommunicationException e) {
  343. LOG.warn(e.getMessage());
  344. };
  345. // TYuck, another TODO this properly, for now, wait up to 5 secs
  346. int i= 0;
  347. while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
  348. try {
  349. i++;
  350. Thread.sleep(WAIT_TIME_SECS);
  351. } catch (InterruptedException e) {
  352. // TODO Auto-generated catch block
  353. e.printStackTrace();
  354. }
  355. }
  356. if (commsResult != null)
  357. return this.commsResult.getUserDetails();
  358. return null;
  359. }
  360. public ShareInfo getFriendShareInfo(String friendid)
  361. {
  362. // We want to sent all messages for Netowrking Client to the metworking server
  363. // hardcode for now TODO : Read from properties
  364. IIdentity toIdentity = null;
  365. commsResult = null;
  366. try {
  367. toIdentity = getCommManager().getIdManager().fromJid(netServerID);
  368. } catch (InvalidFormatException e1) {
  369. // TODO Auto-generated catch block
  370. e1.printStackTrace();
  371. }
  372. Stanza stanza = new Stanza(toIdentity);
  373. // CREATE MESSAGE BEAN
  374. NetworkingBean netBean = new NetworkingBean();
  375. netBean.setMethod(Method.GETFRIENDSHAREINFO);
  376. netBean.setFrienduserid(friendid);
  377. netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
  378. try {
  379. getCommManager().sendIQGet(stanza, netBean, this);
  380. } catch (CommunicationException e) {
  381. LOG.warn(e.getMessage());
  382. };
  383. // TYuck, another TODO this properly, for now, wait up to 5 secs
  384. int i= 0;
  385. while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
  386. try {
  387. i++;
  388. Thread.sleep(WAIT_TIME_SECS);
  389. } catch (InterruptedException e) {
  390. // TODO Auto-generated catch block
  391. e.printStackTrace();
  392. }
  393. }
  394. if (commsResult != null)
  395. return this.commsResult.getSharedInfo();
  396. return null;
  397. }
  398. public ShareInfo getShareInfo(String friendid)
  399. {
  400. // We want to sent all messages for Netowrking Client to the metworking server
  401. // hardcode for now TODO : Read from properties
  402. IIdentity toIdentity = null;
  403. commsResult = null;
  404. try {
  405. toIdentity = getCommManager().getIdManager().fromJid(netServerID);
  406. } catch (InvalidFormatException e1) {
  407. // TODO Auto-generated catch block
  408. e1.printStackTrace();
  409. }
  410. Stanza stanza = new Stanza(toIdentity);
  411. // CREATE MESSAGE BEAN
  412. NetworkingBean netBean = new NetworkingBean();
  413. netBean.setMethod(Method.GETSHAREINFO);
  414. netBean.setFrienduserid(friendid);
  415. netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
  416. try {
  417. getCommManager().sendIQGet(stanza, netBean, this);
  418. } catch (CommunicationException e) {
  419. LOG.warn(e.getMessage());
  420. };
  421. // TYuck, another TODO this properly, for now, wait up to 5 secs
  422. int i= 0;
  423. while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
  424. try {
  425. i++;
  426. Thread.sleep(WAIT_TIME_SECS);
  427. } catch (InterruptedException e) {
  428. // TODO Auto-generated catch block
  429. e.printStackTrace();
  430. }
  431. }
  432. if (commsResult != null)
  433. return this.commsResult.getSharedInfo();
  434. return null;
  435. }
  436. public ShareInfo updateShareInfo(ShareInfo info)
  437. {
  438. // We want to sent all messages for Netowrking Client to the metworking server
  439. // hardcode for now TODO : Read from properties
  440. IIdentity toIdentity = null;
  441. commsResult = null;
  442. try {
  443. toIdentity = getCommManager().getIdManager().fromJid(netServerID);
  444. } catch (InvalidFormatException e1) {
  445. // TODO Auto-generated catch block
  446. e1.printStackTrace();
  447. }
  448. Stanza stanza = new Stanza(toIdentity);
  449. // CREATE MESSAGE BEAN
  450. NetworkingBean netBean = new NetworkingBean();
  451. netBean.setMethod(Method.UPDATESHAREINFO);
  452. netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
  453. info.setUserid(netBean.getMyuserid());
  454. netBean.setSharedInfo(info);
  455. try {
  456. getCommManager().sendIQGet(stanza, netBean, this);
  457. } catch (CommunicationException e) {
  458. LOG.warn(e.getMessage());
  459. };
  460. // TYuck, another TODO this properly, for now, wait up to 5 secs
  461. int i= 0;
  462. while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
  463. try {
  464. i++;
  465. Thread.sleep(WAIT_TIME_SECS);
  466. } catch (InterruptedException e) {
  467. // TODO Auto-generated catch block
  468. e.printStackTrace();
  469. }
  470. }
  471. if (commsResult != null)
  472. return this.commsResult.getSharedInfo();
  473. return null;
  474. }
  475. public List<ZoneEvent> getCisActivity(String cisID)
  476. {
  477. // We want to sent all messages for Netowrking Client to the metworking server
  478. // hardcode for now TODO : Read from properties
  479. IIdentity toIdentity = null;
  480. commsResult = null;
  481. try {
  482. toIdentity = getCommManager().getIdManager().fromJid(netServerID);
  483. } catch (InvalidFormatException e1) {
  484. // TODO Auto-generated catch block
  485. e1.printStackTrace();
  486. }
  487. Stanza stanza = new Stanza(toIdentity);
  488. // CREATE MESSAGE BEAN
  489. NetworkingBean netBean = new NetworkingBean();
  490. netBean.setMethod(Method.GETZONEEVENTS);
  491. netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
  492. netBean.setMycurrentzone(cisID);
  493. try {
  494. getCommManager().sendIQGet(stanza, netBean, this);
  495. } catch (CommunicationException e) {
  496. LOG.warn(e.getMessage());
  497. };
  498. // TYuck, another TODO this properly, for now, wait up to 5 secs
  499. int i= 0;
  500. while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
  501. try {
  502. i++;
  503. Thread.sleep(WAIT_TIME_SECS);
  504. } catch (InterruptedException e) {
  505. // TODO Auto-generated catch block
  506. e.printStackTrace();
  507. }
  508. }
  509. if (commsResult != null)
  510. return this.commsResult.getZoneeventlist();
  511. return null;
  512. }
  513. public List<MemberDetails> getMemberDetails(List<String> memberIDs)
  514. {
  515. // We want to sent all messages for Netowrking Client to the metworking server
  516. // hardcode for now TODO : Read from properties
  517. IIdentity toIdentity = null;
  518. commsResult = null;
  519. try {
  520. toIdentity = getCommManager().getIdManager().fromJid(netServerID);
  521. } catch (InvalidFormatException e1) {
  522. // TODO Auto-generated catch block
  523. e1.printStackTrace();
  524. }
  525. Stanza stanza = new Stanza(toIdentity);
  526. // CREATE MESSAGE BEAN
  527. NetworkingBean netBean = new NetworkingBean();
  528. netBean.setMethod(Method.GETMEMBERDETAILS);
  529. netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
  530. netBean.setUseridlist(memberIDs);
  531. try {
  532. getCommManager().sendIQGet(stanza, netBean, this);
  533. } catch (CommunicationException e) {
  534. LOG.warn(e.getMessage());
  535. };
  536. // TYuck, another TODO this properly, for now, wait up to 5 secs
  537. int i= 0;
  538. while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
  539. try {
  540. i++;
  541. Thread.sleep(WAIT_TIME_SECS);
  542. } catch (InterruptedException e) {
  543. // TODO Auto-generated catch block
  544. e.printStackTrace();
  545. }
  546. }
  547. if (commsResult != null)
  548. return this.commsResult.getMemberdetaillist();
  549. return null;
  550. }
  551. public List<UserDetails> getUserDetailsList(List<String> memberIDs)
  552. {
  553. // We want to sent all messages for Netowrking Client to the metworking server
  554. // hardcode for now TODO : Read from properties
  555. IIdentity toIdentity = null;
  556. commsResult = null;
  557. try {
  558. toIdentity = getCommManager().getIdManager().fromJid(netServerID);
  559. } catch (InvalidFormatException e1) {
  560. // TODO Auto-generated catch block
  561. e1.printStackTrace();
  562. }
  563. Stanza stanza = new Stanza(toIdentity);
  564. // CREATE MESSAGE BEAN
  565. NetworkingBean netBean = new NetworkingBean();
  566. netBean.setMethod(Method.GETUSERDETAILSLIST);
  567. netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
  568. netBean.setUseridlist(memberIDs);
  569. try {
  570. getCommManager().sendIQGet(stanza, netBean, this);
  571. } catch (CommunicationException e) {
  572. LOG.warn(e.getMessage());
  573. };
  574. // TYuck, another TODO this properly, for now, wait up to 5 secs
  575. int i= 0;
  576. while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
  577. try {
  578. i++;
  579. Thread.sleep(WAIT_TIME_SECS);
  580. } catch (InterruptedException e) {
  581. // TODO Auto-generated catch block
  582. e.printStackTrace();
  583. }
  584. }
  585. if (commsResult != null)
  586. return this.commsResult.getUserDetailsList();
  587. return null;
  588. }
  589. public List<String> addnote(String friendid, String note) {
  590. // We want to sent all messages for Netowrking Client to the metworking server
  591. // hardcode for now TODO : Read from properties
  592. IIdentity toIdentity = null;
  593. commsResult = null;
  594. try {
  595. toIdentity = getCommManager().getIdManager().fromJid(netServerID);
  596. } catch (InvalidFormatException e1) {
  597. // TODO Auto-generated catch block
  598. e1.printStackTrace();
  599. }
  600. Stanza stanza = new Stanza(toIdentity);
  601. // CREATE MESSAGE BEAN
  602. NetworkingBean netBean = new NetworkingBean();
  603. netBean.setMethod(Method.ADDNOTE);
  604. netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
  605. netBean.setFrienduserid(friendid);
  606. netBean.setNote(note);
  607. try {
  608. getCommManager().sendIQGet(stanza, netBean, this);
  609. } catch (CommunicationException e) {
  610. LOG.warn(e.getMessage());
  611. };
  612. // TYuck, another TODO this properly, for now, wait up to 5 secs
  613. int i= 0;
  614. while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
  615. try {
  616. i++;
  617. Thread.sleep(WAIT_TIME_SECS);
  618. } catch (InterruptedException e) {
  619. // TODO Auto-generated catch block
  620. e.printStackTrace();
  621. }
  622. }
  623. if (commsResult != null)
  624. return this.commsResult.getNotes();
  625. return null;
  626. }
  627. public List<String> getnotes(String friendid) {
  628. // We want to sent all messages for Netowrking Client to the metworking server
  629. // hardcode for now TODO : Read from properties
  630. IIdentity toIdentity = null;
  631. commsResult = null;
  632. try {
  633. toIdentity = getCommManager().getIdManager().fromJid(netServerID);
  634. } catch (InvalidFormatException e1) {
  635. // TODO Auto-generated catch block
  636. e1.printStackTrace();
  637. }
  638. Stanza stanza = new Stanza(toIdentity);
  639. // CREATE MESSAGE BEAN
  640. NetworkingBean netBean = new NetworkingBean();
  641. netBean.setMethod(Method.GETNOTES);
  642. netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
  643. netBean.setFrienduserid(friendid);
  644. try {
  645. getCommManager().sendIQGet(stanza, netBean, this);
  646. } catch (CommunicationException e) {
  647. LOG.warn(e.getMessage());
  648. };
  649. // TYuck, another TODO this properly, for now, wait up to 5 secs
  650. int i= 0;
  651. while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
  652. try {
  653. i++;
  654. Thread.sleep(WAIT_TIME_SECS);
  655. } catch (InterruptedException e) {
  656. // TODO Auto-generated catch block
  657. e.printStackTrace();
  658. }
  659. }
  660. if (commsResult != null)
  661. return this.commsResult.getNotes();
  662. return null;
  663. }
  664. public List<ZoneDetails> getZoneDetails() {
  665. IIdentity toIdentity = null;
  666. commsResult = null;
  667. try {
  668. toIdentity = getCommManager().getIdManager().fromJid(netServerID);
  669. } catch (InvalidFormatException e1) {
  670. // TODO Auto-generated catch block
  671. e1.printStackTrace();
  672. }
  673. Stanza stanza = new Stanza(toIdentity);
  674. // CREATE MESSAGE BEAN
  675. NetworkingBean netBean = new NetworkingBean();
  676. netBean.setMethod(Method.GETZONEDETAILS);
  677. try {
  678. getCommManager().sendIQGet(stanza, netBean, this);
  679. } catch (CommunicationException e) {
  680. LOG.warn(e.getMessage());
  681. };
  682. // TYuck, another TODO this properly, for now, wait up to 5 secs
  683. int i= 0;
  684. while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
  685. try {
  686. i++;
  687. Thread.sleep(WAIT_TIME_SECS);
  688. } catch (InterruptedException e) {
  689. // TODO Auto-generated catch block
  690. e.printStackTrace();
  691. }
  692. }
  693. if (commsResult != null)
  694. return this.commsResult.getZonedetails();
  695. return null;
  696. }
  697. public NetworkingBeanResult getStartupInfo()
  698. {
  699. IIdentity toIdentity = null;
  700. commsResult = null;
  701. try {
  702. toIdentity = getCommManager().getIdManager().fromJid(netServerID);
  703. } catch (InvalidFormatException e1) {
  704. // TODO Auto-generated catch block
  705. e1.printStackTrace();
  706. }
  707. Stanza stanza = new Stanza(toIdentity);
  708. // CREATE MESSAGE BEAN
  709. NetworkingBean netBean = new NetworkingBean();
  710. netBean.setMethod(Method.GETSTARTUPINFO);
  711. netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
  712. try {
  713. getCommManager().sendIQGet(stanza, netBean, this);
  714. } catch (CommunicationException e) {
  715. LOG.warn(e.getMessage());
  716. };
  717. // Yuck, another TODO this properly, for now, wait up to 5 secs
  718. int i= 0;
  719. while (commsResult == null && (i < (50 * TEST_TIME_MULTIPLER))){
  720. try {
  721. i++;
  722. Thread.sleep(WAIT_TIME_SECS);
  723. } catch (InterruptedException e) {
  724. e.printStackTrace();
  725. }
  726. }
  727. // Give commresult change to pupolate fully
  728. try {
  729. Thread.sleep(WAIT_TIME_SECS);
  730. } catch (InterruptedException e) {
  731. e.printStackTrace();
  732. }
  733. return this.commsResult;
  734. }
  735. public String getNetServerID() {
  736. return netServerID;
  737. }
  738. public void setNetServerID(String netServerID) {
  739. this.netServerID = netServerID;
  740. }
  741. }