|
From: <the...@us...> - 2003-12-18 15:30:21
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/controller
In directory sc8-pr-cvs1:/tmp/cvs-serv581
Modified Files:
WhoIsOnlineAction.java
Log Message:
commented; now uses HostIteratorProvider.getOnlineComputerIterator();
Index: WhoIsOnlineAction.java
===================================================================
RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/controller/WhoIsOnlineAction.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** WhoIsOnlineAction.java 18 Dec 2003 09:14:32 -0000 1.3
--- WhoIsOnlineAction.java 18 Dec 2003 15:30:17 -0000 1.4
***************
*** 43,53 ****
/**
! *
! * @author mp
*/
public class WhoIsOnlineAction extends Action {
public static final String KEY_ONLINE_ITERATOR = "wio-iterator";
public static final String KEY_NUM_ONLINE = "wio-num-online";
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm,
--- 43,64 ----
/**
! * Action Handler for WhoIsOnline page
! * @author Marcus Proest (theevilflow at users dot sf dot net)
*/
public class WhoIsOnlineAction extends Action {
+ /** key to retrieve the iterating object */
public static final String KEY_ONLINE_ITERATOR = "wio-iterator";
+
+ /** key to retrieve the size of the iterating object */
public static final String KEY_NUM_ONLINE = "wio-num-online";
+ /** execute method of the action
+ * @param actionMapping actionMapping
+ * @param actionForm actionForm
+ * @param httpServletRequest httpServletRequest
+ * @param httpServletRespone httpServletRespone
+ * @return actionforward
+ * @throws Exception Exception
+ */
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm,
***************
*** 55,84 ****
HttpServletResponse httpServletRespone)
throws Exception {
HostMap hosts = (HostMap) getServlet().getServletContext()
.getAttribute(ScannerPlugin.KEY_HOSTS_MAP);
! Iterator i = hosts.getOnlineIterator();
TreeSet sortedOnline = new TreeSet();
while (i.hasNext()) {
! String ip = (String) i.next();
! NameOnline no = (NameOnline) hosts.get(ip);
!
! Computer c = new Computer();
!
! c.setIp(ip);
! c.setName(no.getName());
! c.setNetFiles(null);
! c.setOnline(no.getOnline());
! sortedOnline.add(c);
}
i = sortedOnline.iterator();
! int w = 3; //this will be a parameter
! int h = (sortedOnline.size() / w) + 1;
! ArrayList col = new ArrayList();
for (int x = 0; x < h; x++) {
ArrayList row = new ArrayList();
--- 66,89 ----
HttpServletResponse httpServletRespone)
throws Exception {
+ //get hostmap from context
HostMap hosts = (HostMap) getServlet().getServletContext()
.getAttribute(ScannerPlugin.KEY_HOSTS_MAP);
! Iterator i = hosts.getOnlineComputerIterator();
TreeSet sortedOnline = new TreeSet();
+ //create a sorted set of computers
while (i.hasNext()) {
! sortedOnline.add(i.next());
}
i = sortedOnline.iterator();
! int w = 3; //this will be a parameter //write w hosts in a row
! int h = (sortedOnline.size() / w) + 1; //height of the table
! ArrayList col = new ArrayList(); //this will be saved to the request
+ //create some sort of a multidimensional ArrayList object
for (int x = 0; x < h; x++) {
ArrayList row = new ArrayList();
***************
*** 90,94 ****
row.add(c);
} else {
! break;
}
}
--- 95,99 ----
row.add(c);
} else {
! row.add(null);
}
}
***************
*** 97,102 ****
}
httpServletRequest.setAttribute(KEY_ONLINE_ITERATOR, col);
! httpServletRequest.setAttribute(KEY_NUM_ONLINE, new Integer(sortedOnline.size()));
--- 102,110 ----
}
+
+ //save to the request
httpServletRequest.setAttribute(KEY_ONLINE_ITERATOR, col);
! httpServletRequest.setAttribute(KEY_NUM_ONLINE,
! new Integer(sortedOnline.size()));
|