[jboss-cvs] jboss-portal/core/src/main/org/jboss/portal/core/portlet/management/actions ...
Boleslaw Dawidowicz
bdaw at o2.pl
Thu Jul 27 08:36:03 EDT 2006
User: bdaw
Date: 06/07/27 08:36:03
Added: core/src/main/org/jboss/portal/core/portlet/management/actions
PortalAction.java
Removed: core/src/main/org/jboss/portal/core/portlet/management/actions
AddPortalAction.java
Log:
management - enabling portal defaut page choice
Revision Changes Path
1.1 date: 2006/07/27 12:36:03; author: bdaw; state: Exp;jboss-portal/core/src/main/org/jboss/portal/core/portlet/management/actions/PortalAction.java
Index: PortalAction.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., 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.portlet.management.actions;
import org.jboss.portal.core.portlet.management.PortalObjectManagerBean;
import org.jboss.portal.core.model.portal.PortalObjectPermission;
import org.jboss.portal.core.model.portal.Context;
import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.security.spi.provider.DomainConfigurator;
import org.jboss.portal.security.RoleSecurityBinding;
import org.jboss.portal.security.SecurityConstants;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.server.PortalConstants;
import javax.faces.context.FacesContext;
import javax.faces.component.UIComponent;
import javax.faces.application.FacesMessage;
import javax.faces.validator.ValidatorException;
import java.util.Set;
import java.util.Collections;
import java.util.HashSet;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
* @author <a href="mailto:julien at jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
public class PortalAction
{
/**
* .
*/
private PortalObjectManagerBean pomgr;
/**
* .
*/
private String portalName;
//private String defaultPageName;
/**
* .
*/
private static final String ERROR_DUPE_NAME = "Duplicate Portal name found on this portal!";
/**
* .
*/
private static final String ERROR_EMPTY_NAME = "Portal name cannot be blank!";
public PortalObjectManagerBean getPortalObjectManager()
{
return pomgr;
}
public void setPortalObjectManager(PortalObjectManagerBean portalObjectManager)
{
this.pomgr = portalObjectManager;
}
public String getPortalName()
{
return portalName;
}
public void setPortalName(String portalName)
{
this.portalName = portalName;
}
public String getDefaultPageName()
{
return pomgr.getSelectedObject().getDeclaredProperty(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME);
}
public void setDefaultPageName(String defaultPageName)
{
if (defaultPageName != null && !defaultPageName.equals(""))
{
pomgr.getSelectedObject().setDeclaredProperty(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME, defaultPageName);
}
else if (defaultPageName == null || defaultPageName.equals(""))
{
pomgr.getSelectedObject().setDeclaredProperty(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME, null);
}
}
/**
* Checks for duplicate portal 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 validatePortalName(FacesContext context, UIComponent toValidate, Object value)
{
String portalName = (String)value;
// check for empty string
if (portalName.startsWith(" "))
{
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, PortalAction.ERROR_EMPTY_NAME, PortalAction.ERROR_EMPTY_NAME);
throw new ValidatorException(message);
}
// Check for duplicate child name
if (pomgr.getSelectedObject().getChild(portalName) != null)
{
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, PortalAction.ERROR_DUPE_NAME, PortalAction.ERROR_DUPE_NAME);
throw new ValidatorException(message);
}
}
public void addPortal()
{
try
{
Context context = (Context)pomgr.getSelectedObject();
Portal portal = context.createPortal(portalName);
DomainConfigurator configurator = pomgr.getDomainConfigurator();
//initial portal permissions
Set actions = new HashSet();
actions.add(PortalObjectPermission.VIEW_ACTION);
actions.add(PortalObjectPermission.PERSONALIZE_RECURSIVE_ACTION);
RoleSecurityBinding binding = new RoleSecurityBinding(actions, SecurityConstants.UNCHECKED_ROLE_NAME);
Set constraints = Collections.singleton(binding);
configurator.setBindings(portal.getId(), constraints);
//we need to add initial layout sets to avoid problems...
portal.setDeclaredProperty(ThemeConstants.PORTAL_PROP_LAYOUT, "generic");
portal.setDeclaredProperty(ThemeConstants.PORTAL_PROP_THEME, "Nphalanx");
portal.setDeclaredProperty(ThemeConstants.PORTAL_PROP_RENDERSET, "divRenderer");
portal.setDeclaredProperty(ThemeConstants.PORTAL_PROP_STRATEGY, "maximizedRegion");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
More information about the jboss-cvs-commits
mailing list