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

Last change on this file since 7235 was 7235, checked in by Nicklas Nordborg, 6 years ago

References #2042: Add support for ignoring an extension or other file in the extensions directory

Allow the "Ignore" option also for modified extensions that are already installed.

File size: 9.9 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.io.File"
50  import="java.util.Date"
51%>
52<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
53<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
54<%
55final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
56final String ID = sc.getId();
57final float scale = Base.getScale(sc);
58DbControl dc = null;
59try
60{
61  Formatter<Date> dateFormatter = FormatterFactory.getDateTimeFormatter(sc);
62 
63  dc = sc.newDbControl();
64  ExtensionsControl ec = ExtensionsControl.get(dc);
65  ec.checkPermission(Permission.WRITE);
66  ec.scanForChanges();
67  List<ExtensionsFile> xtFiles = ec.getFiles();
68  List<File> ignoredFiles = ec.getIgnoredFiles();
69  %>
70  <base:page type="popup" title="Extensions and plug-ins installation wizard">
71  <base:head scripts="table.js,~wizard.js" styles="table.css">
72  <style>
73    .ignored-header td
74    {
75      font-weight: bold;
76      border-top-style: solid;
77      border-bottom-style: solid;
78      border-top-width: 1px;
79      border-bottom-width: 1px;
80      padding: 1px 2px;
81    }
82    .ignored-file td
83    {
84      opacity: 0.5;
85    }
86    .ignored-file .input
87    {
88      opacity: 1;
89    }
90  </style>
91  </base:head>
92  <base:body>
93  <h1>Extensions and plug-ins installation wizard <base:help helpid="extensions.install-wizard" /></h1>
94  <div class="content">
95  <tbl:table id="scan" subclass="fulltable" action="index.jsp" >
96    <tbl:columndef id="file" title="File" />
97    <tbl:columndef id="status" title="Status" style="text-align: center;"/>
98    <tbl:columndef id="install" title="Install" style="text-align: center;"/>
99    <tbl:columndef id="uninstall" title="Uninstall" style="text-align: center;"/>
100    <tbl:columndef id="ignore" title="Ignore" style="text-align: center;" />
101    <tbl:columndef id="about" title="About" />
102 
103    <tbl:data style="top: 0px; margin-top: 0px;">
104      <tbl:headers>
105        <tbl:headerrow>
106          <tbl:columnheaders />
107        </tbl:headerrow>
108      </tbl:headers>
109      <tbl:rows>
110      <%
111      for (ExtensionsFile xtFile : xtFiles)
112      {
113        if (xtFile.getFile() == null) continue; // We skip internal extensions/plug-ins files
114        List<Extension<?>> unsafeExtensions = ec.checkUnsafeScriptableUsage(xtFile);
115       
116        About about = xtFile.getAbout();
117        ExtendedAbout xtAbout = about instanceof ExtendedAbout ? (ExtendedAbout)about : null;
118        Throwable error = null;
119        String name = xtFile.getName();
120        String status = "";
121        String icon = "";
122        boolean allowInstall = false;
123        boolean allowUninstall = false;
124        boolean allowIgnore = false;
125        boolean checkInstall = false;
126        boolean checkUninstall = false;
127        boolean checkIgnore = false;
128        if (!xtFile.exists())
129        {
130          status = "Deleted";
131          allowUninstall = true;
132          checkUninstall = true;
133        }
134        else if (!xtFile.isValid())
135        {
136          status = "Invalid";
137          error = xtFile.getValidationError();
138          if (xtFile.isInstalled())
139          {
140            allowUninstall = true;
141            checkUninstall = true;
142          }
143          allowIgnore = true;
144          checkIgnore = true;
145        }
146        else if (xtFile.isNew())
147        {
148          status = "New";
149          allowInstall = true;
150          allowIgnore = true;
151          checkInstall = true;
152        }
153        else if (xtFile.wasModified())
154        {
155          status = "Modified";
156          allowInstall = true;
157          allowUninstall = true;
158          allowIgnore = true;
159          checkInstall = true;
160        }
161        else if (xtFile.hasError())
162        {
163          status = "Error";
164          allowInstall = true;
165          allowUninstall = true;
166          allowIgnore = true;
167        }
168        else
169        {
170          status = "Already installed";
171          allowInstall = true;
172          allowUninstall = true;
173          allowIgnore = true;
174        }
175        %>
176        <tbl:row>
177          <tbl:cell column="file" style="white-space: nowrap;"><%=name%></tbl:cell>
178          <tbl:cell column="status" style="text-align: center;"><%=status%></tbl:cell>
179          <tbl:cell column="install" style="text-align: center;">
180            <%
181            if (allowInstall)
182            {
183              %>
184              <input type="checkbox" class="auto-init" data-auto-init="install" 
185                name="<%=name%>.install" value="1" <%=checkInstall ? "checked" : "" %>
186                >
187              <%
188            }
189            %>
190          </tbl:cell>
191          <tbl:cell column="uninstall" style="text-align: center;">
192            <%
193            if (allowUninstall)
194            {
195              %>
196              <input type="checkbox" class="auto-init" data-auto-init="uninstall"
197                name="<%=name%>.uninstall" value="1" <%=checkUninstall ? "checked" : "" %>
198                >
199              <%
200            }
201            %>
202          </tbl:cell>
203          <tbl:cell column="ignore" style="text-align: center;">
204            <%
205            if (allowIgnore)
206            {
207              %>
208              <input type="checkbox" class="auto-init" data-auto-init="ignore"
209                name="<%=name%>.ignore" value="1" <%=checkIgnore ? "checked" : "" %>
210                >
211              <%
212            }
213            %>
214          </tbl:cell>
215          <tbl:cell column="about">
216            <%
217            if (about != null)
218            {
219              %>
220              <b><%=HTML.encodeTags(about.getName())%></b> <%=about.getVersion() == null ? "" : "(v" + about.getVersion() + ")"%><br>
221              <%=HTML.encodeTags(about.getDescription())%><br>
222              <%=HTML.niceFormat(about.getUrl())%>
223              <%
224            }
225            if (unsafeExtensions.size() > 0)
226            {
227              %>
228              <div class="messagecontainer note">
229                <base:icon image="warning.png" />
230                This plug-in contain <%=unsafeExtensions.size()%> extension(s) that
231                may violate the <b>Content Security Policy</b> setting on this server.
232                See BASE documentation for more information.
233              </div>
234              <%
235            }
236            if (error != null)
237            {
238              %>
239              <div class="messagecontainer error">
240              <%=error.getClass().getSimpleName()%>: <%=HTML.encodeTags(error.getMessage())%>
241              </div>
242              <%
243            }
244            %>
245          </tbl:cell>
246         
247        </tbl:row>
248        <%
249      }
250      if (ignoredFiles.size() > 0)
251      {
252        %>
253        <tr class="ignored-header bg-filled-100">
254          <td colspan="2">Ignored files (<%=ignoredFiles.size() %>)</td>
255          <td class="cell" style="text-align: center;">Install</td>
256          <td class="cell" ></td>
257          <td  class="cell" style="text-align: center;">Stop ignoring</td>
258          <td class="cell"></td>
259        </tr>
260        <%
261        for (File ignoredFile : ignoredFiles)
262        {
263          String name = ignoredFile.getName();
264          String fileInfo = "";
265          boolean checkStopIgnore = false;
266          boolean allowInstall = true;
267          if (ignoredFile.isFile())
268          {
269            fileInfo = Values.formatBytes(ignoredFile.length());
270            fileInfo += "; " + dateFormatter.format(new Date(ignoredFile.lastModified()));
271          }
272          else
273          {
274            fileInfo = "File does not exist.";
275            checkStopIgnore = true;
276            allowInstall = false;
277          }
278          %>
279          <tbl:row clazz="ignored-file">
280            <tbl:cell column="file" style="white-space: nowrap;"><%=name%></tbl:cell>
281            <tbl:cell column="status" style="text-align: center;">Ignored</tbl:cell>
282            <tbl:cell clazz="cell input" column="install" style="text-align: center;">
283              <%
284              if (allowInstall)
285              {
286                %>
287                <input type="checkbox" class="auto-init" data-auto-init="install" 
288                  name="<%=name%>.install" value="1">
289                <%
290              }
291              %>
292            </tbl:cell>
293            <tbl:cell clazz="cell input" column="ignore" style="text-align: center;">
294              <input type="checkbox" class="auto-init" data-auto-init="stop-ignore"
295                name="<%=name%>.stopignore" value="1" <%=checkStopIgnore ? "checked" : "" %>>
296            </tbl:cell>
297            <tbl:cell column="about"><%=HTML.encodeTags(fileInfo) %></tbl:cell>
298          </tbl:row>
299          <%
300        }
301      }
302      %>
303      </tbl:rows>
304    </tbl:data>
305  </tbl:table>
306  </div>
307
308  <base:buttongroup subclass="dialogbuttons">
309    <base:button id="startScan" title="Next" />
310    <base:button id="close" title="Cancel" />
311  </base:buttongroup>
312 
313  </base:body>
314  </base:page>
315  <%
316}
317finally
318{
319  if (dc != null) dc.close();
320}
321%>
Note: See TracBrowser for help on using the repository browser.