[kune-commits] r1856 - in trunk/src: main/java/cc/kune/barters/server main/java/cc/kune/blogs/server main/java/cc/kune/core/client/sn main/java/cc/kune/core/server main/java/cc/kune/core/server/content main/java/cc/kune/core/server/tool main/java/cc/kune/docs/server main/java/cc/kune/events/server main/java/cc/kune/gallery/server main/java/cc/kune/lists/server main/java/cc/kune/tasks/server main/java/cc/kune/wave/server main/java/cc/kune/wiki/server test/java/cc/kune/lists/server test/java/cc/kune/wiki/server

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Thu Apr 19 04:16:59 CEST 2012


Author: vjrj_
Date: 2012-04-19 04:16:59 +0200 (Thu, 19 Apr 2012)
New Revision: 1856

Added:
   trunk/src/main/java/cc/kune/core/server/AbstractWaveBasedServerTool.java
   trunk/src/main/java/cc/kune/core/server/tool/ServerToolWithWave.java
   trunk/src/main/java/cc/kune/core/server/tool/ServerToolWithWaveGadget.java
Removed:
   trunk/src/main/java/cc/kune/core/server/tool/ServerWaveTool.java
Modified:
   trunk/src/main/java/cc/kune/barters/server/BarterServerTool.java
   trunk/src/main/java/cc/kune/blogs/server/BlogServerTool.java
   trunk/src/main/java/cc/kune/core/client/sn/AbstractSNPanel.java
   trunk/src/main/java/cc/kune/core/client/sn/GroupSNPanel.java
   trunk/src/main/java/cc/kune/core/client/sn/UserSNPanel.java
   trunk/src/main/java/cc/kune/core/client/sn/UserSNPresenter.java
   trunk/src/main/java/cc/kune/core/server/content/ContentManagerDefault.java
   trunk/src/main/java/cc/kune/core/server/content/CreationServiceDefault.java
   trunk/src/main/java/cc/kune/docs/server/DocumentServerTool.java
   trunk/src/main/java/cc/kune/events/server/EventsServerTool.java
   trunk/src/main/java/cc/kune/gallery/server/GalleryServerTool.java
   trunk/src/main/java/cc/kune/lists/server/ListsServerTool.java
   trunk/src/main/java/cc/kune/tasks/server/TaskServerTool.java
   trunk/src/main/java/cc/kune/wave/server/ParticipantUtils.java
   trunk/src/main/java/cc/kune/wiki/server/WikiServerTool.java
   trunk/src/test/java/cc/kune/lists/server/ListsServerToolTest.java
   trunk/src/test/java/cc/kune/wiki/server/WikiServerToolTest.java
Log:
CLOSED - # 248: Wikis aren't editable by anyone by default 
http://kune.ourproject.org/issues/ticket/248
CLOSED - # 237: Add buddies number in title of your Social Network 
http://kune.ourproject.org/issues/ticket/237

Modified: trunk/src/main/java/cc/kune/barters/server/BarterServerTool.java
===================================================================
--- trunk/src/main/java/cc/kune/barters/server/BarterServerTool.java	2012-04-18 23:14:10 UTC (rev 1855)
+++ trunk/src/main/java/cc/kune/barters/server/BarterServerTool.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -30,13 +30,13 @@
 import java.util.Date;
 
 import cc.kune.common.shared.i18n.I18nTranslationService;
-import cc.kune.core.server.AbstractServerTool;
+import cc.kune.core.server.AbstractWaveBasedServerTool;
 import cc.kune.core.server.content.ContainerManager;
 import cc.kune.core.server.content.ContentManager;
 import cc.kune.core.server.content.CreationService;
 import cc.kune.core.server.manager.ToolConfigurationManager;
 import cc.kune.core.server.tool.ServerToolTarget;
-import cc.kune.core.server.tool.ServerWaveTool;
+import cc.kune.core.server.tool.ServerToolWithWaveGadget;
 import cc.kune.core.server.utils.UrlUtils;
 import cc.kune.core.shared.domain.ContentStatus;
 import cc.kune.core.shared.domain.GroupListMode;
@@ -48,7 +48,7 @@
 
 import com.google.inject.Inject;
 
