source: trunk/www/admin/extensions/wizard.jsp @ 7943

Last change on this file since 7943 was 7943, checked in by Nicklas Nordborg, 2 years ago

Merged BASE 3.18.1 to the trunk.

File size: 10.1 KB
Line 
1<%-- $Id:manual_scan.jsp 4187 2008-03-20 11:15:25Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
4  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg
5  Copyright (C) 2007 Martin Svensson
6
7  This file is part of BASE - BioArray Software Environment.
8  Available at http://base.thep.lu.se/
9
10  BASE is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License
12  as published by the Free Software Foundation; either version 3
13  of the License, or (at your option) any later version.
14
15  BASE is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  GNU General Public License for more details.
19
20  You should have received a copy of the GNU General Public License
21  along with BASE. If not, see <http://www.gnu.org/licenses/>.
22  ------------------------------------------------------------------
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page pageEncoding="UTF-8" session="false"
28  import="net.sf.basedb.core.Application"
29  import="net.sf.basedb.core.SessionControl"
30  import="net.sf.basedb.core.DbControl"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.Permission"
33  import="net.sf.basedb.core.plugin.About"
34  import="net.sf.basedb.clients.web.Base"
35  import="net.sf.basedb.clients.web.WebException"
36  import="net.sf.basedb.util.Values"
37  import="net.sf.basedb.clients.web.util.HTML"
38  import="net.sf.basedb.util.formatter.Formatter"
39  import="net.sf.basedb.util.extensions.ExtensionPoint"
40  import="net.sf.basedb.util.extensions.Extension"
41  import="net.sf.basedb.util.extensions.ExtendedAbout"
42  import="net.sf.basedb.util.extensions.manager.ExtensionsManager"
43  import="net.sf.basedb.util.extensions.manager.ExtensionsFile"
44  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
45  import="net.sf.basedb.clients.web.extensions.UnsafeScriptable"
46  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
47  import="net.sf.basedb.clients.web.servlet.ContentSecurityPolicyFilter"
48  import="java.util.List"
49  import="java.util.Date"
50  import="java.io.File"
51  import="java.io.FileNotFoundException"
52%>
53<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
54<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
55<%
56final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
57final String ID = sc.getId();
58final float scale = Base.getScale(sc);
59DbControl dc = null;
60try
61{
62  Formatter<Date> dateFormatter = FormatterFactory.getDateTimeFormatter(sc);
63 
64  dc = sc.newDbControl();
65  ExtensionsControl ec = ExtensionsControl.get(dc);
66  ec.checkPermission(Permission.WRITE);
67  ec.scanForChanges();
68  List<ExtensionsFile> xtFiles = ec.getFiles();
69  List<File> ignoredFiles = ec.getIgnoredFiles();
70  %>
71  <base:page type="popup" title="Extensions and plug-ins installation wizard">
72  <base:head scripts="table.js,~wizard.js" styles="table.css">
73  <style>
74    #ignored-header td
75    {
76      font-weight: bold;
77      border-top-style: solid;
78      border-bottom-style: solid;
79      border-top-width: 1px;
80      border-bottom-width: 1px;
81      border-top-color: inherit;
82      border-bottom-color: inherit;
83      padding: 1px 2px;
84    }
85    .ignored-file td
86    {
87      opacity: 0.5;
88    }
89    .ignored-file .input
90    {
91      opacity: 1;
92    }
93  </style>
94  </base:head>
95  <base:body>
96  <h1>Extensions and plug-ins installation wizard <base:help helpid="extensions.install-wizard" /></h1>
97  <div class="content">
98  <tbl:table id="scan" subclass="fulltable" stickyheaders="<%=null%>" action="index.jsp" >
99    <tbl:columndef id="file" title="File" />
100    <tbl:columndef id="status" title="Status" style="text-align: center;"/>
101    <tbl:columndef id="install" title="Install" style="text-align: center;"/>
102    <tbl:columndef id="uninstall" title="Uninstall" style="text-align: center;"/>
103    <tbl:columndef id="ignore" title="Ignore" style="text-align: center;" />
104    <tbl:columndef id="about" title="About" />
105 
106    <tbl:data style="top: 0px; margin-top: 0px;">
107      <tbl:headers>
108        <tbl:headerrow>
109          <tbl:columnheaders />
110        </tbl:headerrow>
111      </tbl:headers>
112      <tbl:rows>
113      <%
114      for (ExtensionsFile xtFile : xtFiles)
115      {
116        if (xtFile.getFile() == null) continue; // We skip internal extensions/plug-ins files
117        List<Extension<?>> unsafeExtensions = ec.checkUnsafeScriptableUsage(xtFile);
118       
119        About about = xtFile.getAbout();
120        ExtendedAbout xtAbout = about instanceof ExtendedAbout ? (ExtendedAbout)about : null;
121        Throwable error = null;
122        String name = xtFile.getName();
123        String status = "";
124        String icon = "";
125        boolean allowInstall = false;
126        boolean allowUninstall = false;
127        boolean allowIgnore = false;
128        boolean checkInstall = false;
129        boolean checkUninstall = false;
130        boolean checkIgnore = false;
131        if (!xtFile.exists())
132        {
133          status = "Deleted";
134          allowUninstall = true;
135          checkUninstall = true;
136          error = new FileNotFoundException(xtFile.getFile() + " doesn't exist or is not readable.");
137        }
138        else if (!xtFile.isValid())
139        {
140          status = "Invalid";
141          error = xtFile.getValidationError();
142          if (xtFile.isInstalled())
143          {
144            allowUninstall = true;
145            checkUninstall = true;
146          }
147          allowIgnore = true;
148          checkIgnore = true;
149        }
150        else if (xtFile.isNew())
151        {
152          status = "New";
153          allowInstall = true;
154          allowIgnore = true;
155          checkInstall = true;
156        }
157        else if (xtFile.wasModified())
158        {
159          status = "Modified";
160          allowInstall = true;
161          allowUninstall = true;
162          allowIgnore = true;
163          checkInstall = true;
164        }
165        else if (xtFile.hasError())
166        {
167          status = "Error";
168          allowInstall = true;
169          allowUninstall = true;
170          allowIgnore = true;
171        }
172        else
173        {
174          status = "Already installed";
175          allowInstall = true;
176          allowUninstall = true;
177          allowIgnore = true;
178        }
179        %>
180        <tbl:row>
181          <tbl:cell column="file" style="white-space: nowrap;"><%=name%></tbl:cell>
182          <tbl:cell column="status" style="text-align: center;"><%=status%></tbl:cell>
183          <tbl:cell column="install" style="text-align: center;">
184            <%
185            if (allowInstall)
186            {
187              %>
188              <input type="checkbox" class="auto-init" data-auto-init="install" 
189                name="<%=name%>.install" value="1" <%=checkInstall ? "checked" : "" %>
190                >
191              <%
192            }
193            %>
194          </tbl:cell>
195          <tbl:cell column="uninstall" style="text-align: center;">
196            <%
197            if (allowUninstall)
198            {
199              %>
200              <input type="checkbox" class="auto-init" data-auto-init="uninstall"
201                name="<%=name%>.uninstall" value="1" <%=checkUninstall ? "checked" : "" %>
202                >
203              <%
204            }
205            %>
206          </tbl:cell>
207          <tbl:cell column="ignore" style="text-align: center;">
208            <%
209            if (allowIgnore)
210            {
211              %>
212              <input type="checkbox" class="auto-init" data-auto-init="ignore"
213                name="<%=name%>.ignore" value="1" <%=checkIgnore ? "checked" : "" %>
214                >
215              <%
216            }
217            %>
218          </tbl:cell>
219          <tbl:cell column="about">
220            <%
221            if (about != null)
222            {
223              %>
224              <b><%=HTML.encodeTags(about.getName())%></b> <%=about.getVersion() == null ? "" : "(v" + about.getVersion() + ")"%><br>
225              <%=HTML.encodeTags(about.getDescription())%><br>
226              <%=HTML.niceFormat(about.getUrl())%>
227              <%
228            }
229            if (unsafeExtensions.size() > 0)
230            {
231              %>
232              <div class="messagecontainer note">
233                <base:icon image="warning.png" />
234                This plug-in contain <%=unsafeExtensions.size()%> extension(s) that
235                may violate the <b>Content Security Policy</b> setting on this server.
236                See BASE documentation for more information.
237              </div>
238              <%
239            }
240            if (error != null)
241            {
242              %>
243              <div class="messagecontainer error">
244              <%=error.getClass().getSimpleName()%>: <%=HTML.encodeTags(error.getMessage())%>
245              </div>
246              <%
247            }
248            %>
249          </tbl:cell>
250         
251        </tbl:row>
252        <%
253      }
254      if (ignoredFiles.size() > 0)
255      {
256        %>
257        <tr id="ignored-header" class="ignored-header bg-filled-100">
258          <td colspan="2">Ignored files (<%=ignoredFiles.size() %>)</td>
259          <td class="cell" style="text-align: center;">Install</td>
260          <td class="cell" ></td>
261          <td  class="cell" style="text-align: center;">Stop ignoring</td>
262          <td class="cell"></td>
263        </tr>
264        <%
265        for (File ignoredFile : ignoredFiles)
266        {
267          String name = ignoredFile.getName();
268          String fileInfo = "";
269          boolean checkStopIgnore = false;
270          boolean allowInstall = true;
271          if (ignoredFile.isFile())
272          {
273            fileInfo = Values.formatBytes(ignoredFile.length());
274            fileInfo += "; " + dateFormatter.format(new Date(ignoredFile.lastModified()));
275          }
276          else
277          {
278            fileInfo = "File does not exist.";
279            checkStopIgnore = true;
280            allowInstall = false;
281          }
282          %>
283          <tbl:row clazz="ignored-file">
284            <tbl:cell column="file" style="white-space: nowrap;"><%=name%></tbl:cell>
285            <tbl:cell column="status" style="text-align: center;">Ignored</tbl:cell>
286            <tbl:cell clazz="cell input" column="install" style="text-align: center;">
287              <%
288              if (allowInstall)
289              {
290                %>
291                <input type="checkbox" class="auto-init" data-auto-init="install" 
292                  name="<%=name%>.install" value="1">
293                <%
294              }
295              %>
296            </tbl:cell>
297            <tbl:cell clazz="cell input" column="ignore" style="text-align: center;">
298              <input type="checkbox" class="auto-init" data-auto-init="stop-ignore"
299                name="<%=name%>.stopignore" value="1" <%=checkStopIgnore ? "checked" : "" %>>
300            </tbl:cell>
301            <tbl:cell column="about"><%=HTML.encodeTags(fileInfo) %></tbl:cell>
302          </tbl:row>
303          <%
304        }
305      }
306      %>
307      </tbl:rows>
308    </tbl:data>
309  </tbl:table>
310  </div>
311
312  <base:buttongroup subclass="dialogbuttons">
313    <base:button id="startScan" title="Next" />
314    <base:button id="close" title="Cancel" />
315  </base:buttongroup>
316 
317  </base:body>
318  </base:page>
319  <%
320}
321finally
322{
323  if (dc != null) dc.close();
324}
325%>
Note: See TracBrowser for help on using the repository browser.