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

Last change on this file since 6194 was 6194, checked in by Nicklas Nordborg, 11 years ago

References #1729 and #1730.

Fixed for frameset resizing code in three places: file manager, item overview and extensions overview.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 15.5 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" styles="newjoust.css,table.css,toolbar.css">
128  <script>
129
130  function enableExtension(enable)
131  {
132    var iconName = enable ? 'Extension' : 'ExtensionDisabled';
133    window.parent.frames['tree'].setIcon('<%=extensionId%>', iconName);
134    var url = 'index.jsp?ID=<%=ID%>&cmd=EnableExtension';
135    url += '&extensionId=<%=extensionId%>';
136    url += '&enable='+enable;
137    location.href = url;
138  }
139
140  function enableExtensionPoint(enable)
141  {
142    var iconName = enable ? 'ExtensionPoint' : 'ExtensionPointDisabled';
143    window.parent.frames['tree'].setIcon('<%=extensionPointId%>', iconName);
144    var url = 'index.jsp?ID=<%=ID%>&cmd=EnableExtensionPoint';
145    url += '&extensionPointId=<%=extensionPointId%>';
146    url += '&enable='+enable;
147    location.href = url;
148  }
149 
150  function enableFile(enable)
151  {
152    window.parent.frames['tree'].setChildIcons('<%=HTML.javaScriptEncode(file != null ? file.getName() : "")%>', enable);
153    var url = 'index.jsp?ID=<%=ID%>&cmd=EnableFile';
154    url += '&fileuri=<%=HTML.urlEncode(fileuri)%>';
155    url += '&enable='+enable;
156    location.href = url;
157  }
158 
159  function showFile(fileuri)
160  {
161    window.parent.frames['tree'].selectFile(fileuri);
162  }
163
164  function editPlugin(pluginId)
165  {
166    Main.viewOrEditItem('<%=ID%>', 'PLUGINDEFINITION', pluginId, true);
167  }
168 
169  function manualScan()
170  {
171    Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ManualScan', 'ManualScan', 750, 500);
172  }
173 
174  function scanResults()
175  {
176    Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ScanResults', 'ScanResults', 600, 400);
177  }
178
179  function toggleStacktrace(evt, id)
180  {
181    Main.showHide('stacktrace.' + id);
182  }
183 
184  </script>
185  </base:head>
186    <base:body>
187
188    <div class="absolutefull auto-init" data-auto-init="drag-support">
189
190    <tbl:toolbar subclass="bottomborder">
191    <%
192    if (ext != null)
193    {
194      boolean isEnabled = ec.isEnabled(ext);
195      boolean hasRegistrationError = extFile != null && extFile.hasError();
196      boolean allow = writePermission && !hasRegistrationError;
197      %>
198      <tbl:button 
199        onclick="<%="enableExtension(" + (isEnabled ? "0" : "1") + ")"%>" 
200        title="<%=isEnabled ? "Disable" : "Enable" %>" 
201        image="<%=allow ? "joust/extension.png" : "joust/extensiondisabled.png" %>"
202        tooltip="Disable this extension"
203        disabled="<%=!allow%>"
204      />
205      <tbl:button
206        image="help.png"
207        onclick="<%="Main.openHelp('" + ID +"', 'extensions.details.extension')"%>"
208        title="Help&hellip;"
209        tooltip="Get help about this page"
210      />
211      <%
212    }
213    else if (ep != null)
214    {
215      boolean isEnabled = ec.isEnabled(ep);
216      boolean hasRegistrationError = epFile != null && epFile.hasError();
217      boolean allow = writePermission && !hasRegistrationError;
218      %>
219      <tbl:button 
220        onclick="<%="enableExtensionPoint(" + (isEnabled ? "0" : "1") + ")"%>" 
221        title="<%=isEnabled ? "Disable" : "Enable" %>" 
222        image="<%=allow ? "joust/extensionpoint.png" : "joust/extensionpointdisabled.png" %>"
223        tooltip="Disable this extension point"
224        disabled="<%=!allow%>"
225      />
226      <tbl:button
227        image="help.png"
228        onclick="<%="Main.openHelp('" + ID +"', 'extensions.details.extensionspoint')"%>"
229        title="Help&hellip;"
230        tooltip="Get help about this page"
231      />
232      <%
233    }
234    else if (file != null)
235    {
236      boolean hasRegistrationError = file.hasError();
237      boolean allow = writePermission && !hasRegistrationError;
238      %>
239      <tbl:button 
240        onclick="enableFile(1)" 
241        title="Enable all" 
242        image="<%=allow ? "joust/extension.png" : "joust/extensiondisabled.png" %>"
243        tooltip="Enable all extensions in this file"
244        disabled="<%=!allow%>"
245      />
246      <tbl:button 
247        onclick="enableFile(0)" 
248        title="Disable all" 
249        image="<%=allow ? "joust/extension.png" : "joust/extensiondisabled.png" %>"
250        tooltip="Disable all extensions in this file"
251        disabled="<%=!allow%>"
252      />
253      <%
254    }
255    else
256    {
257      %>
258      <tbl:button
259        onclick="manualScan()"
260        title="Install/uninstall&hellip;"
261        image="new_wizard.png"
262        tooltip="Install and uninstall extensions and plug-ins"
263        disabled="<%=!writePermission%>"
264      />
265      <tbl:button
266        image="help.png"
267        onclick="<%="Main.openHelp('" + ID +"', 'extensions.details.main')"%>"
268        title="Help&hellip;"
269        tooltip="Get help about this page"
270      />
271      <%
272    }
273    %>
274    </tbl:toolbar>
275
276    <div class="bottomborder">
277      <table class="fullform outlined">
278      <%
279      if (ext != null)
280      {
281        About about = ext.getAbout();
282        if (about == null) about = new AboutBean();
283        Throwable error = ec.getLastExtensionError(ext.getId());
284        %>
285        <tbody>
286        <%
287        if (error != null)
288        {
289          %>
290          <tr>
291            <th></th>
292            <td>
293            <div class="messagecontainer error">
294              <base:icon image="error.png" 
295                onclick="<%="toggleStacktrace(event, '" + ext.getId() + "')"%>" 
296                style="float: left;"
297                tooltip="Error - click to show full stack trace"
298              /><%=error.getMessage() %>
299              <div id="stacktrace.<%=ext.getId()%>"
300                class="stacktrace"
301                style="display: none;"
302                ><%=ThrowableUtil.stackTraceToString(error)%></div>
303            </div>
304            </td>
305          </tr>
306          <%
307        }
308        %>
309        <tr>
310          <th>ID</th>
311          <td><%=ext.getId()%></td>
312        </tr>
313        <tr>
314          <th>Name</th>
315          <td><%=HTML.encodeTags(about.getName())%></td>
316        </tr>
317        <tr>
318          <th>File</th>
319          <td>
320            <a href="javascript:showFile('<%=HTML.javaScriptEncode(extFile.getName())%>')"
321            ><%=extFile.getName()%></a> 
322            (<%=extFile.checkModified() ? "Modified" : "Up to date" %>;
323            <%=extFile.hasError() ? "Error" : "Ok" %>)
324          </td>
325        </tr>
326        <tr>
327          <th>Version</th>
328          <td><%=HTML.encodeTags(about.getVersion())%></td>
329        </tr>
330        <tr class="big">
331          <th>Description</th>
332          <td><%=HTML.niceFormat(about.getDescription())%></td>
333        </tr>
334        <tr>
335          <th>Copyright</th>
336          <td><%=HTML.encodeTags(about.getCopyright())%></td>
337        </tr>
338        <tr>
339          <th>Contact</th>
340          <td><%=HTML.encodeTags(about.getContact())%></td>
341        </tr>
342        <tr>
343          <th>Email</th>
344          <td><%=HTML.scanForLinks(about.getEmail(), HTML.LINK_EMAIL, "_blank")%></td>
345        </tr>
346        <tr>
347          <th>Url</th>
348          <td><%=HTML.scanForLinks(about.getUrl(), HTML.LINK_URL, "_blank")%></td>
349        </tr>
350        <tr class="big">
351          <th>Action factory</th>
352          <td><%=displayFactory(extFile, ext.getActionFactory())%></td>
353        </tr>
354        <tr class="big">
355          <th>Renderer factory</th>
356          <td><%=displayFactory(extFile, ext.getRendererFactory())%></td>
357        </tr>
358        </tbody>
359        <%
360      }
361      if (ep != null)
362      {
363        if (ext != null)
364        {
365          %>
366          <tbody class="sectionheader">
367            <tr>
368              <th colspan="2">Extension point</th>
369            </tr>
370          </tbody>
371          <%
372        }
373        %>
374        <tbody>
375        <%
376        Throwable error = ec.getLastExtensionPointError(ep.getId());
377        if (error != null)
378        {
379          %>
380          <tr>
381            <th></th>
382            <td>
383            <div class="messagecontainer error">
384              <base:icon image="error.png" 
385                onclick="<%="toggleStacktrace(event, '" + ep.getId() + "')"%>" 
386                style="float: left;"
387                tooltip="Error - click to show full stack trace"
388              /><%=error.getMessage() %>
389              <div id="stacktrace.<%=ep.getId()%>"
390                class="stacktrace"
391                style="display: none;"
392                ><%=ThrowableUtil.stackTraceToString(error)%></div>
393            </div>
394            </td>
395          </tr>
396          <%
397        }
398        %>
399        <tr>
400          <th>ID</th>
401          <td><%=ep.getId()%></td>
402        </tr>
403        <tr>
404          <th>Name</th>
405          <td><%=HTML.encodeTags(ep.getName())%></td>
406        </tr>
407        <tr>
408          <th>File</th>
409          <td>
410            <%
411            if (epFile != null)
412            {
413              %>
414              <a href="javascript:showFile('<%=HTML.javaScriptEncode(epFile.getName())%>')"
415              ><%=epFile.getName()%></a> 
416              (<%=epFile.checkModified() ? "Modified" : "Up to date" %>;
417              <%=epFile.hasError() ? "Error" : "Ok" %>)
418              <%
419            }
420            %>
421          </td>
422        </tr>
423        <tr class="big">
424          <th>Description</th>
425          <td><%=HTML.niceFormat(ep.getDescription())%></td>
426        </tr>
427        <tr>
428          <th>Action class</th>
429          <td><%=ep.getActionClass().getName()%></td>
430        </tr>
431        <tr class="big">
432          <th>Renderer factory</th>
433          <td><%=displayFactory(epFile, ep.getRendererFactory())%></td>
434        </tr>
435        <tr class="big">
436          <th>Error handler factory</th>
437          <td><%=displayFactory(epFile, ep.getErrorHandlerFactory() == null ? 
438              ec.getDefaultErrorHandlerFactory() : ep.getErrorHandlerFactory())%></td>
439        </tr>
440        </tbody>
441        <%
442      }
443      if (file != null)
444      {
445        About about = file.getAbout();
446        if (about == null) about = new AboutBean();
447        %>
448        <tbody>
449        <tr>
450          <th>File</th>
451          <td><%=file.getName()%></td>
452        </tr>
453        <tr>
454          <th>Type</th>
455          <td><%=file.isJar() ? "JAR file" : "XML file"%></td>
456        </tr>
457        <tr>
458          <th>Up to date</th>
459          <td><%=file.checkModified() ? "No" : "Yes"%></td>
460        </tr>
461        <tr class="big">
462          <th>Errors</th>
463          <td>
464            <%
465            if (file.hasError())
466            {
467              ProcessResults results = ec.getLastScanResults();
468              FileResults fileResults = results.getResults(file);
469              List<String> messages = fileResults.getMessages();
470              Throwable validationError = file.getValidationError();
471              %>
472              <div class="messagecontainer error">
473              <ul style="padding-left: 20px; margin: 0px; text-align: left;">
474              <%
475              if (validationError != null)
476              {
477                %>
478                <li><%=validationError.getClass().getSimpleName()%>: <%=HTML.niceFormat(validationError.getMessage())%>
479                <%
480              }
481              for (String msg : messages)
482              {
483                %>
484                <li><%=HTML.niceFormat(msg)%>
485                <%
486              }
487              %>
488              </ul>
489              </div>
490              <%
491            }
492            else
493            {
494              %>
495              No
496              <%
497            }
498            %>
499          </td>
500        </tr>
501        <tr>
502          <th>Name</th>
503          <td><%=HTML.encodeTags(about.getName())%></td>
504        </tr>
505        <tr>
506          <th>Version</th>
507          <td><%=HTML.encodeTags(about.getVersion())%></td>
508        </tr>
509        <tr class="big">
510          <th>Description</th>
511          <td><%=HTML.niceFormat(about.getDescription())%></td>
512        </tr>
513        <tr>
514          <th>Copyright</th>
515          <td><%=HTML.encodeTags(about.getCopyright())%></td>
516        </tr>
517        <tr>
518          <th>Contact</th>
519          <td><%=HTML.encodeTags(about.getContact())%></td>
520        </tr>
521        <tr>
522          <th>Email</th>
523          <td><%=HTML.scanForLinks(about.getEmail(), HTML.LINK_EMAIL, "_blank")%></td>
524        </tr>
525        <tr>
526          <th>Url</th>
527          <td><%=HTML.scanForLinks(about.getUrl(), HTML.LINK_URL, "_blank")%></td>
528        </tr>
529        </tbody>
530        <%
531      }
532      %>
533      <%
534      if (ext == null && ep == null && file == null)
535      {
536        ProcessResults results = ec.getLastScanResults();
537        Formatter dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
538        %>
539        <tbody>
540        <tr>
541          <th>Last installation</th>
542          <td><%=results.hasError() ? "Failed": "Successful" %></td>
543        </tr>
544        <tr>
545          <th class="subprompt">- ended</th>
546          <td><%=dateTimeFormatter.format(new Date(results.getEndTime())) %></td>
547        </tr>
548        <tr class="big">
549          <th class="subprompt">- summary</th>
550          <td>
551          <%=HTML.niceFormat(results.getSummary())%></td>
552        </tr>
553        <tr>
554          <th class="subprompt"></th>
555          <td>
556            <table><tr><td>
557            <base:button image="bullet.png" 
558              onclick="scanResults()" 
559              title="More details&hellip;"
560              tooltip="Display detailed information about the last scan"
561            />
562            </td></tr></table>
563          </td>
564        </tr>
565        </tbody>
566        <%
567      }
568      %>
569    </table>
570    </div>
571    </div>
572    </base:body>
573  </base:page>
574  <%
575}
576finally
577{
578  if (dc != null) dc.close();
579}
580%>
Note: See TracBrowser for help on using the repository browser.