-public class BarterServerTool extends AbstractServerTool implements ServerWaveTool {
+public class BarterServerTool extends AbstractWaveBasedServerTool implements ServerToolWithWaveGadget {
 
   private static final String BARTER_GADGET = "http://troco.ourproject.org/gadget/org.ourproject.troco.client.TrocoWaveGadget.gadget.xml";
   private final URL gadgetUrl;

Modified: trunk/src/main/java/cc/kune/blogs/server/BlogServerTool.java
===================================================================
--- trunk/src/main/java/cc/kune/blogs/server/BlogServerTool.java	2012-04-18 23:14:10 UTC (rev 1855)
+++ trunk/src/main/java/cc/kune/blogs/server/BlogServerTool.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -19,8 +19,8 @@
  */
 package cc.kune.blogs.server;
 
+import static cc.kune.blogs.shared.BlogsToolConstants.ROOT_NAME;
 import static cc.kune.blogs.shared.BlogsToolConstants.TOOL_NAME;
-import static cc.kune.blogs.shared.BlogsToolConstants.ROOT_NAME;
 import static cc.kune.blogs.shared.BlogsToolConstants.TYPE_BLOG;
 import static cc.kune.blogs.shared.BlogsToolConstants.TYPE_POST;
 import static cc.kune.blogs.shared.BlogsToolConstants.TYPE_ROOT;
@@ -29,7 +29,7 @@
 import java.util.Arrays;
 
 import cc.kune.common.shared.i18n.I18nTranslationService;
-import cc.kune.core.server.AbstractServerTool;
+import cc.kune.core.server.AbstractWaveBasedServerTool;
 import cc.kune.core.server.content.ContainerManager;
 import cc.kune.core.server.content.ContentManager;
 import cc.kune.core.server.content.CreationService;
@@ -40,7 +40,7 @@
 
 import com.google.inject.Inject;
 
-public class BlogServerTool extends AbstractServerTool {
+public class BlogServerTool extends AbstractWaveBasedServerTool {
 
   @Inject
   public BlogServerTool(final ContentManager contentManager, final ContainerManager containerManager,

Modified: trunk/src/main/java/cc/kune/core/client/sn/AbstractSNPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sn/AbstractSNPanel.java	2012-04-18 23:14:10 UTC (rev 1855)
+++ trunk/src/main/java/cc/kune/core/client/sn/AbstractSNPanel.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -132,6 +132,10 @@
     actions.clear();
   }
 
+  protected String countAsString(final int count) {
+    return count > 0 ? new StringBuffer("(").append(count).append(")").toString() : "";
+  }
+
   public BasicDragableThumb createThumb(final String text, final String avatarUrl, final String tooltip,
       final String tooltipTitle, final GuiActionDescCollection menuitems, final StateToken token,
       final boolean dragable) {

Modified: trunk/src/main/java/cc/kune/core/client/sn/GroupSNPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sn/GroupSNPanel.java	2012-04-18 23:14:10 UTC (rev 1855)
+++ trunk/src/main/java/cc/kune/core/client/sn/GroupSNPanel.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -97,7 +97,7 @@
   @Override
   public void setAdminsCount(final int count) {
     armor.getEntityToolsNorth();
-    firstCategoryCount.setText(new StringBuffer("(").append(count).append(")").toString());
+    firstCategoryCount.setText(countAsString(count));
   }
 
   @Override
@@ -107,7 +107,7 @@
 
   @Override
   public void setCollabsCount(final int count) {
-    sndCategoryCount.setText(new StringBuffer("(").append(count).append(")").toString());
+    sndCategoryCount.setText(countAsString(count));
   }
 
   @Override
@@ -117,7 +117,7 @@
 
   @Override
   public void setPendingsCount(final int count) {
-    trdCategoryCount.setText(new StringBuffer("(").append(count).append(")").toString());
+    trdCategoryCount.setText(countAsString(count));
   }
 
   @Override

Modified: trunk/src/main/java/cc/kune/core/client/sn/UserSNPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sn/UserSNPanel.java	2012-04-18 23:14:10 UTC (rev 1855)
+++ trunk/src/main/java/cc/kune/core/client/sn/UserSNPanel.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -100,7 +100,7 @@
 
   @Override
   public void setBuddiesCount(final int count) {
-    firstCategoryCount.setText(new StringBuffer("(").append(count).append(")").toString());
+    firstCategoryCount.setText(countAsString(count));
     firstCategoryLabel.setText(i18n.t("Buddies"));
   }
 
@@ -118,7 +118,7 @@
 
   @Override
   public void setParticipationCount(final int count) {
-    sndCategoryCount.setText(new StringBuffer("(").append(count).append(")").toString());
+    sndCategoryCount.setText(countAsString(count));
   }
 
   @Override

Modified: trunk/src/main/java/cc/kune/core/client/sn/UserSNPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sn/UserSNPresenter.java	2012-04-18 23:14:10 UTC (rev 1855)
+++ trunk/src/main/java/cc/kune/core/client/sn/UserSNPresenter.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -177,6 +177,7 @@
   private int setBuddiesState(final StateAbstractDTO state) {
     final UserBuddiesDataDTO userBuddiesData = state.getUserBuddies();
     final List<UserSimpleDTO> buddies = userBuddiesData.getBuddies();
+    // setBuddiesState
     for (final UserSimpleDTO user : buddies) {
       final String avatarUrl = downloadProvider.get().getUserAvatar(user);
       getView().addBuddie(user, avatarUrl, user.getCompoundName(), "",
@@ -185,6 +186,7 @@
     }
     final boolean hasLocalBuddies = buddies.size() > 0;
     final int numExtBuddies = userBuddiesData.getOtherExtBuddies();
+    final int buddieNumber = buddies.size() + numExtBuddies;
     if (numExtBuddies > 0) {
       if (hasLocalBuddies) {
         // i18n: plural
@@ -202,7 +204,8 @@
         getView().setNoBuddies();
       }
     }
-    return buddies.size() + numExtBuddies;
+    getView().setBuddiesCount(buddieNumber);
+    return buddieNumber;
   }
 
   private int setParticipationState(final StateAbstractDTO state) {
@@ -222,7 +225,7 @@
           state.getGroupRights().isAdministrable());
     }
     final int totalGroups = numAdmins + numCollaborators;
-    // getView().setParticipationCount(totalGroups);
+    getView().setParticipationCount(totalGroups);
     getView().setParticipationVisible(totalGroups > 0, areMany(totalGroups));
     return totalGroups;
   }

Added: trunk/src/main/java/cc/kune/core/server/AbstractWaveBasedServerTool.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/AbstractWaveBasedServerTool.java	                        (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/AbstractWaveBasedServerTool.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -0,0 +1,62 @@
+/*
+ *
+ * Copyright (C) 2007-2012 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package cc.kune.core.server;
+
+import java.util.List;
+
+import org.apache.commons.lang.ArrayUtils;
+
+import cc.kune.common.shared.i18n.I18nTranslationService;
+import cc.kune.core.server.content.ContainerManager;
+import cc.kune.core.server.content.ContentManager;
+import cc.kune.core.server.content.CreationService;
+import cc.kune.core.server.manager.ToolConfigurationManager;
+import cc.kune.core.server.tool.ServerToolTarget;
+import cc.kune.core.server.tool.ServerToolWithWave;
+import cc.kune.domain.Container;
+
+public abstract class AbstractWaveBasedServerTool extends AbstractServerTool implements
+    ServerToolWithWave {
+
+  public AbstractWaveBasedServerTool(final String name, final String rootName, final String typeRoot,
+      final List<String> validContents, final List<String> validContentParents,
+      final List<String> validContainers, final List<String> validContainerParents,
+      final ContentManager contentManager, final ContainerManager containerManager,
+      final CreationService creationService, final ToolConfigurationManager configurationManager,
+      final I18nTranslationService i18n, final ServerToolTarget target) {
+    super(name, rootName, typeRoot, validContents, validContentParents, validContainers,
+        validContainerParents, contentManager, containerManager, creationService, configurationManager,
+        i18n, target);
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see
+   * cc.kune.core.server.tool.ServerToolWithWave#getNewContentAdditionalParts
+   * (cc.kune.domain.Container)
+   */
+  @Override
+  public String[] getNewContentAdditionalParts(final Container containerParent) {
+    return ArrayUtils.EMPTY_STRING_ARRAY;
+  }
+
+}

Modified: trunk/src/main/java/cc/kune/core/server/content/ContentManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/content/ContentManagerDefault.java	2012-04-18 23:14:10 UTC (rev 1855)
+++ trunk/src/main/java/cc/kune/core/server/content/ContentManagerDefault.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -213,7 +213,7 @@
 
   protected Content createContent(final String title, final String body, final WaveRef waveIdToCopy,
       final User author, final Container container, final String typeId, final URL gadgetUrl,
-      final Map<String, String> gadgetProperties) {
+      final Map<String, String> gadgetProperties, final String... otherParticipants) {
     FilenameUtils.checkBasicFilename(title);
     final String newtitle = findInexistentTitle(container, title);
     final Content newContent = new Content();
@@ -228,7 +228,8 @@
     if (newContent.isWave()) {
       final String authorName = author.getShortName();
       final WaveRef waveRef = kuneWaveManager.createWave(newtitle, body, waveIdToCopy,
-          KuneWaveService.DO_NOTHING_CBACK, gadgetUrl, gadgetProperties, participantUtils.of(authorName));
+          KuneWaveService.DO_NOTHING_CBACK, gadgetUrl, gadgetProperties,
+          participantUtils.of(authorName, otherParticipants));
       newContent.setWaveId(JavaWaverefEncoder.encodeToUriPathSegment(waveRef));
       newContent.setModifiedOn((new Date()).getTime());
     }

Modified: trunk/src/main/java/cc/kune/core/server/content/CreationServiceDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/content/CreationServiceDefault.java	2012-04-18 23:14:10 UTC (rev 1855)
+++ trunk/src/main/java/cc/kune/core/server/content/CreationServiceDefault.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -21,10 +21,14 @@
 
 import java.net.URL;
 import java.util.Collections;
+import java.util.Map;
 
+import org.apache.commons.lang.ArrayUtils;
+
 import cc.kune.core.server.tool.ServerTool;
 import cc.kune.core.server.tool.ServerToolRegistry;
-import cc.kune.core.server.tool.ServerWaveTool;
+import cc.kune.core.server.tool.ServerToolWithWave;
+import cc.kune.core.server.tool.ServerToolWithWaveGadget;
 import cc.kune.domain.Container;
 import cc.kune.domain.Content;
 import cc.kune.domain.Group;
@@ -38,6 +42,8 @@
 @Singleton
 public class CreationServiceDefault implements CreationService {
 
+  private static final String[] NO_MORE_PARTICIPANTS = ArrayUtils.EMPTY_STRING_ARRAY;
+  private static final Map<String, String> NO_PROPERTIES = Collections.<String, String> emptyMap();
   private final ContainerManager containerManager;
   private final ContentManagerDefault contentManager;
   private final ServerToolRegistry tools;
@@ -63,10 +69,12 @@
       final Container container, final String typeId) {
     final ServerTool tool = tools.get(container.getToolName());
     tool.checkTypesBeforeContentCreation(container.getTypeId(), typeId);
-    final URL gagdetUrl = tool instanceof ServerWaveTool ? ((ServerWaveTool) tool).getGadgetUrl()
+    final URL gagdetUrl = tool instanceof ServerToolWithWaveGadget ? ((ServerToolWithWaveGadget) tool).getGadgetUrl()
         : KuneWaveService.WITHOUT_GADGET;
+    final String[] otherParticipants = tool instanceof ServerToolWithWave ? ((ServerToolWithWave) tool).getNewContentAdditionalParts(container)
+        : NO_MORE_PARTICIPANTS;
     final Content content = contentManager.createContent(title, body, KuneWaveService.NO_WAVE_TO_COPY,
-        user, container, typeId, gagdetUrl, Collections.<String, String> emptyMap());
+        user, container, typeId, gagdetUrl, NO_PROPERTIES, otherParticipants);
     tool.onCreateContent(content, container);
     return content;
   }

Added: trunk/src/main/java/cc/kune/core/server/tool/ServerToolWithWave.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/tool/ServerToolWithWave.java	                        (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/tool/ServerToolWithWave.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -0,0 +1,37 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package cc.kune.core.server.tool;
+
+import cc.kune.domain.Container;
+
+public interface ServerToolWithWave extends ServerTool {
+
+  /**
+   * Gets the new content additional participants. Use this if you want to add
+   * some wave participant in each new content
+   * 
+   * @param containerParent
+   *          the container parent of the new content
+   * 
+   * @return the new content additional parts
+   */
+  String[] getNewContentAdditionalParts(Container containerParent);
+
+}

Copied: trunk/src/main/java/cc/kune/core/server/tool/ServerToolWithWaveGadget.java (from rev 1847, trunk/src/main/java/cc/kune/core/server/tool/ServerWaveTool.java)
===================================================================
--- trunk/src/main/java/cc/kune/core/server/tool/ServerToolWithWaveGadget.java	                        (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/tool/ServerToolWithWaveGadget.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -0,0 +1,28 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package cc.kune.core.server.tool;
+
+import java.net.URL;
+
+public interface ServerToolWithWaveGadget extends ServerToolWithWave {
+
+  URL getGadgetUrl();
+
+}

Deleted: trunk/src/main/java/cc/kune/core/server/tool/ServerWaveTool.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/tool/ServerWaveTool.java	2012-04-18 23:14:10 UTC (rev 1855)
+++ trunk/src/main/java/cc/kune/core/server/tool/ServerWaveTool.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -1,28 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package cc.kune.core.server.tool;
-
-import java.net.URL;
-
-public interface ServerWaveTool extends ServerTool {
-
-  URL getGadgetUrl();
-
-}

Modified: trunk/src/main/java/cc/kune/docs/server/DocumentServerTool.java
===================================================================
--- trunk/src/main/java/cc/kune/docs/server/DocumentServerTool.java	2012-04-18 23:14:10 UTC (rev 1855)
+++ trunk/src/main/java/cc/kune/docs/server/DocumentServerTool.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -19,8 +19,8 @@
  */
 package cc.kune.docs.server;
 
+import static cc.kune.docs.shared.DocsToolConstants.ROOT_NAME;
 import static cc.kune.docs.shared.DocsToolConstants.TOOL_NAME;
-import static cc.kune.docs.shared.DocsToolConstants.ROOT_NAME;
 import static cc.kune.docs.shared.DocsToolConstants.TYPE_DOCUMENT;
 import static cc.kune.docs.shared.DocsToolConstants.TYPE_FOLDER;
 import static cc.kune.docs.shared.DocsToolConstants.TYPE_ROOT;
@@ -29,7 +29,7 @@
 import java.util.Arrays;
 
 import cc.kune.common.shared.i18n.I18nTranslationService;
-import cc.kune.core.server.AbstractServerTool;
+import cc.kune.core.server.AbstractWaveBasedServerTool;
 import cc.kune.core.server.content.ContainerManager;
 import cc.kune.core.server.content.ContentManager;
 import cc.kune.core.server.content.CreationService;
@@ -43,15 +43,15 @@
 
 import com.google.inject.Inject;
 
-public class DocumentServerTool extends AbstractServerTool {
+public class DocumentServerTool extends AbstractWaveBasedServerTool {
 
   @Inject
   public DocumentServerTool(final ContentManager contentManager,
       final ContainerManager containerManager, final ToolConfigurationManager configurationManager,
       final I18nTranslationService i18n, final CreationService creationService) {
-    super(TOOL_NAME, ROOT_NAME, TYPE_ROOT, Arrays.asList(TYPE_DOCUMENT, TYPE_UPLOADEDFILE), Arrays.asList(
-        TYPE_ROOT, TYPE_FOLDER), Arrays.asList(TYPE_FOLDER), Arrays.asList(TYPE_ROOT, TYPE_FOLDER),
-        contentManager, containerManager, creationService, configurationManager, i18n,
+    super(TOOL_NAME, ROOT_NAME, TYPE_ROOT, Arrays.asList(TYPE_DOCUMENT, TYPE_UPLOADEDFILE),
+        Arrays.asList(TYPE_ROOT, TYPE_FOLDER), Arrays.asList(TYPE_FOLDER), Arrays.asList(TYPE_ROOT,
+            TYPE_FOLDER), contentManager, containerManager, creationService, configurationManager, i18n,
         ServerToolTarget.forBoth);
   }
 

Modified: trunk/src/main/java/cc/kune/events/server/EventsServerTool.java
===================================================================
--- trunk/src/main/java/cc/kune/events/server/EventsServerTool.java	2012-04-18 23:14:10 UTC (rev 1855)
+++ trunk/src/main/java/cc/kune/events/server/EventsServerTool.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -30,13 +30,13 @@
 import java.util.Date;
 
 import cc.kune.common.shared.i18n.I18nTranslationService;
-import cc.kune.core.server.AbstractServerTool;
+import cc.kune.core.server.AbstractWaveBasedServerTool;
 import cc.kune.core.server.content.ContainerManager;
 import cc.kune.core.server.content.ContentManager;
 import cc.kune.core.server.content.CreationService;
 import cc.kune.core.server.manager.ToolConfigurationManager;
 import cc.kune.core.server.tool.ServerToolTarget;
-import cc.kune.core.server.tool.ServerWaveTool;
+import cc.kune.core.server.tool.ServerToolWithWaveGadget;
 import cc.kune.core.server.utils.UrlUtils;
 import cc.kune.core.shared.domain.ContentStatus;
 import cc.kune.core.shared.domain.GroupListMode;
@@ -49,7 +49,7 @@
 
 import com.google.inject.Inject;
 
-public class EventsServerTool extends AbstractServerTool implements ServerWaveTool {
+public class EventsServerTool extends AbstractWaveBasedServerTool implements ServerToolWithWaveGadget {
 
   private static final String MEETING_GADGET = "http://mass-mob.appspot.com/massmob/org.ourproject.massmob.client.MassmobGadget.gadget.xml";
   private final EventsCache eventsCache;

Modified: trunk/src/main/java/cc/kune/gallery/server/GalleryServerTool.java
===================================================================
--- trunk/src/main/java/cc/kune/gallery/server/GalleryServerTool.java	2012-04-18 23:14:10 UTC (rev 1855)
+++ trunk/src/main/java/cc/kune/gallery/server/GalleryServerTool.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -19,8 +19,8 @@
  */
 package cc.kune.gallery.server;
 
+import static cc.kune.gallery.shared.GalleryToolConstants.ROOT_NAME;
 import static cc.kune.gallery.shared.GalleryToolConstants.TOOL_NAME;
-import static cc.kune.gallery.shared.GalleryToolConstants.ROOT_NAME;
 import static cc.kune.gallery.shared.GalleryToolConstants.TYPE_ALBUM;
 import static cc.kune.gallery.shared.GalleryToolConstants.TYPE_ROOT;
 import static cc.kune.gallery.shared.GalleryToolConstants.TYPE_UPLOADEDFILE;
@@ -28,7 +28,7 @@
 import java.util.Arrays;
 
 import cc.kune.common.shared.i18n.I18nTranslationService;
-import cc.kune.core.server.AbstractServerTool;
+import cc.kune.core.server.AbstractWaveBasedServerTool;
 import cc.kune.core.server.content.ContainerManager;
 import cc.kune.core.server.content.ContentManager;
 import cc.kune.core.server.content.CreationService;
@@ -40,7 +40,7 @@
 
 import com.google.inject.Inject;
 
-public class GalleryServerTool extends AbstractServerTool {
+public class GalleryServerTool extends AbstractWaveBasedServerTool {
 
   @Inject
   public GalleryServerTool(final ContentManager contentManager, final ContainerManager containerManager,

Modified: trunk/src/main/java/cc/kune/lists/server/ListsServerTool.java
===================================================================
--- trunk/src/main/java/cc/kune/lists/server/ListsServerTool.java	2012-04-18 23:14:10 UTC (rev 1855)
+++ trunk/src/main/java/cc/kune/lists/server/ListsServerTool.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -19,8 +19,8 @@
  */
 package cc.kune.lists.server;
 
-import static cc.kune.lists.shared.ListsToolConstants.TOOL_NAME;
 import static cc.kune.lists.shared.ListsToolConstants.ROOT_NAME;
+import static cc.kune.lists.shared.ListsToolConstants.TOOL_NAME;
 import static cc.kune.lists.shared.ListsToolConstants.TYPE_LIST;
 import static cc.kune.lists.shared.ListsToolConstants.TYPE_POST;
 import static cc.kune.lists.shared.ListsToolConstants.TYPE_ROOT;
@@ -32,7 +32,7 @@
 import java.util.Set;
 
 import cc.kune.common.shared.i18n.I18nTranslationService;
-import cc.kune.core.server.AbstractServerTool;
+import cc.kune.core.server.AbstractWaveBasedServerTool;
 import cc.kune.core.server.UserSessionManager;
 import cc.kune.core.server.content.ContainerManager;
 import cc.kune.core.server.content.ContentManager;
@@ -44,28 +44,39 @@
 import cc.kune.domain.Content;
 import cc.kune.domain.Group;
 import cc.kune.domain.User;
-import cc.kune.wave.server.KuneWaveServerUtils;
-import cc.kune.wave.server.kspecific.KuneWaveService;
 
 import com.google.inject.Inject;
 
-public class ListsServerTool extends AbstractServerTool {
+public class ListsServerTool extends AbstractWaveBasedServerTool {
 
   private final UserSessionManager userSessionManager;
-  private final KuneWaveService waveManager;
 
   @Inject
   public ListsServerTool(final ContentManager contentManager, final ContainerManager containerManager,
       final ToolConfigurationManager configurationManager, final I18nTranslationService i18n,
-      final UserSessionManager userSessionManager, final KuneWaveService waveManager,
-      final CreationService creationService) {
+      final UserSessionManager userSessionManager, final CreationService creationService) {
     super(TOOL_NAME, ROOT_NAME, TYPE_ROOT, Arrays.asList(TYPE_POST), Arrays.asList(TYPE_LIST),
         Arrays.asList(TYPE_LIST), Arrays.asList(TYPE_ROOT), contentManager, containerManager,
         creationService, configurationManager, i18n, ServerToolTarget.forGroups);
     this.userSessionManager = userSessionManager;
-    this.waveManager = waveManager;
   }
 
+  @Override
+  public String[] getNewContentAdditionalParts(final Container parent) {
+    final Set<Group> admins = parent.getAccessLists().getAdmins().getList();
+    final Set<Group> editors = parent.getAccessLists().getEditors().getList();
+    final ArrayList<String> members = new ArrayList<String>();
+    for (final Group admin : admins) {
+      members.add(admin.getShortName());
+    }
+    for (final Group editor : editors) {
+      members.add(editor.getShortName());
+    }
+    members.add(getUserGroup().getShortName());
+    Collections.sort(members);
+    return members.toArray(new String[members.size()]);
+  }
+
   private Group getUserGroup() {
     return userSessionManager.getUser().getUserGroup();
   }
@@ -78,22 +89,9 @@
 
   @Override
   public void onCreateContent(final Content content, final Container parent) {
+    // TODO Fix closed list??
     content.setStatus(ContentStatus.publishedOnline);
     content.setPublishedOn(new Date());
-    final Set<Group> admins = parent.getAccessLists().getAdmins().getList();
-    final Set<Group> editors = parent.getAccessLists().getEditors().getList();
-    final ArrayList<String> members = new ArrayList<String>();
-    for (final Group admin : admins) {
-      members.add(admin.getShortName());
-    }
-    for (final Group editor : editors) {
-      members.add(editor.getShortName());
-    }
-    members.add(getUserGroup().getShortName());
-    Collections.sort(members);
-    waveManager.addParticipants(KuneWaveServerUtils.getWaveRef(content),
-        content.getAuthors().get(0).getShortName(), getUserGroup().getShortName(),
-        members.toArray(new String[members.size()]));
   }
 
 }

Modified: trunk/src/main/java/cc/kune/tasks/server/TaskServerTool.java
===================================================================
--- trunk/src/main/java/cc/kune/tasks/server/TaskServerTool.java	2012-04-18 23:14:10 UTC (rev 1855)
+++ trunk/src/main/java/cc/kune/tasks/server/TaskServerTool.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -19,8 +19,8 @@
  */
 package cc.kune.tasks.server;
 
+import static cc.kune.tasks.shared.TasksToolConstants.ROOT_NAME;
 import static cc.kune.tasks.shared.TasksToolConstants.TOOL_NAME;
-import static cc.kune.tasks.shared.TasksToolConstants.ROOT_NAME;
 import static cc.kune.tasks.shared.TasksToolConstants.TYPE_FOLDER;
 import static cc.kune.tasks.shared.TasksToolConstants.TYPE_ROOT;
 import static cc.kune.tasks.shared.TasksToolConstants.TYPE_TASK;
@@ -29,7 +29,7 @@
 import java.util.Date;
 
 import cc.kune.common.shared.i18n.I18nTranslationService;
-import cc.kune.core.server.AbstractServerTool;
+import cc.kune.core.server.AbstractWaveBasedServerTool;
 import cc.kune.core.server.content.ContainerManager;
 import cc.kune.core.server.content.ContentManager;
 import cc.kune.core.server.content.CreationService;
@@ -44,14 +44,14 @@
 
 import com.google.inject.Inject;
 
-public class TaskServerTool extends AbstractServerTool {
+public class TaskServerTool extends AbstractWaveBasedServerTool {
 
   @Inject
   public TaskServerTool(final ContentManager contentManager, final ContainerManager containerManager,
       final ToolConfigurationManager configurationManager, final I18nTranslationService i18n,
       final CreationService creationService) {
-    super(TOOL_NAME, ROOT_NAME, TYPE_ROOT, Arrays.asList(TYPE_TASK), Arrays.asList(TYPE_FOLDER, TYPE_ROOT),
-        Arrays.asList(TYPE_FOLDER), Arrays.asList(TYPE_ROOT, TYPE_FOLDER), contentManager,
+    super(TOOL_NAME, ROOT_NAME, TYPE_ROOT, Arrays.asList(TYPE_TASK), Arrays.asList(TYPE_FOLDER,
+        TYPE_ROOT), Arrays.asList(TYPE_FOLDER), Arrays.asList(TYPE_ROOT, TYPE_FOLDER), contentManager,
         containerManager, creationService, configurationManager, i18n, ServerToolTarget.forBoth);
   }
 

Modified: trunk/src/main/java/cc/kune/wave/server/ParticipantUtils.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/server/ParticipantUtils.java	2012-04-18 23:14:10 UTC (rev 1855)
+++ trunk/src/main/java/cc/kune/wave/server/ParticipantUtils.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -129,10 +129,26 @@
     return array;
   }
 
+  public ParticipantId[] of(final String... list) {
+    return listFrom(list);
+  }
+
   public ParticipantId of(final String username) {
     return ofImpl(username);
   }
 
+  public ParticipantId[] of(final String author, final String[] list) {
+    if (list == null) {
+      return listFrom(author);
+    }
+    final ParticipantId[] array = new ParticipantId[list.length + 1];
+    array[0] = of(author);
+    for (int i = 0; i < list.length; i++) {
+      array[i + 1] = of(list[i]);
+    }
+    return array;
+  }
+
   private ParticipantId ofImpl(final String username) {
     try {
       if (username.contains(ParticipantId.DOMAIN_PREFIX)) {
@@ -144,4 +160,5 @@
       throw new DefaultException("Error getting Wave participant Id");
     }
   }
+
 }

Modified: trunk/src/main/java/cc/kune/wiki/server/WikiServerTool.java
===================================================================
--- trunk/src/main/java/cc/kune/wiki/server/WikiServerTool.java	2012-04-18 23:14:10 UTC (rev 1855)
+++ trunk/src/main/java/cc/kune/wiki/server/WikiServerTool.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -19,8 +19,8 @@
  */
 package cc.kune.wiki.server;
 
+import static cc.kune.wiki.shared.WikiToolConstants.ROOT_NAME;
 import static cc.kune.wiki.shared.WikiToolConstants.TOOL_NAME;
-import static cc.kune.wiki.shared.WikiToolConstants.ROOT_NAME;
 import static cc.kune.wiki.shared.WikiToolConstants.TYPE_FOLDER;
 import static cc.kune.wiki.shared.WikiToolConstants.TYPE_ROOT;
 import static cc.kune.wiki.shared.WikiToolConstants.TYPE_UPLOADEDFILE;
@@ -30,7 +30,7 @@
 import java.util.Date;
 
 import cc.kune.common.shared.i18n.I18nTranslationService;
-import cc.kune.core.server.AbstractServerTool;
+import cc.kune.core.server.AbstractWaveBasedServerTool;
 import cc.kune.core.server.content.ContainerManager;
 import cc.kune.core.server.content.ContentManager;
 import cc.kune.core.server.content.CreationService;
@@ -43,22 +43,32 @@
 import cc.kune.domain.Content;
 import cc.kune.domain.Group;
 import cc.kune.domain.User;
+import cc.kune.wave.server.ParticipantUtils;
 
 import com.google.inject.Inject;
 
-public class WikiServerTool extends AbstractServerTool {
+public class WikiServerTool extends AbstractWaveBasedServerTool {
 
+  private final String[] publicArray;
+
   @Inject
   public WikiServerTool(final ContentManager contentManager, final ContainerManager containerManager,
       final ToolConfigurationManager configurationManager, final I18nTranslationService i18n,
-      final CreationService creationService) {
-    super(TOOL_NAME, ROOT_NAME, TYPE_ROOT, Arrays.asList(TYPE_WIKIPAGE, TYPE_UPLOADEDFILE), Arrays.asList(
-        TYPE_ROOT, TYPE_FOLDER), Arrays.asList(TYPE_FOLDER), Arrays.asList(TYPE_ROOT, TYPE_FOLDER),
-        contentManager, containerManager, creationService, configurationManager, i18n,
+      final CreationService creationService, final ParticipantUtils participantUtils) {
+    super(TOOL_NAME, ROOT_NAME, TYPE_ROOT, Arrays.asList(TYPE_WIKIPAGE, TYPE_UPLOADEDFILE),
+        Arrays.asList(TYPE_ROOT, TYPE_FOLDER), Arrays.asList(TYPE_FOLDER), Arrays.asList(TYPE_ROOT,
+            TYPE_FOLDER), contentManager, containerManager, creationService, configurationManager, i18n,
         ServerToolTarget.forBoth);
+    publicArray = new String[1];
+    publicArray[0] = participantUtils.getPublicParticipantId().toString();
   }
 
   @Override
+  public String[] getNewContentAdditionalParts(final Container containerParent) {
+    return publicArray;
+  }
+
+  @Override
   public Group initGroup(final User user, final Group group, final Object... otherVars) {
     createRoot(group);
     return group;

Modified: trunk/src/test/java/cc/kune/lists/server/ListsServerToolTest.java
===================================================================
--- trunk/src/test/java/cc/kune/lists/server/ListsServerToolTest.java	2012-04-18 23:14:10 UTC (rev 1855)
+++ trunk/src/test/java/cc/kune/lists/server/ListsServerToolTest.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -35,7 +35,7 @@
 
   @Before
   public void before() {
-    serverTool = new ListsServerTool(null, null, null, null, null, null, null);
+    serverTool = new ListsServerTool(null, null, null, null, null, null);
   }
 
   @Test

Modified: trunk/src/test/java/cc/kune/wiki/server/WikiServerToolTest.java
===================================================================
--- trunk/src/test/java/cc/kune/wiki/server/WikiServerToolTest.java	2012-04-18 23:14:10 UTC (rev 1855)
+++ trunk/src/test/java/cc/kune/wiki/server/WikiServerToolTest.java	2012-04-19 02:16:59 UTC (rev 1856)
@@ -26,14 +26,21 @@
 
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mockito;
+import org.waveprotocol.wave.model.wave.InvalidParticipantAddress;
+import org.waveprotocol.wave.model.wave.ParticipantId;
 
+import cc.kune.wave.server.ParticipantUtils;
+
 public class WikiServerToolTest { // extends PersistenceTest {
 
   private WikiServerTool serverTool;
 
   @Before
-  public void before() {
-    serverTool = new WikiServerTool(null, null, null, null, null);
+  public void before() throws InvalidParticipantAddress {
+    final ParticipantUtils partUtils = Mockito.mock(ParticipantUtils.class);
+    Mockito.when(partUtils.getPublicParticipantId()).thenReturn(new ParticipantId("example.org"));
+    serverTool = new WikiServerTool(null, null, null, null, null, partUtils);
   }
 
   @Test




More information about the kune-commits mailing list