[kune-commits] r1473 - in trunk/src: main/java/cc/kune/core/server/content main/java/cc/kune/domain main/java/cc/kune/gspace/client main/java/cc/kune/gspace/client/resources main/webapp/others test/java/cc/kune/core/server/manager

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Fri Jul 29 14:48:57 CEST 2011


Author: vjrj_
Date: 2011-07-29 14:48:57 +0200 (Fri, 29 Jul 2011)
New Revision: 1473

Added:
   trunk/src/test/java/cc/kune/core/server/manager/ContainerManagerDefaultTest.java
Modified:
   trunk/src/main/java/cc/kune/core/server/content/ContainerManagerDefault.java
   trunk/src/main/java/cc/kune/domain/Container.java
   trunk/src/main/java/cc/kune/gspace/client/GSpaceArmorImpl.java
   trunk/src/main/java/cc/kune/gspace/client/GSpaceArmorImpl.ui.xml
   trunk/src/main/java/cc/kune/gspace/client/resources/gSpaceArmor.css
   trunk/src/main/webapp/others/kune-client-actions.xml
Log:
CLOSED - # 71: D-and-D folder into folder fails 
http://kune.ourproject.org/issues/ticket/71
CLOSED - # 76: RootPanel setSize for drag and d. arise height problems in chrommium 
http://kune.ourproject.org/issues/ticket/76

Modified: trunk/src/main/java/cc/kune/core/server/content/ContainerManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/content/ContainerManagerDefault.java	2011-07-29 01:24:35 UTC (rev 1472)
+++ trunk/src/main/java/cc/kune/core/server/content/ContainerManagerDefault.java	2011-07-29 12:48:57 UTC (rev 1473)
@@ -29,9 +29,9 @@
 import org.apache.lucene.queryParser.ParseException;
 import org.apache.lucene.search.Query;
 
+import cc.kune.core.client.errors.AccessViolationException;
 import cc.kune.core.client.errors.DefaultException;
 import cc.kune.core.client.errors.NameInUseException;
-import cc.kune.core.client.errors.UnderDevelopmentException;
 import cc.kune.core.server.manager.file.FileUtils;
 import cc.kune.core.server.manager.impl.DefaultManager;
 import cc.kune.core.server.manager.impl.SearchResult;
@@ -67,18 +67,9 @@
       final I18nLanguage language, final String typeId) {
     FilenameUtils.checkBasicFilename(name);
     final String newtitle = findInexistentName(parent, name);
-    final List<Container> parentAbsolutePath = parent.getAbsolutePath();
-    final List<Container> childAbsolutePath = new ArrayList<Container>();
-
-    for (final Container parentRef : parentAbsolutePath) {
-      childAbsolutePath.add(parentRef);
-    }
-    // FIXME: use
-    // childAbsolutePath.addAll(parentAbsolutePath);
     final Container child = new Container(newtitle, group, parent.getToolName());
-    childAbsolutePath.add(child);
+    child.setAbsolutePath(setAbsolutePath(child, parent));
     child.setLanguage(language);
-    child.setAbsolutePath(childAbsolutePath);
     child.setTypeId(typeId);
     parent.addChild(child);
     persist(child);
@@ -114,7 +105,20 @@
 
   @Override
   public void moveContainer(final Container container, final Container newContainer) {
-    throw new UnderDevelopmentException();
+    final String title = container.getName();
+    if (findIfExistsTitle(newContainer, title)) {
+      throw new NameInUseException();
+    }
+    if (container.isRoot()) {
+      // Cannot move root container
+      throw new AccessViolationException();
+    }
+    final Container oldContainer = container.getParent();
+    oldContainer.removeChild(container);
+    newContainer.addChild(container);
+    // AbsolutePath
+    container.setAbsolutePath(setAbsolutePath(container, newContainer));
+    persist(container);
   }
 
   @Override
@@ -152,6 +156,18 @@
     return super.search(query, firstResult, maxResults);
   }
 
+  private List<Container> setAbsolutePath(final Container child, final Container parent) {
+    final List<Container> parentAbsolutePath = parent.getAbsolutePath();
+    final List<Container> childAbsolutePath = new ArrayList<Container>();
+    for (final Container parentRef : parentAbsolutePath) {
+      childAbsolutePath.add(parentRef);
+    }
+    // FIXME: use (tested but change this in other time, not in a pre-release)
+    // childAbsolutePath.addAll(parentAbsolutePath);
+    childAbsolutePath.add(child);
+    return childAbsolutePath;
+  }
+
   @Override
   public void setAccessList(final Container container, final AccessLists accessList) {
     container.setAccessLists(accessList);

Modified: trunk/src/main/java/cc/kune/domain/Container.java
===================================================================
--- trunk/src/main/java/cc/kune/domain/Container.java	2011-07-29 01:24:35 UTC (rev 1472)
+++ trunk/src/main/java/cc/kune/domain/Container.java	2011-07-29 12:48:57 UTC (rev 1473)
@@ -238,6 +238,11 @@
     return parent == null;
   }
 
