svn commit: r1055441 - in /lenya/branches/BRANCH_2_1_X/src: impl/java/org/apache/lenya/cms/cluster/impl/ webapp/lenya/config/sitemap/ webapp/lenya/content/exception/ webapp/lenya/resources/i18n/
[email protected] Wed, 05 Jan 2011 12:28:59 -0000
| Newsgroups | gmane.comp.cms.lenya.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: froethenbacher
Date: Wed Jan 5 12:28:58 2011
New Revision: 1055441
URL: http://svn.apache.org/viewvc?rev=1055441&view=rev
Log:
Added cluster action to prevent access to authoring area when running as slave in cluster mode.
Added:
lenya/branches/BRANCH_2_1_X/src/impl/java/org/apache/lenya/cms/cluster/impl/ClusterAction.java
lenya/branches/BRANCH_2_1_X/src/webapp/lenya/content/exception/cluster-authoring-disabled.jx
Modified:
lenya/branches/BRANCH_2_1_X/src/webapp/lenya/config/sitemap/actions.xmap
lenya/branches/BRANCH_2_1_X/src/webapp/lenya/config/sitemap/pipelines.xmap
lenya/branches/BRANCH_2_1_X/src/webapp/lenya/resources/i18n/cmsui.xml
lenya/branches/BRANCH_2_1_X/src/webapp/lenya/resources/i18n/cmsui_de.xml
Added: lenya/branches/BRANCH_2_1_X/src/impl/java/org/apache/lenya/cms/cluster/impl/ClusterAction.java
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/impl/java/org/apache/lenya/cms/cluster/impl/ClusterAction.java?rev=1055441&view=auto
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/impl/java/org/apache/lenya/cms/cluster/impl/ClusterAction.java (added)
+++ lenya/branches/BRANCH_2_1_X/src/impl/java/org/apache/lenya/cms/cluster/impl/ClusterAction.java Wed Jan 5 12:28:58 2011
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.cluster.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.acting.AbstractAction;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Redirector;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.lenya.cms.cluster.ClusterManager;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.URLInformation;
+
+/**
+ * Cluster action.
+ * Executes sitemap inside statements if Lenya instance
+ * is running as slave in cluster mode.
+ */
+public class ClusterAction extends AbstractAction
+implements Serviceable, ThreadSafe
+{
+ private ClusterManager clusterManager;
+
+ @Override
+ public Map act(Redirector redirector, SourceResolver resolver,
+ Map objectModel, String source, Parameters parameters)
+ throws Exception
+ {
+ Request request = ObjectModelHelper.getRequest(objectModel);
+ if (clusterManager.isSlave() &&
+ Publication.AUTHORING_AREA.equals(getArea(request)))
+ {
+ if (getLogger().isDebugEnabled())
+ getLogger().debug("Lenya instance is running as slave in " +
+ "cluster mode. Access to authoring denied.");
+ // Deny access to authoring. Returning non-null value.
+ return new HashMap();
+ } else {
+ // Allow access to authoring.
+ return null;
+ }
+ }
+
+ private String getArea(Request request) {
+ String context = request.getContextPath();
+ String requestURI = request.getRequestURI();
+ String webappUrl = requestURI.substring(context.length());
+ URLInformation lenyaURL = new URLInformation(webappUrl);
+ String area = lenyaURL.getArea();
+ return area;
+ }
+
+ @Override
+ public void service(ServiceManager manager) throws ServiceException {
+ clusterManager = (ClusterManager) manager.lookup(ClusterManager.ROLE);
+ }
+
+}
Modified: lenya/branches/BRANCH_2_1_X/src/webapp/lenya/config/sitemap/actions.xmap
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/webapp/lenya/config/sitemap/actions.xmap?rev=1055441&r1=1055440&r2=1055441&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/webapp/lenya/config/sitemap/actions.xmap (original)
+++ lenya/branches/BRANCH_2_1_X/src/webapp/lenya/config/sitemap/actions.xmap Wed Jan 5 12:28:58 2011
@@ -29,4 +29,5 @@
<map:action name="resource-exists" logger="sitemap.action.resource-exists" src="org.apache.cocoon.acting.ResourceExistsAction"/>
<map:action name="resource-exists-enhanced" logger="sitemap.action.resource-exists-enhanced" src="org.apache.lenya.cms.cocoon.acting.ResourceExistsAction"/>
<map:action name="session-propagator" logger="sitemap.action.session-propagator" src="org.apache.cocoon.acting.SessionPropagatorAction"/>
-</xmap>
\ No newline at end of file
+ <map:action name="cluster" logger="sitemap.action.cluster" src="org.apache.lenya.cms.cluster.impl.ClusterAction"/>
+</xmap>
Modified: lenya/branches/BRANCH_2_1_X/src/webapp/lenya/config/sitemap/pipelines.xmap
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/webapp/lenya/config/sitemap/pipelines.xmap?rev=1055441&r1=1055440&r2=1055441&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/webapp/lenya/config/sitemap/pipelines.xmap (original)
+++ lenya/branches/BRANCH_2_1_X/src/webapp/lenya/config/sitemap/pipelines.xmap Wed Jan 5 12:28:58 2011
@@ -63,6 +63,15 @@
<map:act type="ssl-redirect">
<map:redirect-to uri="{redirectUri}" session="true"/>
</map:act>
+
+ <map:act type="cluster">
+ <map:generate type="jx" src="lenya/content/exception/cluster-authoring-disabled.jx"/>
+ <map:transform type="i18n">
+ <map:parameter name="locale" value="{request:locale}"></map:parameter>
+ </map:transform>
+ <map:call resource="style-cms-page"/>
+ <map:serialize status-code="403" />
+ </map:act>
<map:match pattern="*/webdav**">
<map:act type="authorizer">
Added: lenya/branches/BRANCH_2_1_X/src/webapp/lenya/content/exception/cluster-authoring-disabled.jx
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/webapp/lenya/content/exception/cluster-authoring-disabled.jx?rev=1055441&view=auto
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/webapp/lenya/content/exception/cluster-authoring-disabled.jx (added)
+++ lenya/branches/BRANCH_2_1_X/src/webapp/lenya/content/exception/cluster-authoring-disabled.jx Wed Jan 5 12:28:58 2011
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jx:template xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+
+ <page:page
+ xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
+ xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+ xmlns="http://www.w3.org/1999/xhtml">
+
+ <page:title><i18n:text>cluster-authoring-disabled</i18n:text></page:title>
+
+ <page:body>
+ <p>
+ <i18n:text>cluster-authoring-disabled-explanation</i18n:text>
+ </p>
+ <p>
+ <a href="/index.html"><i18n:text>Back</i18n:text></a>
+ </p>
+ </page:body>
+
+ </page:page>
+
+</jx:template>
\ No newline at end of file
Modified: lenya/branches/BRANCH_2_1_X/src/webapp/lenya/resources/i18n/cmsui.xml
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/webapp/lenya/resources/i18n/cmsui.xml?rev=1055441&r1=1055440&r2=1055441&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/webapp/lenya/resources/i18n/cmsui.xml (original)
+++ lenya/branches/BRANCH_2_1_X/src/webapp/lenya/resources/i18n/cmsui.xml Wed Jan 5 12:28:58 2011
@@ -398,6 +398,9 @@
<message key="publication-does-not-exist">The publication does not exist</message>
<message key="publication-...-does-not-exist">The publication with the ID "{0}" does not exist.</message>
+
+ <message key="cluster-authoring-disabled">Authoring disabled</message>
+ <message key="cluster-authoring-disabled-explanation">Lenya instance is running as slave in cluster mode. Authoring is disabled for this instance. Please use master instance for authoring.</message>
<message key="configure-content-repository">
<xhtml:strong>Note:</xhtml:strong> Make sure that your content repository
Modified: lenya/branches/BRANCH_2_1_X/src/webapp/lenya/resources/i18n/cmsui_de.xml
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/webapp/lenya/resources/i18n/cmsui_de.xml?rev=1055441&r1=1055440&r2=1055441&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/webapp/lenya/resources/i18n/cmsui_de.xml (original)
+++ lenya/branches/BRANCH_2_1_X/src/webapp/lenya/resources/i18n/cmsui_de.xml Wed Jan 5 12:28:58 2011
@@ -411,6 +411,9 @@
<message key="publication-does-not-exist">Die Publikation existiert nicht</message>
<message key="publication-...-does-not-exist">Die Publikation mit der ID "{0}" existiert nicht.</message>
+
+ <message key="cluster-authoring-disabled">Bearbeitung deaktiviert</message>
+ <message key="cluster-authoring-disabled-explanation">Lenya-Instanz läuft als Slave im Cluster-Modus. Bearbeitung ist deaktiviert für diese Instanz. Bitte benutzen Sie eine Master-Instanz für die Bearbeitung.</message>
<message key="configure-content-repository">
<xhtml:strong>Hinweis:</xhtml:strong> Ãberprüfen Sie, ob das Content-Repository