001 package railo.runtime.extension; 002 003 import railo.commons.lang.StringUtil; 004 import railo.runtime.PageContext; 005 import railo.runtime.converter.ConverterException; 006 import railo.runtime.converter.ScriptConverter; 007 import railo.runtime.exp.PageException; 008 import railo.runtime.type.Struct; 009 import railo.runtime.type.StructImpl; 010 import railo.runtime.type.dt.DateTime; 011 012 public class ExtensionImpl implements Extension { 013 014 private String provider; 015 private String id; 016 private String strConfig; 017 private Struct config; 018 private String version; 019 private String name; 020 private String label; 021 private String description; 022 private String category; 023 private String image; 024 private String author; 025 private String codename; 026 private String video; 027 private String support; 028 private String documentation; 029 private String forum; 030 private String mailinglist; 031 private String network; 032 private DateTime created; 033 private String type; 034 035 036 public ExtensionImpl(String strConfig, String id, String provider, String version, 037 String name, String label, String description, String category, String image, 038 String author,String codename,String video,String support,String documentation, 039 String forum,String mailinglist,String network,DateTime created,String type) { 040 this.strConfig=strConfig; 041 this.id = id; 042 this.provider = provider; 043 this.version = version; 044 this.name = name; 045 this.label = label; 046 this.description = description; 047 this.category = category; 048 this.image = image; 049 050 this.author = author; 051 this.codename = codename; 052 this.video = video; 053 this.support = support; 054 this.documentation = documentation; 055 this.forum = forum; 056 this.mailinglist = mailinglist; 057 this.network = network; 058 this.created = created; 059 060 if("server".equalsIgnoreCase(type))this.type="server"; 061 else if("all".equalsIgnoreCase(type))this.type="all"; 062 else this.type="web"; 063 064 } 065 066 public ExtensionImpl(Struct config, String id, String provider, String version, 067 String name, String label, String description, String category, String image, 068 String author,String codename,String video,String support,String documentation, 069 String forum,String mailinglist,String network,DateTime created,String type) { 070 if(config==null) this.config=new StructImpl(); 071 else this.config = config; 072 this.id = id; 073 this.provider = provider; 074 this.version = version; 075 this.name = name; 076 this.label = label; 077 this.description = description; 078 this.category = category; 079 this.image = image; 080 081 this.author = author; 082 this.codename = codename; 083 this.video = video; 084 this.support = support; 085 this.documentation = documentation; 086 this.forum = forum; 087 this.mailinglist = mailinglist; 088 this.network = network; 089 this.created = created; 090 if("server".equalsIgnoreCase(type))this.type="server"; 091 else if("all".equalsIgnoreCase(type))this.type="all"; 092 else this.type="web"; 093 } 094 095 096 097 public String getAuthor() { 098 return author; 099 } 100 101 102 103 public String getCodename() { 104 return codename; 105 } 106 107 108 109 public String getVideo() { 110 return video; 111 } 112 113 114 115 public String getSupport() { 116 return support; 117 } 118 119 120 121 public String getDocumentation() { 122 return documentation; 123 } 124 125 126 127 public String getForum() { 128 return forum; 129 } 130 131 132 133 public String getMailinglist() { 134 return mailinglist; 135 } 136 137 138 139 public String getNetwork() { 140 return network; 141 } 142 143 144 145 public DateTime getCreated() { 146 return created; 147 } 148 149 150 151 public String getName() { 152 return name; 153 } 154 155 public String getLabel() { 156 return label; 157 } 158 159 public String getDescription() { 160 return description; 161 } 162 163 public String getCategory() { 164 return category; 165 } 166 167 public String getImage() { 168 return image; 169 } 170 171 public String getVersion() { 172 return version; 173 } 174 175 public String getProvider() { 176 return provider; 177 } 178 public String getId() { 179 return id; 180 } 181 public Struct getConfig(PageContext pc) { 182 if(config==null) { 183 if(StringUtil.isEmpty(strConfig)) config= new StructImpl(); 184 else { 185 try { 186 config= (Struct)pc.evaluate(strConfig); 187 } catch (PageException e) { 188 return new StructImpl(); 189 } 190 } 191 } 192 return config; 193 } 194 195 public String getStrConfig() { 196 if(config!=null && strConfig==null) { 197 try { 198 strConfig=new ScriptConverter().serialize(config); 199 } catch (ConverterException e) { 200 return ""; 201 } 202 } 203 return strConfig; 204 } 205 206 public String getType() { 207 return type; 208 } 209 }