Fehler #2400 FormprocessException, modul ccm-webpage

git-svn-id: https://svn.libreccm.org/ccm/trunk@3221 8810af33-2d31-482b-a856-94f89814c4df
master
konermann 2015-02-18 13:52:49 +00:00
parent 0f1b1cb8b7
commit 6f4ebfe78f
6 changed files with 84 additions and 10 deletions

View File

@ -0,0 +1,9 @@
webpage.ui.error=There is an error on the form
webpage.ui.contentsection_null=ContentSection is null
webpage.ui.insufficient_permissions=Insufficient permissions
webpage.ui.contentsection_doesnt_match=Content section does not match!
webpage.ui.no_such_contentsection=no such content section.
webpage.ui.illegal_portlet=Illegal portlet ID
webpage.ui.illegal_webpage_portlet=Illegal Webpage Portlet ID
webpage.ui.no_permission_edit=You do not have permission to edit this item.

View File

@ -0,0 +1,9 @@
webpage.ui.error=Es ist ein Fehler aufgetreten
webpage.ui.contentsection_null=Contentsection ist null
webpage.ui.insufficient_permissions=Keine Erlaubnis
webpage.ui.contentsection_doesnt_match=Content section does not match!
webpage.ui.no_such_contentsection=no such content section.
webpage.ui.illegal_portlet=Illegal portlet ID
webpage.ui.illegal_webpage_portlet=Illegal Webpage Portlet ID
webpage.ui.no_permission_edit=Sie haben nicht die Erlaubnis dieses Item zu editieren.

View File

@ -51,6 +51,7 @@ import com.arsdigita.cms.ui.CMSDHTMLEditor;
import com.arsdigita.cms.util.SecurityConstants;
import com.arsdigita.cms.webpage.Webpage;
import com.arsdigita.cms.webpage.WebpageConstants;
import com.arsdigita.cms.webpage.util.WebpageGlobalizationUtil;
import com.arsdigita.cms.workflow.CMSTask;
import com.arsdigita.dispatcher.DispatcherHelper;
import com.arsdigita.kernel.User;
@ -336,7 +337,8 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
}
}
if (!valid) {
throw new FormProcessException("There is an error on the form");
throw new FormProcessException(WebpageGlobalizationUtil.globalize(
"webpage.ui.error"));
}
}
@ -371,17 +373,20 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
}
if (section == null) {
throw new FormProcessException("ContentSection is null");
throw new FormProcessException(WebpageGlobalizationUtil
.globalize("webpage.ui.contentsection_null"));
}
SecurityManager sm = new SecurityManager(section);
User user = Web.getWebContext().getUser();
if (webpage != null) {
if (!sm.canAccess(user, SecurityConstants.EDIT_ITEM, webpage)) {
throw new FormProcessException("Insufficient permissions");
throw new FormProcessException(WebpageGlobalizationUtil
.globalize("webpage.ui.insufficient_permissions"));
}
if (!webpage.getContentSection().equals(section)) {
throw new FormProcessException("content section doesn't match!");
throw new FormProcessException(WebpageGlobalizationUtil
.globalize("webpage.ui.contentsection_doesnt_match"));
}
webpage.setTitle((String) m_title.getValue(state));
webpage.setName("webpage" + webpage.getID());
@ -392,7 +397,8 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
webpage.save();
} else {
if (!sm.canAccess(user, SecurityConstants.NEW_ITEM)) {
throw new FormProcessException("Insufficient permissions");
throw new FormProcessException(WebpageGlobalizationUtil
.globalize("webpage.ui.insufficient_permissions"));
}
webpage = new Webpage();
webpage.setLanguage("en");

View File

@ -30,7 +30,6 @@ import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.bebop.portal.PortletConfigFormSection;
import com.arsdigita.categorization.Category;
import com.arsdigita.categorization.CategoryCollection;
import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ContentSection;
@ -52,6 +51,7 @@ import com.arsdigita.util.Assert;
import com.arsdigita.util.StringUtils;
import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.web.Web;
import com.arsdigita.cms.webpage.util.WebpageGlobalizationUtil;
import com.arsdigita.workflow.simple.Engine;
import com.arsdigita.workflow.simple.Task;
import com.arsdigita.workflow.simple.TaskCollection;
@ -166,7 +166,8 @@ public class WebpagePortletEditor extends PortletConfigFormSection {
if (webpage == null) {
ContentSection section = Initializer.getConfig().getWebpageSection();
if (section == null) {
throw new FormProcessException("no such content section");
throw new FormProcessException(WebpageGlobalizationUtil
.globalize("webpage.ui.no_such_contentsection"));
}
// FR: move reference from PortalSite to Application (could be Workspace)

View File

@ -31,6 +31,7 @@ import com.arsdigita.cms.dispatcher.CMSPage;
import com.arsdigita.cms.ui.CMSDHTMLEditor;
import com.arsdigita.cms.webpage.Webpage;
import com.arsdigita.cms.webpage.WebpageConstants;
import com.arsdigita.cms.webpage.util.WebpageGlobalizationUtil;
// import com.arsdigita.cms.webpage.installer.Initializer;
import com.arsdigita.dispatcher.DispatcherHelper;
import com.arsdigita.kernel.User;
@ -194,7 +195,8 @@ public class WebpagePortletEditorPage extends CMSPage {
private WebpagePortlet getWebpagePortlet(PageState ps) throws FormProcessException {
String portletIDString = ps.getRequest().getParameter(PORTLET_ID);
if (portletIDString == null) {
throw new FormProcessException("Illegal portlet ID: " + portletIDString);
throw new FormProcessException(WebpageGlobalizationUtil
.globalize("webpage.ui.illegal_portlet"));
}
BigDecimal portletID = new BigDecimal(portletIDString);
@ -204,14 +206,16 @@ public class WebpagePortletEditorPage extends CMSPage {
protected WebpagePortlet getWebpagePortlet(PageState ps, BigDecimal portletID) throws FormProcessException {
WebpagePortlet portlet = (WebpagePortlet) Portlet.retrievePortlet(portletID);
if (portlet == null) {
throw new FormProcessException("Illegal Webpage Portlet ID: " + portletID);
throw new FormProcessException(WebpageGlobalizationUtil
.globalize("webpage.ui.illegal_webpage_portlet"));
}
User user = Web.getWebContext().getUser();
PermissionDescriptor perm = new PermissionDescriptor(PrivilegeDescriptor.EDIT,
portlet.getParentResource(), user);
if (!PermissionService.checkPermission(perm)) {
throw new FormProcessException("You do not have permission to edit this item.");
throw new FormProcessException(WebpageGlobalizationUtil
.globalize("webpage.ui.no_permission_edit"));
}
return portlet;
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (C) 2002-2004 Red Hat Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.webpage.util;
import com.arsdigita.globalization.Globalized;
import com.arsdigita.globalization.GlobalizedMessage;
/**
* <p>
* .
* Contains methods to simplify globalizing keys
* </p>
*
* @author Konermann
*/
public class WebpageGlobalizationUtil implements Globalized {
private static final String BUNDLE_NAME =
"com.arsdigita.webpage.WebpageResources";
public static GlobalizedMessage globalize(String key) {
return new GlobalizedMessage(key, BUNDLE_NAME);
}
public static GlobalizedMessage globalize(String key, Object[] args) {
return new GlobalizedMessage(key, BUNDLE_NAME, args);
}
}