View Javadoc

1   /*
2    * Copyright 2010 Metastratus Web Solutions Limited. All Rights Reserved.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.fatwire.gst.foundation.taglib.install;
18  
19  import java.io.IOException;
20  import java.util.ArrayList;
21  import java.util.Arrays;
22  import java.util.List;
23  import java.util.Map;
24  
25  import javax.servlet.jsp.JspException;
26  
27  /**
28   * Perform all installation tasks that remain un-done so far. Once completed,
29   * return the installation status.
30   * 
31   * @author Tony Field
32   * @author Dolf Dijkstra
33   * @since Mar, 2012
34   */
35  public class Install extends InstallStatus {
36  
37      private String[] components;
38  
39      public void doTag() throws JspException, IOException {
40          InstallerEngine ie = new InstallerEngine(getICS(), getPageContext().getServletContext(),
41                  getTargetFlexFamilies());
42          Map<GSFComponent, Boolean> bInstallStatus = ie.getInstallStatus();
43          List<String> toInstall = new ArrayList<String>();
44          List<String> todo = new ArrayList<String>();
45          todo.addAll(Arrays.asList(components));
46          for (Map.Entry<GSFComponent, Boolean> e : bInstallStatus.entrySet()) {
47              String n = e.getKey().getClass().getSimpleName();
48              if (e.getValue() == false && todo.contains(n)) {
49                  toInstall.add(n);
50              }
51  
52          }
53          ie.doInstall(toInstall);
54          super.doTag();
55      }
56  
57      /**
58       * @return the components
59       */
60      public String[] getComponents() {
61          return components;
62      }
63  
64      /**
65       * @param components the components to set
66       */
67      public void setComponents(String[] components) {
68          this.components = components;
69      }
70  
71  }