source: trunk/www/admin/extensions/details.jsp @ 6259

Last change on this file since 6259 was 6259, checked in by Nicklas Nordborg, 10 years ago

References #1729 and #1730. Fixed for the extension manager except the frame with the tree outline.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 14.7 KB
Line 
1<%-- $Id:details.jsp 4187 2008-03-20 11:15:25Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Nicklas Nordborg
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 3
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with BASE. If not, see <http://www.gnu.org/licenses/>.
20  ------------------------------------------------------------------
21
22  @author Nicklas
23  @version 2.0
24--%>
25<%@ page pageEncoding="UTF-8" session="false"
26  import="net.sf.basedb.core.SessionControl"
27  import="net.sf.basedb.core.DbControl"
28  import="net.sf.basedb.core.Client"
29  import="net.sf.basedb.core.PluginDefinition"
30  import="net.sf.basedb.core.Item"
31  import="net.sf.basedb.core.Permission"
32  import="net.sf.basedb.clients.web.Base"
33  import="net.sf.basedb.clients.web.util.HTML"
34  import="net.sf.basedb.util.Values"
35  import="net.sf.basedb.core.ItemNotFoundException"
36  import="net.sf.basedb.util.error.ThrowableUtil"
37  import="net.sf.basedb.util.extensions.ExtensionPoint"
38  import="net.sf.basedb.util.extensions.Extension"
39  import="net.sf.basedb.util.extensions.ActionFactory"
40  import="net.sf.basedb.util.extensions.RendererFactory"
41  import="net.sf.basedb.util.extensions.AboutBean"
42  import="net.sf.basedb.util.extensions.manager.ExtensionsFile"
43  import="net.sf.basedb.util.extensions.manager.ExtensionPointKey"
44  import="net.sf.basedb.util.extensions.manager.ExtensionKey"
45  import="net.sf.basedb.util.extensions.manager.PluginInfoKey"
46  import="net.sf.basedb.util.extensions.manager.FactoryParametersKey"
47  import="net.sf.basedb.util.extensions.manager.ProcessResults"
48  import="net.sf.basedb.util.extensions.manager.ProcessResults.FileResults"
49  import="net.sf.basedb.util.extensions.xml.PluginInfo"
50  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
51  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
52  import="net.sf.basedb.util.formatter.Formatter"
53  import="net.sf.basedb.core.plugin.About"
54  import="java.util.List"
55  import="java.util.Date"
56  import="java.util.Iterator"
57%>
58<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
59<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
60<%!
61String displayFactory(ExtensionsFile file, Object factory)
62{
63  if (factory == null)
64  {
65    return "<i>- none -</i>";
66  }
67  String text = factory.getClass().getName();
68  String parameters = file == null ? null : file.getMetadata(new FactoryParametersKey(factory));
69  if (parameters != null)
70  {
71    text += "<pre>" + HTML.encodeTags(parameters) + "</pre>";
72  }
73  return text;
74}
75%>
76<%
77final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
78final String ID = sc.getId();
79final float scale = Base.getScale(sc);
80String extensionId = request.getParameter("extensionId");
81String extensionPointId = request.getParameter("extensionPointId");
82String fileuri = request.getParameter("fileuri");
83
84DbControl dc = sc.newDbControl();
85try
86{
87  final ExtensionsControl ec = ExtensionsControl.get(dc);
88  final boolean writePermission = ec.hasPermission(Permission.WRITE);
89 
90  Extension<?> ext = null;
91  ExtensionPoint<?> ep = null;
92  ExtensionsFile file = null;
93  ExtensionsFile extFile = null;
94  ExtensionsFile epFile = null;
95
96  if (fileuri != null)
97  {
98    file = ec.getFile(fileuri);
99    if (file == null)
100    {
101      throw new ItemNotFoundException("ExtensionsFile[uri=" + fileuri + "]");
102    }
103  }
104 
105  if (extensionId != null)
106  {
107    ext = ec.getExtension(extensionId);
108    if (ext == null)
109    {
110      throw new ItemNotFoundException("Extension[id=" + extensionId + "]");
111    }
112    extensionPointId = ext.getExtends();
113    extFile = ec.getFileByObjectKey(new ExtensionKey(extensionId));
114  }
115 
116  if (extensionPointId != null)
117  {
118    ep = ec.getExtensionPoint(extensionPointId);
119    if (ep == null)
120    {
121      throw new ItemNotFoundException("ExtensionPoint[id=" + extensionPointId + "]");
122    }
123    epFile = ec.getFileByObjectKey(new ExtensionPointKey(extensionPointId));
124  }
125%>
126<base:page title="" type="iframe">
127  <base:head scripts="newjoust.js,table.js,dragdrop.js,~details.js" styles="newjoust.css,table.css,toolbar.css" />
128  <base:body>
129
130    <div class="absolutefull auto-init" data-auto-init="drag-support">
131
132    <tbl:toolbar subclass="bottomborder">
133    <tbl:button
134      id="btnInstall"
135      title="Install/uninstall&hellip;"
136      image="new_wizard.png"
137      tooltip="Install and uninstall extensions and plug-ins"
138      disabled="<%=!writePermission%>"
139    />
140    <%
141    if (ext != null)
142    {
143      boolean isEnabled = ec.isEnabled(ext);
144      boolean hasRegistrationError = extFile != null && extFile.hasError();
145      boolean allow = writePermission && !hasRegistrationError;
146      %>
147      <tbl:button 
148        id="btnToggleExtension"
149        data-extension-id="<%=extensionId%>"
150        data-is-enabled="<%=isEnabled ? "1" : "0"%>"
151        title="<%=isEnabled ? "Disable" : "Enable" %>" 
152        image="<%=allow ? "joust/extension.png" : "joust/extensiondisabled.png" %>"
153        tooltip="Disable/enable this extension"
154        disabled="<%=!allow%>"
155      />
156      <tbl:button
157        image="help.png"
158        subclass="auto-init"
159        data-auto-init="help"
160        data-help-id="extensions.details.extension"
161        title="Help&hellip;"
162        tooltip="Get help about this page"
163      />
164      <%
165    }
166    else if (ep != null)
167    {
168      boolean isEnabled = ec.isEnabled(ep);
169      boolean hasRegistrationError = epFile != null && epFile.hasError();
170      boolean allow = writePermission && !hasRegistrationError;
171      %>
172      <tbl:button 
173        id="btnToggleExtensionPoint"
174        data-extension-point-id="<%=extensionPointId%>"
175        data-is-enabled="<%=isEnabled ? "1" : "0"%>"
176        title="<%=isEnabled ? "Disable" : "Enable" %>" 
177        image="<%=allow ? "joust/extensionpoint.png" : "joust/extensionpointdisabled.png" %>"
178        tooltip="Disable this extension point"
179        disabled="<%=!allow%>"
180      />
181      <tbl:button
182        image="help.png"
183        subclass="auto-init"
184        data-auto-init="help"
185        data-help-id="extensions.details.extensionspoint"
186        title="Help&hellip;"
187        tooltip="Get help about this page"
188      />
189      <%
190    }
191    else if (file != null)
192    {
193      boolean hasRegistrationError = file.hasError();
194      boolean allow = writePermission && !hasRegistrationError;
195      %>
196      <tbl:button
197        id="btnEnableFile" 
198        data-file-name="<%=HTML.encodeTags(file.getName())%>"
199        data-file-uri="<%=HTML.encodeTags(fileuri)%>"
200        data-enable="1"
201        title="Enable all" 
202        image="<%=allow ? "joust/extension.png" : "joust/extensiondisabled.png" %>"
203        tooltip="Enable all extensions in this file"
204        disabled="<%=!allow%>"
205      />
206      <tbl:button 
207        id="btnDisableFile" 
208        data-file-name="<%=HTML.encodeTags(file.getName())%>"
209        data-file-uri="<%=HTML.encodeTags(fileuri)%>"
210        data-enable="0"
211        title="Disable all" 
212        image="<%=allow ? "joust/extension.png" : "joust/extensiondisabled.png" %>"
213        tooltip="Disable all extensions in this file"
214        disabled="<%=!allow%>"
215      />
216      <%
217    }
218    else
219    {
220      %>
221      <tbl:button
222        image="help.png"
223        subclass="auto-init"
224        data-auto-init="help"
225        data-help-id="extensions.details.main"
226        title="Help&hellip;"
227        tooltip="Get help about this page"
228      />
229      <%
230    }
231    %>
232    </tbl:toolbar>
233
234    <div class="bottomborder">
235      <table class="fullform outlined">
236      <%
237      if (ext != null)
238      {
239        About about = ext.getAbout();
240        if (about == null) about = new AboutBean();
241        Throwable error = ec.getLastExtensionError(ext.getId());
242        %>
243        <tbody>
244        <%
245        if (error != null)
246        {
247          %>
248          <tr>
249            <th></th>
250            <td>
251            <div class="messagecontainer error">
252              <base:icon image="error.png"
253                subclass="auto-init link"
254                data-auto-init="toggle-stacktrace"
255                data-stacktrace-id="<%="stacktrace." + ext.getId()%>"
256                style="float: left; margin-right: 5px;"
257                tooltip="Error - click to show full stack trace"
258              /><%=error.getMessage() %>
259              <div id="stacktrace.<%=ext.getId()%>"
260                class="stacktrace"
261                style="display: none;"
262                ><%=ThrowableUtil.stackTraceToString(error)%></div>
263            </div>
264            </td>
265          </tr>
266          <%
267        }
268        %>
269        <tr>
270          <th>ID</th>
271          <td><%=ext.getId()%></td>
272        </tr>
273        <tr>
274          <th>Name</th>
275          <td><%=HTML.encodeTags(about.getName())%></td>
276        </tr>
277        <tr>
278          <th>File</th>
279          <td>
280            <a class="auto-init" data-auto-init="show-file" data-file-uri="<%=HTML.encodeTags(extFile.getName()) %>"
281            ><%=extFile.getName()%></a> 
282            (<%=extFile.checkModified() ? "Modified" : "Up to date" %>;
283            <%=extFile.hasError() ? "Error" : "Ok" %>)
284          </td>
285        </tr>
286        <tr>
287          <th>Version</th>
288          <td><%=HTML.encodeTags(about.getVersion())%></td>
289        </tr>
290        <tr class="big">
291          <th>Description</th>
292          <td><%=HTML.niceFormat(about.getDescription())%></td>
293        </tr>
294        <tr>
295          <th>Copyright</th>
296          <td><%=HTML.encodeTags(about.getCopyright())%></td>
297        </tr>
298        <tr>
299          <th>Contact</th>
300          <td><%=HTML.encodeTags(about.getContact())%></td>
301        </tr>
302        <tr>
303          <th>Email</th>
304          <td><%=HTML.scanForLinks(about.getEmail(), HTML.LINK_EMAIL, "_blank")%></td>
305        </tr>
306        <tr>
307          <th>Url</th>
308          <td><%=HTML.scanForLinks(about.getUrl(), HTML.LINK_URL, "_blank")%></td>
309        </tr>
310        <tr class="big">
311          <th>Action factory</th>
312          <td><%=displayFactory(extFile, ext.getActionFactory())%></td>
313        </tr>
314        <tr class="big">
315          <th>Renderer factory</th>
316          <td><%=displayFactory(extFile, ext.getRendererFactory())%></td>
317        </tr>
318        </tbody>
319        <%
320      }
321      if (ep != null)
322      {
323        if (ext != null)
324        {
325          %>
326          <tbody class="sectionheader">
327            <tr>
328              <th colspan="2">Extension point</th>
329            </tr>
330          </tbody>
331          <%
332        }
333        %>
334        <tbody>
335        <%
336        Throwable error = ec.getLastExtensionPointError(ep.getId());
337        if (error != null)
338        {
339          %>
340          <tr>
341            <th></th>
342            <td>
343            <div class="messagecontainer error">
344              <base:icon image="error.png" 
345                subclass="auto-init link"
346                data-auto-init="toggle-stacktrace"
347                data-stacktrace-id="<%="stacktrace." + ep.getId()%>"
348                style="float: left; margin-right: 5px;"
349                tooltip="Error - click to show full stack trace"
350              /><%=error.getMessage() %>
351              <div id="stacktrace.<%=ep.getId()%>"
352                class="stacktrace"
353                style="display: none;"
354                ><%=ThrowableUtil.stackTraceToString(error)%></div>
355            </div>
356            </td>
357          </tr>
358          <%
359        }
360        %>
361        <tr>
362          <th>ID</th>
363          <td><%=ep.getId()%></td>
364        </tr>
365        <tr>
366          <th>Name</th>
367          <td><%=HTML.encodeTags(ep.getName())%></td>
368        </tr>
369        <tr>
370          <th>File</th>
371          <td>
372            <%
373            if (epFile != null)
374            {
375              %>
376              <a class="auto-init" data-auto-init="show-file" data-file-uri="<%=HTML.encodeTags(epFile.getName()) %>"
377              ><%=epFile.getName()%></a> 
378              (<%=epFile.checkModified() ? "Modified" : "Up to date" %>;
379              <%=epFile.hasError() ? "Error" : "Ok" %>)
380              <%
381            }
382            %>
383          </td>
384        </tr>
385        <tr class="big">
386          <th>Description</th>
387          <td><%=HTML.niceFormat(ep.getDescription())%></td>
388        </tr>
389        <tr>
390          <th>Action class</th>
391          <td><%=ep.getActionClass().getName()%></td>
392        </tr>
393        <tr class="big">
394          <th>Renderer factory</th>
395          <td><%=displayFactory(epFile, ep.getRendererFactory())%></td>
396        </tr>
397        <tr class="big">
398          <th>Error handler factory</th>
399          <td><%=displayFactory(epFile, ep.getErrorHandlerFactory() == null ? 
400              ec.getDefaultErrorHandlerFactory() : ep.getErrorHandlerFactory())%></td>
401        </tr>
402        </tbody>
403        <%
404      }
405      if (file != null)
406      {
407        About about = file.getAbout();
408        if (about == null) about = new AboutBean();
409        %>
410        <tbody>
411        <tr>
412          <th>File</th>
413          <td><%=file.getName()%></td>
414        </tr>
415        <tr>
416          <th>Type</th>
417          <td><%=file.isJar() ? "JAR file" : "XML file"%></td>
418        </tr>
419        <tr>
420          <th>Up to date</th>
421          <td><%=file.checkModified() ? "No" : "Yes"%></td>
422        </tr>
423        <tr class="big">
424          <th>Errors</th>
425          <td>
426            <%
427            if (file.hasError())
428            {
429              ProcessResults results = ec.getLastScanResults();
430              FileResults fileResults = results.getResults(file);
431              List<String> messages = fileResults.getMessages();
432              Throwable validationError = file.getValidationError();
433              %>
434              <div class="messagecontainer error">
435              <ul style="padding-left: 20px; margin: 0px; text-align: left;">
436              <%
437              if (validationError != null)
438              {
439                %>
440                <li><%=validationError.getClass().getSimpleName()%>: <%=HTML.niceFormat(validationError.getMessage())%>
441                <%
442              }
443              for (String msg : messages)
444              {
445                %>
446                <li><%=HTML.niceFormat(msg)%>
447                <%
448              }
449              %>
450              </ul>
451              </div>
452              <%
453            }
454            else
455            {
456              %>
457              No
458              <%
459            }
460            %>
461          </td>
462        </tr>
463        <tr>
464          <th>Name</th>
465          <td><%=HTML.encodeTags(about.getName())%></td>
466        </tr>
467        <tr>
468          <th>Version</th>
469          <td><%=HTML.encodeTags(about.getVersion())%></td>
470        </tr>
471        <tr class="big">
472          <th>Description</th>
473          <td><%=HTML.niceFormat(about.getDescription())%></td>
474        </tr>
475        <tr>
476          <th>Copyright</th>
477          <td><%=HTML.encodeTags(about.getCopyright())%></td>
478        </tr>
479        <tr>
480          <th>Contact</th>
481          <td><%=HTML.encodeTags(about.getContact())%></td>
482        </tr>
483        <tr>
484          <th>Email</th>
485          <td><%=HTML.scanForLinks(about.getEmail(), HTML.LINK_EMAIL, "_blank")%></td>
486        </tr>
487        <tr>
488          <th>Url</th>
489          <td><%=HTML.scanForLinks(about.getUrl(), HTML.LINK_URL, "_blank")%></td>
490        </tr>
491        </tbody>
492        <%
493      }
494      %>
495      <%
496      if (ext == null && ep == null && file == null)
497      {
498        ProcessResults results = ec.getLastScanResults();
499        Formatter dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
500        %>
501        <tbody>
502        <tr>
503          <th>Last installation</th>
504          <td><%=results.hasError() ? "Failed": "Successful" %></td>
505        </tr>
506        <tr>
507          <th class="subprompt">- ended</th>
508          <td><%=dateTimeFormatter.format(new Date(results.getEndTime())) %></td>
509        </tr>
510        <tr class="big">
511          <th class="subprompt">- summary</th>
512          <td>
513          <%=HTML.niceFormat(results.getSummary())%></td>
514        </tr>
515        <tr>
516          <th class="subprompt"></th>
517          <td>
518            <table><tr><td>
519            <base:button 
520              id="btnScanResults"
521              image="bullet.png" 
522              title="More details&hellip;"
523              tooltip="Display detailed information about the last scan"
524            />
525            </td></tr></table>
526          </td>
527        </tr>
528        </tbody>
529        <%
530      }
531      %>
532    </table>
533    </div>
534    </div>
535    </base:body>
536  </base:page>
537  <%
538}
539finally
540{
541  if (dc != null) dc.close();
542}
543%>
Note: See TracBrowser for help on using the repository browser.