1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.miloss.fgsms.presentation;
23
24 import java.util.List;
25 import org.apache.log4j.Level;
26
27 import org.miloss.fgsms.common.Utility;
28 import org.miloss.fgsms.services.interfaces.common.SecurityWrapper;
29 import org.miloss.fgsms.services.interfaces.dataaccessservice.DataAccessService;
30 import org.miloss.fgsms.services.interfaces.policyconfiguration.*;
31
32
33
34
35
36 public class ManageHelper {
37
38 GetProcessesListByMachineResponseMsg res = null;
39
40 public String GetPartitionNamesAsHtmlListboxForThroughput(String url, String domain, String machine, PCS pcsport, SecurityWrapper c, List<String> existingItems) {
41 GetProcessesListByMachineRequestMsg req = new GetProcessesListByMachineRequestMsg();
42 req.setClassification(c);
43 req.setHostname(machine);
44 StringBuilder s = new StringBuilder();
45 if (res == null) {
46 try {
47 res = pcsport.getProcessesListByMachine(req);
48 } catch (AccessDeniedException ex) {
49 LogHelper.getLog().log(Level.WARN, null, ex);
50 } catch (ServiceUnavailableException ex) {
51 LogHelper.getLog().log(Level.WARN, null, ex);
52 }
53 }
54 if (res != null && res.getMachineInformation() != null) {
55
56 s = s.append("<select name=\"recorddiskusage\" id=\"recorddiskusage\" multiple=\"multiple\" >");
57 for (int i = 0; i < res.getMachineInformation().getDriveInformation().size(); i++) {
58 s = s.append(" <option value=\"").append(Utility.encodeHTML(res.getMachineInformation().getDriveInformation().get(i).getSystemid())).append("\"");
59 if (isIn(res.getMachineInformation().getDriveInformation().get(i).getSystemid(), existingItems)) {
60 s = s.append(" selected ");
61 }
62 s = s.append(" >").
63 append(Utility.encodeHTML(res.getMachineInformation().getDriveInformation().get(i).getSystemid())).append("</option>");
64 }
65 s = s.append("</select>");
66 } else {
67 s = s.append("<input type=text name=\"recorddiskusage\" value=\"").append(Utility.encodeHTML(Utility.listStringtoString(existingItems))).append("\" >");
68 }
69 return s.toString();
70 }
71
72 public String GetNICNamesAsHtmlListbox(String url, String domain, String machine, PCS pcsport, SecurityWrapper c, List<String> existingItems) {
73 GetProcessesListByMachineRequestMsg req = new GetProcessesListByMachineRequestMsg();
74 req.setClassification(c);
75 req.setHostname(machine);
76 StringBuilder s = new StringBuilder();
77 if (res == null) {
78 try {
79 res = pcsport.getProcessesListByMachine(req);
80 } catch (AccessDeniedException ex) {
81 LogHelper.getLog().log(Level.WARN, null, ex);
82 } catch (ServiceUnavailableException ex) {
83 LogHelper.getLog().log(Level.WARN, null, ex);
84 }
85 }
86 if (res != null && res.getMachineInformation() != null) {
87
88 s = s.append("<select name=\"recordnetworkusage\" id=\"recordnetworkusage\" multiple=\"multiple\" >");
89 for (int i = 0; i < res.getMachineInformation().getAddresses().size(); i++) {
90 s = s.append(" <option value=\"").append(Utility.encodeHTML(res.getMachineInformation().getAddresses().get(i).getAdapterName())).append("\"");
91 if (isIn(res.getMachineInformation().getAddresses().get(i).getAdapterName(), existingItems)) {
92 s = s.append(" selected ");
93 }
94 s = s.append(" >").
95 append(Utility.encodeHTML(res.getMachineInformation().getAddresses().get(i).getAdapterName())).append(" on ").
96 append(Utility.encodeHTML(Utility.listStringtoString(res.getMachineInformation().getAddresses().get(i).getIp()))).append("</option>");
97 }
98 s = s.append("</select>");
99 } else {
100 s = s.append("<input type=text name=\"recordnetworkusage\" value=\"").append(Utility.encodeHTML(Utility.listStringtoString(existingItems))).append("\" >");
101 }
102 return s.toString();
103 }
104
105 public String GetPartitionNamesAsHtmlListboxForFreeSpace(String url, String domain, String machine, PCS pcsport, SecurityWrapper c, List<String> existingItems) {
106 GetProcessesListByMachineRequestMsg req = new GetProcessesListByMachineRequestMsg();
107 req.setClassification(c);
108 req.setHostname(machine);
109 StringBuilder s = new StringBuilder();
110 if (res == null) {
111 try {
112 res = pcsport.getProcessesListByMachine(req);
113 } catch (AccessDeniedException ex) {
114 LogHelper.getLog().log(Level.WARN, null, ex);
115 } catch (ServiceUnavailableException ex) {
116 LogHelper.getLog().log(Level.WARN, null, ex);
117 }
118 }
119 if (res != null && res.getMachineInformation() != null) {
120
121 s = s.append("<select name=\"recorddrivespace\" id=\"recorddrivespace\" multiple=\"multiple\" >");
122 for (int i = 0; i < res.getMachineInformation().getDriveInformation().size(); i++) {
123 s = s.append(" <option value=\"").append(Utility.encodeHTML(res.getMachineInformation().getDriveInformation().get(i).getSystemid())).append("\"");
124 if (isIn(res.getMachineInformation().getDriveInformation().get(i).getSystemid(), existingItems)) {
125 s = s.append(" selected ");
126 }
127 s = s.append(" >").
128 append(Utility.encodeHTML(res.getMachineInformation().getDriveInformation().get(i).getSystemid())).append("</option>");
129 }
130 s = s.append("</select>");
131 } else {
132 s = s.append("<input type=text name=\"recorddrivespace\" value=\"").append(Utility.encodeHTML(Utility.listStringtoString(existingItems))).append("\" >");
133 }
134 return s.toString();
135 }
136
137
138
139 private boolean isIn(String systemid, List<String> existingItems) {
140 for (int i = 0; i < existingItems.size(); i++) {
141 if (systemid.equalsIgnoreCase(existingItems.get(i))) {
142 return true;
143 }
144 }
145 return false;
146 }
147 }