From do-not-reply at jboss.org Fri Apr 9 04:20:45 2010 Content-Type: multipart/mixed; boundary="===============8885085074393646911==" MIME-Version: 1.0 From: do-not-reply at jboss.org To: gatein-commits at lists.jboss.org Subject: [gatein-commits] gatein SVN: r2543 - in portal/trunk/component/portal/src: main/java/org/exoplatform/portal/pom/config/tasks and 2 other directories. Date: Fri, 09 Apr 2010 04:20:45 -0400 Message-ID: <201004090820.o398KjOQ005383@svn01.web.mwc.hst.phx2.redhat.com> --===============8885085074393646911== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: julien_viet Date: 2010-04-09 04:20:43 -0400 (Fri, 09 Apr 2010) New Revision: 2543 Added: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/confi= g/StaleModelException.java Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/c= onfig/tasks/PageTask.java portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/d= ata/Mapper.java portal/trunk/component/portal/src/test/java/org/exoplatform/portal/confi= g/TestDataStorage.java Log: GTNPORTAL-962 : applied submitted patch and completed it : Lose permission = in clone node (when edit page navigation) Added: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/c= onfig/StaleModelException.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/conf= ig/StaleModelException.java (rev 0) +++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/conf= ig/StaleModelException.java 2010-04-09 08:20:43 UTC (rev 2543) @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2009 eXo Platform SAS. + * + * 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.exoplatform.portal.config; + +/** + * This exception signals that the passed argument model is stale and that= the underlying update operation + * could not be accomplished. + * + * @author Julien Viet + * @version $Revision$ + */ +public class StaleModelException extends StorageException +{ + + public StaleModelException() + { + } + + public StaleModelException(String message) + { + super(message); + } + + public StaleModelException(Throwable cause) + { + super(cause); + } + + public StaleModelException(String message, Throwable cause) + { + super(message, cause); + } +} Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/porta= l/pom/config/tasks/PageTask.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/= config/tasks/PageTask.java 2010-04-09 06:37:13 UTC (rev 2542) +++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/= config/tasks/PageTask.java 2010-04-09 08:20:43 UTC (rev 2543) @@ -21,6 +21,7 @@ = import org.exoplatform.portal.config.NoSuchDataException; import org.exoplatform.portal.mop.Described; +import org.exoplatform.portal.mop.ProtectedResource; import org.exoplatform.portal.pom.config.POMTask; import org.exoplatform.portal.pom.config.cache.DataAccessMode; import org.exoplatform.portal.pom.config.cache.CacheableDataTask; @@ -164,6 +165,12 @@ dstDescribed.setName(srcDescribed.getName()); dstDescribed.setDescription(srcDescribed.getDescription()); = + // Copy src permissions to dst permission + PageData srcPageData =3D new Mapper(session).load(srcPage); + ProtectedResource pr =3D dstPage.adapt(ProtectedResource.class); + pr.setAccessPermissions(srcPageData.getAccessPermissions()); + pr.setEditPermission(srcPageData.getEditPermission()); + copy(srcPage, dstPage, srcPage.getRootComponent(), dstPage.getRoo= tComponent()); = // @@ -178,6 +185,24 @@ UIComponent dstChild =3D dst.add(srcChild.getObjectType(), src= Child.getObjectId()); = // + if (srcChild.isAdapted(Described.class)) + { + Described srcDescribed =3D srcChild.adapt(Described.class); + Described dstDescribed =3D dstChild.adapt(Described.class); + dstDescribed.setName(srcDescribed.getName()); + dstDescribed.setDescription(srcDescribed.getDescription()); + } + + // + if (srcChild.isAdapted(ProtectedResource.class)) + { + ProtectedResource srcPR =3D srcChild.adapt(ProtectedResourc= e.class); + ProtectedResource dstPR =3D dstChild.adapt(ProtectedResourc= e.class); + dstPR.setAccessPermissions(srcPR.getAccessPermissions()); + dstPR.setEditPermission(srcPR.getEditPermission()); + } + + // Attributes srcAttrs =3D srcChild.getAttributes(); Attributes dstAttrs =3D dstChild.getAttributes(); for (String key : srcAttrs.getKeys()) Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/porta= l/pom/data/Mapper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/= data/Mapper.java 2010-04-09 06:37:13 UTC (rev 2542) +++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/= data/Mapper.java 2010-04-09 08:20:43 UTC (rev 2543) @@ -20,6 +20,7 @@ package org.exoplatform.portal.pom.data; = import org.exoplatform.portal.config.NoSuchDataException; +import org.exoplatform.portal.config.StaleModelException; import org.exoplatform.portal.config.UserACL; import org.exoplatform.portal.config.model.ApplicationState; import org.exoplatform.portal.config.model.ApplicationType; @@ -708,7 +709,7 @@ dstChild =3D session.findObjectById(ObjectType.COMPONENT, srcC= hildId); if (dstChild =3D=3D null) { - throw new AssertionError("Could not find supposed present c= hild with id " + srcChildId); + throw new StaleModelException("Could not find supposed pres= ent child with id " + srcChildId); } = // julien : this can fail due to a bug in chromattic not imple= menting equals method properly @@ -774,7 +775,7 @@ } else { - throw new AssertionError("Was not expecting child " + srcCh= ild); + throw new StaleModelException("Was not expecting child " + = srcChild); } changes.add(new ModelChange.Create(dst.getObjectId(), srcChild= )); } Modified: portal/trunk/component/portal/src/test/java/org/exoplatform/porta= l/config/TestDataStorage.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- portal/trunk/component/portal/src/test/java/org/exoplatform/portal/conf= ig/TestDataStorage.java 2010-04-09 06:37:13 UTC (rev 2542) +++ portal/trunk/component/portal/src/test/java/org/exoplatform/portal/conf= ig/TestDataStorage.java 2010-04-09 08:20:43 UTC (rev 2543) @@ -24,16 +24,7 @@ import org.exoplatform.container.PortalContainer; import org.exoplatform.portal.application.PortletPreferences; import org.exoplatform.portal.application.Preference; -import org.exoplatform.portal.config.model.Application; -import org.exoplatform.portal.config.model.ApplicationState; -import org.exoplatform.portal.config.model.ApplicationType; -import org.exoplatform.portal.config.model.Container; -import org.exoplatform.portal.config.model.Dashboard; -import org.exoplatform.portal.config.model.Page; -import org.exoplatform.portal.config.model.PageNavigation; -import org.exoplatform.portal.config.model.PageNode; -import org.exoplatform.portal.config.model.PortalConfig; -import org.exoplatform.portal.config.model.TransientApplicationState; +import org.exoplatform.portal.config.model.*; import org.exoplatform.portal.pom.config.POMSession; import org.exoplatform.portal.pom.config.POMSessionManager; import org.exoplatform.portal.pom.data.ModelChange; @@ -627,6 +618,26 @@ // Application banner2 =3D (Application)container.getChildren().get(0); // assertEquals(banner2.getInstanceId(), banner1.getInstanceId()); + + // + Page srcPage =3D storage_.getPage("portal::test::test4"); + srcPage.setEditPermission("Administrator"); + Applicationportlet =3D (Application)srcPage.getChi= ldren().get(0); + portlet.setDescription("NewPortlet"); + + ArrayList modelObject =3D srcPage.getChildren(); + modelObject.set(0, portlet); + + srcPage.setChildren(modelObject); + + storage_.save(srcPage); + Page dstPage =3D storage_.clonePage(srcPage.getPageId(), srcPage.get= OwnerType(), srcPage.getOwnerId(), "_PageTest1234"); + Applicationportlet1 =3D (Application)dstPage.getCh= ildren().get(0); + // Check src's edit permission and dst's edit permission + assertEquals(srcPage.getEditPermission(), dstPage.getEditPermission(= )); + + // Check src's children and dst's children + assertEquals(portlet.getDescription(), portlet1.getDescription()); } = public void testDashboard() throws Exception --===============8885085074393646911==--