[jboss-svn-commits] JBL Code SVN: r9203 - in labs/jbosslabs/trunk/portal-extensions-newprj: forge-ejb3 and 15 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jan 31 12:43:03 EST 2007
Author: adamw
Date: 2007-01-31 12:43:03 -0500 (Wed, 31 Jan 2007)
New Revision: 9203
Added:
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/forge-ejb3.iml
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/maven.xml
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/project.properties
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/project.xml
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/AbstractAuthorizationBean.java
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/InstanceManagerBean.java
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/LazyPortalObjectTreeNode.java
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/PortalObjectManagerBean.java
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/PortletManagerBean.java
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/PreferencesBean.java
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/Refresher.java
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/AddPageAction.java
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/AddWindowAction.java
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/CreateInstanceAction.java
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/PortalAction.java
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/PreferenceAction.java
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/PropertyAction.java
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/ThemePropertyAction.java
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java/
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java/org/
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java/org/jboss/
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java/org/jboss/labs/
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java/org/jboss/labs/services/
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java/org/jboss/labs/services/projectpages/
labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java/org/jboss/labs/services/projectpages/ProjectPagesServiceImpl.java
Log:
Labs EJB3 components
Property changes on: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3
___________________________________________________________________
Name: svn:ignore
+ target
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/forge-ejb3.iml
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/forge-ejb3.iml (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/forge-ejb3.iml 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+ <component name="ModuleRootManager" />
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/java-portal" isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="forge-common" />
+ <orderEntry type="module" module-name="shotoku-aop" />
+ <orderEntry type="module" module-name="shotoku-base" />
+ <orderEntry type="library" name="jboss" level="application" />
+ <orderEntry type="library" name="portal" level="application" />
+ <orderEntry type="library" name="portlet" level="application" />
+ <orderEntryProperties />
+ </component>
+</module>
+
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/maven.xml
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/maven.xml (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/maven.xml 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,25 @@
+<!--
+ JBoss, the OpenSource J2EE webOS
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+ -->
+<project xmlns:j="jelly:core" xmlns:ant="jelly:ant" xmlns:u="jelly:util">
+ <!-- Default war-project goals -->
+
+ <goal name="all">
+ <attainGoal name="prj-all" />
+ </goal>
+
+ <goal name="build">
+ <attainGoal name="jar" />
+ </goal>
+
+ <goal name="deploy">
+ <ant:copy file="target/${maven.final.name}.jar"
+ tofile="${local.deploy.dir}/${maven.final.name}.ejb3" />
+ </goal>
+
+ <goal name="clean">
+ <attainGoal name="prj-clean" />
+ </goal>
+</project>
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/project.properties
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/project.properties (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/project.properties 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,5 @@
+maven.repo.remote=http://repo1.maven.org/maven
+maven.junit.fork=yes
+maven.war.src=${basedir}/src/web
+
+maven.final.name=${pom.artifactId}
\ No newline at end of file
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/project.xml
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/project.xml (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/project.xml 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,46 @@
+<?xml version='1.0' encoding='ISO-8859-1'?>
+<!--
+ JBoss, the OpenSource J2EE webOS
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+ -->
+<project>
+ <pomVersion>3</pomVersion>
+ <extend>../common.xml</extend>
+ <id>forge-ejb3</id>
+ <name>Various forge ejb3 components</name>
+ <currentVersion>1.0</currentVersion>
+ <organization>
+ <name>Adam Warski</name>
+ <url>http://mamut.net.pl</url>
+ </organization>
+ <description></description>
+
+ <dependencies>
+ <dependency>
+ <groupId>jboss-forge</groupId>
+ <artifactId>forge-common</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>ejb3-persistence</artifactId>
+ <jar>ejb3-persistence.jar</jar>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-ejb3x</artifactId>
+ <jar>jboss-ejb3x.jar</jar>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ <jar>jboss-j2ee.jar</jar>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-annotations-ejb3</artifactId>
+ <jar>jboss-annotations-ejb3.jar</jar>
+ </dependency>
+ </dependencies>
+</project>
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java/org/jboss/labs/services/projectpages/ProjectPagesServiceImpl.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java/org/jboss/labs/services/projectpages/ProjectPagesServiceImpl.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java/org/jboss/labs/services/projectpages/ProjectPagesServiceImpl.java 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,17 @@
+package org.jboss.labs.services.projectpages;
+
+import org.jboss.annotation.ejb.Service;
+import org.jboss.annotation.ejb.Management;
+import org.jboss.annotation.ejb.Depends;
+import org.jboss.forge.common.soa.projectpages.ProjectPagesService;
+import org.jboss.forge.common.soa.projects.ProjectsService;
+
+/**
+ * @author <a href="mailto:adamw at aster.pl">Adam Warski</a>
+ */
+//@Service(objectName= ProjectPagesService.PROJECT_PAGES_SERVICE)
+//@Management(ProjectPagesService.class)
+//@Depends(ProjectsService.PROJECTS_SERVICE)
+public class ProjectPagesServiceImpl {
+
+}
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/AbstractAuthorizationBean.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/AbstractAuthorizationBean.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/AbstractAuthorizationBean.java 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,156 @@
+/******************************************************************************
+ * 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.portlet.management;
+
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.faces.el.PropertyAccessor;
+import org.jboss.portal.security.RoleSecurityBinding;
+import org.jboss.portal.security.spi.provider.DomainConfigurator;
+import org.jboss.portal.security.spi.provider.SecurityConfigurationException;
+
+import javax.faces.model.SelectItem;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public abstract class AbstractAuthorizationBean
+{
+
+ public DomainConfigurator getDomainConfigurator()
+ {
+ throw new UnsupportedOperationException("Implement me");
+ }
+
+ public PropertyAccessor getForRole()
+ {
+ return new PropertyAccessor()
+ {
+ public Class getType(Object propertyName)
+ {
+ return String[].class;
+ }
+
+ public Object getValue(Object propertyName)
+ {
+ return getActionsForRole((String)propertyName);
+ }
+
+ public void setValue(Object propertyName, Object value)
+ {
+ setActionsForRole((String)propertyName, (String[])value);
+ }
+ };
+ }
+
+ public void setActionsForRole(String roleName, String[] actions)
+ {
+ String uri = getURI();
+ if (uri != null)
+ {
+ Set constraints = getDomainConfigurator().getSecurityBindings(uri);
+ Map newConstraints = new HashMap();
+ if (constraints != null)
+ {
+ for (Iterator i = constraints.iterator(); i.hasNext();)
+ {
+ RoleSecurityBinding binding = (RoleSecurityBinding)i.next();
+ newConstraints.put(binding.getRoleName(), binding);
+ }
+ }
+ Set blah = Tools.toSet(actions);
+ newConstraints.put(roleName, new RoleSecurityBinding(blah, roleName));
+ try
+ {
+ getDomainConfigurator().setSecurityBindings(uri, new HashSet(newConstraints.values()));
+ }
+ catch (SecurityConfigurationException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public String[] getActionsForRole(String roleName)
+ {
+ String uri = getURI();
+ if (uri != null)
+ {
+ Set constraints = getDomainConfigurator().getSecurityBindings(uri);
+ if (constraints != null)
+ {
+ Set actions = new HashSet();
+ for (Iterator i = constraints.iterator(); i.hasNext();)
+ {
+ RoleSecurityBinding binding = (RoleSecurityBinding)i.next();
+ if (binding.getRoleName().equals(roleName))
+ {
+ actions.addAll(binding.getActions());
+ }
+ }
+ return (String[])actions.toArray(new String[actions.size()]);
+ }
+ else
+ {
+ return new String[0];
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /** Return the roles. */
+ public String[] getRoles()
+ {
+ String uri = getURI();
+ if (uri != null)
+ {
+ Set roleNames = new HashSet();
+ Set constraints = getDomainConfigurator().getSecurityBindings(uri);
+ if (constraints != null)
+ {
+ for (Iterator i = constraints.iterator(); i.hasNext();)
+ {
+ RoleSecurityBinding binding = (RoleSecurityBinding)i.next();
+ roleNames.add(binding.getRoleName());
+ }
+ }
+ return (String[])roleNames.toArray(new String[roleNames.size()]);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public abstract SelectItem[] getAvailableActions();
+
+ protected abstract String getURI();
+}
Property changes on: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/AbstractAuthorizationBean.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/InstanceManagerBean.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/InstanceManagerBean.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/InstanceManagerBean.java 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,475 @@
+/******************************************************************************
+ * 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.portlet.management;
+
+import org.jboss.logging.Logger;
+import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.common.value.Value;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.instance.NoSuchInstanceException;
+import org.jboss.portal.faces.matrix.Cell;
+import org.jboss.portal.faces.matrix.Row;
+import org.jboss.portal.faces.matrix.RowSetModel;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.info.MetaInfo;
+import org.jboss.portal.portlet.info.PreferencesInfo;
+import org.jboss.portal.portlet.state.PropertyMap;
+import org.jboss.portal.security.AuthorizationDomainRegistry;
+import org.jboss.portal.security.SecurityConstants;
+import org.jboss.portal.security.spi.provider.DomainConfigurator;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.model.SelectItem;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 5915 $
+ */
+public class InstanceManagerBean
+{
+
+ /** . */
+ private Logger log = Logger.getLogger(getClass());
+
+ /** . */
+ private InstanceContainer instanceContainer;
+
+ /** . */
+ private String selectedId;
+
+ /** . */
+ private String selectedPlugin;
+
+ /** . */
+ private AuthorizationDomainRegistry authorizationDomainRegistry;
+
+ /** . */
+ private RoleModule roleModule;
+
+ /** . */
+ private PreferencesBean selectedPreferences;
+
+ /** . */
+ private AbstractAuthorizationBean auth = new AuthorizationBean();
+
+ /** . */
+ private Integer selectedRow;
+
+ private String sortColumn;
+
+ private boolean sortAscending;
+
+ public InstanceManagerBean()
+ {
+ }
+
+ public String getSortColumn()
+ {
+ return sortColumn;
+ }
+
+ public void setSortColumn(String sortColumn)
+ {
+ this.sortColumn = sortColumn;
+ }
+
+ public boolean getSortAscending()
+ {
+ return sortAscending;
+ }
+
+ public void setSortAscending(boolean sortAscending)
+ {
+ this.sortAscending = sortAscending;
+ }
+
+ public Integer getSelectedRow()
+ {
+ return selectedRow;
+ }
+
+ public void setSelectedRow(Integer selectedRow)
+ {
+ this.selectedRow = selectedRow;
+ }
+
+ public InstanceContainer getInstanceContainer()
+ {
+ return instanceContainer;
+ }
+
+ public void setInstanceContainer(InstanceContainer instanceContainer)
+ {
+ this.instanceContainer = instanceContainer;
+ }
+
+ public String getSelectedId()
+ {
+ return selectedId;
+ }
+
+ public void setSelectedId(String selectedId)
+ {
+ this.selectedId = selectedId;
+ }
+
+ public AuthorizationDomainRegistry getAuthorizationDomainRegistry()
+ {
+ return authorizationDomainRegistry;
+ }
+
+ public void setAuthorizationDomainRegistry(AuthorizationDomainRegistry authorizationDomainRegistry)
+ {
+ this.authorizationDomainRegistry = authorizationDomainRegistry;
+ }
+
+ public RoleModule getRoleModule()
+ {
+ return roleModule;
+ }
+
+ public void setRoleModule(RoleModule roleModule)
+ {
+ this.roleModule = roleModule;
+ }
+
+ public DomainConfigurator getDomainConfigurator()
+ {
+ return authorizationDomainRegistry.getDomain("instance").getConfigurator();
+ }
+
+ public Instance getSelectedInstance()
+ {
+ if (selectedId != null)
+ {
+ return instanceContainer.getDefinition(selectedId);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public PreferencesBean getSelectedPreferences()
+ {
+ return selectedPreferences;
+ }
+
+ public String getSelectedPlugin()
+ {
+ return selectedPlugin;
+ }
+
+ public void setSelectedPlugin(String selectedPlugin)
+ {
+ this.selectedPlugin = selectedPlugin;
+ }
+
+ public void selectPlugin()
+ {
+ // Get id
+ Map pmap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
+ selectedPlugin = (String)pmap.get("plugin");
+ }
+
+ public AbstractAuthorizationBean getAuth()
+ {
+ return auth;
+ }
+
+ /** Return an array of all instances known in this container. */
+ public Collection getInstances()
+ {
+ List instances = new ArrayList();
+ for (Iterator i = instanceContainer.getDefinitions().iterator(); i.hasNext();)
+ {
+ Instance instance = (Instance)i.next();
+ try
+ {
+ Portlet portlet = instance.getPortlet();
+ Object[] line = new Object[]
+ {
+ instance,
+ portlet,
+ };
+ instances.add(line);
+ }
+ catch (PortletInvokerException e)
+ {
+ log.warn("Couldn't access portlet invoker associated to instance " + instance.getId()
+ + ". This instance won't be listed.\nReason:\n\t" + e.getLocalizedMessage());
+ }
+ }
+
+ try
+ {
+ sortInstances(instances, sortColumn, sortAscending);
+ }
+ catch (Exception e)
+ {
+ log.warn("Error during sorting instances list");
+ }
+
+ return instances;
+ }
+
+ public void selectInstance()
+ {
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ ExternalContext ectx = ctx.getExternalContext();
+ Map params = ectx.getRequestParameterMap();
+ selectedId = (String)params.get("id");
+ selectedPreferences = null;
+ selectedPlugin = "preferences";
+ }
+
+ public void deleteInstance()
+ {
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ ExternalContext ectx = ctx.getExternalContext();
+ Map params = ectx.getRequestParameterMap();
+ String id = (String)params.get("id");
+
+ if (id == null)
+ {
+ // Error
+ }
+
+ try
+ {
+ instanceContainer.destroyDefinition(id);
+
+ //
+ if (id.equals(selectedId))
+ {
+ selectedId = null;
+ selectedPreferences = null;
+ }
+ }
+ catch (NoSuchInstanceException e)
+ {
+ e.printStackTrace();
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+
+ /** Refresh the selected prefs. */
+ public void refresh()
+ {
+ selectedPreferences = null;
+
+ //
+ Instance selectedInstance = getSelectedInstance();
+ if (selectedInstance != null)
+ {
+ PreferencesInfo prefsInfo = null;
+ try
+ {
+ prefsInfo = selectedInstance.getPortlet().getInfo().getPreferences();
+ }
+ catch (PortletInvokerException e)
+ {
+ log.warn("Couldn't access portlet invoker associated to instance " + selectedInstance.getId()
+ + ". This instance won't be refreshed.\nReason:\n\t" + e.getLocalizedMessage());
+ }
+
+ if (prefsInfo != null)
+ {
+ RowSetModel model = new RowSetModel(null, prefsInfo.getKeys().size());
+
+ //
+ PropertyMap prefs;
+ try
+ {
+ prefs = getSelectedInstance().getProperties();
+ }
+ catch (PortletInvokerException e)
+ {
+ throw new Error("Handle me gracefully please", e);
+ }
+
+ //
+ int index = 0;
+ for (Iterator i = prefsInfo.getKeys().iterator(); i.hasNext(); index++)
+ {
+ String key = (String)i.next();
+
+ // Get info for this key
+// PreferenceInfo info = prefsInfo.getPreference(key);
+// boolean readOnly = info.isReadOnly();
+ boolean readOnly = false;
+// Value value = info.getValue();
+
+ // Get value from the state
+ Value value = prefs.getProperty(key);
+
+ //
+ Row row = model.getRow(index);
+ row.setReadOnly(readOnly);
+
+ //
+ Cell cell = row.getCell();
+ cell.setHandback("" + i);
+ cell.setValue(value.asStringArray());
+
+ //
+ row.setHandback(key);
+ row.setKey(key);
+ row.setName("Description");
+ row.setReadOnly(false);
+ row.setValue(value.asStringArray());
+ }
+
+ //
+ selectedPreferences = new PreferencesBean(model);
+
+ //
+ if (selectedRow != null)
+ {
+ selectedPreferences.selectRow(selectedRow);
+ }
+ }
+ }
+ }
+
+ public static void sortInstances(List instances, final String column, final boolean ascending)
+ {
+ Comparator comparator = new Comparator()
+ {
+ public int compare(Object o1, Object o2)
+ {
+ if (column == null)
+ {
+ return 0;
+ }
+ if (column.equals("id"))
+ {
+ Instance i1 = (Instance)((Object[])o1)[0];
+ Instance i2 = (Instance)((Object[])o2)[0];
+ return ascending ? i1.getId().compareToIgnoreCase(i2.getId()) : i2.getId()
+ .compareToIgnoreCase(i1.getId());
+ }
+ if (column.equals("portlet"))
+ {
+ Portlet p1 = (Portlet)((Object[])o1)[1];
+ Portlet p2 = (Portlet)((Object[])o2)[1];
+
+ LocalizedString displayName = p1.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ Locale locale = ctx.getExternalContext().getRequestLocale();
+ String name1 = displayName.getString(locale, true);
+ displayName = p2.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
+ String name2 = displayName.getString(locale, true);
+
+ if (name1 == null || name2 == null)
+ {
+ return 0;
+ }
+
+ return ascending ? name1.compareToIgnoreCase(name2) : name2
+ .compareToIgnoreCase(name1);
+ }
+
+ else
+ {
+ return 0;
+ }
+ }
+ };
+ Collections.sort(instances, comparator);
+ }
+
+ public class AuthorizationBean extends AbstractAuthorizationBean
+ {
+
+ public DomainConfigurator getDomainConfigurator()
+ {
+ return InstanceManagerBean.this.getDomainConfigurator();
+ }
+
+ protected String getURI()
+ {
+ Instance instance = getSelectedInstance();
+ if (instance != null)
+ {
+ return instance.getId();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ public String[] getRoles()
+ {
+ String[] roles = super.getRoles();
+ if (roles != null)
+ {
+ try
+ {
+ Set tmp = Tools.toSet(roles);
+ tmp.add(SecurityConstants.UNCHECKED_ROLE_NAME);
+ for (Iterator i = getRoleModule().findRoles().iterator(); i.hasNext();)
+ {
+ Role role = (Role)i.next();
+ tmp.add(role.getName());
+ }
+ roles = (String[])tmp.toArray(new String[tmp.size()]);
+ }
+ catch (IdentityException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ return roles;
+ }
+
+ public SelectItem[] getAvailableActions()
+ {
+ return new SelectItem[]{
+ new SelectItem("view")
+ };
+ }
+ }
+}
Property changes on: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/InstanceManagerBean.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/LazyPortalObjectTreeNode.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/LazyPortalObjectTreeNode.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/LazyPortalObjectTreeNode.java 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,176 @@
+/******************************************************************************
+ * 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.portlet.management;
+
+import org.apache.myfaces.custom.tree2.TreeNode;
+import org.jboss.portal.core.model.portal.PortalContainer;
+import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 5774 $
+ */
+public class LazyPortalObjectTreeNode implements TreeNode
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 7253085860667670643L;
+
+ /** . */
+ private PortalObject object;
+
+ /** . */
+ private List children;
+
+ /** . */
+ private String description;
+
+ /** . */
+ private String type;
+
+ public LazyPortalObjectTreeNode(PortalObject object)
+ {
+ this.object = object;
+ this.description = object.getName();
+ switch (object.getType())
+ {
+ case PortalObject.TYPE_CONTEXT:
+ type = "context";
+ break;
+ case PortalObject.TYPE_PORTAL:
+ type = "portal";
+ break;
+ case PortalObject.TYPE_PAGE:
+ type = "page";
+ break;
+ case PortalObject.TYPE_WINDOW:
+ type = "window";
+ break;
+ }
+ }
+
+ public boolean isLeaf()
+ {
+ return object.getChildren().size() == 0;
+ }
+
+ public void setLeaf(boolean b)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public List getChildren()
+ {
+ if (children == null)
+ {
+ children = new ArrayList(object.getChildren());
+ Collections.sort(children, new Comparator()
+ {
+ public int compare(Object o1, Object o2)
+ {
+ int high1 = getOrder(o1);
+ int high2 = getOrder(o2);
+ if (high1 == high2)
+ {
+ return ((PortalObject)o1).getName().compareTo(((PortalObject)o2).getName());
+ }
+ else
+ {
+ return high1 - high2;
+ }
+ }
+ });
+ for (int i = 0; i < children.size(); i++)
+ {
+ PortalObject child = (PortalObject)children.get(i);
+ children.set(i, new LazyPortalObjectTreeNode(child));
+ }
+ }
+ return children;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType(String name)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String name)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getIdentifier()
+ {
+ return object.getId().toString(PortalObjectId.CANONICAL_FORMAT);
+ }
+
+ public void setIdentifier(String name)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getChildCount()
+ {
+ return object.getChildren().size();
+ }
+
+ private static int getOrder(Object o)
+ {
+ if (o instanceof PortalContainer)
+ {
+ return 0;
+ }
+ if (o instanceof Portal)
+ {
+ return 1;
+ }
+ if (o instanceof Page)
+ {
+ return 2;
+ }
+ if (o instanceof Window)
+ {
+ return 3;
+ }
+ return 4;
+ }
+}
Property changes on: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/LazyPortalObjectTreeNode.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/PortalObjectManagerBean.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/PortalObjectManagerBean.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/PortalObjectManagerBean.java 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,1110 @@
+/******************************************************************************
+ * 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.portlet.management;
+
+import org.apache.myfaces.custom.tree2.HtmlTree;
+import org.apache.myfaces.custom.tree2.TreeModel;
+import org.apache.myfaces.custom.tree2.TreeModelBase;
+import org.apache.myfaces.custom.tree2.TreeNode;
+import org.jboss.logging.Logger;
+import org.jboss.portal.api.node.PortalNode;
+import org.jboss.portal.common.MediaType;
+import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.core.aspects.controller.node.Navigation;
+import org.jboss.portal.core.impl.model.portal.PortalObjectImpl;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.PortalObjectContainer;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.faces.el.DelegatingPropertyResolver;
+import org.jboss.portal.faces.el.PropertyDef;
+import org.jboss.portal.faces.el.TypeDef;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.info.MetaInfo;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.security.AuthorizationDomainRegistry;
+import org.jboss.portal.security.SecurityConstants;
+import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
+import org.jboss.portal.security.spi.provider.DomainConfigurator;
+import org.jboss.portal.theme.LayoutService;
+import org.jboss.portal.theme.PortalLayout;
+import org.jboss.portal.theme.PortalTheme;
+import org.jboss.portal.theme.ServerRegistrationID;
+import org.jboss.portal.theme.ThemeConstants;
+import org.jboss.portal.theme.ThemeService;
+import org.jboss.portal.theme.render.PortalRenderSet;
+import org.jboss.portal.theme.strategy.LayoutStrategy;
+import org.jboss.portlet.JBossRenderResponse;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.model.SelectItem;
+import javax.faces.validator.ValidatorException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+/** The portal object manager bean. */
+public class PortalObjectManagerBean implements Serializable
+{
+
+ private Logger log = Logger.getLogger(getClass());
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -8923517554726982622L;
+
+ static
+ {
+ TypeDef roleModuleDef = new TypeDef(RoleModule.class);
+ roleModuleDef.addAccessor("roles", new PropertyDef(Set.class)
+ {
+ public Object getValue(Object base)
+ {
+ try
+ {
+ RoleModule module = (RoleModule)base;
+ return module.findRoles();
+ }
+ catch (IdentityException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+ });
+
+ //
+ TypeDef portletDef = new TypeDef(Portlet.class);
+ portletDef.addAccessor("name", new PropertyDef(String.class)
+ {
+ public Object getValue(Object base)
+ {
+ Portlet portlet = (Portlet)base;
+ LocalizedString displayName = portlet.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ Locale locale = ctx.getExternalContext().getRequestLocale();
+ String name = displayName.getString(locale, true);
+ return name;
+ }
+ });
+ portletDef.addAccessor("description", new PropertyDef(String.class)
+ {
+ public Object getValue(Object base)
+ {
+ Portlet portlet = (Portlet)base;
+ LocalizedString displayName = portlet.getInfo().getMeta().getMetaValue(MetaInfo.DESCRIPTION);
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ Locale locale = ctx.getExternalContext().getRequestLocale();
+ String name = displayName.getString(locale, true);
+ if (name == null)
+ {
+ name = "-";
+ }
+ return name;
+ }
+ });
+ portletDef.addAccessor("remotable", new PropertyDef(String.class)
+ {
+ public Object getValue(Object base)
+ {
+ Portlet portlet = (Portlet)base;
+ PortletInfo info = portlet.getInfo();
+ Boolean remotable = info.isRemotable();
+ return remotable;
+ }
+ });
+ DelegatingPropertyResolver.registerTypeDef(portletDef);
+ }
+
+ /** The selected id. */
+ private String selectedId;
+
+ /** The selected node properties. */
+ private List selectedProperties;
+
+ /** The current tab name. */
+ private String selectedPlugin;
+
+ /** . */
+ private RoleModule roleModule;
+
+ /** . */
+ private PortalObjectContainer portalObjectContainer;
+
+ /** . */
+ private InstanceContainer instanceContainer;
+
+ /** . */
+ private LayoutService layoutService;
+
+ /** . */
+ private ThemeService themeService;
+
+ /** . */
+ private AuthorizationDomainRegistry authorizationDomainRegistry;
+
+ /** . */
+ private PortalAuthorizationManagerFactory portalAuthorizationManagerFactory;
+
+ /** . */
+ private AbstractAuthorizationBean auth = new PortalObjectAuthorizationBean();
+
+ /** . */
+ private ThemeBean themes = new ThemeBean();
+
+ /** Compares two windows according to their order. */
+ private static final Comparator comparator = new Comparator()
+ {
+ public int compare(Object o1, Object o2)
+ {
+ Window w1 = (Window)o1;
+ Window w2 = (Window)o2;
+ int sign = getOrder(w1) - getOrder(w2);
+ if (sign == 0)
+ {
+ sign = w1.getId().compareTo(w2.getId());
+ }
+ return sign;
+ }
+ };
+
+ public RoleModule getRoleModule()
+ {
+ return roleModule;
+ }
+
+ public void setRoleModule(RoleModule roleModule)
+ {
+ this.roleModule = roleModule;
+ }
+
+ public PortalObjectContainer getPortalObjectContainer()
+ {
+ return portalObjectContainer;
+ }
+
+ public void setPortalObjectContainer(PortalObjectContainer poc)
+ {
+ this.portalObjectContainer = poc;
+ }
+
+ public InstanceContainer getInstanceContainer()
+ {
+ return instanceContainer;
+ }
+
+ public void setInstanceContainer(InstanceContainer instanceContainer)
+ {
+ this.instanceContainer = instanceContainer;
+ }
+
+ public LayoutService getLayoutService()
+ {
+ return layoutService;
+ }
+
+ public void setLayoutService(LayoutService layoutService)
+ {
+ this.layoutService = layoutService;
+ }
+
+
+ public ThemeService getThemeService()
+ {
+ return themeService;
+ }
+
+
+ /**
+ * bind the theme service. (defined in the faces-config.xml; injected in WebAppEnhancer, based on jboss-portlet.xml
+ * service entry)
+ *
+ * @param themeService
+ */
+ public void setThemeService(ThemeService themeService)
+ {
+ this.themeService = themeService;
+ }
+
+ public AuthorizationDomainRegistry getAuthorizationDomainRegistry()
+ {
+ return authorizationDomainRegistry;
+ }
+
+ public void setAuthorizationDomainRegistry(AuthorizationDomainRegistry authorizationDomainRegistry)
+ {
+ this.authorizationDomainRegistry = authorizationDomainRegistry;
+ }
+
+ public AbstractAuthorizationBean getAuth()
+ {
+ return auth;
+ }
+
+ public ThemeBean getThemes()
+ {
+ return themes;
+ }
+
+ // ****************************
+
+ public DomainConfigurator getDomainConfigurator()
+ {
+ return authorizationDomainRegistry.getDomain("portalobject").getConfigurator();
+ }
+
+ public PortalObject getSelectedObject()
+ {
+ PortalObject result = null;
+ if (selectedId != null)
+ {
+ try
+ {
+ PortalObjectId id = PortalObjectId.parse(selectedId, PortalObjectId.CANONICAL_FORMAT);
+ result = portalObjectContainer.getObject(id);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ return result;
+ }
+
+ public List getSelectedProperties()
+ {
+ //return selectedProperties;
+ PortalObject object = getSelectedObject();
+ List properties = new ArrayList();
+ for (Iterator i = object.getDeclaredProperties().entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ properties.add(new String[]{(String)entry.getKey(), (String)entry.getValue()});
+ }
+ return properties;
+ }
+
+ public String getSelectedPlugin()
+ {
+ return selectedPlugin;
+ }
+
+ public void selectPlugin()
+ {
+ // Get id
+ Map pmap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
+ selectedPlugin = (String)pmap.get("plugin");
+ }
+
+ /** Proceed to an object selection. */
+ public void selectObject()
+ {
+ try
+ {
+ // Select the empty plugin
+ // selectedPlugin = null;
+
+ // Clear state
+ selectedId = null;
+ selectedProperties = null;
+ selectedPlugin = null;
+
+ // Get id
+ Map pmap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
+ String id = (String)pmap.get("id");
+
+ // Set the state from the id
+ if (id != null)
+ {
+ PortalObjectId poid = PortalObjectId.parse(id, PortalObjectId.CANONICAL_FORMAT);
+ PortalObject object = portalObjectContainer.getObject(poid);
+
+ //
+ if (object != null)
+ {
+ List properties = new ArrayList();
+ for (Iterator i = object.getDeclaredProperties().entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ properties.add(new String[]{(String)entry.getKey(), (String)entry.getValue()});
+ }
+
+ // Update state
+ selectedId = id;
+ selectedPlugin = "manager";
+ selectedProperties = properties;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** Proceed to object destroy. */
+ public void destroyObject()
+ {
+ try
+ {
+ // Clear state
+ selectedId = null;
+ selectedProperties = null;
+ selectedPlugin = null;
+
+ // Get id
+ Map pmap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
+ String id = (String)pmap.get("id");
+
+ // Destroy the object
+ if (id != null)
+ {
+ PortalObjectId poid = PortalObjectId.parse(id, PortalObjectId.CANONICAL_FORMAT);
+ PortalObject object = portalObjectContainer.getObject(poid);
+
+ //
+ object.getParent().destroyChild(object.getName());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private HtmlTree _tree;
+
+ public TreeNode getTreeData()
+ {
+ PortalObject root = portalObjectContainer.getRootObject();
+ return new LazyPortalObjectTreeNode(root);
+ }
+
+ public SelectItem[] getInstanceItems()
+ {
+ Collection instances = instanceContainer.getDefinitions();
+
+ //sort instances by id
+ List sortedInstances = new LinkedList();
+ for (Iterator i = instances.iterator(); i.hasNext();)
+ {
+ Instance instance = (Instance)i.next();
+ sortedInstances.add(instance);
+ }
+ try
+ {
+ sortInstances(sortedInstances, "id", true);
+ }
+ catch (Exception e)
+ {
+ log.warn("Error while sorting instances list");
+ }
+
+ ArrayList list = new ArrayList(instances.size());
+ for (Iterator i = sortedInstances.iterator(); i.hasNext();)
+ {
+ Instance instance = (Instance)i.next();
+ SelectItem item = new SelectItem(instance.getId());
+ list.add(item);
+ }
+ return (SelectItem[])list.toArray(new SelectItem[list.size()]);
+ }
+
+ public SelectItem[] getPortalPageItems()
+ {
+ Collection pages = getSelectedObject().getChildren();
+
+ ArrayList list = new ArrayList(pages.size() + 1);
+ for (Iterator iterator = pages.iterator(); iterator.hasNext();)
+ {
+ PortalObject o = (PortalObject)iterator.next();
+ if (o.getType() == PortalObject.TYPE_PAGE)
+ {
+ SelectItem item = new SelectItem(o.getName());
+ list.add(item);
+ }
+
+ }
+ list.add(new SelectItem("", "no selection"));
+
+ return (SelectItem[])list.toArray(new SelectItem[list.size()]);
+ }
+
+
+ public static void sortInstances(List instances, final String column, final boolean ascending)
+ {
+ Comparator comparator = new Comparator()
+ {
+ public int compare(Object o1, Object o2)
+ {
+ Instance i1 = (Instance)o1;
+ Instance i2 = (Instance)o2;
+
+ if (column == null)
+ {
+ return 0;
+ }
+ if (column.equals("id"))
+ {
+ return ascending ? i1.getId().compareToIgnoreCase(i2.getId()) : i2.getId()
+ .compareToIgnoreCase(i1.getId());
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ };
+ Collections.sort(instances, comparator);
+ }
+
+ private static int getOrder(Window w)
+ {
+ try
+ {
+ return Integer.parseInt(w.getDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER));
+ }
+ catch (NumberFormatException e)
+ {
+ return Integer.MAX_VALUE;
+ }
+ }
+
+ public void moveUp()
+ {
+ try
+ {
+ Map pmap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
+ String id = (String)pmap.get("id");
+ PortalObjectId poid = PortalObjectId.parse(id, PortalObjectId.CANONICAL_FORMAT);
+ Window target = (Window)portalObjectContainer.getObject(poid);
+ move(target, MOVE_UP);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void moveDown()
+ {
+ try
+ {
+ Map pmap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
+ String id = (String)pmap.get("id");
+ PortalObjectId poid = PortalObjectId.parse(id, PortalObjectId.CANONICAL_FORMAT);
+ Window target = (Window)portalObjectContainer.getObject(poid);
+ move(target, MOVE_DOWN);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void moveRight()
+ {
+ try
+ {
+ Map pmap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
+ String id = (String)pmap.get("id");
+ PortalObjectId poid = PortalObjectId.parse(id, PortalObjectId.CANONICAL_FORMAT);
+ Window target = (Window)portalObjectContainer.getObject(poid);
+ move(target, MOVE_RIGHT);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void moveLeft()
+ {
+ try
+ {
+ Map pmap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
+ String id = (String)pmap.get("id");
+ PortalObjectId poid = PortalObjectId.parse(id, PortalObjectId.CANONICAL_FORMAT);
+ Window target = (Window)portalObjectContainer.getObject(poid);
+ move(target, MOVE_LEFT);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void move(Window target, int direction)
+ {
+ try
+ {
+ // Get region
+ String region = target.getDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION);
+ if (region == null)
+ {
+ region = "unknown";
+ }
+
+ // Get page
+ Page page = (Page)target.getParent();
+
+ // Build the set of cols
+ Map columns = getWindows(page);
+
+ //
+ List regions = new ArrayList(columns.keySet());
+ Collections.sort(regions);
+
+ // Do the move
+ switch (direction)
+ {
+ case MOVE_UP:
+ {
+ List column = new ArrayList((SortedSet)columns.get(region));
+ int order = column.indexOf(target);
+ int newOrder = order - 1;
+ if (newOrder >= 0 && newOrder < column.size())
+ {
+ column.set(order, column.set(newOrder, target));
+ }
+ for (int index = 0; index < column.size(); index++)
+ {
+ Window window = (Window)column.get(index);
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, "" + index);
+ }
+ break;
+ }
+ case MOVE_DOWN:
+ {
+ List column = new ArrayList((SortedSet)columns.get(region));
+ int order = column.indexOf(target);
+ int newOrder = order + 1;
+ if (newOrder >= 0 && newOrder < column.size())
+ {
+ column.set(order, column.set(newOrder, target));
+ }
+ for (int index = 0; index < column.size(); index++)
+ {
+ Window window = (Window)column.get(index);
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, "" + index);
+ }
+ break;
+ }
+ case MOVE_RIGHT:
+ {
+ int index = regions.indexOf(region);
+ if (index < regions.size() - 1)
+ {
+ String newRegion = (String)regions.get(index + 1);
+ target.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, newRegion);
+ target.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, "" + Integer.MAX_VALUE);
+ ((SortedSet)columns.get(region)).remove(target);
+ ((SortedSet)columns.get(newRegion)).add(target);
+ List column = new ArrayList((SortedSet)columns.get(newRegion));
+ for (int i = 0; i < column.size(); i++)
+ {
+ Window window = (Window)column.get(i);
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, "" + i);
+ }
+ }
+ break;
+ }
+ case MOVE_LEFT:
+ {
+ int index = regions.indexOf(region);
+ if (index > 0)
+ {
+ String newRegion = (String)regions.get(index - 1);
+ target.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, newRegion);
+ target.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, "" + Integer.MAX_VALUE);
+ ((SortedSet)columns.get(region)).remove(target);
+ ((SortedSet)columns.get(newRegion)).add(target);
+ List column = new ArrayList((SortedSet)columns.get(newRegion));
+ for (int i = 0; i < column.size(); i++)
+ {
+ Window window = (Window)column.get(i);
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, "" + i);
+ }
+ }
+ break;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** Returns a <Region,<Window>SortedSet>Map. */
+ private Map getWindows(Page page) throws Exception
+ {
+ // Get the layout
+ String layoutId = page.getProperty(ThemeConstants.PORTAL_PROP_LAYOUT);
+ PortalLayout layout = layoutService.getLayout(layoutId, false);
+
+ //
+ LinkedHashMap windows = new LinkedHashMap();
+ for (Iterator i = layout.getLayoutInfo().getRegionNames().iterator(); i.hasNext();)
+ {
+ String region = (String)i.next();
+ windows.put(region, new TreeSet(comparator));
+ }
+ windows.put("unknown", new TreeSet(comparator));
+
+ //
+ for (Iterator j = getSelectedObject().getChildren().iterator(); j.hasNext();)
+ {
+ PortalObject object = (PortalObject)j.next();
+ if (object.getType() == PortalObject.TYPE_WINDOW)
+ {
+ String region = object.getProperty(ThemeConstants.PORTAL_PROP_REGION);
+ if (!windows.containsKey(region))
+ {
+ region = "unknown";
+ }
+ SortedSet set = (SortedSet)windows.get(region);
+ set.add(object);
+ }
+ }
+ return windows;
+ }
+
+ /** Return the <Region>List on the selected object which must be a page. */
+ public List getCols() throws Exception
+ {
+ Map windows = getWindows((Page)getSelectedObject());
+
+ //
+ List regions = new ArrayList(windows.keySet());
+ Collections.sort(regions);
+
+ //
+ return regions;
+ }
+
+ /** Return an array of <Region,Window>Map on the selected object which must be a page. */
+ public Map[] getRows() throws Exception
+ {
+ Map windows = getWindows((Page)getSelectedObject());
+
+ //
+ List regions = new ArrayList(windows.keySet());
+ Collections.sort(regions);
+
+ //
+ Iterator[] iterators = new Iterator[regions.size()];
+ for (int i = 0; i < regions.size(); i++)
+ {
+ String region = (String)regions.get(i);
+ iterators[i] = ((SortedSet)windows.get(region)).iterator();
+ }
+
+ //
+ List maps = new ArrayList();
+ while (true)
+ {
+ Map row = new HashMap();
+ for (int i = 0; i < iterators.length; i++)
+ {
+ Iterator iterator = iterators[i];
+ if (iterator.hasNext())
+ {
+ row.put(regions.get(i), iterator.next());
+ }
+ }
+ if (row.size() == 0)
+ {
+ break;
+ }
+ maps.add(row);
+ }
+
+ return (Map[])maps.toArray(new Map[maps.size()]);
+ }
+
+
+ private static final int MOVE_UP = 0;
+ private static final int MOVE_DOWN = 1;
+ private static final int MOVE_LEFT = 2;
+ private static final int MOVE_RIGHT = 3;
+
+ // ***
+
+ /**
+ * NOTE: This is just to show an alternative way of supplying tree data. You can supply either a TreeModel or
+ * TreeNode.
+ *
+ * @return TreeModel
+ */
+ public TreeModel getExpandedTreeData()
+ {
+ return new TreeModelBase(getTreeData());
+ }
+
+ public void setTree(HtmlTree tree)
+ {
+ _tree = tree;
+ }
+
+ public HtmlTree getTree()
+ {
+ return _tree;
+ }
+
+ public String expandAll()
+ {
+ _tree.expandAll();
+ return null;
+ }
+
+ private String _nodePath;
+
+ public void setNodePath(String nodePath)
+ {
+ _nodePath = nodePath;
+ }
+
+ public String getNodePath()
+ {
+ return _nodePath;
+ }
+
+ public void checkPath(FacesContext context, UIComponent component, java.lang.Object value)
+ {
+ // make sure path is valid (leaves cannot be expanded or renderer will complain)
+ FacesMessage message = null;
+
+ String[] path = _tree.getPathInformation(value.toString());
+
+ for (int i = 0; i < path.length; i++)
+ {
+ String nodeId = path[i];
+ try
+ {
+ _tree.setNodeId(nodeId);
+ }
+ catch (Exception e)
+ {
+ throw new ValidatorException(message, e);
+ }
+
+ if (_tree.getNode().isLeaf())
+ {
+ message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
+ "Invalid node path (cannot expand a leaf): " + nodeId,
+ "Invalid node path (cannot expand a leaf): " + nodeId);
+ throw new ValidatorException(message);
+ }
+ }
+ }
+
+ public void expandPath()
+ {
+ _tree.expandPath(_tree.getPathInformation(_nodePath));
+ }
+
+ // ****************************
+
+ public class PortalObjectAuthorizationBean extends AbstractAuthorizationBean
+ {
+
+ public DomainConfigurator getDomainConfigurator()
+ {
+ return PortalObjectManagerBean.this.getDomainConfigurator();
+ }
+
+ protected String getURI()
+ {
+ PortalObject po = getSelectedObject();
+ if (po != null)
+ {
+ return po.getId().toString(PortalObjectId.CANONICAL_FORMAT);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ public String[] getRoles()
+ {
+ String[] roles = super.getRoles();
+ if (roles != null)
+ {
+ try
+ {
+ Set tmp = Tools.toSet(roles);
+ tmp.add(SecurityConstants.UNCHECKED_ROLE_NAME);
+ for (Iterator i = getRoleModule().findRoles().iterator(); i.hasNext();)
+ {
+ Role role = (Role)i.next();
+ tmp.add(role.getName());
+ }
+ roles = (String[])tmp.toArray(new String[tmp.size()]);
+ }
+ catch (IdentityException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ return roles;
+ }
+
+ public SelectItem[] getAvailableActions()
+ {
+ return new SelectItem[]{
+ new SelectItem("view"),
+ new SelectItem("viewrecursive"),
+ new SelectItem("personalize"),
+ new SelectItem("personalizerecursive"),
+ new SelectItem("dashboard"),
+ };
+ }
+ }
+
+ public final class ThemeBean
+ {
+ public boolean isWindow()
+ {
+ PortalObject po = getSelectedObject();
+ if (po != null)
+ {
+ return (po.getType() == PortalObject.TYPE_WINDOW);
+ }
+
+ return false;
+ }
+
+ public String getLayoutName()
+ {
+ return getDeclaredProperty(ThemeConstants.PORTAL_PROP_LAYOUT);
+ }
+
+ public String getThemeName()
+ {
+ return getDeclaredProperty(ThemeConstants.PORTAL_PROP_THEME);
+ }
+
+ public String getRenderSetName()
+ {
+ return getDeclaredProperty(ThemeConstants.PORTAL_PROP_RENDERSET);
+ }
+
+ public String getStrategyName()
+ {
+ return getDeclaredProperty(ThemeConstants.PORTAL_PROP_STRATEGY);
+ }
+
+ public String getWindowRenderer()
+ {
+ return getDeclaredProperty(ThemeConstants.PORTAL_PROP_WINDOW_RENDERER);
+ }
+
+ public String getDecorationRenderer()
+ {
+ return getDeclaredProperty(ThemeConstants.PORTAL_PROP_DECORATION_RENDERER);
+ }
+
+ public String getPortletRenderer()
+ {
+ return getDeclaredProperty(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER);
+ }
+
+ /**
+ * Get the list of available layouts
+ *
+ * @return an array of the available layout names to pick a layout from
+ */
+ public SelectItem[] getLayoutNames()
+ {
+ Collection layouts = layoutService.getLayouts();
+ SelectItem[] names = new SelectItem[layouts.size() + 1];
+ int p = 0;
+ for (Iterator i = layouts.iterator(); i.hasNext();)
+ {
+ PortalLayout layout = (PortalLayout)i.next();
+ names[p++] = new SelectItem(layout.getLayoutInfo().getName(), layout.getLayoutInfo().getName());
+ }
+ names[p] = new SelectItem("", "no selection");
+ return names;
+ }
+
+ /**
+ * Get the list of available themes
+ *
+ * @return an array of the available theme names to pick a theme from
+ */
+ public SelectItem[] getThemeNames()
+ {
+ Collection themes = themeService.getThemes();
+ SelectItem[] themeNames = new SelectItem[themes.size() + 1];
+
+ int p = 0;
+ for (Iterator i = themes.iterator(); i.hasNext();)
+ {
+ PortalTheme theme = (PortalTheme)i.next();
+ themeNames[p++] = new SelectItem(theme.getThemeInfo().getName(), theme.getThemeInfo().getName());
+ }
+ themeNames[p] = new SelectItem("", "no selection");
+
+ return themeNames;
+ }
+
+ /**
+ * Get a list of available render sets
+ *
+ * @return and array of all available render set names to pick a render set from
+ */
+ public SelectItem[] getRenderSetNames()
+ {
+ Collection renderSets = layoutService.getRenderSets();
+ Map names = new HashMap();
+ for (Iterator i = renderSets.iterator(); i.hasNext();)
+ {
+ ServerRegistrationID renderSetId = (ServerRegistrationID)i.next();
+ PortalRenderSet renderSet = layoutService.getRenderSet(renderSetId, MediaType.HTML);
+ if (renderSet != null)
+ {
+ names.put(renderSet.getName(), renderSet.getName());
+ }
+ }
+ SelectItem[] renderSetNames = new SelectItem[names.size() + 1];
+ int i = 0;
+ for (Iterator it = names.keySet().iterator(); it.hasNext();)
+ {
+ String key = (String)it.next();
+ renderSetNames[i++] = new SelectItem(key, (String)names.get(key));
+ }
+ renderSetNames[i] = new SelectItem("", "no selection");
+ return renderSetNames;
+ }
+
+ public SelectItem[] getStrategyNames()
+ {
+ Collection strategies = layoutService.getStrategies();
+ Map names = new HashMap();
+ for (Iterator i = strategies.iterator(); i.hasNext();)
+ {
+ ServerRegistrationID id = (ServerRegistrationID)i.next();
+ LayoutStrategy strategy = layoutService.getStrategy(id, MediaType.HTML);
+ if (strategy != null)
+ {
+ names.put(strategy.getName(), strategy.getName());
+ }
+ }
+ SelectItem[] strategyNames = new SelectItem[names.size() + 1];
+
+ int i = 0;
+ for (Iterator it = names.keySet().iterator(); it.hasNext();)
+ {
+ String key = (String)it.next();
+ strategyNames[i++] = new SelectItem(key, (String)names.get(key));
+ }
+ strategyNames[i] = new SelectItem("", "no selection");
+ return strategyNames;
+ }
+
+ private String getDeclaredProperty(String key)
+ {
+ String value = null;
+ PortalObject po = getSelectedObject();
+ if (po != null)
+ {
+ value = po.getDeclaredProperty(key);
+ }
+
+ return value;
+ }
+ }
+
+ public PortalAuthorizationManagerFactory getPortalAuthorizationManagerFactory()
+ {
+ return portalAuthorizationManagerFactory;
+ }
+
+ public void setPortalAuthorizationManagerFactory(PortalAuthorizationManagerFactory portalAuthorizationManagerFactory)
+ {
+ this.portalAuthorizationManagerFactory = portalAuthorizationManagerFactory;
+ }
+
+ public String getPreviewURL()
+ {
+ try
+ {
+ //set up the root node
+ PortalNode root = Navigation.getCurrentNode();
+ for (; root.getParent() != null;)
+ {
+ root = root.getParent();
+ }
+
+ //obtain the path to our node
+ PortalObjectImpl object = (PortalObjectImpl)getSelectedObject();
+ String path = object.getObjectNode().getPath();
+
+ //iterate to our point
+ String[] nodes = path.split("\\.");
+ PortalNode dest = root;
+
+ for (int i = 0; i < nodes.length; i++)
+ {
+ String s = nodes[i];
+ dest = dest.getChild(s);
+ }
+
+ //generate url
+ JBossRenderResponse response = (JBossRenderResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
+ String url = response.createRenderURL(dest).toString();
+ return url;
+ }
+ catch (Exception e)
+ {
+ log.info("Failed to generate object preview link");
+ e.printStackTrace();
+ }
+ //in case it fails let's point to some nice page ;)
+ return "http://www.jboss.org";
+ }
+}
Property changes on: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/PortalObjectManagerBean.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/PortletManagerBean.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/PortletManagerBean.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/PortletManagerBean.java 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,465 @@
+/******************************************************************************
+ * 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.portlet.management;
+
+import org.jboss.logging.Logger;
+import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.common.value.Value;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.faces.matrix.Cell;
+import org.jboss.portal.faces.matrix.Row;
+import org.jboss.portal.faces.matrix.RowSetModel;
+import org.jboss.portal.portlet.federation.FederatedPortletInvoker;
+import org.jboss.portal.portlet.federation.FederatingPortletInvoker;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.info.MetaInfo;
+import org.jboss.portal.portlet.info.PreferenceInfo;
+import org.jboss.portal.portlet.info.PreferencesInfo;
+import org.jboss.portal.security.AuthorizationDomainRegistry;
+import org.jboss.portal.security.SecurityConstants;
+import org.jboss.portal.security.spi.provider.DomainConfigurator;
+
+import javax.faces.context.FacesContext;
+import javax.faces.model.SelectItem;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 6117 $
+ */
+public class PortletManagerBean
+{
+
+ /** . */
+ private Logger log = Logger.getLogger(getClass());
+
+ /** . */
+ private InstanceContainer instanceContainer;
+
+ /** . */
+ private AuthorizationDomainRegistry authorizationDomainRegistry;
+
+ /** . */
+ private String selectedPortletId;
+
+ /** The current tab name. */
+ private String selectedPlugin;
+
+ /** . */
+ private RoleModule roleModule;
+
+ /** . */
+ private PreferencesBean selectedPreferences;
+
+ /** . */
+ private String selectedFederatedId;
+
+ /** . */
+ private AbstractAuthorizationBean auth = new AuthorizationBean();
+
+ /** . */
+ private FederatingPortletInvoker federatingPortletInvoker;
+
+ private String sortColumn;
+
+ private boolean sortAscending;
+
+ public String getSortColumn()
+ {
+ return sortColumn;
+ }
+
+ public void setSortColumn(String sortColumn)
+ {
+ this.sortColumn = sortColumn;
+ }
+
+ public boolean getSortAscending()
+ {
+ return sortAscending;
+ }
+
+ public void setSortAscending(boolean sortAscending)
+ {
+ this.sortAscending = sortAscending;
+ }
+
+ public RoleModule getRoleModule()
+ {
+ return roleModule;
+ }
+
+ public void setRoleModule(RoleModule roleModule)
+ {
+ this.roleModule = roleModule;
+ }
+
+ private PortletInvoker getPortletInvoker()
+ {
+ FederatedPortletInvoker federated = federatingPortletInvoker.getFederatedInvoker(selectedFederatedId);
+ return federated;
+ }
+
+ public Collection getFederatedIds()
+ {
+ ArrayList toto = new ArrayList();
+ toto.add(new SelectItem("local"));
+ for (Iterator i = federatingPortletInvoker.getFederatedInvokers().iterator(); i.hasNext();)
+ {
+ FederatedPortletInvoker federated = (FederatedPortletInvoker)i.next();
+ if ("local".equals(federated.getId()) == false)
+ {
+ toto.add(new SelectItem(federated.getId()));
+ }
+ }
+ return toto;
+ }
+
+ public InstanceContainer getInstanceContainer()
+ {
+ return instanceContainer;
+ }
+
+ public void setInstanceContainer(InstanceContainer instanceContainer)
+ {
+ this.instanceContainer = instanceContainer;
+ }
+
+ public AuthorizationDomainRegistry getAuthorizationDomainRegistry()
+ {
+ return authorizationDomainRegistry;
+ }
+
+ public void setAuthorizationDomainRegistry(AuthorizationDomainRegistry authorizationDomainRegistry)
+ {
+ this.authorizationDomainRegistry = authorizationDomainRegistry;
+ }
+
+ public String getSelectedPlugin()
+ {
+ return selectedPlugin;
+ }
+
+ public void setSelectedPlugin(String selectedPlugin)
+ {
+ this.selectedPlugin = selectedPlugin;
+ }
+
+ public String getSelectedFederatedId()
+ {
+ return selectedFederatedId;
+ }
+
+ public void setSelectedFederatedId(String selectedFederatedId)
+ {
+ this.selectedFederatedId = selectedFederatedId;
+ }
+
+ public FederatingPortletInvoker getFederatingPortletInvoker()
+ {
+ return federatingPortletInvoker;
+ }
+
+ public void setFederatingPortletInvoker(FederatingPortletInvoker federatingPortletInvoker)
+ {
+ this.federatingPortletInvoker = federatingPortletInvoker;
+ }
+
+ public Collection getPortlets()
+ {
+ List portlets = Collections.EMPTY_LIST;
+ try
+ {
+ portlets = new ArrayList(getPortletInvoker().getPortlets());
+ }
+ catch (PortletInvokerException e)
+ {
+ log.warn("Couldn't access portlet invoker. Portlets won't be listed.\nReason:\n\t" + e.getLocalizedMessage());
+ }
+
+ try
+ {
+ sortPortlets(portlets, sortColumn, sortAscending);
+ }
+ catch (Exception e)
+ {
+ log.warn("Error during sorting portlets list");
+ }
+
+ return portlets;
+ }
+
+ // ****************
+
+ public DomainConfigurator getDomainConfigurator()
+ {
+ return authorizationDomainRegistry.getDomain("portlet").getConfigurator();
+ }
+
+ public String[] getToto()
+ {
+ return new String[]{"1", "2", "3"};
+ }
+
+ public AbstractAuthorizationBean getAuth()
+ {
+ return auth;
+ }
+
+ public Portlet getSelectedPortlet()
+ {
+ if (selectedPortletId != null)
+ {
+ try
+ {
+ return getPortletInvoker().getPortlet(PortletContext.createPortletContext(selectedPortletId));
+ }
+ catch (PortletInvokerException e)
+ {
+ // todo: find a way to report these errors to the user
+ log.warn("Portlet invoker unavailable for portlet: " + selectedPortletId
+ + ". Returning null instead.\nReason:\n\t" + e.getLocalizedMessage());
+ return null;
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public String selectPortlet()
+ {
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ selectedPortletId = (String)ctx.getExternalContext().getRequestParameterMap().get("id");
+ selectedPlugin = "manager";
+ return "portlets";
+ }
+
+ public void selectPlugin()
+ {
+ // Get id
+ Map pmap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
+ selectedPlugin = (String)pmap.get("plugin");
+ }
+
+ public PreferencesBean getSelectedPreferences()
+ {
+ return selectedPreferences;
+ }
+
+ /** Refresh the selected prefs if they are available. */
+ public void refresh()
+ {
+ selectedPreferences = null;
+
+ // Get user locale
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ Locale locale = ctx.getExternalContext().getRequestLocale();
+
+ // Get portlet
+ Portlet portlet = getSelectedPortlet();
+
+ if (portlet != null)
+ {
+ // Get preferences info
+ PreferencesInfo prefsInfo = portlet.getInfo().getPreferences();
+
+ // If the portlet has preferences info then we display them
+ if (prefsInfo != null)
+ {
+ RowSetModel model = new RowSetModel(null, prefsInfo.getKeys().size());
+ model.setMutable(false);
+
+ //
+ int index = 0;
+ for (Iterator i = prefsInfo.getKeys().iterator(); i.hasNext(); index++)
+ {
+ String key = (String)i.next();
+
+ //
+ PreferenceInfo prefs = prefsInfo.getPreference(key);
+ Value value = prefs.getDefaultValue();
+ Boolean readOnly = prefs.isReadOnly();
+
+ //
+ Row row = model.getRow(index);
+
+ //
+ Cell cell = row.getCell();
+ cell.setHandback("" + i);
+ cell.setValue(value.asStringArray());
+
+ //
+ row.setHandback(key);
+ row.setKey(key);
+ row.setName(prefs.getDisplayName().getString(locale, true));
+ row.setReadOnly(Boolean.TRUE.equals(readOnly));
+ row.setValue(value.asStringArray());
+ }
+
+ //
+ selectedPreferences = new PreferencesBean(model);
+ }
+ }
+ }
+
+ public static void sortPortlets(List portlets, final String column, final boolean ascending)
+ {
+ Comparator comparator = new Comparator()
+ {
+ public int compare(Object o1, Object o2)
+ {
+ Portlet p1 = (Portlet)o1;
+ Portlet p2 = (Portlet)o2;
+
+ if (p1 == null || p2 == null)
+ {
+ return 0;
+ }
+
+ if (column == null)
+ {
+ return 0;
+ }
+ if (column.equals("id"))
+ {
+ return ascending ? p1.getContext().getId().compareToIgnoreCase(p2.getContext().getId()) : p2.getContext().getId()
+ .compareToIgnoreCase(p1.getContext().getId());
+ }
+ if (column.equals("name"))
+ {
+
+ LocalizedString displayName = p1.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ Locale locale = ctx.getExternalContext().getRequestLocale();
+ String name1 = displayName.getString(locale, true);
+ if (name1 == null)
+ {
+ name1 = "";
+ }
+ displayName = p2.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
+ String name2 = displayName.getString(locale, true);
+ if (name2 == null)
+ {
+ name2 = "";
+ }
+
+ return ascending ? name1.compareToIgnoreCase(name2) : name2
+ .compareToIgnoreCase(name1);
+ }
+
+ if (column.equals("description"))
+ {
+ LocalizedString displayName = p1.getInfo().getMeta().getMetaValue(MetaInfo.DESCRIPTION);
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ Locale locale = ctx.getExternalContext().getRequestLocale();
+ String name1 = displayName.getString(locale, true);
+ if (name1 == null)
+ {
+ name1 = "-";
+ }
+ displayName = p2.getInfo().getMeta().getMetaValue(MetaInfo.DESCRIPTION);
+ String name2 = displayName.getString(locale, true);
+ if (name2 == null)
+ {
+ name2 = "-";
+ }
+
+ return ascending ? name1.compareToIgnoreCase(name2) : name2
+ .compareToIgnoreCase(name1);
+ }
+
+ else
+ {
+ return 0;
+ }
+ }
+ };
+ Collections.sort(portlets, comparator);
+ }
+
+ public class AuthorizationBean extends AbstractAuthorizationBean
+ {
+
+ protected String getURI()
+ {
+ Portlet portlet = getSelectedPortlet();
+ if (portlet != null)
+ {
+ return portlet.getContext().getId();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public String[] getRoles()
+ {
+ String[] roles = super.getRoles();
+ if (roles != null)
+ {
+ try
+ {
+ Set tmp = Tools.toSet(roles);
+ tmp.add(SecurityConstants.UNCHECKED_ROLE_NAME);
+ for (Iterator i = getRoleModule().findRoles().iterator(); i.hasNext();)
+ {
+ Role role = (Role)i.next();
+ tmp.add(role.getName());
+ }
+ roles = (String[])tmp.toArray(new String[tmp.size()]);
+ }
+ catch (IdentityException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ return roles;
+ }
+
+ public SelectItem[] getAvailableActions()
+ {
+ return new SelectItem[]{
+ new SelectItem("view")
+ };
+ }
+ }
+}
Property changes on: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/PortletManagerBean.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/PreferencesBean.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/PreferencesBean.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/PreferencesBean.java 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * 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.portlet.management;
+
+import org.jboss.portal.faces.matrix.Cell;
+import org.jboss.portal.faces.matrix.Row;
+import org.jboss.portal.faces.matrix.RowSetModel;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class PreferencesBean
+{
+
+ /** . */
+ private RowSetModel model;
+
+ /** . */
+ private Cell selectedPreference;
+
+ public PreferencesBean(RowSetModel selectedPreferences)
+ {
+ this.model = selectedPreferences;
+ }
+
+ public Cell getSelectedPreference()
+ {
+ return selectedPreference;
+ }
+
+ public void setSelectedPreference(Cell selectedPreference)
+ {
+ this.selectedPreference = selectedPreference;
+ }
+
+ public RowSetModel getModel()
+ {
+ return model;
+ }
+
+ public void selectRow(Integer index)
+ {
+ if (index != null)
+ {
+ Row row = model.getRow(index.intValue());
+ selectedPreference = row.getCell();
+ }
+ else
+ {
+ selectedPreference = null;
+ }
+ }
+}
Property changes on: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/PreferencesBean.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/Refresher.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/Refresher.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/Refresher.java 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * 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.portlet.management;
+
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+/**
+ * Refresh the beans before JSR performs the render.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class Refresher implements PhaseListener
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -5027591744094332498L;
+
+ public void afterPhase(PhaseEvent phaseEvent)
+ {
+ }
+
+ public void beforePhase(PhaseEvent phaseEvent)
+ {
+ if (phaseEvent.getPhaseId() == PhaseId.RENDER_RESPONSE)
+ {
+ FacesContext ctx = phaseEvent.getFacesContext();
+
+ //
+ InstanceManagerBean instancemgr = (InstanceManagerBean)ctx.getApplication().createValueBinding("#{instancemgr}").getValue(ctx);
+ instancemgr.refresh();
+
+ //
+ PortletManagerBean portletmgr = (PortletManagerBean)ctx.getApplication().createValueBinding("#{portletmgr}").getValue(ctx);
+ portletmgr.refresh();
+ }
+ }
+
+ public PhaseId getPhaseId()
+ {
+ return PhaseId.ANY_PHASE;
+ }
+}
\ No newline at end of file
Property changes on: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/Refresher.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/AddPageAction.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/AddPageAction.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/AddPageAction.java 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,122 @@
+/******************************************************************************
+ * 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.portlet.management.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.portlet.management.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 at 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();
+ }
+ }
+}
Property changes on: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/AddPageAction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/AddWindowAction.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/AddWindowAction.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/AddWindowAction.java 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,132 @@
+/******************************************************************************
+ * 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.portlet.management.actions;
+
+import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.portlet.management.PortalObjectManagerBean;
+import org.jboss.portal.theme.ThemeConstants;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.validator.ValidatorException;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 6082 $
+ */
+public class AddWindowAction
+{
+
+ /** . */
+ private PortalObjectManagerBean pomgr;
+
+ /** . */
+ private String instanceId;
+
+ /** . */
+ private String windowName;
+
+ public PortalObjectManagerBean getPortalObjectManager()
+ {
+ return pomgr;
+ }
+
+ public void setPortalObjectManager(PortalObjectManagerBean portalObjectManager)
+ {
+ this.pomgr = portalObjectManager;
+ }
+
+ public String getWindowName()
+ {
+ return windowName;
+ }
+
+ public void setWindowName(String windowName)
+ {
+ this.windowName = windowName;
+ }
+
+ public String getInstanceId()
+ {
+ return instanceId;
+ }
+
+ public void setInstanceId(String instanceId)
+ {
+ this.instanceId = instanceId;
+ }
+
+ /**
+ * Checks for duplicate window names on the page. Blank window names are not allowed and are controlled by the
+ * required attribute in the presentation page.
+ *
+ * @param context
+ * @param toValidate
+ * @param value
+ */
+ public void validateWindowName(FacesContext context, UIComponent toValidate, Object value)
+ {
+ String windowName = (String)value;
+
+ // check for empty string
+ if (windowName.startsWith(" "))
+ {
+ String error = "Window name cannot be blank!";
+ FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, error, error);
+ throw new ValidatorException(message);
+ }
+
+ // check for duplicate window name
+ Page page = (Page)pomgr.getSelectedObject();
+ if (page.getWindow(windowName) != null)
+ {
+ String error = "Duplicate window name found on this page!";
+ FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, error, error);
+ throw new ValidatorException(message);
+ }
+ }
+
+ public void execute()
+ {
+ try
+ {
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ ValueBinding vb = ctx.getApplication().createValueBinding("#{col}");
+ String region = (String)vb.getValue(ctx);
+ Page page = (Page)pomgr.getSelectedObject();
+
+ //
+ Window window = page.createWindow(windowName, ContentType.PORTLET, instanceId);
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, region);
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, "" + Integer.MAX_VALUE);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
Property changes on: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/AddWindowAction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/CreateInstanceAction.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/CreateInstanceAction.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/CreateInstanceAction.java 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,119 @@
+/******************************************************************************
+ * 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.portlet.management.actions;
+
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.portlet.management.InstanceManagerBean;
+import org.jboss.portal.core.portlet.management.PortletManagerBean;
+import org.jboss.portal.portlet.Portlet;
+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.context.FacesContext;
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 5915 $
+ */
+public class CreateInstanceAction
+{
+
+ /** . */
+ private String instanceId;
+
+ /** . */
+ private PortletManagerBean portletMgr;
+
+ /** . */
+ private InstanceManagerBean instanceMgr;
+
+ public String getInstanceId()
+ {
+ return instanceId;
+ }
+
+ public void setInstanceId(String instanceId)
+ {
+ this.instanceId = instanceId;
+ }
+
+ public PortletManagerBean getPortletManager()
+ {
+ return portletMgr;
+ }
+
+ public void setPortletManager(PortletManagerBean portletManager)
+ {
+ this.portletMgr = portletManager;
+ }
+
+ public InstanceManagerBean getInstanceManager()
+ {
+ return instanceMgr;
+ }
+
+ public void setInstanceManager(InstanceManagerBean instanceManager)
+ {
+ this.instanceMgr = instanceManager;
+ }
+
+ public String execute()
+ {
+ Portlet portlet = portletMgr.getSelectedPortlet();
+ if (portlet == null)
+ {
+ // Todo validate here
+ return null;
+ }
+ else
+ {
+ InstanceContainer container = instanceMgr.getInstanceContainer();
+ try
+ {
+ Instance instance = container.createDefinition(instanceId, portlet.getContext().getId());
+ instanceMgr.setSelectedId(instanceId);
+
+ //
+ DomainConfigurator configurator = instanceMgr.getDomainConfigurator();
+ Set constraints = Collections.singleton(new RoleSecurityBinding("view", SecurityConstants.UNCHECKED_ROLE_NAME));
+ configurator.setSecurityBindings(instance.getId(), constraints);
+
+ //
+ return "instances";
+ }
+ catch (Exception e)
+ {
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ FacesMessage msg = new FacesMessage("An instance with this name already exist");
+ ctx.addMessage(null, msg);
+ return null;
+ }
+ }
+ }
+
+}
Property changes on: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/CreateInstanceAction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/PortalAction.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/PortalAction.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/PortalAction.java 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,180 @@
+/******************************************************************************
+ * 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.portlet.management.actions;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.core.model.portal.PortalContainer;
+import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.PortalObjectPermission;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.portlet.management.PortalObjectManagerBean;
+import org.jboss.portal.security.RoleSecurityBinding;
+import org.jboss.portal.security.SecurityConstants;
+import org.jboss.portal.security.spi.provider.DomainConfigurator;
+import org.jboss.portal.theme.ThemeConstants;
+
+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.HashSet;
+import java.util.Set;
+
+/**
+ * @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: 5763 $
+ */
+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
+ {
+ PortalContainer portalContainer = (PortalContainer)pomgr.getSelectedObject();
+ Portal portal = portalContainer.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.setSecurityBindings(portal.getId().toString(PortalObjectId.CANONICAL_FORMAT), 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");
+
+ //
+ portal.getSupportedWindowStates().add(WindowState.MAXIMIZED);
+ portal.getSupportedWindowStates().add(WindowState.MINIMIZED);
+ portal.getSupportedWindowStates().add(WindowState.NORMAL);
+
+ //
+ portal.getSupportedModes().add(Mode.EDIT);
+ portal.getSupportedModes().add(Mode.HELP);
+ portal.getSupportedModes().add(Mode.VIEW);
+
+ // Create the default page
+ Page page = portal.createPage("default");
+ constraints = Collections.singleton(new RoleSecurityBinding(PortalObjectPermission.VIEW_RECURSIVE_ACTION, SecurityConstants.UNCHECKED_ROLE_NAME));
+ configurator.setSecurityBindings(page.getId().toString(PortalObjectId.CANONICAL_FORMAT), constraints);
+
+ portal.setDeclaredProperty(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME, page.getName());
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
Property changes on: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/PortalAction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/PreferenceAction.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/PreferenceAction.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/PreferenceAction.java 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,182 @@
+/******************************************************************************
+ * 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.portlet.management.actions;
+
+import org.jboss.portal.common.value.StringValue;
+import org.jboss.portal.common.value.Value;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.portlet.management.InstanceManagerBean;
+import org.jboss.portal.faces.matrix.AbstractCellAction;
+import org.jboss.portal.faces.matrix.Cell;
+import org.jboss.portal.faces.matrix.Row;
+import org.jboss.portal.faces.matrix.RowSetModel;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.state.PropertyChange;
+import org.jboss.portal.portlet.state.PropertyMap;
+import org.jboss.portal.portlet.state.SimplePropertyMap;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class PreferenceAction extends AbstractCellAction
+{
+
+ /** The instance manager bean. */
+ private InstanceManagerBean manager;
+
+ public InstanceManagerBean getManager()
+ {
+ return manager;
+ }
+
+ public void setManager(InstanceManagerBean manager)
+ {
+ this.manager = manager;
+ }
+
+ public void appendLine(String appendedValue)
+ {
+ try
+ {
+ //
+ Row row = getSelectedRow();
+ String key = row.getHandback();
+
+ //
+ Instance instance = manager.getSelectedInstance();
+ PropertyMap prefs = instance.getProperties();
+
+ Value value = prefs.getProperty(key);
+ String[] strings = value.asStringArray();
+ String[] strings2 = new String[strings.length + 1];
+ System.arraycopy(strings, 0, strings2, 0, strings.length);
+ strings2[strings.length] = appendedValue;
+ Value value2 = new StringValue(strings2);
+
+ //
+ PropertyChange change = PropertyChange.newUpdate(key, value2);
+ instance.setProperties(new PropertyChange[]{change});
+ }
+ catch (PortletInvokerException e)
+ {
+ throw new Error("Handle me gracefully please", e);
+ }
+ }
+
+ public void deleteLine(int index)
+ {
+ try
+ {
+ Row row = getSelectedRow();
+ String key = row.getHandback();
+
+ //
+ Instance instance = manager.getSelectedInstance();
+ PropertyMap prefs = instance.getProperties();
+
+ //
+ Value value = prefs.getProperty(key);
+ String[] strings = value.asStringArray();
+ List list = new ArrayList(Arrays.asList(strings));
+ list.remove(index);
+ String[] strings2 = (String[])list.toArray(new String[list.size()]);
+ Value value2 = new StringValue(strings2);
+
+ //
+ PropertyChange change = PropertyChange.newUpdate(key, value2);
+ instance.setProperties(new PropertyChange[]{change});
+ }
+ catch (PortletInvokerException e)
+ {
+ throw new Error("Handle me gracefully please", e);
+ }
+ }
+
+ public void updateCell()
+ {
+ try
+ {
+ Cell cell = manager.getSelectedPreferences().getSelectedPreference();
+ StringValue value = new StringValue(cell.getValue());
+
+ //
+ Row row = cell.getRow();
+ String key = row.getHandback();
+
+ //
+ Instance instance = manager.getSelectedInstance();
+
+ //
+ PropertyChange change = PropertyChange.newUpdate(key, value);
+ instance.setProperties(new PropertyChange[]{change});
+
+ // Unselect the current row has we consider that the update work is done
+ manager.setSelectedRow(null);
+ }
+ catch (PortletInvokerException e)
+ {
+ throw new Error("Handle me gracefully please", e);
+ }
+ }
+
+
+ public void selectRow(int rowIndex)
+ {
+ manager.setSelectedRow(new Integer(rowIndex));
+ }
+
+ public void deleteRow(Row row)
+ {
+ try
+ {
+ //
+ Instance instance = manager.getSelectedInstance();
+ PropertyMap prefs = instance.getProperties();
+ PropertyMap newPrefs = new SimplePropertyMap(prefs);
+
+ //
+ String key = row.getHandback();
+
+ //
+ PropertyChange change = PropertyChange.newReset(key);
+ instance.setProperties(new PropertyChange[]{change});
+ }
+ catch (PortletInvokerException e)
+ {
+ throw new Error("Handle me gracefully please", e);
+ }
+ }
+
+ private Row getSelectedRow()
+ {
+ int selectedRow = manager.getSelectedRow().intValue();
+ RowSetModel model = manager.getSelectedPreferences().getModel();
+ Row row = model.getRow(selectedRow);
+ return row;
+ }
+}
Property changes on: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/PreferenceAction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/PropertyAction.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/PropertyAction.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/PropertyAction.java 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,137 @@
+/******************************************************************************
+ * 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.portlet.management.actions;
+
+import org.apache.myfaces.component.html.ext.HtmlDataTable;
+import org.jboss.logging.Logger;
+import org.jboss.portal.core.portlet.management.PortalObjectManagerBean;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.ValidatorException;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 5448 $
+ */
+public class PropertyAction
+{
+ private Logger log = Logger.getLogger(getClass());
+
+ /** . */
+ private PortalObjectManagerBean pomgr;
+
+ private HtmlDataTable propertyDataTable;
+
+ private String selectedProperty;
+
+ private String propertyValue;
+
+ private static final String ERROR_WRONG_NAME = "Wrong property name!";
+
+ private static final String ERROR_EMPTY_NAME = "Property name cannot be blank!";
+
+ public PortalObjectManagerBean getPortalObjectManager()
+ {
+ //don't know why but this isn't injected properly in faces-config.xml
+ if (pomgr == null)
+ {
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ pomgr = (PortalObjectManagerBean)ctx.getApplication().createValueBinding("#{portalobjectmgr}").getValue(ctx);
+ }
+ return pomgr;
+ }
+
+ public void setPortalObjectManager(PortalObjectManagerBean portalObjectManager)
+ {
+ this.pomgr = portalObjectManager;
+ }
+
+ public String getSelectedProperty()
+ {
+ return selectedProperty;
+ }
+
+ public void setSelectedProperty(String selectedProperty)
+ {
+ this.selectedProperty = selectedProperty;
+ }
+
+ public HtmlDataTable getPropertyDataTable()
+ {
+ return propertyDataTable;
+ }
+
+ public void setPropertyDataTable(HtmlDataTable propertyDataTable)
+ {
+ this.propertyDataTable = propertyDataTable;
+ }
+
+ public String getPropertyValue()
+ {
+ return propertyValue;
+ }
+
+ public void setPropertyValue(String propertyValue)
+ {
+ this.propertyValue = propertyValue;
+ }
+
+
+ public void validatePropertyName(FacesContext context, UIComponent toValidate, Object value)
+ {
+ String propertyName = (String)value;
+
+ // check for empty string
+ if (propertyName == null || propertyName.startsWith(" ") || propertyName.equals(""))
+ {
+ FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, PropertyAction.ERROR_EMPTY_NAME, PropertyAction.ERROR_EMPTY_NAME);
+ throw new ValidatorException(message);
+ }
+
+
+ }
+
+ public void selectProperty()
+ {
+ String[] property = (String[])getPropertyDataTable().getRowData();
+ selectedProperty = property[0];
+ propertyValue = property[1];
+ }
+
+ public void removeProperty()
+ {
+ String[] property = (String[])getPropertyDataTable().getRowData();
+ getPortalObjectManager().getSelectedObject().setDeclaredProperty(property[0], null);
+ }
+
+ public void updateProperty()
+ {
+ if (!(getSelectedProperty() == null || getSelectedProperty().equals("") || getSelectedProperty().startsWith(" ")))
+ {
+ getPortalObjectManager().getSelectedObject().setDeclaredProperty(getSelectedProperty(), getPropertyValue());
+ }
+ }
+
+}
Property changes on: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/PropertyAction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/ThemePropertyAction.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/ThemePropertyAction.java (rev 0)
+++ labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/ThemePropertyAction.java 2007-01-31 17:43:03 UTC (rev 9203)
@@ -0,0 +1,201 @@
+/******************************************************************************
+ * 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.portlet.management.actions;
+
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.portlet.management.PortalObjectManagerBean;
+import org.jboss.portal.theme.ThemeConstants;
+
+/**
+ * @author <a href="mailto:mholzner at novell.com">Martin Holzner</a>
+ * @version $Revision: 5448 $
+ */
+public class ThemePropertyAction
+{
+
+ /** . */
+ private PortalObjectManagerBean pomgr;
+
+ /** . */
+ private String layoutName;
+
+ /** . */
+ private String themeName;
+
+ /** . */
+ private String renderSetName;
+
+ /** . */
+ private String strategyName;
+
+ /** . */
+ private String windowRendererName;
+
+ /** . */
+ private String decorationRendererName;
+
+ /** . */
+ private String portletRendererName;
+
+ public PortalObjectManagerBean getPortalObjectManager()
+ {
+ return pomgr;
+ }
+
+ public void setPortalObjectManager(PortalObjectManagerBean portalObjectManager)
+ {
+ this.pomgr = portalObjectManager;
+
+ layoutName = pomgr.getThemes().getLayoutName();
+ themeName = pomgr.getThemes().getThemeName();
+ renderSetName = pomgr.getThemes().getRenderSetName();
+ strategyName = pomgr.getThemes().getStrategyName();
+ windowRendererName = pomgr.getThemes().getWindowRenderer();
+ decorationRendererName = pomgr.getThemes().getDecorationRenderer();
+ portletRendererName = pomgr.getThemes().getPortletRenderer();
+ }
+
+ public String getLayoutName()
+ {
+ return layoutName;
+ }
+
+ public void setLayoutName(String layoutName)
+ {
+ this.layoutName = ("".equals(layoutName) ? null : layoutName);
+ }
+
+ public String getThemeName()
+ {
+ return themeName;
+ }
+
+ public void setThemeName(String themeName)
+ {
+ this.themeName = ("".equals(themeName) ? null : themeName);
+ }
+
+ public String getRenderSetName()
+ {
+ return renderSetName;
+ }
+
+ public void setRenderSetName(String renderSetName)
+ {
+ this.renderSetName = ("".equals(renderSetName) ? null : renderSetName);
+ }
+
+ public String getStrategyName()
+ {
+ return strategyName;
+ }
+
+ public void setStrategyName(String strategyName)
+ {
+ this.strategyName = ("".equals(strategyName) ? null : strategyName);
+ }
+
+ public String getWindowRendererName()
+ {
+ return windowRendererName;
+ }
+
+ public void setWindowRendererName(String windowRendererName)
+ {
+ this.windowRendererName = ("".equals(windowRendererName) ? null : windowRendererName);
+ }
+
+ public String getDecorationRendererName()
+ {
+ return decorationRendererName;
+ }
+
+ public void setDecorationRendererName(String decorationRendererName)
+ {
+ this.decorationRendererName = ("".equals(decorationRendererName) ? null : decorationRendererName);
+ }
+
+ public String getPortletRendererName()
+ {
+ return portletRendererName;
+ }
+
+ public void setPortletRendererName(String portletRendererName)
+ {
+ this.portletRendererName = ("".equals(portletRendererName) ? null : portletRendererName);
+ }
+
+ public void execute()
+ {
+ PortalObject po = pomgr.getSelectedObject();
+
+ if (po.getType() == PortalObject.TYPE_PORTAL || po.getType() == PortalObject.TYPE_PAGE)
+ {
+ if (layoutName == null || !layoutName.equals(pomgr.getThemes().getLayoutName()))
+ {
+// log.info("set layout to '" + layoutName + "' for " + po.getName());
+ po.setDeclaredProperty(ThemeConstants.PORTAL_PROP_LAYOUT, layoutName);
+ }
+ if (themeName == null || !themeName.equals(pomgr.getThemes().getThemeName()))
+ {
+ if ("".equals(themeName))
+ {
+ }
+// log.info("set theme to '" + themeName + "' for " + po.getName());
+ po.setDeclaredProperty(ThemeConstants.PORTAL_PROP_THEME, themeName);
+ }
+ if (renderSetName == null || !renderSetName.equals(pomgr.getThemes().getRenderSetName()))
+ {
+// log.info("set renderSet to '" + renderSetName + "' for " + po.getName());
+ po.setDeclaredProperty(ThemeConstants.PORTAL_PROP_RENDERSET, renderSetName);
+ }
+ if (strategyName == null || !strategyName.equals(pomgr.getThemes().getStrategyName()))
+ {
+// log.info("set strategy to '" + strategyName + "' for " + po.getName());
+ po.setDeclaredProperty(ThemeConstants.PORTAL_PROP_STRATEGY, strategyName);
+ }
+ }
+ else if (po.getType() == PortalObject.TYPE_WINDOW)
+ {
+ if (windowRendererName == null || !windowRendererName.equals(pomgr.getThemes().getWindowRenderer()))
+ {
+// log.info("set window renderer to '" + windowRendererName + "' for " + po.getName());
+ po.setDeclaredProperty(ThemeConstants.PORTAL_PROP_WINDOW_RENDERER, windowRendererName);
+ }
+ if (decorationRendererName == null || !decorationRendererName.equals(pomgr.getThemes().getDecorationRenderer()))
+ {
+// log.info("set decoration renderer to '" + decorationRendererName + "' for " + po.getName());
+ po.setDeclaredProperty(ThemeConstants.PORTAL_PROP_DECORATION_RENDERER, decorationRendererName);
+ }
+ if (portletRendererName == null || !portletRendererName.equals(pomgr.getThemes().getPortletRenderer()))
+ {
+// log.info("set portlet renderer to '" + portletRendererName + "' for " + po.getName());
+ po.setDeclaredProperty(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER, portletRendererName);
+ }
+ }
+ else
+ {
+// log.error("attempt to set a theme property on an unknown node type: " + po);
+ }
+ }
+}
Property changes on: labs/jbosslabs/trunk/portal-extensions-newprj/forge-ejb3/src/java-portal/org/jboss/portal/core/portlet/management/actions/ThemePropertyAction.java
___________________________________________________________________
Name: svn:executable
+ *
More information about the jboss-svn-commits
mailing list