Timeout, cache size and cache expiry time for the site proxy can now be configured using the siteproxy.properties file
git-svn-id: https://svn.libreccm.org/ccm/trunk@3106 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
f3e88be801
commit
9bae8e9d87
|
|
@ -1,4 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<registry>
|
<registry>
|
||||||
<!-- nothing yet -->
|
<config class="com.arsdigita.cms.contenttypes.SiteProxyConfig"
|
||||||
|
storage="ccm-cms-types-siteproxy/siteproxy.properties"/>
|
||||||
</registry>
|
</registry>
|
||||||
|
|
|
||||||
|
|
@ -34,10 +34,17 @@ public class SiteProxyExtraXMLGenerator implements ExtraXMLGenerator {
|
||||||
private static final String C_DATA_DATA_TYPE = "cdata";
|
private static final String C_DATA_DATA_TYPE = "cdata";
|
||||||
private static final String XML_DATA_TYPE = "xml";
|
private static final String XML_DATA_TYPE = "xml";
|
||||||
private static final String s_cacheServiceKey = "SiteProxyPanel";
|
private static final String s_cacheServiceKey = "SiteProxyPanel";
|
||||||
private static final URLCache s_cache = new URLCache(1000000, 1 * 60 * 1000);
|
private static final SiteProxyConfig config = new SiteProxyConfig();
|
||||||
private static final URLPool s_pool = new URLPool();
|
// private static final URLCache s_cache = new URLCache(1000000, 1 * 60 * 1000);
|
||||||
|
// private static final URLPool s_pool = new URLPool(10, 10000);
|
||||||
|
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 {
|
static {
|
||||||
|
config.load();
|
||||||
|
|
||||||
logger.debug("Static initalizer starting...");
|
logger.debug("Static initalizer starting...");
|
||||||
URLFetcher.registerService(s_cacheServiceKey, s_pool, s_cache);
|
URLFetcher.registerService(s_cacheServiceKey, s_pool, s_cache);
|
||||||
logger.debug("Static initalizer finished.");
|
logger.debug("Static initalizer finished.");
|
||||||
|
|
|
||||||
|
|
@ -24,24 +24,27 @@ import com.arsdigita.cms.contenttypes.util.SiteProxyGlobalizationUtil;
|
||||||
import com.arsdigita.bebop.Label;
|
import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.cms.CMS;
|
import com.arsdigita.cms.CMS;
|
||||||
import com.arsdigita.cms.ContentSection;
|
import com.arsdigita.cms.ContentSection;
|
||||||
|
import com.arsdigita.cms.contenttypes.SiteProxyConfig;
|
||||||
import com.arsdigita.util.url.URLFetcher;
|
import com.arsdigita.util.url.URLFetcher;
|
||||||
import com.arsdigita.util.url.URLPool;
|
import com.arsdigita.util.url.URLPool;
|
||||||
import com.arsdigita.util.url.URLCache;
|
import com.arsdigita.util.url.URLCache;
|
||||||
import com.arsdigita.util.url.URLData;
|
import com.arsdigita.util.url.URLData;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
import com.arsdigita.xml.Document;
|
import com.arsdigita.xml.Document;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import javax.servlet.http.*;
|
import javax.servlet.http.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>This <code>SiteProxyPanel</code> component fetches
|
* <p>
|
||||||
* the {@link com.arsdigita.cms.dispatcher.XMLGenerator} for the content
|
* This <code>SiteProxyPanel</code> component fetches the
|
||||||
* section. It also uses the url from the SiteProxy object to
|
* {@link com.arsdigita.cms.dispatcher.XMLGenerator} for the content section. It also uses the url
|
||||||
* retrieve XML or HTML from the specified location. This XML/HTML is
|
* from the SiteProxy object to retrieve XML or HTML from the specified location. This XML/HTML is
|
||||||
* integrated in to the resulting DOM
|
* integrated in to the resulting DOM
|
||||||
*
|
*
|
||||||
* @author Michael Pih (pihman@arsdigita.com)
|
* @author Michael Pih (pihman@arsdigita.com)
|
||||||
|
|
@ -56,26 +59,34 @@ public class SiteProxyPanel extends ContentPanel {
|
||||||
private static String DATA_TYPE = "dataType";
|
private static String DATA_TYPE = "dataType";
|
||||||
private static String C_DATA_DATA_TYPE = "cdata";
|
private static String C_DATA_DATA_TYPE = "cdata";
|
||||||
private static String XML_DATA_TYPE = "xml";
|
private static String XML_DATA_TYPE = "xml";
|
||||||
|
|
||||||
private static String s_cacheServiceKey = "SiteProxyPanel";
|
private static String s_cacheServiceKey = "SiteProxyPanel";
|
||||||
private static URLCache s_cache = new URLCache(1000000, 15*60*1000);
|
private static final SiteProxyConfig config = new SiteProxyConfig();
|
||||||
private static URLPool s_pool = new URLPool();
|
// 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 {
|
static {
|
||||||
|
config.load();
|
||||||
|
|
||||||
s_log.debug("Static initalizer starting...");
|
s_log.debug("Static initalizer starting...");
|
||||||
URLFetcher.registerService(s_cacheServiceKey, s_pool, s_cache);
|
URLFetcher.registerService(s_cacheServiceKey, s_pool, s_cache);
|
||||||
s_log.debug("Static initalizer finished.");
|
s_log.debug("Static initalizer finished.");
|
||||||
};
|
}
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
public SiteProxyPanel() {
|
public SiteProxyPanel() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches an XML Generator. This method can be overidden to fetch
|
* Fetches an XML Generator. This method can be overidden to fetch any
|
||||||
* any {@link com.arsdigita.cms.dispatcher.XMLGenerator}, but by default,
|
* {@link com.arsdigita.cms.dispatcher.XMLGenerator}, but by default, it fetches the
|
||||||
* it fetches the <code>XMLGenerator</code> registered to the current
|
* <code>XMLGenerator</code> registered to the current {@link com.arsdigita.cms.ContentSection}.
|
||||||
* {@link com.arsdigita.cms.ContentSection}.
|
|
||||||
*
|
*
|
||||||
* @param state The page state
|
* @param state The page state
|
||||||
*/
|
*/
|
||||||
|
|
@ -83,24 +94,22 @@ public class SiteProxyPanel extends ContentPanel {
|
||||||
return new SiteProxyXMLGenerator();
|
return new SiteProxyXMLGenerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve remote XML for SiteProxy item.
|
* Retrieve remote XML for SiteProxy item.
|
||||||
*
|
*
|
||||||
* @param child com.arsdigita.xml.Element where remote XML is placed
|
* @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) {
|
public static URLData internalGetRemoteXML(Element child, String url) {
|
||||||
URLData data = URLFetcher.fetchURLData(url, s_cacheServiceKey);
|
URLData data = URLFetcher.fetchURLData(url, s_cacheServiceKey);
|
||||||
if (data == null || data.getException() != null || data.getContent().length == 0) {
|
if (data == null || data.getException() != null || data.getContent().length == 0) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
String contentType = data.getContentType();
|
String contentType = data.getContentType();
|
||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
if (contentType != null &&
|
if (contentType != null && contentType.toLowerCase().indexOf("/xml") > -1) {
|
||||||
contentType.toLowerCase().indexOf("/xml") > -1) {
|
|
||||||
// we use the /xml intead of text/xml because
|
// we use the /xml intead of text/xml because
|
||||||
// things like application/xml are also valid
|
// things like application/xml are also valid
|
||||||
Document document = null;
|
Document document = null;
|
||||||
|
|
@ -108,77 +117,79 @@ public class SiteProxyPanel extends ContentPanel {
|
||||||
document = new Document(data.getContent());
|
document = new Document(data.getContent());
|
||||||
success = true;
|
success = true;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
s_log.info("The document is not proper XML, trying to " +
|
s_log.info("The document is not proper XML, trying to "
|
||||||
"add the property xml headers to the file " +
|
+ "add the property xml headers to the file " + "retrieved from " + url,
|
||||||
"retrieved from " + url, ex);
|
ex);
|
||||||
try {
|
try {
|
||||||
String xmlString = data.getContentAsString();
|
String xmlString = data.getContentAsString();
|
||||||
xmlString = "<?xml version=\"1.0\"?> \n" + xmlString;
|
xmlString = "<?xml version=\"1.0\"?> \n" + xmlString;
|
||||||
document = new Document(xmlString);
|
document = new Document(xmlString);
|
||||||
success = true;
|
success = true;
|
||||||
s_log.info("Adding the headers to " + url +
|
s_log
|
||||||
" allowed it to be properly parsed.");
|
.info("Adding the headers to " + url + " allowed it to be properly parsed.");
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
s_log.info("The document found at " + url +
|
s_log.info("The document found at " + url + " is not correctly formed XML",
|
||||||
" is not correctly formed XML", exception);
|
exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (success) {
|
if (success) {
|
||||||
child.addContent(document.getRootElement());
|
child.addContent(document.getRootElement());
|
||||||
child.addAttribute(DATA_TYPE, XML_DATA_TYPE);
|
child.addAttribute(DATA_TYPE, XML_DATA_TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!success) {
|
if (!success) {
|
||||||
// just add the item as CDATA
|
// just add the item as CDATA
|
||||||
child.setCDATASection(data.getContentAsString());
|
child.setCDATASection(data.getContentAsString());
|
||||||
child.addAttribute(DATA_TYPE, C_DATA_DATA_TYPE);
|
child.addAttribute(DATA_TYPE, C_DATA_DATA_TYPE);
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
class SiteProxyXMLGenerator extends SimpleXMLGenerator {
|
class SiteProxyXMLGenerator extends SimpleXMLGenerator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateXML(PageState state, Element parent, String useContext) {
|
public void generateXML(PageState state, Element parent, String useContext) {
|
||||||
|
|
||||||
ContentSection section = CMS.getContext().getContentSection();
|
ContentSection section = CMS.getContext().getContentSection();
|
||||||
SiteProxy item = (SiteProxy)getContentItem(state);
|
SiteProxy item = (SiteProxy) getContentItem(state);
|
||||||
String url = passParameters(state.getRequest(), item.getURL());
|
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);
|
CMS.CMS_XML_NS);
|
||||||
URLData data = internalGetRemoteXML(child, url);
|
URLData data = internalGetRemoteXML(child, url);
|
||||||
|
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
String[] urlArray = {url};
|
String[] urlArray = {url};
|
||||||
(new Label(SiteProxyGlobalizationUtil.globalize
|
(new Label(SiteProxyGlobalizationUtil.globalize(
|
||||||
("cms.contenttypes.dispatcher.siteproxy.error_fetching_url",
|
"cms.contenttypes.dispatcher.siteproxy.error_fetching_url",
|
||||||
urlArray))).generateXML(state, parent);
|
urlArray))).generateXML(state, parent);
|
||||||
} else if (data.getException() != null) {
|
} else if (data.getException() != null) {
|
||||||
String[] urlArray =
|
String[] urlArray = {url, data.getException().getClass().getName(),
|
||||||
{url, data.getException().getClass().getName(),
|
data.getException().getMessage()};
|
||||||
data.getException().getMessage()};
|
(new Label(SiteProxyGlobalizationUtil.globalize(
|
||||||
(new Label(SiteProxyGlobalizationUtil.globalize
|
"cms.contenttypes.siteproxy.dispatcher.exception_fetching_url",
|
||||||
("cms.contenttypes.siteproxy.dispatcher.exception_fetching_url",
|
urlArray))).generateXML(state, parent);
|
||||||
urlArray))).generateXML(state, parent);
|
|
||||||
} else if (data.getContent().length == 0) {
|
} else if (data.getContent().length == 0) {
|
||||||
String[] urlArray = {url};
|
String[] urlArray = {url};
|
||||||
(new Label(SiteProxyGlobalizationUtil.globalize
|
(new Label(SiteProxyGlobalizationUtil.globalize(
|
||||||
("cms.contenttypes.siteproxy.dispatcher.empty_page_returned",
|
"cms.contenttypes.siteproxy.dispatcher.empty_page_returned",
|
||||||
urlArray))).generateXML(state, parent);
|
urlArray))).generateXML(state, parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String passParameters(HttpServletRequest request, String url){
|
private String passParameters(HttpServletRequest request, String url) {
|
||||||
StringBuffer sb = new StringBuffer(url);
|
StringBuffer sb = new StringBuffer(url);
|
||||||
String enc = request.getCharacterEncoding();
|
String enc = request.getCharacterEncoding();
|
||||||
if (enc == null) enc = "UTF-8";
|
if (enc == null) {
|
||||||
|
enc = "UTF-8";
|
||||||
|
}
|
||||||
Enumeration en = request.getParameterNames();
|
Enumeration en = request.getParameterNames();
|
||||||
while (en.hasMoreElements()){
|
while (en.hasMoreElements()) {
|
||||||
String paramName = (String) en.nextElement();
|
String paramName = (String) en.nextElement();
|
||||||
String[] paramValues = request.getParameterValues(paramName);
|
String[] paramValues = request.getParameterValues(paramName);
|
||||||
for(int i=0; i<paramValues.length; ++i) {
|
for (int i = 0; i < paramValues.length; ++i) {
|
||||||
if (sb.indexOf("?") < 0) {
|
if (sb.indexOf("?") < 0) {
|
||||||
sb.append("?");
|
sb.append("?");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -195,5 +206,5 @@ public class SiteProxyPanel extends ContentPanel {
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -964,7 +964,7 @@ cms.ui.item.lifecycle.do=Ausf\u00fchren
|
||||||
cms.ui.item.lifecycle.do.not_authorized=Sie sind nicht berechtigt, dieses Item zu publizieren.
|
cms.ui.item.lifecycle.do.not_authorized=Sie sind nicht berechtigt, dieses Item zu publizieren.
|
||||||
cms.ui.item.lifecycle.publish_locked=Dieses Content-Item wird gerade (re-)publiziert
|
cms.ui.item.lifecycle.publish_locked=Dieses Content-Item wird gerade (re-)publiziert
|
||||||
cms.ui.item.lifecycle.publish_locked.update=Aktualisieren
|
cms.ui.item.lifecycle.publish_locked.update=Aktualisieren
|
||||||
cms.ui.lifecycle.publish.error=W\u00e4hrend des Publizierens ist ein Fehler aufgetreten. Der System-Administrator wurde per \u00fcber das Problem informiert. Dieses Item bleibt besperrt, bis der Administrator die Sperre manuell entfernt.
|
cms.ui.lifecycle.publish.error=W\u00e4hrend des Publizierens ist ein Fehler aufgetreten. Der System-Administrator wurde \u00fcber das Problem informiert. Dieses Item bleibt gesperrt, bis der Administrator die Sperre manuell entfernt.
|
||||||
cms.ui.delete_confirmation=Wollen Sie dieses Content-Item l\u00f6schen?
|
cms.ui.delete_confirmation=Wollen Sie dieses Content-Item l\u00f6schen?
|
||||||
cms.ui.lifecycle.details.last_published=Das Item wurde zuletzt republiziert am
|
cms.ui.lifecycle.details.last_published=Das Item wurde zuletzt republiziert am
|
||||||
cms.ui.item_search.flat.filter=Liste filtern
|
cms.ui.item_search.flat.filter=Liste filtern
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import com.arsdigita.cms.CMS;
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
import com.arsdigita.cms.ContentItemXMLRenderer;
|
import com.arsdigita.cms.ContentItemXMLRenderer;
|
||||||
import com.arsdigita.cms.SecurityManager;
|
import com.arsdigita.cms.SecurityManager;
|
||||||
|
import com.arsdigita.cms.dispatcher.ItemResolver;
|
||||||
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||||
import com.arsdigita.cms.portlet.ContentItemPortlet;
|
import com.arsdigita.cms.portlet.ContentItemPortlet;
|
||||||
import com.arsdigita.dispatcher.AccessDeniedException;
|
import com.arsdigita.dispatcher.AccessDeniedException;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ com.arsdigita.cms.contenttypes.publications.attach_orgaunits_step.format = [Bool
|
||||||
com.arsdigita.cms.contenttypes.publications.orgaunits_step_sort_key.title = Sort key for the publication -> GenericOrganizationalUnit authoring step
|
com.arsdigita.cms.contenttypes.publications.orgaunits_step_sort_key.title = Sort key for the publication -> GenericOrganizationalUnit authoring step
|
||||||
com.arsdigita.cms.contenttypes.publications.orgaunits_step_sort_key.purpose = Sort key for the publication -> GenericOrganizationalUnit authoring step
|
com.arsdigita.cms.contenttypes.publications.orgaunits_step_sort_key.purpose = Sort key for the publication -> GenericOrganizationalUnit authoring step
|
||||||
com.arsdigita.cms.contenttypes.publications.orgaunits_step_sort_key.example = 10
|
com.arsdigita.cms.contenttypes.publications.orgaunits_step_sort_key.example = 10
|
||||||
com.arsdigita.cms.contenttypes.publications.orgaunits_step_sort_key = [Integer]
|
com.arsdigita.cms.contenttypes.publications.orgaunits_step_sort_key.format = [Integer]
|
||||||
|
|
||||||
com.arsdigita.cms.contenttypes.publications.attach_organization_publications_step_to.title = Enable OrganizationPublications step
|
com.arsdigita.cms.contenttypes.publications.attach_organization_publications_step_to.title = Enable OrganizationPublications step
|
||||||
com.arsdigita.cms.contenttypes.publications.attach_organization_publications_step_to.purpose = Attaches an authoring step to GenericOrganizationalUnit which displays all publications of the type UnPublished to which the organizational unit is assigned as publishing organization.
|
com.arsdigita.cms.contenttypes.publications.attach_organization_publications_step_to.purpose = Attaches an authoring step to GenericOrganizationalUnit which displays all publications of the type UnPublished to which the organizational unit is assigned as publishing organization.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue