1 31 32 package org.opencms.staticexport; 33 34 import org.opencms.main.CmsIllegalArgumentException; 35 import org.opencms.main.OpenCms; 36 37 import java.util.ArrayList ; 38 import java.util.Collections ; 39 import java.util.List ; 40 import java.util.regex.Pattern ; 41 42 49 public class CmsStaticExportRfsRule { 50 51 52 private String m_description; 53 54 55 private String m_exportPath; 56 57 58 private final String m_exportPathConfigured; 59 60 61 private String m_name; 62 63 64 private List m_relatedSystemResources; 65 66 67 private final String m_rfsPreConfigured; 68 69 70 private String m_rfsPrefix; 71 72 73 private final Pattern m_source; 74 75 76 private Boolean m_useRelativeLinks; 77 78 88 public CmsStaticExportRfsRule( 89 String name, 90 String description, 91 String source, 92 String rfsPrefix, 93 String exportPath, 94 Boolean useRelativeLinks) { 95 96 m_name = name; 97 m_description = description; 98 m_source = Pattern.compile(source); 99 m_rfsPreConfigured = rfsPrefix; 100 m_exportPathConfigured = exportPath; 101 m_useRelativeLinks = useRelativeLinks; 102 m_relatedSystemResources = new ArrayList (); 103 } 104 105 116 public CmsStaticExportRfsRule( 117 String name, 118 String description, 119 String source, 120 String rfsPrefix, 121 String exportPath, 122 Boolean useRelativeLinks, 123 List relatedSystemRes) { 124 125 this(name, description, source, rfsPrefix, exportPath, useRelativeLinks); 126 m_relatedSystemResources.addAll(relatedSystemRes); 127 } 128 129 134 public void addRelatedSystemRes(String regex) { 135 136 m_relatedSystemResources.add(Pattern.compile(regex)); 137 } 138 139 144 public String getDescription() { 145 146 return m_description; 147 } 148 149 154 public String getExportPath() { 155 156 return m_exportPath; 157 } 158 159 164 public String getExportPathConfigured() { 165 166 return m_exportPathConfigured; 167 } 168 169 174 public String getName() { 175 176 return m_name; 177 } 178 179 184 public List getRelatedSystemResources() { 185 186 return Collections.unmodifiableList(m_relatedSystemResources); 187 } 188 189 194 public String getRfsPrefix() { 195 196 return m_rfsPrefix; 197 } 198 199 204 public String getRfsPrefixConfigured() { 205 206 return m_rfsPreConfigured; 207 } 208 209 214 public Pattern getSource() { 215 216 return m_source; 217 } 218 219 224 public Boolean getUseRelativeLinks() { 225 226 return m_useRelativeLinks; 227 } 228 229 235 public boolean match(String vfsName) { 236 237 for (int j = 0; j < m_relatedSystemResources.size(); j++) { 238 Pattern pattern = (Pattern )m_relatedSystemResources.get(j); 239 if (pattern.matcher(vfsName).matches()) { 240 return true; 241 } 242 } 243 return false; 244 } 245 246 251 public void setExportPath(String exportPath) { 252 253 if (exportPath.equals(OpenCms.getSystemInfo().getWebApplicationRfsPath())) { 254 throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_INVALID_EXPORT_PATH_1, m_name)); 256 } 257 m_exportPath = exportPath; 258 } 259 260 265 public void setRfsPrefix(String rfsPrefix) { 266 267 m_rfsPrefix = rfsPrefix; 268 } 269 270 273 public String toString() { 274 275 StringBuffer ret = new StringBuffer (getClass().getName()); 276 ret.append(":["); 277 ret.append("name: ").append(m_name).append("; "); 278 ret.append("description: ").append(m_description).append("; "); 279 ret.append("source: ").append(m_source).append("; "); 280 ret.append("exportPath: ").append(m_exportPath).append("; "); 281 ret.append("rfsPrefix: ").append(m_rfsPrefix).append("; "); 282 ret.append("useRelativeLinks: ").append(m_useRelativeLinks).append("; "); 283 ret.append("relatedSystemRes: ").append(m_relatedSystemResources).append("; "); 284 return ret.append("]").toString(); 285 } 286 287 } 288 | Popular Tags |