5426 |
24 Sep 10 |
nicklas |
1 |
<%@ page pageEncoding="UTF-8" session="false" |
4320 |
29 May 08 |
nicklas |
2 |
import="net.sf.basedb.core.SessionControl" |
4320 |
29 May 08 |
nicklas |
3 |
import="net.sf.basedb.core.Application" |
4320 |
29 May 08 |
nicklas |
4 |
import="net.sf.basedb.core.DbControl" |
4320 |
29 May 08 |
nicklas |
5 |
import="net.sf.basedb.core.Permission" |
4618 |
30 Oct 08 |
nicklas |
6 |
import="net.sf.basedb.util.error.ThrowableUtil" |
4320 |
29 May 08 |
nicklas |
7 |
import="net.sf.basedb.util.extensions.ActionIterator" |
4320 |
29 May 08 |
nicklas |
8 |
import="net.sf.basedb.util.extensions.Extension" |
4320 |
29 May 08 |
nicklas |
9 |
import="net.sf.basedb.util.extensions.ExtensionsFilter" |
4320 |
29 May 08 |
nicklas |
10 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
4618 |
30 Oct 08 |
nicklas |
11 |
import="net.sf.basedb.util.extensions.Registry" |
4320 |
29 May 08 |
nicklas |
12 |
import="net.sf.basedb.clients.web.Base" |
4320 |
29 May 08 |
nicklas |
13 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
4320 |
29 May 08 |
nicklas |
14 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
4320 |
29 May 08 |
nicklas |
15 |
import="net.sf.basedb.clients.web.extensions.service.ServiceControllerAction" |
4320 |
29 May 08 |
nicklas |
16 |
import="net.sf.basedb.clients.web.extensions.service.Services" |
8144 |
21 Apr 23 |
nicklas |
17 |
import="net.sf.basedb.util.extensions.logging.ExtensionsLog" |
4320 |
29 May 08 |
nicklas |
18 |
import="java.util.Iterator" |
4320 |
29 May 08 |
nicklas |
19 |
%> |
4320 |
29 May 08 |
nicklas |
20 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
4320 |
29 May 08 |
nicklas |
21 |
<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
7271 |
19 Jan 17 |
nicklas |
22 |
<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
4320 |
29 May 08 |
nicklas |
23 |
<% |
4320 |
29 May 08 |
nicklas |
24 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
4320 |
29 May 08 |
nicklas |
25 |
final String ID = sc.getId(); |
4320 |
29 May 08 |
nicklas |
26 |
String cmd = request.getParameter("cmd"); |
4320 |
29 May 08 |
nicklas |
27 |
|
7954 |
12 May 21 |
nicklas |
28 |
DbControl dc = sc.newDbControl(":List service extensions"); |
4320 |
29 May 08 |
nicklas |
29 |
|
4320 |
29 May 08 |
nicklas |
30 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext); |
7605 |
26 Feb 19 |
nicklas |
31 |
ExtensionsInvoker<ServiceControllerAction> invoker = ExtensionsControl.useExtensions(jspContext, |
4320 |
29 May 08 |
nicklas |
32 |
(ExtensionsFilter)null, Services.EXTENSION_POINT_ID); |
4320 |
29 May 08 |
nicklas |
33 |
ExtensionsControl ec = ExtensionsControl.get(dc); |
4320 |
29 May 08 |
nicklas |
34 |
boolean writePermission = ec.hasPermission(Permission.WRITE); |
4320 |
29 May 08 |
nicklas |
35 |
ActionIterator<ServiceControllerAction> it = invoker.iterate(); |
4320 |
29 May 08 |
nicklas |
36 |
int numServices = 0; |
4320 |
29 May 08 |
nicklas |
37 |
|
7604 |
25 Feb 19 |
nicklas |
38 |
ExtensionsInvoker<ServiceControllerAction> actionsInvoker = |
7605 |
26 Feb 19 |
nicklas |
39 |
ExtensionsControl.useExtensions(jspContext, "net.sf.basedb.clients.web.services.list.actions"); |
4320 |
29 May 08 |
nicklas |
40 |
try |
4320 |
29 May 08 |
nicklas |
41 |
{ |
8144 |
21 Apr 23 |
nicklas |
42 |
%> |
8144 |
21 Apr 23 |
nicklas |
43 |
<base:page title="Manage Services" id="list-page"> |
7271 |
19 Jan 17 |
nicklas |
44 |
<base:head scripts="table.js,~services.js" styles="table.css"> |
8144 |
21 Apr 23 |
nicklas |
45 |
<ext:scripts context="<%=jspContext%>" /> |
7271 |
19 Jan 17 |
nicklas |
46 |
<ext:stylesheets context="<%=jspContext%>" /> |
7271 |
19 Jan 17 |
nicklas |
47 |
</base:head> |
4320 |
29 May 08 |
nicklas |
48 |
<base:body> |
5949 |
08 Feb 12 |
nicklas |
49 |
<h1>Manage Services</h1> |
5949 |
08 Feb 12 |
nicklas |
50 |
<div class="content"> |
4320 |
29 May 08 |
nicklas |
51 |
<tbl:table |
4320 |
29 May 08 |
nicklas |
52 |
id="services" |
5949 |
08 Feb 12 |
nicklas |
53 |
subclass="fulltable topborder" |
4320 |
29 May 08 |
nicklas |
54 |
columns="all" |
7943 |
04 May 21 |
nicklas |
55 |
stickyheaders="<%=null%>" |
4320 |
29 May 08 |
nicklas |
56 |
> |
4320 |
29 May 08 |
nicklas |
57 |
<tbl:columndef |
4320 |
29 May 08 |
nicklas |
58 |
id="extension" |
4320 |
29 May 08 |
nicklas |
59 |
title="Extension" |
4320 |
29 May 08 |
nicklas |
60 |
/> |
4320 |
29 May 08 |
nicklas |
61 |
<tbl:columndef |
4320 |
29 May 08 |
nicklas |
62 |
id="service" |
4320 |
29 May 08 |
nicklas |
63 |
title="Service" |
4320 |
29 May 08 |
nicklas |
64 |
/> |
4320 |
29 May 08 |
nicklas |
65 |
<tbl:columndef |
4320 |
29 May 08 |
nicklas |
66 |
id="status" |
4320 |
29 May 08 |
nicklas |
67 |
title="Status" |
4320 |
29 May 08 |
nicklas |
68 |
/> |
4320 |
29 May 08 |
nicklas |
69 |
<tbl:columndef |
4320 |
29 May 08 |
nicklas |
70 |
id="actions" |
4320 |
29 May 08 |
nicklas |
71 |
title="Actions" |
4320 |
29 May 08 |
nicklas |
72 |
/> |
5949 |
08 Feb 12 |
nicklas |
73 |
<tbl:data style="top: 0px; margin-top: 0px;"> |
5949 |
08 Feb 12 |
nicklas |
74 |
<tbl:headers> |
5949 |
08 Feb 12 |
nicklas |
75 |
<tbl:headerrow> |
5949 |
08 Feb 12 |
nicklas |
76 |
<tbl:columnheaders /> |
5949 |
08 Feb 12 |
nicklas |
77 |
</tbl:headerrow> |
5949 |
08 Feb 12 |
nicklas |
78 |
</tbl:headers> |
4320 |
29 May 08 |
nicklas |
79 |
<tbl:rows> |
4320 |
29 May 08 |
nicklas |
80 |
<% |
7604 |
25 Feb 19 |
nicklas |
81 |
Extension<? extends ServiceControllerAction> last = null; |
8144 |
21 Apr 23 |
nicklas |
82 |
while (it.hasNext()) |
8144 |
21 Apr 23 |
nicklas |
83 |
{ |
8144 |
21 Apr 23 |
nicklas |
84 |
numServices++; |
8144 |
21 Apr 23 |
nicklas |
85 |
ServiceControllerAction action = it.next(); |
8144 |
21 Apr 23 |
nicklas |
86 |
Extension<? extends ServiceControllerAction> ext = it.getExtension(); |
8144 |
21 Apr 23 |
nicklas |
87 |
boolean isNewExtension = ext != last; |
8144 |
21 Apr 23 |
nicklas |
88 |
last = ext; |
8144 |
21 Apr 23 |
nicklas |
89 |
ExtensionsLog serviceLog = ExtensionsLog.getLog(ext.getId(), false); |
8144 |
21 Apr 23 |
nicklas |
90 |
String serviceLogSummary = ""; |
8144 |
21 Apr 23 |
nicklas |
91 |
String serviceLogIcon = "service_log.png"; |
8144 |
21 Apr 23 |
nicklas |
92 |
if (serviceLog != null) |
8144 |
21 Apr 23 |
nicklas |
93 |
{ |
8144 |
21 Apr 23 |
nicklas |
94 |
serviceLogSummary = "View the log for this service; "+ |
8144 |
21 Apr 23 |
nicklas |
95 |
serviceLog.getNumEntries() +" entries; " + |
8144 |
21 Apr 23 |
nicklas |
96 |
serviceLog.getNumErrors()+" errors; "+ |
8144 |
21 Apr 23 |
nicklas |
97 |
serviceLog.getNumWarnings()+" warnings"; |
8144 |
21 Apr 23 |
nicklas |
98 |
if (serviceLog.getNumErrors() > 0) |
8144 |
21 Apr 23 |
nicklas |
99 |
{ |
8144 |
21 Apr 23 |
nicklas |
100 |
serviceLogIcon = "service_log_error.png"; |
8144 |
21 Apr 23 |
nicklas |
101 |
} |
8144 |
21 Apr 23 |
nicklas |
102 |
else if (serviceLog.getNumWarnings() > 0) |
8144 |
21 Apr 23 |
nicklas |
103 |
{ |
8144 |
21 Apr 23 |
nicklas |
104 |
serviceLogIcon = "service_log_warning.png"; |
8144 |
21 Apr 23 |
nicklas |
105 |
} |
8144 |
21 Apr 23 |
nicklas |
106 |
} |
8144 |
21 Apr 23 |
nicklas |
107 |
boolean isRunning = false; |
8144 |
21 Apr 23 |
nicklas |
108 |
Throwable error = null; |
8144 |
21 Apr 23 |
nicklas |
109 |
try |
8144 |
21 Apr 23 |
nicklas |
110 |
{ |
8144 |
21 Apr 23 |
nicklas |
111 |
isRunning = action.isRunning(); |
8144 |
21 Apr 23 |
nicklas |
112 |
if (!isRunning) error = ec.getLastExtensionError(ext.getId()); |
8144 |
21 Apr 23 |
nicklas |
113 |
} |
8144 |
21 Apr 23 |
nicklas |
114 |
catch (Throwable t) |
8144 |
21 Apr 23 |
nicklas |
115 |
{ |
8144 |
21 Apr 23 |
nicklas |
116 |
error = t; |
8144 |
21 Apr 23 |
nicklas |
117 |
} |
8144 |
21 Apr 23 |
nicklas |
118 |
boolean hasError = error != null; |
8144 |
21 Apr 23 |
nicklas |
119 |
%> |
4320 |
29 May 08 |
nicklas |
120 |
<tbl:row> |
4320 |
29 May 08 |
nicklas |
121 |
<tbl:cell column="extension"> |
4320 |
29 May 08 |
nicklas |
122 |
<% |
4320 |
29 May 08 |
nicklas |
123 |
if (isNewExtension) |
4320 |
29 May 08 |
nicklas |
124 |
{ |
4320 |
29 May 08 |
nicklas |
125 |
%> |
4320 |
29 May 08 |
nicklas |
126 |
<%=ext.getId()%> |
4320 |
29 May 08 |
nicklas |
127 |
<% |
4320 |
29 May 08 |
nicklas |
128 |
} |
4320 |
29 May 08 |
nicklas |
129 |
%> |
4320 |
29 May 08 |
nicklas |
130 |
</tbl:cell> |
4320 |
29 May 08 |
nicklas |
131 |
<tbl:cell column="service"><%=action.toString()%></tbl:cell> |
4618 |
30 Oct 08 |
nicklas |
132 |
<tbl:cell column="status"> |
4618 |
30 Oct 08 |
nicklas |
133 |
<% |
4618 |
30 Oct 08 |
nicklas |
134 |
if (hasError) |
4618 |
30 Oct 08 |
nicklas |
135 |
{ |
4618 |
30 Oct 08 |
nicklas |
136 |
%> |
5949 |
08 Feb 12 |
nicklas |
137 |
<div class="messagecontainer error"> |
6290 |
05 Jun 13 |
nicklas |
138 |
<base:icon |
6290 |
05 Jun 13 |
nicklas |
139 |
id="<%="toggle-stacktrace."+ext.getId()%>" |
6290 |
05 Jun 13 |
nicklas |
140 |
subclass="auto-init" |
6290 |
05 Jun 13 |
nicklas |
141 |
data-auto-init="toggle-stacktrace" |
6290 |
05 Jun 13 |
nicklas |
142 |
data-extension-id="<%=ext.getId() %>" |
6290 |
05 Jun 13 |
nicklas |
143 |
image="error.png" |
6290 |
05 Jun 13 |
nicklas |
144 |
style="float: left;" |
6290 |
05 Jun 13 |
nicklas |
145 |
tooltip="Error - click to show full stack trace" |
4618 |
30 Oct 08 |
nicklas |
146 |
/><%=error.getMessage() %> |
4618 |
30 Oct 08 |
nicklas |
147 |
<div id="stacktrace.<%=ext.getId()%>" |
4618 |
30 Oct 08 |
nicklas |
148 |
class="stacktrace" |
4618 |
30 Oct 08 |
nicklas |
149 |
style="display: none;" |
4618 |
30 Oct 08 |
nicklas |
150 |
><%=ThrowableUtil.stackTraceToString(error)%></div> |
4618 |
30 Oct 08 |
nicklas |
151 |
</div> |
4618 |
30 Oct 08 |
nicklas |
152 |
<% |
4618 |
30 Oct 08 |
nicklas |
153 |
} |
4618 |
30 Oct 08 |
nicklas |
154 |
else |
4618 |
30 Oct 08 |
nicklas |
155 |
{ |
4618 |
30 Oct 08 |
nicklas |
156 |
%> |
4618 |
30 Oct 08 |
nicklas |
157 |
<%=isRunning ? "Running" : "Stopped"%> |
4618 |
30 Oct 08 |
nicklas |
158 |
<% |
4618 |
30 Oct 08 |
nicklas |
159 |
} |
4618 |
30 Oct 08 |
nicklas |
160 |
%> |
4618 |
30 Oct 08 |
nicklas |
161 |
</tbl:cell> |
4320 |
29 May 08 |
nicklas |
162 |
<tbl:cell column="actions"> |
4320 |
29 May 08 |
nicklas |
163 |
<% |
7271 |
19 Jan 17 |
nicklas |
164 |
if (writePermission) |
4320 |
29 May 08 |
nicklas |
165 |
{ |
7271 |
19 Jan 17 |
nicklas |
166 |
if (isNewExtension) |
4320 |
29 May 08 |
nicklas |
167 |
{ |
7271 |
19 Jan 17 |
nicklas |
168 |
if (isRunning) |
7271 |
19 Jan 17 |
nicklas |
169 |
{ |
7271 |
19 Jan 17 |
nicklas |
170 |
%> |
7271 |
19 Jan 17 |
nicklas |
171 |
<base:icon |
7271 |
19 Jan 17 |
nicklas |
172 |
id="<%="stop."+ext.getId()%>" |
7271 |
19 Jan 17 |
nicklas |
173 |
subclass="auto-init" |
7271 |
19 Jan 17 |
nicklas |
174 |
data-auto-init="control-service" |
7271 |
19 Jan 17 |
nicklas |
175 |
data-cmd="Stop" |
7271 |
19 Jan 17 |
nicklas |
176 |
data-extension-id="<%=ext.getId()%>" |
7271 |
19 Jan 17 |
nicklas |
177 |
image="stop.png" |
7271 |
19 Jan 17 |
nicklas |
178 |
tooltip="Stop all services in this extension" |
7271 |
19 Jan 17 |
nicklas |
179 |
/> |
7271 |
19 Jan 17 |
nicklas |
180 |
<% |
7271 |
19 Jan 17 |
nicklas |
181 |
} |
7271 |
19 Jan 17 |
nicklas |
182 |
else |
7271 |
19 Jan 17 |
nicklas |
183 |
{ |
7271 |
19 Jan 17 |
nicklas |
184 |
%> |
7271 |
19 Jan 17 |
nicklas |
185 |
<base:icon |
7271 |
19 Jan 17 |
nicklas |
186 |
id="<%="start."+ext.getId()%>" |
7271 |
19 Jan 17 |
nicklas |
187 |
subclass="auto-init" |
7271 |
19 Jan 17 |
nicklas |
188 |
data-auto-init="control-service" |
7271 |
19 Jan 17 |
nicklas |
189 |
data-cmd="Start" |
7271 |
19 Jan 17 |
nicklas |
190 |
data-extension-id="<%=ext.getId()%>" |
7271 |
19 Jan 17 |
nicklas |
191 |
image="start.png" |
7271 |
19 Jan 17 |
nicklas |
192 |
tooltip="Start all services in this extension" |
7271 |
19 Jan 17 |
nicklas |
193 |
/> |
7271 |
19 Jan 17 |
nicklas |
194 |
<% |
7271 |
19 Jan 17 |
nicklas |
195 |
} |
4320 |
29 May 08 |
nicklas |
196 |
} |
7271 |
19 Jan 17 |
nicklas |
197 |
%> |
8144 |
21 Apr 23 |
nicklas |
198 |
<base:icon |
8144 |
21 Apr 23 |
nicklas |
199 |
id="<%="log."+ext.getId()%>" |
8144 |
21 Apr 23 |
nicklas |
200 |
subclass="auto-init" |
8144 |
21 Apr 23 |
nicklas |
201 |
data-auto-init="view-log" |
8144 |
21 Apr 23 |
nicklas |
202 |
data-extension-id="<%=ext.getId()%>" |
8144 |
21 Apr 23 |
nicklas |
203 |
image="<%=serviceLogIcon%>" |
8144 |
21 Apr 23 |
nicklas |
204 |
tooltip="<%=serviceLogSummary%>" |
8144 |
21 Apr 23 |
nicklas |
205 |
visible="<%=serviceLog != null%>" |
8144 |
21 Apr 23 |
nicklas |
206 |
/> |
7271 |
19 Jan 17 |
nicklas |
207 |
<ext:render extensions="<%=actionsInvoker%>" context="<%=jspContext%>" item="<%=action%>" /> |
7271 |
19 Jan 17 |
nicklas |
208 |
<% |
4320 |
29 May 08 |
nicklas |
209 |
} |
4320 |
29 May 08 |
nicklas |
210 |
%> |
4320 |
29 May 08 |
nicklas |
211 |
</tbl:cell> |
4320 |
29 May 08 |
nicklas |
212 |
</tbl:row> |
4320 |
29 May 08 |
nicklas |
213 |
<% |
4320 |
29 May 08 |
nicklas |
214 |
} |
5949 |
08 Feb 12 |
nicklas |
215 |
if (numServices == 0) |
5949 |
08 Feb 12 |
nicklas |
216 |
{ |
5949 |
08 Feb 12 |
nicklas |
217 |
%> |
6604 |
18 Nov 14 |
nicklas |
218 |
<tbl:panel subclass="bg-filled-50"> |
5949 |
08 Feb 12 |
nicklas |
219 |
<div class="messagecontainer note">No services are installed</div> |
5949 |
08 Feb 12 |
nicklas |
220 |
</tbl:panel> |
5949 |
08 Feb 12 |
nicklas |
221 |
<% |
5949 |
08 Feb 12 |
nicklas |
222 |
} |
4320 |
29 May 08 |
nicklas |
223 |
%> |
4320 |
29 May 08 |
nicklas |
224 |
</tbl:rows> |
4320 |
29 May 08 |
nicklas |
225 |
</tbl:data> |
4320 |
29 May 08 |
nicklas |
226 |
</tbl:table> |
5949 |
08 Feb 12 |
nicklas |
227 |
</div> |
4320 |
29 May 08 |
nicklas |
228 |
</base:body> |
4320 |
29 May 08 |
nicklas |
229 |
</base:page> |
4320 |
29 May 08 |
nicklas |
230 |
<% |
4320 |
29 May 08 |
nicklas |
231 |
} |
4320 |
29 May 08 |
nicklas |
232 |
finally |
4320 |
29 May 08 |
nicklas |
233 |
{ |
4320 |
29 May 08 |
nicklas |
234 |
if (dc != null) dc.close(); |
4320 |
29 May 08 |
nicklas |
235 |
} |
4320 |
29 May 08 |
nicklas |
236 |
%> |