PageRenderTime 1744ms CodeModel.GetById 727ms app.highlight 356ms RepoModel.GetById 652ms app.codeStats 1ms

/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
  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 */
 25package org.societies.thirdpartyservices.networking.client;
 26
 27import java.util.Arrays;
 28import java.util.Collections;
 29import java.util.List;
 30
 31import org.slf4j.Logger;
 32import org.slf4j.LoggerFactory;
 33import org.societies.api.comm.xmpp.datatypes.Stanza;
 34import org.societies.api.comm.xmpp.datatypes.XMPPInfo;
 35import org.societies.api.comm.xmpp.exceptions.CommunicationException;
 36import org.societies.api.comm.xmpp.exceptions.XMPPError;
 37import org.societies.api.comm.xmpp.interfaces.ICommCallback;
 38import org.societies.api.comm.xmpp.interfaces.ICommManager;
 39
 40
 41import org.societies.api.identity.IIdentity;
 42import org.societies.api.identity.InvalidFormatException;
 43
 44import org.societies.api.ext3p.networking.MemberDetails;
 45import org.societies.api.ext3p.networking.NetworkingBean;
 46import org.societies.api.ext3p.networking.Method;
 47import org.societies.api.ext3p.networking.NetworkingBeanResult;
 48import org.societies.api.ext3p.networking.ShareInfo;
 49import org.societies.api.ext3p.networking.UserDetails;
 50import org.societies.api.ext3p.networking.ZoneDetails;
 51import org.societies.api.ext3p.networking.ZoneEvent;
 52/**
 53 * Comms Client that initiates the remote communication for the networking zone
 54 * 
 55 * @author Maria Mannion
 56 * 
 57 */
 58public class NetworkingClientComms implements ICommCallback {
 59	private static final List<String> NAMESPACES = Collections
 60			.unmodifiableList(Arrays
 61					.asList("http://societies.org/api/ext3p/networking"));
 62	private static final List<String> PACKAGES = Collections
 63			.unmodifiableList(Arrays
 64					.asList("org.societies.api.ext3p.networking"));
 65
 66	//TODO : Temporary while testing
 67	private int TEST_TIME_MULTIPLER = 10;
 68	private int WAIT_TIME_SECS = 100;
 69	
 70	// PRIVATE VARIABLES
 71	private ICommManager commManager;
 72	private static Logger LOG = LoggerFactory.getLogger(NetworkingClientComms.class);
 73
 74	
 75	private NetworkingBeanResult commsResult;
 76	
 77	private String netServerID;
 78	
 79	// PROPERTIES
 80	public ICommManager getCommManager() {
 81		return commManager;
 82	}
 83
 84	public void setCommManager(ICommManager commManager) {
 85		this.commManager = commManager;
 86	}
 87
 88	public NetworkingClientComms() {
 89		netServerID = new String("networking.societies.local");
 90	}
 91	
 92	public NetworkingClientComms(String networkingserver) {
 93		this.netServerID = networkingserver;
 94	}
 95
 96	public void InitService() {
 97		// Registry Netowkring Client with the Comms Manager
 98
 99		if (LOG.isDebugEnabled())
100			LOG.debug("Registering the Networking Client with the XMPP Communication Manager");
101
102		try {
103			getCommManager().register(this);
104		} catch (CommunicationException e) {
105			e.printStackTrace();
106		}
107	
108	}
109
110	/*
111	 * (non-Javadoc)
112	 * 
113	 * @see
114	 * org.societies.api.comm.xmpp.interfaces.ICommCallback#getJavaPackages()
115	 */
116	@Override
117	public List<String> getJavaPackages() {
118		return PACKAGES;
119	}
120
121	/*
122	 * (non-Javadoc)
123	 * 
124	 * @see
125	 * org.societies.api.comm.xmpp.interfaces.ICommCallback#getXMLNamespaces()
126	 */
127	@Override
128	public List<String> getXMLNamespaces() {
129		return NAMESPACES;
130	}
131
132	/*
133	 * (non-Javadoc)
134	 * 
135	 * @see
136	 * org.societies.api.comm.xmpp.interfaces.ICommCallback#receiveError(org
137	 * .societies.api.comm.xmpp.datatypes.Stanza,
138	 * org.societies.api.comm.xmpp.exceptions.XMPPError)
139	 */
140	@Override
141	public void receiveError(Stanza arg0, XMPPError arg1) {
142		// TODO Auto-generated method stub
143
144	}
145
146	/*
147	 * (non-Javadoc)
148	 * 
149	 * @see
150	 * org.societies.api.comm.xmpp.interfaces.ICommCallback#receiveInfo(org.
151	 * societies.api.comm.xmpp.datatypes.Stanza, java.lang.String,
152	 * org.societies.api.comm.xmpp.datatypes.XMPPInfo)
153	 */
154	@Override
155	public void receiveInfo(Stanza arg0, String arg1, XMPPInfo arg2) {
156		// TODO Auto-generated method stub
157
158	}
159
160	/*
161	 * (non-Javadoc)
162	 * 
163	 * @see
164	 * org.societies.api.comm.xmpp.interfaces.ICommCallback#receiveItems(org
165	 * .societies.api.comm.xmpp.datatypes.Stanza, java.lang.String,
166	 * java.util.List)
167	 */
168	@Override
169	public void receiveItems(Stanza arg0, String arg1, List<String> arg2) {
170		// TODO Auto-generated method stub
171
172	}
173
174	/*
175	 * (non-Javadoc)
176	 * 
177	 * @see
178	 * org.societies.api.comm.xmpp.interfaces.ICommCallback#receiveMessage(org
179	 * .societies.api.comm.xmpp.datatypes.Stanza, java.lang.Object)
180	 */
181	@Override
182	public void receiveMessage(Stanza arg0, Object arg1) {
183		// TODO Auto-generated method stub
184
185	}
186
187	/*
188	 * (non-Javadoc)
189	 * 
190	 * @see
191	 * org.societies.api.comm.xmpp.interfaces.ICommCallback#receiveResult(org
192	 * .societies.api.comm.xmpp.datatypes.Stanza, java.lang.Object)
193	 */
194	@Override
195	public void receiveResult(Stanza arg0, Object arg1) {
196		// TODO Auto-generated method stub
197		if (arg1 instanceof NetworkingBeanResult){
198			commsResult = (NetworkingBeanResult) arg1;	
199		}
200	}
201
202	
203	
204	public String getServerCisID() {
205		// We want to sent all messages for Netowrking Client to the metworking server
206		// hardcode for now TODO : Read from properties
207		IIdentity toIdentity = null;
208		commsResult = null;
209		try {
210			toIdentity = getCommManager().getIdManager().fromJid(netServerID);
211		} catch (InvalidFormatException e1) {
212			// TODO Auto-generated catch block
213			e1.printStackTrace();
214		}
215		Stanza stanza = new Stanza(toIdentity);
216
217		// CREATE MESSAGE BEAN
218		NetworkingBean netBean = new NetworkingBean();
219		netBean.setMethod(Method.WHOAREYOU);
220
221		try {
222			getCommManager().sendIQGet(stanza, netBean, this);
223			
224		} catch (CommunicationException e) {
225			LOG.warn(e.getMessage());
226		}
227		;
228
229		// TYuck, another TODO this properly, for now, wait up to 5 secs
230		int i= 0;
231		while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
232			try {
233				i++;
234				Thread.sleep(WAIT_TIME_SECS);
235			} catch (InterruptedException e) {
236				// TODO Auto-generated catch block
237				e.printStackTrace();
238			}
239		}
240		
241		if (commsResult != null)
242		{
243			return this.commsResult.getNetworkingCis();
244		}
245		
246		return null;
247	}
248
249	public List<String> getZoneCisID() {
250		// We want to sent all messages for Netowrking Client to the metworking server
251		// hardcode for now TODO : Read from properties
252		IIdentity toIdentity = null;
253		commsResult = null;
254		try {
255			toIdentity = getCommManager().getIdManager().fromJid(netServerID);
256		} catch (InvalidFormatException e1) {
257			// TODO Auto-generated catch block
258			e1.printStackTrace();
259		}
260		Stanza stanza = new Stanza(toIdentity);
261
262		// CREATE MESSAGE BEAN
263		NetworkingBean netBean = new NetworkingBean();
264		netBean.setMethod(Method.GET_ZONE_LIST);
265
266		try {
267			getCommManager().sendIQGet(stanza, netBean, this);
268				
269		} catch (CommunicationException e) {
270			LOG.warn(e.getMessage());
271		};
272
273				// TYuck, another TODO this properly, for now, wait up to 5 secs
274				int i= 0;
275				while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
276					try {
277						i++;
278						Thread.sleep(WAIT_TIME_SECS);
279					} catch (InterruptedException e) {
280						// TODO Auto-generated catch block
281						e.printStackTrace();
282					}
283				}
284				
285		if (commsResult != null)
286			return this.commsResult.getZones();
287		
288		return null;
289	}
290
291	public UserDetails getFriendDetails(String friendid)
292	{
293		// We want to sent all messages for Netowrking Client to the metworking server
294		// hardcode for now TODO : Read from properties
295		IIdentity toIdentity = null;
296		commsResult = null;
297		try {
298			toIdentity = getCommManager().getIdManager().fromJid(netServerID);
299		} catch (InvalidFormatException e1) {
300			// TODO Auto-generated catch block
301			e1.printStackTrace();
302		}
303		Stanza stanza = new Stanza(toIdentity);
304		
305		// CREATE MESSAGE BEAN
306		NetworkingBean netBean = new NetworkingBean();
307		netBean.setMethod(Method.GETUSERDETAILS);
308		netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
309		netBean.setFrienduserid(friendid);
310		try {
311			getCommManager().sendIQGet(stanza, netBean, this);
312				
313		} catch (CommunicationException e) {
314			LOG.warn(e.getMessage());
315		};
316
317				// TYuck, another TODO this properly, for now, wait up to 5 secs
318				int i= 0;
319				while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
320					try {
321						i++;
322						Thread.sleep(WAIT_TIME_SECS);
323					} catch (InterruptedException e) {
324						// TODO Auto-generated catch block
325						e.printStackTrace();
326					}
327				}
328				
329		if (commsResult != null)
330			return this.commsResult.getUserDetails();
331		
332		return null;
333	}
334	
335	public UserDetails getMyDetails()
336	{
337		// We want to sent all messages for Netowrking Client to the metworking server
338		// hardcode for now TODO : Read from properties
339		IIdentity toIdentity = null;
340		commsResult = null;
341		try {
342			toIdentity = getCommManager().getIdManager().fromJid(netServerID);
343		} catch (InvalidFormatException e1) {
344			// TODO Auto-generated catch block
345			e1.printStackTrace();
346		}
347		Stanza stanza = new Stanza(toIdentity);
348		
349		// CREATE MESSAGE BEAN
350		NetworkingBean netBean = new NetworkingBean();
351		netBean.setMethod(Method.GETMYDETAILS);
352		netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
353		
354		try {
355			getCommManager().sendIQGet(stanza, netBean, this);
356				
357		} catch (CommunicationException e) {
358			LOG.warn(e.getMessage());
359		};
360
361				// TYuck, another TODO this properly, for now, wait up to 5 secs
362				int i= 0;
363				while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
364					try {
365						i++;
366						Thread.sleep(WAIT_TIME_SECS);
367					} catch (InterruptedException e) {
368						// TODO Auto-generated catch block
369						e.printStackTrace();
370					}
371				}
372				
373		if (commsResult != null)
374			return this.commsResult.getUserDetails();
375		
376		return null;
377	}
378	
379	public UserDetails updateMyDetails(UserDetails newDetails)
380	{
381		// We want to sent all messages for Netowrking Client to the metworking server
382		// hardcode for now TODO : Read from properties
383		IIdentity toIdentity = null;
384		commsResult = null;
385		try {
386			toIdentity = getCommManager().getIdManager().fromJid(netServerID);
387		} catch (InvalidFormatException e1) {
388			// TODO Auto-generated catch block
389			e1.printStackTrace();
390		}
391		Stanza stanza = new Stanza(toIdentity);
392		
393		// CREATE MESSAGE BEAN
394		NetworkingBean netBean = new NetworkingBean();
395		netBean.setMethod(Method.UPDATEMYDETAILS);
396		netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
397		
398		LOG.info("updateMyDetails : newDetails.getDisplayName() " +newDetails.getDisplayName());
399		newDetails.setUserid(netBean.getMyuserid());
400		netBean.setMyDetails(newDetails);
401		
402		try {
403			getCommManager().sendIQGet(stanza, netBean, this);
404				
405		} catch (CommunicationException e) {
406			LOG.warn(e.getMessage());
407		};
408
409				// TYuck, another TODO this properly, for now, wait up to 5 secs
410				int i= 0;
411				while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
412					try {
413						i++;
414						Thread.sleep(WAIT_TIME_SECS);
415					} catch (InterruptedException e) {
416						// TODO Auto-generated catch block
417						e.printStackTrace();
418					}
419				}
420				
421		if (commsResult != null)
422			return this.commsResult.getUserDetails();
423		
424		return null;
425	}
426	
427	
428	public ShareInfo getFriendShareInfo(String friendid)
429	{
430		// We want to sent all messages for Netowrking Client to the metworking server
431		// hardcode for now TODO : Read from properties
432		IIdentity toIdentity = null;
433		commsResult = null;
434		try {
435			toIdentity = getCommManager().getIdManager().fromJid(netServerID);
436		} catch (InvalidFormatException e1) {
437			// TODO Auto-generated catch block
438			e1.printStackTrace();
439		}
440		Stanza stanza = new Stanza(toIdentity);
441		
442		// CREATE MESSAGE BEAN
443		NetworkingBean netBean = new NetworkingBean();
444		netBean.setMethod(Method.GETFRIENDSHAREINFO);
445		netBean.setFrienduserid(friendid);
446		netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
447		
448		try {
449			getCommManager().sendIQGet(stanza, netBean, this);
450				
451		} catch (CommunicationException e) {
452			LOG.warn(e.getMessage());
453		};
454
455				// TYuck, another TODO this properly, for now, wait up to 5 secs
456				int i= 0;
457				while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
458					try {
459						i++;
460						Thread.sleep(WAIT_TIME_SECS);
461					} catch (InterruptedException e) {
462						// TODO Auto-generated catch block
463						e.printStackTrace();
464					}
465				}
466				
467		if (commsResult != null)
468			return this.commsResult.getSharedInfo();
469		
470		return null;
471	}
472	
473	public ShareInfo getShareInfo(String friendid)
474	{
475		// We want to sent all messages for Netowrking Client to the metworking server
476		// hardcode for now TODO : Read from properties
477		IIdentity toIdentity = null;
478		commsResult = null;
479		try {
480			toIdentity = getCommManager().getIdManager().fromJid(netServerID);
481		} catch (InvalidFormatException e1) {
482			// TODO Auto-generated catch block
483			e1.printStackTrace();
484		}
485		Stanza stanza = new Stanza(toIdentity);
486		
487		// CREATE MESSAGE BEAN
488		NetworkingBean netBean = new NetworkingBean();
489		netBean.setMethod(Method.GETSHAREINFO);
490		netBean.setFrienduserid(friendid);
491		netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
492		
493		try {
494			getCommManager().sendIQGet(stanza, netBean, this);
495				
496		} catch (CommunicationException e) {
497			LOG.warn(e.getMessage());
498		};
499
500				// TYuck, another TODO this properly, for now, wait up to 5 secs
501				int i= 0;
502				while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
503					try {
504						i++;
505						Thread.sleep(WAIT_TIME_SECS);
506					} catch (InterruptedException e) {
507						// TODO Auto-generated catch block
508						e.printStackTrace();
509					}
510				}
511				
512		if (commsResult != null)
513			return this.commsResult.getSharedInfo();
514		
515		return null;
516	}
517	
518	public ShareInfo updateShareInfo(ShareInfo info)
519	{
520		// We want to sent all messages for Netowrking Client to the metworking server
521		// hardcode for now TODO : Read from properties
522		IIdentity toIdentity = null;
523		commsResult = null;
524		try {
525			toIdentity = getCommManager().getIdManager().fromJid(netServerID);
526		} catch (InvalidFormatException e1) {
527			// TODO Auto-generated catch block
528			e1.printStackTrace();
529		}
530		Stanza stanza = new Stanza(toIdentity);
531		
532		// CREATE MESSAGE BEAN
533		NetworkingBean netBean = new NetworkingBean();
534		netBean.setMethod(Method.UPDATESHAREINFO);
535		netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
536		info.setUserid(netBean.getMyuserid());
537			
538		netBean.setSharedInfo(info);
539		
540		try {
541			getCommManager().sendIQGet(stanza, netBean, this);
542				
543		} catch (CommunicationException e) {
544			LOG.warn(e.getMessage());
545		};
546
547				// TYuck, another TODO this properly, for now, wait up to 5 secs
548				int i= 0;
549				while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
550					try {
551						i++;
552						Thread.sleep(WAIT_TIME_SECS);
553					} catch (InterruptedException e) {
554						// TODO Auto-generated catch block
555						e.printStackTrace();
556					}
557				}
558				
559		if (commsResult != null)
560			return this.commsResult.getSharedInfo();
561		
562		return null;
563	}
564	
565
566	public List<ZoneEvent> getCisActivity(String cisID)
567	{
568		
569		// We want to sent all messages for Netowrking Client to the metworking server
570		// hardcode for now TODO : Read from properties
571		IIdentity toIdentity = null;
572		commsResult = null;
573		try {
574			toIdentity = getCommManager().getIdManager().fromJid(netServerID);
575		} catch (InvalidFormatException e1) {
576			// TODO Auto-generated catch block
577			e1.printStackTrace();
578		}
579		Stanza stanza = new Stanza(toIdentity);
580				
581		// CREATE MESSAGE BEAN
582		NetworkingBean netBean = new NetworkingBean();
583		netBean.setMethod(Method.GETZONEEVENTS);
584		netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
585		netBean.setMycurrentzone(cisID);
586				
587		try {
588			getCommManager().sendIQGet(stanza, netBean, this);
589						
590		} catch (CommunicationException e) {
591			LOG.warn(e.getMessage());
592		};
593
594		// TYuck, another TODO this properly, for now, wait up to 5 secs
595		int i= 0;
596		while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
597			try {
598				i++;
599				Thread.sleep(WAIT_TIME_SECS);
600			} catch (InterruptedException e) {
601			// 	TODO Auto-generated catch block
602				e.printStackTrace();
603			}
604		}
605						
606		
607		if (commsResult != null)
608			return this.commsResult.getZoneeventlist();
609		
610		return null;
611		
612	}
613	
614	public List<MemberDetails> getMemberDetails(List<String> memberIDs)
615	{
616		
617		// We want to sent all messages for Netowrking Client to the metworking server
618		// hardcode for now TODO : Read from properties
619		IIdentity toIdentity = null;
620		commsResult = null;
621		try {
622			toIdentity = getCommManager().getIdManager().fromJid(netServerID);
623		} catch (InvalidFormatException e1) {
624			// TODO Auto-generated catch block
625			e1.printStackTrace();
626		}
627		Stanza stanza = new Stanza(toIdentity);
628				
629		// CREATE MESSAGE BEAN
630		NetworkingBean netBean = new NetworkingBean();
631		netBean.setMethod(Method.GETMEMBERDETAILS);
632		netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
633		netBean.setUseridlist(memberIDs);
634				
635		try {
636			getCommManager().sendIQGet(stanza, netBean, this);
637						
638		} catch (CommunicationException e) {
639			LOG.warn(e.getMessage());
640		};
641
642		// TYuck, another TODO this properly, for now, wait up to 5 secs
643		int i= 0;
644		while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
645			try {
646				i++;
647				Thread.sleep(WAIT_TIME_SECS);
648			} catch (InterruptedException e) {
649			// 	TODO Auto-generated catch block
650				e.printStackTrace();
651			}
652		}
653						
654		
655		if (commsResult != null)
656			return this.commsResult.getMemberdetaillist();
657		
658		return null;
659		
660	}
661	
662	public List<UserDetails> getUserDetailsList(List<String> memberIDs)
663	{
664		
665		// We want to sent all messages for Netowrking Client to the metworking server
666		// hardcode for now TODO : Read from properties
667		IIdentity toIdentity = null;
668		commsResult = null;
669		try {
670			toIdentity = getCommManager().getIdManager().fromJid(netServerID);
671		} catch (InvalidFormatException e1) {
672			// TODO Auto-generated catch block
673			e1.printStackTrace();
674		}
675		Stanza stanza = new Stanza(toIdentity);
676				
677		// CREATE MESSAGE BEAN
678		NetworkingBean netBean = new NetworkingBean();
679		netBean.setMethod(Method.GETUSERDETAILSLIST);
680		netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
681		netBean.setUseridlist(memberIDs);
682				
683		try {
684			getCommManager().sendIQGet(stanza, netBean, this);
685						
686		} catch (CommunicationException e) {
687			LOG.warn(e.getMessage());
688		};
689
690		// TYuck, another TODO this properly, for now, wait up to 5 secs
691		int i= 0;
692		while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
693			try {
694				i++;
695				Thread.sleep(WAIT_TIME_SECS);
696			} catch (InterruptedException e) {
697			// 	TODO Auto-generated catch block
698				e.printStackTrace();
699			}
700		}
701						
702		
703		if (commsResult != null)
704			return this.commsResult.getUserDetailsList();
705		
706		return null;
707		
708	}
709	
710
711	public List<String> addnote(String friendid, String note) {
712		// We want to sent all messages for Netowrking Client to the metworking server
713		// hardcode for now TODO : Read from properties
714		IIdentity toIdentity = null;
715		commsResult = null;
716		try {
717			toIdentity = getCommManager().getIdManager().fromJid(netServerID);
718		} catch (InvalidFormatException e1) {
719			// TODO Auto-generated catch block
720			e1.printStackTrace();
721		}
722		Stanza stanza = new Stanza(toIdentity);
723						
724		// CREATE MESSAGE BEAN
725		NetworkingBean netBean = new NetworkingBean();
726		netBean.setMethod(Method.ADDNOTE);
727		netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
728		netBean.setFrienduserid(friendid);
729		netBean.setNote(note);
730						
731		try {
732			getCommManager().sendIQGet(stanza, netBean, this);
733							
734		} catch (CommunicationException e) {
735			LOG.warn(e.getMessage());
736		};
737
738		// TYuck, another TODO this properly, for now, wait up to 5 secs
739		int i= 0;
740		while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
741			try {
742				i++;
743				Thread.sleep(WAIT_TIME_SECS);
744			} catch (InterruptedException e) {
745			// 	TODO Auto-generated catch block
746				e.printStackTrace();
747			}
748		}
749								
750				
751		if (commsResult != null)
752			return this.commsResult.getNotes();
753				
754		return null;
755	}
756
757	public List<String> getnotes(String friendid) {
758		// We want to sent all messages for Netowrking Client to the metworking server
759				// hardcode for now TODO : Read from properties
760				IIdentity toIdentity = null;
761				commsResult = null;
762				try {
763					toIdentity = getCommManager().getIdManager().fromJid(netServerID);
764				} catch (InvalidFormatException e1) {
765					// TODO Auto-generated catch block
766					e1.printStackTrace();
767				}
768				Stanza stanza = new Stanza(toIdentity);
769								
770				// CREATE MESSAGE BEAN
771				NetworkingBean netBean = new NetworkingBean();
772				netBean.setMethod(Method.GETNOTES);
773				netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
774				netBean.setFrienduserid(friendid);
775				
776								
777				try {
778					getCommManager().sendIQGet(stanza, netBean, this);
779									
780				} catch (CommunicationException e) {
781					LOG.warn(e.getMessage());
782				};
783
784				// TYuck, another TODO this properly, for now, wait up to 5 secs
785				int i= 0;
786				while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
787					try {
788						i++;
789						Thread.sleep(WAIT_TIME_SECS);
790					} catch (InterruptedException e) {
791					// 	TODO Auto-generated catch block
792						e.printStackTrace();
793					}
794				}
795										
796						
797				if (commsResult != null)
798					return this.commsResult.getNotes();
799						
800				return null;
801	}
802	
803	public List<ZoneDetails> getZoneDetails() {
804
805		IIdentity toIdentity = null;
806		commsResult = null;
807		try {
808			toIdentity = getCommManager().getIdManager().fromJid(netServerID);
809		} catch (InvalidFormatException e1) {
810			// TODO Auto-generated catch block
811			e1.printStackTrace();
812		}
813		Stanza stanza = new Stanza(toIdentity);
814								
815		// CREATE MESSAGE BEAN
816		NetworkingBean netBean = new NetworkingBean();
817		netBean.setMethod(Method.GETZONEDETAILS);
818	
819		try {
820			getCommManager().sendIQGet(stanza, netBean, this);
821		} catch (CommunicationException e) {
822			LOG.warn(e.getMessage());
823		};
824
825		// TYuck, another TODO this properly, for now, wait up to 5 secs
826		int i= 0;
827		while (commsResult == null && (i < (5 * TEST_TIME_MULTIPLER))){
828			try {
829				i++;
830				Thread.sleep(WAIT_TIME_SECS);
831			} catch (InterruptedException e) {
832				// 	TODO Auto-generated catch block
833				e.printStackTrace();
834			}
835		}
836										
837						
838		if (commsResult != null)
839			return this.commsResult.getZonedetails();
840						
841		return null;
842	}
843	
844	public NetworkingBeanResult getStartupInfo()
845	{
846		IIdentity toIdentity = null;
847		commsResult = null;
848		try {
849			toIdentity = getCommManager().getIdManager().fromJid(netServerID);
850		} catch (InvalidFormatException e1) {
851			// TODO Auto-generated catch block
852			e1.printStackTrace();
853		}
854		Stanza stanza = new Stanza(toIdentity);
855								
856		// CREATE MESSAGE BEAN
857		NetworkingBean netBean = new NetworkingBean();
858		netBean.setMethod(Method.GETSTARTUPINFO);
859		netBean.setMyuserid(getCommManager().getIdManager().getThisNetworkNode().getBareJid());
860		
861		try {
862			getCommManager().sendIQGet(stanza, netBean, this);
863		} catch (CommunicationException e) {
864			LOG.warn(e.getMessage());
865		};
866		
867		// Yuck, another TODO this properly, for now, wait up to 5 secs
868		int i= 0;
869		while (commsResult == null && (i < (50 * TEST_TIME_MULTIPLER))){
870			try {
871				i++;
872				Thread.sleep(WAIT_TIME_SECS);
873			} catch (InterruptedException e) {
874				e.printStackTrace();
875			}
876		}
877				
878		// Give commresult change to pupolate fully
879		try {
880			Thread.sleep(WAIT_TIME_SECS);
881		} catch (InterruptedException e) {
882			e.printStackTrace();
883		}						
884		
885		return this.commsResult;
886								
887	}
888
889	public String getNetServerID() {
890		return netServerID;
891	}
892
893	public void setNetServerID(String netServerID) {
894		this.netServerID = netServerID;
895	}
896
897}