+  public void removeChild(final Container child) {
+    child.setParent(null);
+    childs.remove(child);
+  }
+
   public void removeContent(final Content content) {
     contents.size();
     contents.remove(content);

Modified: trunk/src/main/java/cc/kune/gspace/client/GSpaceArmorImpl.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/GSpaceArmorImpl.java	2011-07-29 01:24:35 UTC (rev 1472)
+++ trunk/src/main/java/cc/kune/gspace/client/GSpaceArmorImpl.java	2011-07-29 12:48:57 UTC (rev 1473)
@@ -41,7 +41,6 @@
 import com.google.gwt.user.client.ui.SimplePanel;
 import com.google.gwt.user.client.ui.SplitLayoutPanel;
 import com.google.gwt.user.client.ui.TabLayoutPanel;
-import com.google.gwt.user.client.ui.VerticalPanel;
 import com.google.gwt.user.client.ui.Widget;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
@@ -70,7 +69,7 @@
   @UiField
   FlowPanel entityHeader;
   @UiField
-  VerticalPanel entityToolsCenter;
+  FlowPanel entityToolsCenter;
   @UiField
   FlowPanel entityToolsContainer;
   @UiField

Modified: trunk/src/main/java/cc/kune/gspace/client/GSpaceArmorImpl.ui.xml
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/GSpaceArmorImpl.ui.xml	2011-07-29 01:24:35 UTC (rev 1472)
+++ trunk/src/main/java/cc/kune/gspace/client/GSpaceArmorImpl.ui.xml	2011-07-29 12:48:57 UTC (rev 1473)
@@ -93,9 +93,9 @@
                 <g:FlowPanel ui:field="entityToolsContainer">
                   <g:FlowPanel width="100%" ui:field="entityToolsNorth"
                     styleName="{res.style.entityToolsNorth}"></g:FlowPanel>
-                  <g:VerticalPanel width="100%"
+                  <g:FlowPanel width="100%"
                     ui:field="entityToolsCenter" styleName="{res.style.entityToolsCenter}">
-                  </g:VerticalPanel>
+                  </g:FlowPanel>
                 </g:FlowPanel>
                 </g:center>
                 <g:south size="98">

Modified: trunk/src/main/java/cc/kune/gspace/client/resources/gSpaceArmor.css
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/resources/gSpaceArmor.css	2011-07-29 01:24:35 UTC (rev 1472)
+++ trunk/src/main/java/cc/kune/gspace/client/resources/gSpaceArmor.css	2011-07-29 12:48:57 UTC (rev 1473)
@@ -209,7 +209,8 @@
 
 .entityToolsCenter { /*  margin: 10px; */
   overflow: visible !important;
-  margin-top: 10px;
+  padding-top: 10px;
+  clear: both;
 }
 
 .entityToolsCenter span {

Modified: trunk/src/main/webapp/others/kune-client-actions.xml
===================================================================
--- trunk/src/main/webapp/others/kune-client-actions.xml	2011-07-29 01:24:35 UTC (rev 1472)
+++ trunk/src/main/webapp/others/kune-client-actions.xml	2011-07-29 12:48:57 UTC (rev 1473)
@@ -193,6 +193,18 @@
       <iconCss></iconCss>
     </extension>
 
+    <extension>
+      <name>troco</name>
+      <installerUrl>http://troco.ourproject.org/gadget/troco-extension.xml
+      </installerUrl>
+      <gadgetUrl>
+        http://troco.ourproject.org/gadget/org.ourproject.troco.client.TrocoWaveGadget.gadget.xml
+      </gadgetUrl>
+      <iconUrl>http://troco.ourproject.org/gadget/images/icon.png
+      </iconUrl>
+      <iconCss></iconCss>
+    </extension>
+
   </waveExtensions>
 
   <!-- Where and how to use the above extensions ================ -->
@@ -655,7 +667,8 @@
       <description>Make a vector image with others in real-time
       </description>
       <new-content-title>New Vector Image</new-content-title>
-      <new-content-textintro>With this gadget you can make a vector image with others in real-time</new-content-textintro>
+      <new-content-textintro>With this gadget you can make a vector
+        image with others in real-time</new-content-textintro>
       <enabled>true</enabled>
       <typeIds>
         <typeId origTypeId="docs.folder" destTypeId="docs.doc"/>
@@ -672,6 +685,33 @@
       <participants>ask</participants>
     </guiActionDescriptor>
 
+    <guiActionDescriptor>
+      <type>wave-gadget</type>
+      <extensionName>troco</extensionName>
+      <name>New Barter</name>
+      <path>New Gadget»Others</path>
+      <description>Propose a barter deal to others
+      </description>
+      <new-content-title>New Barter</new-content-title>
+      <new-content-textintro>With this gadget you can propose barters to
+        others. Fill up with something you want to give or you something you are looking for, and share with your groups or with the general public. Also you can write more details instead of this text.        </new-content-textintro>
+      <enabled>true</enabled>
+      <typeIds>
+        <typeId origTypeId="docs.folder" destTypeId="docs.doc"/>
+        <typeId origTypeId="docs.root" destTypeId="docs.doc"/>
+        <typeId origTypeId="blogs.blog" destTypeId="blogs.post"/>
+      </typeIds>
+      <rol>
+        <!-- Administrator, Editor, Viewer -->
+        <rolRequired>Editor</rolRequired>
+        <authNeed>true</authNeed>
+      </rol>
+      <!-- only for new waves: anyone, onlymembers, onlyadmins, ask (not
+        used yet) -->
+      <participants>ask</participants>
+    </guiActionDescriptor>
+
+
   </guiActionDescriptors>
 
 </kuneClientActions>

Added: trunk/src/test/java/cc/kune/core/server/manager/ContainerManagerDefaultTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/server/manager/ContainerManagerDefaultTest.java	                        (rev 0)
+++ trunk/src/test/java/cc/kune/core/server/manager/ContainerManagerDefaultTest.java	2011-07-29 12:48:57 UTC (rev 1473)
@@ -0,0 +1,68 @@
+package cc.kune.core.server.manager;
+
+import static cc.kune.docs.shared.DocsConstants.TYPE_FOLDER;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import cc.kune.core.client.errors.AccessViolationException;
+import cc.kune.core.client.errors.NameInUseException;
+import cc.kune.core.server.PersistencePreLoadedDataTest;
+import cc.kune.docs.shared.DocsConstants;
+import cc.kune.domain.Container;
+
+public class ContainerManagerDefaultTest extends PersistencePreLoadedDataTest {
+
+  private Container rootFolder;
+
+  @Before
+  public void before() {
+    rootFolder = containerManager.createRootFolder(user.getUserGroup(), DocsConstants.NAME,
+        DocsConstants.ROOT_NAME, TYPE_FOLDER);
+  }
+
+  private Container createContainer(final Container parent) {
+    return containerManager.createFolder(user.getUserGroup(), parent, "Some title", english, TYPE_FOLDER);
+  }
+
+  @Test
+  public void testCreateFolder() {
+    final Container newFolder = createContainer(rootFolder);
+    assertNotNull(newFolder.getParent());
+    assertEquals(1, rootFolder.getChilds().size());
+    assertEquals(0, newFolder.getChilds().size());
+    assertEquals(1, rootFolder.getAbsolutePath().size());
+    assertEquals(2, newFolder.getAbsolutePath().size());
+  }
+
+  @Test
+  public void testMoveFolder() {
+    final Container folderToMove = createContainer(rootFolder);
+    final Container newParentFolder = createContainer(rootFolder);
+    assertEquals(0, newParentFolder.getChilds().size());
+    containerManager.moveContainer(folderToMove, newParentFolder);
+    assertEquals(newParentFolder, folderToMove.getParent());
+    assertEquals(1, newParentFolder.getChilds().size());
+    assertEquals(1, rootFolder.getChilds().size());
+    assertEquals(3, folderToMove.getAbsolutePath().size());
+    assertEquals(rootFolder, folderToMove.getAbsolutePath().get(0));
+    assertEquals(newParentFolder, folderToMove.getAbsolutePath().get(1));
+    assertEquals(folderToMove, folderToMove.getAbsolutePath().get(2));
+  }
+
+  @Test(expected = NameInUseException.class)
+  public void testMoveFolderNameExists() {
+    final Container folderToMove = createContainer(rootFolder);
+    final Container newParentFolder = createContainer(rootFolder);
+    // Create a folder with the same name
+    createContainer(newParentFolder);
+    containerManager.moveContainer(folderToMove, newParentFolder);
+  }
+
+  @Test(expected = AccessViolationException.class)
+  public void testMoveRootFolderFails() {
+    containerManager.moveContainer(rootFolder, rootFolder);
+  }
+}




More information about the kune-commits mailing list