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.Arrays;
21  import java.util.List;
22  import java.util.Map;
23  
24  import javax.servlet.jsp.JspException;
25  
26  import com.fatwire.gst.foundation.taglib.GsfSimpleTag;
27  
28  import org.apache.commons.lang.StringUtils;
29  
30  /**
31   * @author Tony Field
32   * @author Dolf Dijkstra
33   * @since Mar 23, 2012
34   */
35  public class InstallStatus extends GsfSimpleTag {
36  
37      private String output;
38      private String families = null;
39  
40      public void doTag() throws JspException, IOException {
41  
42          InstallerEngine ie = new InstallerEngine(getICS(), getPageContext().getServletContext(),
43                  getTargetFlexFamilies());
44          Map<GSFComponent, Boolean> installStatus = ie.getInstallStatus();
45          
46          boolean complete = true;
47          for (Boolean b : installStatus.values()) {
48              if (!b) {
49                  complete = false;
50                  break;
51              }
52          }
53          getJspContext().setAttribute(output, installStatus);
54          getJspContext().setAttribute(output + "Complete", complete);
55          super.doTag();
56      }
57  
58      public final void setOutput(String output) {
59          this.output = output;
60      }
61  
62      public void setFamilies(String families) {
63          this.families = families;
64      }
65  
66      protected final List<String> getTargetFlexFamilies() {
67          if (StringUtils.isBlank(families)) {
68              return Arrays.asList("GSTAttribute");
69          }
70          return Arrays.asList(families.split(","));
71      }
72  
73  }