Author: thomas.heute(a)jboss.com
Date: 2007-03-26 12:11:30 -0400 (Mon, 26 Mar 2007)
New Revision: 6829
Added:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/renameObject.xhtml
Modified:
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/objectNavigation.xhtml
Log:
Let the admin rename a page or window.
Added: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java
(rev 0)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java 2007-03-26
16:11:30 UTC (rev 6829)
@@ -0,0 +1,106 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.admin.ui.actions;
+
+import java.util.Set;
+
+import org.jboss.portal.core.admin.ui.PortalObjectManagerBean;
+import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
+import org.jboss.portal.core.model.portal.NoSuchPortalObjectException;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.security.spi.provider.DomainConfigurator;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 5763 $
+ */
+public class RenameAction
+{
+ private String newName;
+
+ /** . */
+ private PortalObjectManagerBean portalObjectManager;
+
+ private DomainConfigurator domainConfigurator;
+
+ public void setNewName(String newName)
+ {
+ this.newName = newName;
+ }
+
+ public String getNewName()
+ {
+ return newName;
+ }
+
+
+ public DomainConfigurator getDomainConfigurator()
+ {
+ return domainConfigurator;
+ }
+
+ public void setDomainConfigurator(DomainConfigurator domainConfigurator)
+ {
+ this.domainConfigurator = domainConfigurator;
+ }
+ public PortalObjectManagerBean getPortalObjectManager()
+ {
+ return portalObjectManager;
+ }
+
+ public void setPortalObjectManager(PortalObjectManagerBean portalObjectManager)
+ {
+ this.portalObjectManager = portalObjectManager;
+ }
+
+ public String execute()
+ {
+ PortalObject portalObject = (PortalObject)portalObjectManager.getSelectedObject();
+ PortalObject parent = portalObject.getParent();
+ try {
+ // Clone portal object
+ PortalObject newObject = portalObject.copy(parent, newName, true);
+
+ // Copy security settings
+ Set set =
domainConfigurator.getSecurityBindings(portalObject.getId().toString(PortalObjectId.CANONICAL_FORMAT));
+
domainConfigurator.setSecurityBindings(newObject.getId().toString(PortalObjectId.CANONICAL_FORMAT),
set);
+
+ // Destroy previous object
+ parent.destroyChild(portalObject.getName());
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (DuplicatePortalObjectException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NoSuchPortalObjectException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ portalObjectManager.selectObject(parent);
+ return "objects";
+ }
+
+
+}
Modified:
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/objectNavigation.xhtml
===================================================================
---
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/objectNavigation.xhtml 2007-03-26
15:22:25 UTC (rev 6828)
+++
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/objectNavigation.xhtml 2007-03-26
16:11:30 UTC (rev 6829)
@@ -71,7 +71,10 @@
</h:commandLink> | <h:commandLink action="editPageTheme"
actionListener="#{portalobjectmgr.selectObject}">
<h:outputText value="Theme"/>
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="confirm"
actionListener="#{portalobjectmgr.selectObject}">
+ </h:commandLink> | <h:commandLink action="renameObject"
actionListener="#{portalobjectmgr.selectObject}">
+ <h:outputText value="Rename"/>
+ <f:param name="id" value="#{object.id}"/>
+ </h:commandLink> | <h:commandLink action="confirm"
actionListener="#{portalobjectmgr.selectObject}">
<h:outputText value="Destroy"/>
<f:param name="id" value="#{object.id}"/>
</h:commandLink>
@@ -101,6 +104,9 @@
<h:commandLink action="editWindowTheme"
actionListener="#{portalobjectmgr.selectObject}">
<h:outputText value="Theme"/>
<f:param name="id" value="#{object.id}"/>
+ </h:commandLink> | <h:commandLink action="renameObject"
actionListener="#{portalobjectmgr.selectObject}">
+ <h:outputText value="Rename"/>
+ <f:param name="id" value="#{object.id}"/>
</h:commandLink> | <h:commandLink action="confirm"
actionListener="#{portalobjectmgr.selectObject}">
<h:outputText value="Destroy"/>
<f:param name="id" value="#{object.id}"/>
Added: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/renameObject.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/renameObject.xhtml
(rev 0)
+++
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/renameObject.xhtml 2007-03-26
16:11:30 UTC (rev 6829)
@@ -0,0 +1,16 @@
+<div
+
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:c="http://java.sun.com/jstl/core">
+ <ui:composition template="/WEB-INF/jsf/objectTemplate.xhtml">
+ <ui:define name="content">
+ <h3>Renaming:</h3>
+ <h:form>
+ <h:inputText value="#{renameAction.newName}"/>
+ <h:commandButton value="Update"
action="#{renameAction.execute}"
styleClass="portlet-form-button"/>
+ </h:form>
+ </ui:define>
+ </ui:composition>
+</div>