diff --git a/ccm-cms-types-siteproxy/src/ccm-cms-types-siteproxy.config b/ccm-cms-types-siteproxy/src/ccm-cms-types-siteproxy.config
index adfdba100..c3182e67d 100755
--- a/ccm-cms-types-siteproxy/src/ccm-cms-types-siteproxy.config
+++ b/ccm-cms-types-siteproxy/src/ccm-cms-types-siteproxy.config
@@ -1,4 +1,5 @@
This SiteProxyPanel component fetches
- * the {@link com.arsdigita.cms.dispatcher.XMLGenerator} for the content
- * section. It also uses the url from the SiteProxy object to
- * retrieve XML or HTML from the specified location. This XML/HTML is
+ *
+ * This SiteProxyPanel component fetches the
+ * {@link com.arsdigita.cms.dispatcher.XMLGenerator} for the content section. It also uses the url
+ * from the SiteProxy object to retrieve XML or HTML from the specified location. This XML/HTML is
* integrated in to the resulting DOM
*
* @author Michael Pih (pihman@arsdigita.com)
@@ -56,26 +59,34 @@ public class SiteProxyPanel extends ContentPanel {
private static String DATA_TYPE = "dataType";
private static String C_DATA_DATA_TYPE = "cdata";
private static String XML_DATA_TYPE = "xml";
-
+
private static String s_cacheServiceKey = "SiteProxyPanel";
- private static URLCache s_cache = new URLCache(1000000, 15*60*1000);
- private static URLPool s_pool = new URLPool();
+ private static final SiteProxyConfig config = new SiteProxyConfig();
+// private static URLCache s_cache = new URLCache(1000000, 15*60*1000);
+// private static URLPool s_pool = new URLPool();
+ private static final URLCache s_cache = new URLCache(
+ config.getUrlCacheSize(), config.getUrlCacheExpiryTime());
+ private static final URLPool s_pool = new URLPool(
+ config.getUrlPoolSize(), config.getUrlPoolTimeout());
static {
+ config.load();
+
s_log.debug("Static initalizer starting...");
URLFetcher.registerService(s_cacheServiceKey, s_pool, s_cache);
s_log.debug("Static initalizer finished.");
- };
+ }
+
+ ;
public SiteProxyPanel() {
super();
}
/**
- * Fetches an XML Generator. This method can be overidden to fetch
- * any {@link com.arsdigita.cms.dispatcher.XMLGenerator}, but by default,
- * it fetches the XMLGenerator registered to the current
- * {@link com.arsdigita.cms.ContentSection}.
+ * Fetches an XML Generator. This method can be overidden to fetch any
+ * {@link com.arsdigita.cms.dispatcher.XMLGenerator}, but by default, it fetches the
+ * XMLGenerator registered to the current {@link com.arsdigita.cms.ContentSection}.
*
* @param state The page state
*/
@@ -83,24 +94,22 @@ public class SiteProxyPanel extends ContentPanel {
return new SiteProxyXMLGenerator();
}
-
/**
* Retrieve remote XML for SiteProxy item.
- *
+ *
* @param child com.arsdigita.xml.Element where remote XML is placed
- * @param url remote XML URL (text/xml)
+ * @param url remote XML URL (text/xml)
*/
public static URLData internalGetRemoteXML(Element child, String url) {
URLData data = URLFetcher.fetchURLData(url, s_cacheServiceKey);
if (data == null || data.getException() != null || data.getContent().length == 0) {
- return data;
+ return data;
}
String contentType = data.getContentType();
boolean success = false;
- if (contentType != null &&
- contentType.toLowerCase().indexOf("/xml") > -1) {
+ if (contentType != null && contentType.toLowerCase().indexOf("/xml") > -1) {
// we use the /xml intead of text/xml because
// things like application/xml are also valid
Document document = null;
@@ -108,77 +117,79 @@ public class SiteProxyPanel extends ContentPanel {
document = new Document(data.getContent());
success = true;
} catch (Exception ex) {
- s_log.info("The document is not proper XML, trying to " +
- "add the property xml headers to the file " +
- "retrieved from " + url, ex);
+ s_log.info("The document is not proper XML, trying to "
+ + "add the property xml headers to the file " + "retrieved from " + url,
+ ex);
try {
String xmlString = data.getContentAsString();
xmlString = " \n" + xmlString;
document = new Document(xmlString);
success = true;
- s_log.info("Adding the headers to " + url +
- " allowed it to be properly parsed.");
+ s_log
+ .info("Adding the headers to " + url + " allowed it to be properly parsed.");
} catch (Exception exception) {
- s_log.info("The document found at " + url +
- " is not correctly formed XML", exception);
+ s_log.info("The document found at " + url + " is not correctly formed XML",
+ exception);
}
}
- if (success) {
- child.addContent(document.getRootElement());
- child.addAttribute(DATA_TYPE, XML_DATA_TYPE);
- }
+ if (success) {
+ child.addContent(document.getRootElement());
+ child.addAttribute(DATA_TYPE, XML_DATA_TYPE);
+ }
}
if (!success) {
// just add the item as CDATA
child.setCDATASection(data.getContentAsString());
child.addAttribute(DATA_TYPE, C_DATA_DATA_TYPE);
- }
- return data;
+ }
+ return data;
}
-
+
class SiteProxyXMLGenerator extends SimpleXMLGenerator {
@Override
public void generateXML(PageState state, Element parent, String useContext) {
ContentSection section = CMS.getContext().getContentSection();
- SiteProxy item = (SiteProxy)getContentItem(state);
+ SiteProxy item = (SiteProxy) getContentItem(state);
String url = passParameters(state.getRequest(), item.getURL());
-
- Element child = parent.newChildElement(SITE_PROXY_PANEL_NAME,
+
+ Element child = parent.newChildElement(SITE_PROXY_PANEL_NAME,
CMS.CMS_XML_NS);
URLData data = internalGetRemoteXML(child, url);
-
+
if (data == null) {
String[] urlArray = {url};
- (new Label(SiteProxyGlobalizationUtil.globalize
- ("cms.contenttypes.dispatcher.siteproxy.error_fetching_url",
- urlArray))).generateXML(state, parent);
+ (new Label(SiteProxyGlobalizationUtil.globalize(
+ "cms.contenttypes.dispatcher.siteproxy.error_fetching_url",
+ urlArray))).generateXML(state, parent);
} else if (data.getException() != null) {
- String[] urlArray =
- {url, data.getException().getClass().getName(),
- data.getException().getMessage()};
- (new Label(SiteProxyGlobalizationUtil.globalize
- ("cms.contenttypes.siteproxy.dispatcher.exception_fetching_url",
- urlArray))).generateXML(state, parent);
+ String[] urlArray = {url, data.getException().getClass().getName(),
+ data.getException().getMessage()};
+ (new Label(SiteProxyGlobalizationUtil.globalize(
+ "cms.contenttypes.siteproxy.dispatcher.exception_fetching_url",
+ urlArray))).generateXML(state, parent);
} else if (data.getContent().length == 0) {
String[] urlArray = {url};
- (new Label(SiteProxyGlobalizationUtil.globalize
- ("cms.contenttypes.siteproxy.dispatcher.empty_page_returned",
- urlArray))).generateXML(state, parent);
+ (new Label(SiteProxyGlobalizationUtil.globalize(
+ "cms.contenttypes.siteproxy.dispatcher.empty_page_returned",
+ urlArray))).generateXML(state, parent);
}
}
+
}
- private String passParameters(HttpServletRequest request, String url){
+ private String passParameters(HttpServletRequest request, String url) {
StringBuffer sb = new StringBuffer(url);
String enc = request.getCharacterEncoding();
- if (enc == null) enc = "UTF-8";
+ if (enc == null) {
+ enc = "UTF-8";
+ }
Enumeration en = request.getParameterNames();
- while (en.hasMoreElements()){
+ while (en.hasMoreElements()) {
String paramName = (String) en.nextElement();
String[] paramValues = request.getParameterValues(paramName);
- for(int i=0; i