Author: julien(a)jboss.com
Date: 2007-03-15 08:48:16 -0400 (Thu, 15 Mar 2007)
New Revision: 6679
Removed:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/AddPageAction.java
Modified:
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
Log:
use the new page action bean which is more reusable
Deleted:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/AddPageAction.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/AddPageAction.java 2007-03-15
12:33:20 UTC (rev 6678)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/AddPageAction.java 2007-03-15
12:48:16 UTC (rev 6679)
@@ -1,122 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This 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 software 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 software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.admin.ui.actions;
-
-import org.jboss.portal.core.model.portal.Page;
-import org.jboss.portal.core.model.portal.PageContainer;
-import org.jboss.portal.core.model.portal.PortalObjectPermission;
-import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.core.admin.ui.PortalObjectManagerBean;
-import org.jboss.portal.security.RoleSecurityBinding;
-import org.jboss.portal.security.SecurityConstants;
-import org.jboss.portal.security.spi.provider.DomainConfigurator;
-
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.validator.ValidatorException;
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 5763 $
- */
-public class AddPageAction
-{
-
- /** . */
- private PortalObjectManagerBean pomgr;
-
- /** . */
- private String pageName;
-
- /** . */
- private static final String ERROR_DUPE_NAME = "Duplicate Page name found on this
portal!";
-
- /** . */
- private static final String ERROR_EMPTY_NAME = "Page name cannot be
blank!";
-
- public PortalObjectManagerBean getPortalObjectManager()
- {
- return pomgr;
- }
-
- public void setPortalObjectManager(PortalObjectManagerBean portalObjectManager)
- {
- this.pomgr = portalObjectManager;
- }
-
- public String getPageName()
- {
- return pageName;
- }
-
- public void setPageName(String pageName)
- {
- this.pageName = pageName;
- }
-
- /**
- * Checks for duplicate page names on the portal instance. Blank page names are not
allowed and are controlled by the
- * required attribute in the presentation page.
- *
- * @param context
- * @param toValidate
- * @param value
- */
- public void validatePageName(FacesContext context, UIComponent toValidate, Object
value)
- {
- String pageName = (String)value;
-
- // check for empty string
- if (pageName.startsWith(" "))
- {
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
ERROR_EMPTY_NAME, ERROR_EMPTY_NAME);
- throw new ValidatorException(message);
- }
-
- // Check for duplicate child name
- if (pomgr.getSelectedObject().getChild(pageName) != null)
- {
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
ERROR_DUPE_NAME, ERROR_DUPE_NAME);
- throw new ValidatorException(message);
- }
- }
-
- public void execute()
- {
- try
- {
- PageContainer pageContainer = (PageContainer)pomgr.getSelectedObject();
- Page page = pageContainer.createPage(pageName);
- DomainConfigurator configurator = pomgr.getDomainConfigurator();
- Set constraints = Collections.singleton(new
RoleSecurityBinding(PortalObjectPermission.VIEW_RECURSIVE_ACTION,
SecurityConstants.UNCHECKED_ROLE_NAME));
-
configurator.setSecurityBindings(page.getId().toString(PortalObjectId.CANONICAL_FORMAT),
constraints);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-}
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2007-03-15
12:33:20 UTC (rev 6678)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2007-03-15
12:48:16 UTC (rev 6679)
@@ -87,12 +87,16 @@
</managed-bean>
<managed-bean>
<managed-bean-name>addPageAction</managed-bean-name>
-
<managed-bean-class>org.jboss.portal.core.admin.ui.actions.AddPageAction</managed-bean-class>
+
<managed-bean-class>org.jboss.portal.core.admin.ui.actions.AddPageAction2</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
- <property-name>portalObjectManager</property-name>
- <value>#{sessionScope.portalobjectmgr}</value>
+ <property-name>pageContainer</property-name>
+ <value>#{portalobjectmgr.selectedObject}</value>
</managed-property>
+ <managed-property>
+ <property-name>domainConfigurator</property-name>
+
<value>#{applicationScope.AuthorizationDomainRegistry.portalobject.configurator}</value>
+ </managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>themePropertyAction</managed-bean-name>