001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.extension; 020 021import lucee.commons.lang.StringUtil; 022import lucee.runtime.PageContext; 023import lucee.runtime.converter.ConverterException; 024import lucee.runtime.converter.ScriptConverter; 025import lucee.runtime.exp.PageException; 026import lucee.runtime.type.Struct; 027import lucee.runtime.type.StructImpl; 028import lucee.runtime.type.dt.DateTime; 029 030public class ExtensionImpl implements Extension { 031 032 private String provider; 033 private String id; 034 private String strConfig; 035 private Struct config; 036 private String version; 037 private String name; 038 private String label; 039 private String description; 040 private String category; 041 private String image; 042 private String author; 043 private String codename; 044 private String video; 045 private String support; 046 private String documentation; 047 private String forum; 048 private String mailinglist; 049 private String network; 050 private DateTime created; 051 private String type; 052 053 054 public ExtensionImpl(String strConfig, String id, String provider, String version, 055 String name, String label, String description, String category, String image, 056 String author,String codename,String video,String support,String documentation, 057 String forum,String mailinglist,String network,DateTime created,String type) { 058 this.strConfig=strConfig; 059 this.id = id; 060 this.provider = provider; 061 this.version = version; 062 this.name = name; 063 this.label = label; 064 this.description = description; 065 this.category = category; 066 this.image = image; 067 068 this.author = author; 069 this.codename = codename; 070 this.video = video; 071 this.support = support; 072 this.documentation = documentation; 073 this.forum = forum; 074 this.mailinglist = mailinglist; 075 this.network = network; 076 this.created = created; 077 078 if("server".equalsIgnoreCase(type))this.type="server"; 079 else if("all".equalsIgnoreCase(type))this.type="all"; 080 else this.type="web"; 081 082 } 083 084 public ExtensionImpl(Struct config, String id, String provider, String version, 085 String name, String label, String description, String category, String image, 086 String author,String codename,String video,String support,String documentation, 087 String forum,String mailinglist,String network,DateTime created,String type) { 088 if(config==null) this.config=new StructImpl(); 089 else this.config = config; 090 this.id = id; 091 this.provider = provider; 092 this.version = version; 093 this.name = name; 094 this.label = label; 095 this.description = description; 096 this.category = category; 097 this.image = image; 098 099 this.author = author; 100 this.codename = codename; 101 this.video = video; 102 this.support = support; 103 this.documentation = documentation; 104 this.forum = forum; 105 this.mailinglist = mailinglist; 106 this.network = network; 107 this.created = created; 108 if("server".equalsIgnoreCase(type))this.type="server"; 109 else if("all".equalsIgnoreCase(type))this.type="all"; 110 else this.type="web"; 111 } 112 113 114 115 public String getAuthor() { 116 return author; 117 } 118 119 120 121 public String getCodename() { 122 return codename; 123 } 124 125 126 127 public String getVideo() { 128 return video; 129 } 130 131 132 133 public String getSupport() { 134 return support; 135 } 136 137 138 139 public String getDocumentation() { 140 return documentation; 141 } 142 143 144 145 public String getForum() { 146 return forum; 147 } 148 149 150 151 public String getMailinglist() { 152 return mailinglist; 153 } 154 155 156 157 public String getNetwork() { 158 return network; 159 } 160 161 162 163 public DateTime getCreated() { 164 return created; 165 } 166 167 168 169 public String getName() { 170 return name; 171 } 172 173 public String getLabel() { 174 return label; 175 } 176 177 public String getDescription() { 178 return description; 179 } 180 181 public String getCategory() { 182 return category; 183 } 184 185 public String getImage() { 186 return image; 187 } 188 189 public String getVersion() { 190 return version; 191 } 192 193 public String getProvider() { 194 return provider; 195 } 196 public String getId() { 197 return id; 198 } 199 public Struct getConfig(PageContext pc) { 200 if(config==null) { 201 if(StringUtil.isEmpty(strConfig)) config= new StructImpl(); 202 else { 203 try { 204 config= (Struct)pc.evaluate(strConfig); 205 } catch (PageException e) { 206 return new StructImpl(); 207 } 208 } 209 } 210 return config; 211 } 212 213 public String getStrConfig() { 214 if(config!=null && strConfig==null) { 215 try { 216 strConfig=new ScriptConverter().serialize(config); 217 } catch (ConverterException e) { 218 return ""; 219 } 220 } 221 return strConfig; 222 } 223 224 public String getType() { 225 return type; 226 } 227}