r1371 - in trunk: img/nav-icons img/nav-icons/suplentes src/main/java/cc/kune src/main/java/cc/kune/barters src/main/java/cc/kune/barters/client src/main/java/cc/kune/barters/client/actions src/main/java/cc/kune/barters/server src/main/java/cc/kune/barters/shared src/main/java/cc/kune/blogs/client src/main/java/cc/kune/blogs/server src/main/java/cc/kune/client src/main/java/cc/kune/core/client/resources/nav src/main/java/cc/kune/core/server src/main/java/cc/kune/core/server/content src/main/j
Author: vjrj_ Date: 2011-05-10 21:13:22 +0200 (Tue, 10 May 2011) New Revision: 1371 Added: trunk/img/nav-icons/barter.png trunk/img/nav-icons/barter_add.png trunk/img/nav-icons/suplentes/refresh-brown.png trunk/src/main/java/cc/kune/barters/ trunk/src/main/java/cc/kune/barters/KuneBarters.gwt.xml trunk/src/main/java/cc/kune/barters/client/ trunk/src/main/java/cc/kune/barters/client/BartersClientTool.java trunk/src/main/java/cc/kune/barters/client/BartersGinModule.java trunk/src/main/java/cc/kune/barters/client/BartersGinjector.java trunk/src/main/java/cc/kune/barters/client/BartersParts.java trunk/src/main/java/cc/kune/barters/client/actions/ trunk/src/main/java/cc/kune/barters/client/actions/BartersClientActions.java trunk/src/main/java/cc/kune/barters/client/actions/DelBartersMenuItem.java trunk/src/main/java/cc/kune/barters/client/actions/DelFolderMenuItem.java trunk/src/main/java/cc/kune/barters/client/actions/GoParentFolderBtn.java trunk/src/main/java/cc/kune/barters/client/actions/NewBartersBtn.java trunk/src/main/java/cc/kune/barters/client/actions/NewFolderBtn.java trunk/src/main/java/cc/kune/barters/client/actions/OpenBartersMenuItem.java trunk/src/main/java/cc/kune/barters/server/ trunk/src/main/java/cc/kune/barters/server/BarterServerModule.java trunk/src/main/java/cc/kune/barters/server/BarterServerTool.java trunk/src/main/java/cc/kune/barters/shared/ trunk/src/main/java/cc/kune/barters/shared/BartersConstants.java trunk/src/main/java/cc/kune/core/client/resources/nav/barter.png trunk/src/main/java/cc/kune/core/client/resources/nav/barter_add.png trunk/src/main/java/cc/kune/core/server/tool/ServerWaveTool.java trunk/src/main/java/cc/kune/core/server/utils/UrlUtils.java trunk/src/main/java/cc/kune/gspace/client/tool/AbstractClientTool.java trunk/src/main/java/cc/kune/gspace/client/tool/FoldableAbstractClientTool.java Removed: trunk/src/main/java/cc/kune/gspace/client/tool/old/ trunk/src/main/java/org/ourproject/kune/blogs/client/ Modified: trunk/src/main/java/cc/kune/Kune.gwt.xml trunk/src/main/java/cc/kune/blogs/client/BlogsClientTool.java trunk/src/main/java/cc/kune/blogs/server/BlogServerTool.java trunk/src/main/java/cc/kune/client/KuneEntryPoint.java trunk/src/main/java/cc/kune/client/KuneGinjector.java trunk/src/main/java/cc/kune/core/client/resources/nav/NavResources.java trunk/src/main/java/cc/kune/core/server/KuneRackModule.java trunk/src/main/java/cc/kune/core/server/content/ContentManager.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/core/server/tool/ServerTool.java trunk/src/main/java/cc/kune/docs/client/DocsClientTool.java trunk/src/main/java/cc/kune/docs/server/DocumentServerTool.java trunk/src/main/java/cc/kune/domain/Content.java trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItemPanel.java trunk/src/main/java/cc/kune/wave/server/KuneWaveManager.java trunk/src/main/java/cc/kune/wave/server/KuneWaveManagerDefault.java trunk/src/main/java/cc/kune/wiki/client/WikiClientTool.java trunk/src/main/java/org/ourproject/kune/chat/server/ChatServerTool.java trunk/src/main/java/org/ourproject/kune/gallery/server/GalleryServerTool.java trunk/src/test/java/cc/kune/wave/server/KuneWaveManagerDefaultTest.java Log: barter tool Added: trunk/img/nav-icons/barter.png =================================================================== (Binary files differ) Property changes on: trunk/img/nav-icons/barter.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/img/nav-icons/barter_add.png =================================================================== (Binary files differ) Property changes on: trunk/img/nav-icons/barter_add.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/img/nav-icons/suplentes/refresh-brown.png =================================================================== (Binary files differ) Property changes on: trunk/img/nav-icons/suplentes/refresh-brown.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/src/main/java/cc/kune/Kune.gwt.xml =================================================================== --- trunk/src/main/java/cc/kune/Kune.gwt.xml 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/cc/kune/Kune.gwt.xml 2011-05-10 19:13:22 UTC (rev 1371) @@ -5,9 +5,10 @@ <inherits name='com.google.gwt.logging.Logging' /> <inherits name="cc.kune.core.KuneCore" /> <inherits name="cc.kune.wave.KuneWave" /> + <inherits name="cc.kune.barters.KuneBarters" /> + <inherits name="cc.kune.blogs.KuneBlogs" /> <inherits name="cc.kune.chat.KuneChat" /> <inherits name="cc.kune.docs.KuneDocs" /> - <inherits name="cc.kune.blogs.KuneBlogs" /> <inherits name="cc.kune.wiki.KuneWiki" /> <inherits name="cc.kune.pspace.PSpace" /> <inherits name="com.calclab.suco.Suco" /> Added: trunk/src/main/java/cc/kune/barters/KuneBarters.gwt.xml =================================================================== --- trunk/src/main/java/cc/kune/barters/KuneBarters.gwt.xml (rev 0) +++ trunk/src/main/java/cc/kune/barters/KuneBarters.gwt.xml 2011-05-10 19:13:22 UTC (rev 1371) @@ -0,0 +1,6 @@ +<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.1.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.1.0/distro-source/core/src/gwt-module.dtd"> +<module> + <inherits name="cc.kune.core.KuneCore" /> + <source path="client" /> + <source path="shared" /> +</module> \ No newline at end of file Property changes on: trunk/src/main/java/cc/kune/barters/KuneBarters.gwt.xml ___________________________________________________________________ Name: svn:mime-type + text/plain Added: trunk/src/main/java/cc/kune/barters/client/BartersClientTool.java =================================================================== --- trunk/src/main/java/cc/kune/barters/client/BartersClientTool.java (rev 0) +++ trunk/src/main/java/cc/kune/barters/client/BartersClientTool.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -0,0 +1,68 @@ +/* + * + * Copyright (C) 2007-2009 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.barters.client; + +import static cc.kune.barters.shared.BartersConstants.NAME; +import static cc.kune.barters.shared.BartersConstants.TYPE_BARTER; +import static cc.kune.barters.shared.BartersConstants.TYPE_FOLDER; +import static cc.kune.barters.shared.BartersConstants.TYPE_ROOT; +import cc.kune.core.client.i18n.I18nUITranslationService; +import cc.kune.core.client.registry.ContentCapabilitiesRegistry; +import cc.kune.core.client.resources.nav.NavResources; +import cc.kune.gspace.client.tool.FoldableAbstractClientTool; +import cc.kune.gspace.client.tool.selector.ToolSelector; + +import com.google.inject.Inject; + +public class BartersClientTool extends FoldableAbstractClientTool { + + private final NavResources navResources; + + @Inject + public BartersClientTool(final I18nUITranslationService i18n, final ToolSelector toolSelector, + final ContentCapabilitiesRegistry cntCapRegistry, final NavResources navResources) { + super(NAME, i18n.t("barters"), toolSelector, cntCapRegistry); + this.navResources = navResources; + + // registerAclEditableTypes(TYPE_DOCUMENT, TYPE_UPLOADEDFILE); + registerAuthorableTypes(TYPE_BARTER); + registerDragableTypes(TYPE_BARTER, TYPE_FOLDER); + registerDropableTypes(TYPE_ROOT, TYPE_FOLDER); + // registerPublishModerableTypes(); + registerRateableTypes(TYPE_BARTER); + registerRenamableTypes(TYPE_FOLDER, TYPE_BARTER); + registerTageableTypes(TYPE_BARTER); + registerTranslatableTypes(TYPE_FOLDER, TYPE_BARTER); + + registerIcons(); + } + + @Override + public String getName() { + return NAME; + } + + private void registerIcons() { + registerContentTypeIcon(TYPE_FOLDER, navResources.folder()); + registerContentTypeIcon(TYPE_ROOT, navResources.folder()); + registerContentTypeIcon(TYPE_BARTER, navResources.barter()); + } + +} Property changes on: trunk/src/main/java/cc/kune/barters/client/BartersClientTool.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: trunk/src/main/java/cc/kune/barters/client/BartersGinModule.java =================================================================== --- trunk/src/main/java/cc/kune/barters/client/BartersGinModule.java (rev 0) +++ trunk/src/main/java/cc/kune/barters/client/BartersGinModule.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -0,0 +1,35 @@ +/* + * + * 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.barters.client; + +import cc.kune.barters.client.actions.BartersClientActions; + +import com.google.inject.Singleton; +import com.gwtplatform.mvp.client.gin.AbstractPresenterModule; + +public class BartersGinModule extends AbstractPresenterModule { + + @Override + protected void configure() { + bind(BartersClientTool.class).in(Singleton.class); + bind(BartersClientActions.class).in(Singleton.class); + } + +} Property changes on: trunk/src/main/java/cc/kune/barters/client/BartersGinModule.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: trunk/src/main/java/cc/kune/barters/client/BartersGinjector.java =================================================================== --- trunk/src/main/java/cc/kune/barters/client/BartersGinjector.java (rev 0) +++ trunk/src/main/java/cc/kune/barters/client/BartersGinjector.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -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.barters.client; + +import com.google.gwt.inject.client.Ginjector; + +public interface BartersGinjector extends Ginjector { + + BartersParts getBartersParts(); + +} Property changes on: trunk/src/main/java/cc/kune/barters/client/BartersGinjector.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: trunk/src/main/java/cc/kune/barters/client/BartersParts.java =================================================================== --- trunk/src/main/java/cc/kune/barters/client/BartersParts.java (rev 0) +++ trunk/src/main/java/cc/kune/barters/client/BartersParts.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -0,0 +1,42 @@ +/* + * + * 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.barters.client; + +import cc.kune.barters.client.actions.BartersClientActions; +import cc.kune.barters.shared.BartersConstants; +import cc.kune.core.client.state.Session; +import cc.kune.gspace.client.tool.ContentViewerSelector; +import cc.kune.gspace.client.viewers.ContentViewerPresenter; +import cc.kune.gspace.client.viewers.FolderViewerPresenter; + +import com.google.inject.Inject; +import com.google.inject.Provider; + +public class BartersParts { + + @Inject + public BartersParts(final Session session, final Provider<BartersClientTool> clientTool, + final ContentViewerSelector viewerSelector, final BartersClientActions bartersActions, + final ContentViewerPresenter contentViewer, final FolderViewerPresenter folderViewer) { + clientTool.get(); + viewerSelector.register(contentViewer, true, BartersConstants.TYPE_BARTER); + viewerSelector.register(folderViewer, true, BartersConstants.TYPE_ROOT, BartersConstants.TYPE_FOLDER); + } +} \ No newline at end of file Property changes on: trunk/src/main/java/cc/kune/barters/client/BartersParts.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: trunk/src/main/java/cc/kune/barters/client/actions/BartersClientActions.java =================================================================== --- trunk/src/main/java/cc/kune/barters/client/actions/BartersClientActions.java (rev 0) +++ trunk/src/main/java/cc/kune/barters/client/actions/BartersClientActions.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -0,0 +1,74 @@ +/* + * + * Copyright (C) 2007-2009 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.barters.client.actions; + +import static cc.kune.barters.shared.BartersConstants.TYPE_BARTER; +import static cc.kune.barters.shared.BartersConstants.TYPE_FOLDER; +import static cc.kune.barters.shared.BartersConstants.TYPE_ROOT; +import cc.kune.core.client.actions.ActionRegistryByType; +import cc.kune.core.client.i18n.I18nUITranslationService; +import cc.kune.core.client.resources.CoreResources; +import cc.kune.core.client.state.Session; +import cc.kune.core.client.state.StateManager; +import cc.kune.docs.client.actions.DelFolderMenuItem; +import cc.kune.docs.client.actions.NewFolderBtn; +import cc.kune.gspace.client.actions.AbstractFoldableToolActions; +import cc.kune.gspace.client.actions.ActionGroups; +import cc.kune.gspace.client.actions.ContentViewerOptionsMenu; +import cc.kune.gspace.client.actions.ParticipateInContentBtn; +import cc.kune.gspace.client.actions.RefreshContentMenuItem; + +import com.google.inject.Inject; +import com.google.inject.Provider; + +public class BartersClientActions extends AbstractFoldableToolActions { + final String[] all = { TYPE_ROOT, TYPE_FOLDER, TYPE_BARTER }; + final String[] containers = { TYPE_ROOT, TYPE_FOLDER }; + final String[] containersNoRoot = { TYPE_FOLDER }; + final String[] contents = { TYPE_BARTER }; + + @Inject + public BartersClientActions(final I18nUITranslationService i18n, final Session session, + final StateManager stateManager, final ActionRegistryByType registry, final CoreResources res, + final Provider<GoParentFolderBtn> folderGoUp, final Provider<NewBartersBtn> newBartersBtn, + final Provider<NewFolderBtn> newFolderBtn, + final Provider<OpenBartersMenuItem> openContentMenuItem, + final Provider<DelBartersMenuItem> delContentMenuItem, + final Provider<ContentViewerOptionsMenu> optionsMenuContent, + final Provider<ParticipateInContentBtn> participateBtn, + final Provider<DelFolderMenuItem> delFolderMenuItem, final Provider<RefreshContentMenuItem> refresh) { + super(session, stateManager, i18n, registry); + actionsRegistry.addAction(ActionGroups.VIEW, optionsMenuContent, all); + actionsRegistry.addAction(ActionGroups.VIEW, refresh, all); + actionsRegistry.addAction(ActionGroups.VIEW, folderGoUp, contents); + actionsRegistry.addAction(ActionGroups.VIEW, folderGoUp, containersNoRoot); + actionsRegistry.addAction(ActionGroups.VIEW, newBartersBtn, containers); + actionsRegistry.addAction(ActionGroups.VIEW, participateBtn, contents); + actionsRegistry.addAction(ActionGroups.VIEW, newFolderBtn, containers); + actionsRegistry.addAction(ActionGroups.MENUITEM, openContentMenuItem, contents); + actionsRegistry.addAction(ActionGroups.MENUITEM, openContentMenuItem, containersNoRoot); + actionsRegistry.addAction(ActionGroups.MENUITEM, delContentMenuItem, contents); + actionsRegistry.addAction(ActionGroups.MENUITEM, delFolderMenuItem, containersNoRoot); + } + + @Override + protected void createPostSessionInitActions() { + } +} Property changes on: trunk/src/main/java/cc/kune/barters/client/actions/BartersClientActions.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: trunk/src/main/java/cc/kune/barters/client/actions/DelBartersMenuItem.java =================================================================== --- trunk/src/main/java/cc/kune/barters/client/actions/DelBartersMenuItem.java (rev 0) +++ trunk/src/main/java/cc/kune/barters/client/actions/DelBartersMenuItem.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -0,0 +1,34 @@ +/* + * + * 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.barters.client.actions; + +import cc.kune.core.client.resources.CoreResources; +import cc.kune.core.shared.i18n.I18nTranslationService; +import cc.kune.gspace.client.actions.DelContentMenuItem; + +import com.google.inject.Inject; + +public class DelBartersMenuItem extends DelContentMenuItem { + + @Inject + public DelBartersMenuItem(final I18nTranslationService i18n, final DelContentAction action, final CoreResources res) { + super(i18n, action, res); + } +} Property changes on: trunk/src/main/java/cc/kune/barters/client/actions/DelBartersMenuItem.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: trunk/src/main/java/cc/kune/barters/client/actions/DelFolderMenuItem.java =================================================================== --- trunk/src/main/java/cc/kune/barters/client/actions/DelFolderMenuItem.java (rev 0) +++ trunk/src/main/java/cc/kune/barters/client/actions/DelFolderMenuItem.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -0,0 +1,35 @@ +/* + * + * 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.barters.client.actions; + +import cc.kune.core.client.resources.CoreResources; +import cc.kune.core.shared.i18n.I18nTranslationService; +import cc.kune.gspace.client.actions.DelContainerMenuItem; + +import com.google.inject.Inject; + +public class DelFolderMenuItem extends DelContainerMenuItem { + + @Inject + public DelFolderMenuItem(final I18nTranslationService i18n, final DelContainerAction action, final CoreResources res) { + super(i18n, action, res); + } + +} Property changes on: trunk/src/main/java/cc/kune/barters/client/actions/DelFolderMenuItem.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: trunk/src/main/java/cc/kune/barters/client/actions/GoParentFolderBtn.java =================================================================== --- trunk/src/main/java/cc/kune/barters/client/actions/GoParentFolderBtn.java (rev 0) +++ trunk/src/main/java/cc/kune/barters/client/actions/GoParentFolderBtn.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -0,0 +1,35 @@ +/* + * + * 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.barters.client.actions; + +import cc.kune.core.client.resources.CoreResources; +import cc.kune.core.shared.i18n.I18nTranslationService; +import cc.kune.gspace.client.actions.GoParentContainerBtn; + +import com.google.inject.Inject; + +public class GoParentFolderBtn extends GoParentContainerBtn { + + @Inject + public GoParentFolderBtn(final I18nTranslationService i18n, final GoParentContainerAction action, final CoreResources res) { + super(i18n, action, res); + } + +} Property changes on: trunk/src/main/java/cc/kune/barters/client/actions/GoParentFolderBtn.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: trunk/src/main/java/cc/kune/barters/client/actions/NewBartersBtn.java =================================================================== --- trunk/src/main/java/cc/kune/barters/client/actions/NewBartersBtn.java (rev 0) +++ trunk/src/main/java/cc/kune/barters/client/actions/NewBartersBtn.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -0,0 +1,39 @@ +/* + * + * 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.barters.client.actions; + +import cc.kune.barters.shared.BartersConstants; +import cc.kune.common.client.shortcuts.GlobalShortcutRegister; +import cc.kune.core.client.resources.nav.NavResources; +import cc.kune.core.shared.i18n.I18nTranslationService; +import cc.kune.gspace.client.actions.NewContentBtn; + +import com.google.inject.Inject; + +public class NewBartersBtn extends NewContentBtn { + + @Inject + public NewBartersBtn(final I18nTranslationService i18n, final NewContentAction action, + final NavResources res, final GlobalShortcutRegister shorcutReg) { + super(i18n, action, res.barterAdd(), shorcutReg, i18n.t("New barter"), + i18n.t("Create a New Barter here"), i18n.t("New barter"), BartersConstants.TYPE_BARTER); + } + +} Property changes on: trunk/src/main/java/cc/kune/barters/client/actions/NewBartersBtn.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: trunk/src/main/java/cc/kune/barters/client/actions/NewFolderBtn.java =================================================================== --- trunk/src/main/java/cc/kune/barters/client/actions/NewFolderBtn.java (rev 0) +++ trunk/src/main/java/cc/kune/barters/client/actions/NewFolderBtn.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -0,0 +1,38 @@ +/* + * + * 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.barters.client.actions; + +import cc.kune.barters.shared.BartersConstants; +import cc.kune.core.client.resources.nav.NavResources; +import cc.kune.core.shared.i18n.I18nTranslationService; +import cc.kune.gspace.client.actions.NewContainerBtn; + +import com.google.inject.Inject; + +public class NewFolderBtn extends NewContainerBtn { + + @Inject + public NewFolderBtn(final I18nTranslationService i18n, final NewContainerAction action, + final NavResources res) { + super(i18n, action, res.barterAdd(), i18n.t("New folder"), i18n.t("Create a new folder here"), + i18n.t("New folder"), BartersConstants.TYPE_FOLDER); + } + +} Property changes on: trunk/src/main/java/cc/kune/barters/client/actions/NewFolderBtn.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: trunk/src/main/java/cc/kune/barters/client/actions/OpenBartersMenuItem.java =================================================================== --- trunk/src/main/java/cc/kune/barters/client/actions/OpenBartersMenuItem.java (rev 0) +++ trunk/src/main/java/cc/kune/barters/client/actions/OpenBartersMenuItem.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -0,0 +1,35 @@ +/* + * + * 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.barters.client.actions; + +import cc.kune.core.client.resources.nav.NavResources; +import cc.kune.core.shared.i18n.I18nTranslationService; +import cc.kune.gspace.client.actions.OpenContentMenuItem; + +import com.google.inject.Inject; + +public class OpenBartersMenuItem extends OpenContentMenuItem { + + @Inject + public OpenBartersMenuItem(final I18nTranslationService i18n, final OpenContentAction action, final NavResources res) { + super(i18n, action, res); + } + +} Property changes on: trunk/src/main/java/cc/kune/barters/client/actions/OpenBartersMenuItem.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: trunk/src/main/java/cc/kune/barters/server/BarterServerModule.java =================================================================== --- trunk/src/main/java/cc/kune/barters/server/BarterServerModule.java (rev 0) +++ trunk/src/main/java/cc/kune/barters/server/BarterServerModule.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -0,0 +1,29 @@ +/* + * + * Copyright (C) 2007-2009 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.barters.server; + +import com.google.inject.Binder; +import com.google.inject.Module; + +public class BarterServerModule implements Module { + public void configure(final Binder binder) { + binder.bind(BarterServerTool.class).asEagerSingleton(); + } +} Property changes on: trunk/src/main/java/cc/kune/barters/server/BarterServerModule.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: trunk/src/main/java/cc/kune/barters/server/BarterServerTool.java =================================================================== --- trunk/src/main/java/cc/kune/barters/server/BarterServerTool.java (rev 0) +++ trunk/src/main/java/cc/kune/barters/server/BarterServerTool.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -0,0 +1,192 @@ +/* + * + * 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.barters.server; + +import static cc.kune.barters.shared.BartersConstants.NAME; +import static cc.kune.barters.shared.BartersConstants.ROOT_NAME; +import static cc.kune.barters.shared.BartersConstants.TYPE_BARTER; +import static cc.kune.barters.shared.BartersConstants.TYPE_FOLDER; +import static cc.kune.barters.shared.BartersConstants.TYPE_ROOT; + +import java.net.URL; +import java.util.Date; + +import org.waveprotocol.wave.model.waveref.InvalidWaveRefException; +import org.waveprotocol.wave.util.escapers.jvm.JavaWaverefEncoder; + +import cc.kune.core.client.errors.ContainerNotPermittedException; +import cc.kune.core.client.errors.ContentNotPermittedException; +import cc.kune.core.client.errors.DefaultException; +import cc.kune.core.server.content.ContainerManager; +import cc.kune.core.server.content.ContentManager; +import cc.kune.core.server.manager.ToolConfigurationManager; +import cc.kune.core.server.tool.ServerToolRegistry; +import cc.kune.core.server.tool.ServerToolTarget; +import cc.kune.core.server.tool.ServerWaveTool; +import cc.kune.core.server.utils.UrlUtils; +import cc.kune.core.shared.domain.ContentStatus; +import cc.kune.core.shared.domain.GroupListMode; +import cc.kune.core.shared.i18n.I18nTranslationService; +import cc.kune.domain.AccessLists; +import cc.kune.domain.Container; +import cc.kune.domain.Content; +import cc.kune.domain.Group; +import cc.kune.domain.ToolConfiguration; +import cc.kune.domain.User; +import cc.kune.wave.server.KuneWaveManager; + +import com.google.inject.Inject; + +public class BarterServerTool implements ServerWaveTool { + + private static final String BARTER_GADGET = "http://op-org.appspot.com/troco_wave_gadget/org.ourproject.troco.client.Troc..."; + private final ToolConfigurationManager configurationManager; + private final ContainerManager containerManager; + private final ContentManager contentManager; + private final URL gadgetUrl; + private final I18nTranslationService i18n; + private final KuneWaveManager waveManager; + + @Inject + public BarterServerTool(final ContentManager contentManager, final ContainerManager containerManager, + final ToolConfigurationManager configurationManager, + final I18nTranslationService translationService, final KuneWaveManager waveManager) { + this.contentManager = contentManager; + this.containerManager = containerManager; + this.configurationManager = configurationManager; + this.i18n = translationService; + this.waveManager = waveManager; + gadgetUrl = UrlUtils.of(BARTER_GADGET); + } + + private void addGadget(final Content content) { + try { + waveManager.addGadget(JavaWaverefEncoder.decodeWaveRefFromPath(content.getWaveId()), + content.getAuthors().get(0).getShortName(), BARTER_GADGET); + } catch (final InvalidWaveRefException e) { + throw new DefaultException("Error creating barter"); + } + } + + void checkContainerTypeId(final String parentTypeId, final String typeId) { + if (typeId.equals(TYPE_FOLDER)) { + // ok valid container + if ((typeId.equals(TYPE_FOLDER) && (parentTypeId.equals(TYPE_ROOT) || parentTypeId.equals(TYPE_FOLDER)))) { + // ok + } else { + throw new ContainerNotPermittedException(); + } + } else { + throw new ContainerNotPermittedException(); + } + } + + void checkContentTypeId(final String parentTypeId, final String typeId) { + if (typeId.equals(TYPE_BARTER)) { + // ok valid content + final boolean parentIsFolderOrRoot = parentTypeId.equals(TYPE_ROOT) + || parentTypeId.equals(TYPE_FOLDER); + if ((typeId.equals(TYPE_BARTER) && parentIsFolderOrRoot)) { + // ok + } else { + throw new ContentNotPermittedException(); + } + } else { + throw new ContentNotPermittedException(); + } + } + + @Override + public void checkTypesBeforeContainerCreation(final String parentTypeId, final String typeId) { + checkContainerTypeId(parentTypeId, typeId); + } + + @Override + public void checkTypesBeforeContentCreation(final String parentTypeId, final String typeId) { + checkContentTypeId(parentTypeId, typeId); + } + + @Override + public URL getGadgetUrl() { + return gadgetUrl; + } + + @Override + public String getName() { + return NAME; + } + + @Override + public String getRootName() { + return ROOT_NAME; + } + + @Override + public ServerToolTarget getTarget() { + return ServerToolTarget.forUsers; + } + + @Override + public Group initGroup(final User user, final Group group, final Object... otherVars) { + final ToolConfiguration config = new ToolConfiguration(); + final Container rootFolder = containerManager.createRootFolder(group, NAME, ROOT_NAME, TYPE_ROOT); + setContainerBartersAcl(rootFolder); + config.setRoot(rootFolder); + group.setToolConfig(NAME, config); + configurationManager.persist(config); + final Content content = contentManager.createContent( + i18n.t("Barter sample"), + i18n.t("This is only a barter sample. You can invite other participants to this barter, but also publish to the general public allowing you to share services, goods, etc."), + user, rootFolder, TYPE_BARTER, gadgetUrl); + content.addAuthor(user); + content.setLanguage(user.getLanguage()); + content.setTypeId(TYPE_BARTER); + content.setStatus(ContentStatus.publishedOnline); + contentManager.save(user, content); + return group; + } + + @Override + public void onCreateContainer(final Container container, final Container parent) { + setContainerBartersAcl(container); + } + + @Override + public void onCreateContent(final Content content, final Container parent) { + // addGadget(content); + content.setStatus(ContentStatus.publishedOnline); + content.setPublishedOn(new Date()); + } + + @Override + @Inject + public void register(final ServerToolRegistry registry) { + registry.register(this); + } + + private void setContainerBartersAcl(final Container container) { + final AccessLists bartersAcl = new AccessLists(); + bartersAcl.getAdmins().setMode(GroupListMode.NORMAL); + bartersAcl.getAdmins().add(container.getOwner()); + bartersAcl.getEditors().setMode(GroupListMode.NORMAL); + bartersAcl.getViewers().setMode(GroupListMode.EVERYONE); + containerManager.setAccessList(container, bartersAcl); + } +} Property changes on: trunk/src/main/java/cc/kune/barters/server/BarterServerTool.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: trunk/src/main/java/cc/kune/barters/shared/BartersConstants.java =================================================================== --- trunk/src/main/java/cc/kune/barters/shared/BartersConstants.java (rev 0) +++ trunk/src/main/java/cc/kune/barters/shared/BartersConstants.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -0,0 +1,32 @@ +/* + * + * 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.barters.shared; + +public final class BartersConstants { + + public static final String NAME = "barters"; + public static final String ROOT_NAME = "barters"; + public static final String TYPE_BARTER = NAME + "." + "barter"; + public static final String TYPE_FOLDER = NAME + "." + "folder"; + public static final String TYPE_ROOT = NAME + "." + "root"; + + private BartersConstants() { + } +} \ No newline at end of file Property changes on: trunk/src/main/java/cc/kune/barters/shared/BartersConstants.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: trunk/src/main/java/cc/kune/blogs/client/BlogsClientTool.java =================================================================== --- trunk/src/main/java/cc/kune/blogs/client/BlogsClientTool.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/cc/kune/blogs/client/BlogsClientTool.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -27,7 +27,7 @@ import cc.kune.core.client.i18n.I18nUITranslationService; import cc.kune.core.client.registry.ContentCapabilitiesRegistry; import cc.kune.core.client.resources.nav.NavResources; -import cc.kune.gspace.client.tool.old.FoldableAbstractClientTool; +import cc.kune.gspace.client.tool.FoldableAbstractClientTool; import cc.kune.gspace.client.tool.selector.ToolSelector; import com.google.inject.Inject; Modified: trunk/src/main/java/cc/kune/blogs/server/BlogServerTool.java =================================================================== --- trunk/src/main/java/cc/kune/blogs/server/BlogServerTool.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/cc/kune/blogs/server/BlogServerTool.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -45,110 +45,111 @@ public class BlogServerTool implements ServerTool { - public static final String ROOT_NAME = "blogs"; + public static final String ROOT_NAME = "blogs"; - private final ToolConfigurationManager configurationManager; - private final ContainerManager containerManager; - private final ContentManager contentManager; - private final I18nTranslationService i18n; + private final ToolConfigurationManager configurationManager; + private final ContainerManager containerManager; + private final ContentManager contentManager; + private final I18nTranslationService i18n; - @Inject - public BlogServerTool(final ContentManager contentManager, final ContainerManager containerManager, - final ToolConfigurationManager configurationManager, final I18nTranslationService translationService) { - this.contentManager = contentManager; - this.containerManager = containerManager; - this.configurationManager = configurationManager; - this.i18n = translationService; - } + @Inject + public BlogServerTool(final ContentManager contentManager, final ContainerManager containerManager, + final ToolConfigurationManager configurationManager, + final I18nTranslationService translationService) { + this.contentManager = contentManager; + this.containerManager = containerManager; + this.configurationManager = configurationManager; + this.i18n = translationService; + } - void checkContainerTypeId(final String parentTypeId, final String typeId) { - if (typeId.equals(TYPE_BLOG)) { - // ok valid container - if ((typeId.equals(TYPE_BLOG) && parentTypeId.equals(TYPE_ROOT))) { - // ok - } else { - throw new ContainerNotPermittedException(); - } - } else { - throw new ContainerNotPermittedException(); - } + void checkContainerTypeId(final String parentTypeId, final String typeId) { + if (typeId.equals(TYPE_BLOG)) { + // ok valid container + if ((typeId.equals(TYPE_BLOG) && parentTypeId.equals(TYPE_ROOT))) { + // ok + } else { + throw new ContainerNotPermittedException(); + } + } else { + throw new ContainerNotPermittedException(); } + } - void checkContentTypeId(final String parentTypeId, final String typeId) { - if (typeId.equals(TYPE_UPLOADEDFILE) || typeId.equals(TYPE_POST)) { - // ok valid content - if ((typeId.equals(TYPE_UPLOADEDFILE) && parentTypeId.equals(TYPE_BLOG)) - || (typeId.equals(TYPE_POST) && parentTypeId.equals(TYPE_BLOG))) { - // ok - } else { - throw new ContentNotPermittedException(); - } + void checkContentTypeId(final String parentTypeId, final String typeId) { + if (typeId.equals(TYPE_UPLOADEDFILE) || typeId.equals(TYPE_POST)) { + // ok valid content + if ((typeId.equals(TYPE_UPLOADEDFILE) && parentTypeId.equals(TYPE_BLOG)) + || (typeId.equals(TYPE_POST) && parentTypeId.equals(TYPE_BLOG))) { + // ok + } else { + throw new ContentNotPermittedException(); + } - } else { - throw new ContentNotPermittedException(); - } + } else { + throw new ContentNotPermittedException(); } + } - @Override - public void checkTypesBeforeContainerCreation(final String parentTypeId, final String typeId) { - checkContainerTypeId(parentTypeId, typeId); - } + @Override + public void checkTypesBeforeContainerCreation(final String parentTypeId, final String typeId) { + checkContainerTypeId(parentTypeId, typeId); + } - @Override - public void checkTypesBeforeContentCreation(final String parentTypeId, final String typeId) { - checkContentTypeId(parentTypeId, typeId); - } + @Override + public void checkTypesBeforeContentCreation(final String parentTypeId, final String typeId) { + checkContentTypeId(parentTypeId, typeId); + } - @Override - public String getName() { - return NAME; - } + @Override + public String getName() { + return NAME; + } - @Override - public String getRootName() { - return ROOT_NAME; - } + @Override + public String getRootName() { + return ROOT_NAME; + } - @Override - public ServerToolTarget getTarget() { - return ServerToolTarget.forBoth; - } + @Override + public ServerToolTarget getTarget() { + return ServerToolTarget.forBoth; + } - @Override - public Group initGroup(final User user, final Group group, final Object... otherVars) { - final ToolConfiguration config = new ToolConfiguration(); - final Container rootFolder = containerManager.createRootFolder(group, NAME, ROOT_NAME, TYPE_ROOT); - config.setRoot(rootFolder); - group.setToolConfig(NAME, config); - configurationManager.persist(config); + @Override + public Group initGroup(final User user, final Group group, final Object... otherVars) { + final ToolConfiguration config = new ToolConfiguration(); + final Container rootFolder = containerManager.createRootFolder(group, NAME, ROOT_NAME, TYPE_ROOT); + config.setRoot(rootFolder); + group.setToolConfig(NAME, config); + configurationManager.persist(config); - final I18nLanguage language = user.getLanguage(); - final Container blog = containerManager.createFolder(group, rootFolder, i18n.t("Blog sample"), language, - TYPE_BLOG); + final I18nLanguage language = user.getLanguage(); + final Container blog = containerManager.createFolder(group, rootFolder, i18n.t("Blog sample"), + language, TYPE_BLOG); - final Content content = contentManager.createContent(i18n.t("A post sample"), - i18n.t("This is only a post sample. You can edit it, rename the post and this blog"), user, blog, - TYPE_POST); - content.addAuthor(user); - content.setLanguage(language); - content.setTypeId(TYPE_POST); - content.setStatus(ContentStatus.publishedOnline); + final Content content = contentManager.createContent(i18n.t("A post sample"), + i18n.t("This is only a post sample. You can edit it, rename the post and this blog"), user, + blog, TYPE_POST); + content.addAuthor(user); + content.setLanguage(language); + content.setTypeId(TYPE_POST); + content.setStatus(ContentStatus.publishedOnline); - contentManager.save(user, content); - return group; - } + contentManager.save(user, content); + return group; + } - @Override - public void onCreateContainer(final Container container, final Container parent) { - } + @Override + public void onCreateContainer(final Container container, final Container parent) { + } - @Override - public void onCreateContent(final Content content, final Container parent) { - } + @Override + public void onCreateContent(final Content content, final Container parent) { + } - @Override - @Inject - public void register(final ServerToolRegistry registry) { - registry.register(this); - } + @Override + @Inject + public void register(final ServerToolRegistry registry) { + registry.register(this); + } } Modified: trunk/src/main/java/cc/kune/client/KuneEntryPoint.java =================================================================== --- trunk/src/main/java/cc/kune/client/KuneEntryPoint.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/cc/kune/client/KuneEntryPoint.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -79,6 +79,7 @@ ginjector.getDocsParts(); ginjector.getBlogsParts(); ginjector.getWikiParts(); + ginjector.getBartersParts(); ginjector.getSiteLogoPresenter(); ginjector.getSpacesTabPresenter(); ginjector.getChatClient(); Modified: trunk/src/main/java/cc/kune/client/KuneGinjector.java =================================================================== --- trunk/src/main/java/cc/kune/client/KuneGinjector.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/cc/kune/client/KuneGinjector.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -19,6 +19,8 @@ */ package cc.kune.client; +import cc.kune.barters.client.BartersGinModule; +import cc.kune.barters.client.BartersGinjector; import cc.kune.blogs.client.BlogsGinModule; import cc.kune.blogs.client.BlogsGinjector; import cc.kune.chat.client.ChatClient; @@ -71,9 +73,9 @@ @GinModules({ KuneGinModule.class, CoreGinModule.class, ChatGinModule.class, WaveGinModule.class, PSpaceGinModule.class, GSpaceGinModule.class, DocsGinModule.class, BlogsGinModule.class, - WikiGinModule.class }) + WikiGinModule.class, BartersGinModule.class }) public interface KuneGinjector extends Ginjector, GSpaceGinjector, DocsGinjector, BlogsGinjector, - WikiGinjector { + WikiGinjector, BartersGinjector { /* * You have to add here all the GWTPresenters (as Provider or AsyncProvider) Modified: trunk/src/main/java/cc/kune/core/client/resources/nav/NavResources.java =================================================================== --- trunk/src/main/java/cc/kune/core/client/resources/nav/NavResources.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/cc/kune/core/client/resources/nav/NavResources.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -24,90 +24,96 @@ public interface NavResources extends ClientBundle { - @Source("blog.png") - ImageResource blog(); + @Source("barter.png") + ImageResource barter(); - @Source("blog_add.png") - ImageResource blogAdd(); + @Source("barter_add.png") + ImageResource barterAdd(); - @Source("download.png") - ImageResource download(); + @Source("blog.png") + ImageResource blog(); - @Source("film.png") - ImageResource film(); + @Source("blog_add.png") + ImageResource blogAdd(); - @Source("folder.png") - ImageResource folder(); + @Source("download.png") + ImageResource download(); - @Source("folder_add.png") - ImageResource folderAdd(); + @Source("film.png") + ImageResource film(); - @Source("gallery.png") - ImageResource gallery(); + @Source("folder.png") + ImageResource folder(); - @Source("gallery_add.png") - ImageResource galleryAdd(); + @Source("folder_add.png") + ImageResource folderAdd(); - @Source("go.png") - ImageResource go(); + @Source("gallery.png") + ImageResource gallery(); - @Source("music.png") - ImageResource music(); + @Source("gallery_add.png") + ImageResource galleryAdd(); - @Source("page.png") - ImageResource page(); + @Source("go.png") + ImageResource go(); - @Source("page_add.png") - ImageResource pageAdd(); + @Source("music.png") + ImageResource music(); - @Source("page_excel.png") - ImageResource pageExcel(); + @Source("page.png") + ImageResource page(); - @Source("page_pdf.png") - ImageResource pagePdf(); + @Source("page_add.png") + ImageResource pageAdd(); - @Source("page_pps.png") - ImageResource pagePps(); + @Source("page_excel.png") + ImageResource pageExcel(); - @Source("page_text.png") - ImageResource pageText(); + @Source("page_pdf.png") + ImageResource pagePdf(); - @Source("page_word.png") - ImageResource pageWord(); + @Source("page_pps.png") + ImageResource pagePps(); - @Source("page_zip.png") - ImageResource pageZip(); + @Source("page_text.png") + ImageResource pageText(); - @Source("picture.png") - ImageResource picture(); + @Source("page_word.png") + ImageResource pageWord(); - @Source("post.png") - ImageResource post(); + @Source("page_zip.png") + ImageResource pageZip(); - @Source("post_add.png") - ImageResource postAdd(); + @Source("picture.png") + ImageResource picture(); - @Source("refresh.png") - ImageResource refresh(); + @Source("post.png") + ImageResource post(); - @Source("room.png") - ImageResource room(); + @Source("post_add.png") + ImageResource postAdd(); - @Source("room_add.png") - ImageResource roomAdd(); + @Source("refresh.png") + ImageResource refresh(); - @Source("upload.png") - ImageResource upload(); + @Source("room.png") + ImageResource room(); - @Source("wiki.png") - ImageResource wiki(); + @Source("room_add.png") + ImageResource roomAdd(); - @Source("wiki_add.png") - ImageResource wikiAdd(); + @Source("upload.png") + ImageResource upload(); - @Source("wikipage.png") - ImageResource wikipage(); + @Source("wiki.png") + ImageResource wiki(); - @Source("wikipage_add.png") - ImageResource wikipageAdd(); + @Source("wiki_add.png") + ImageResource wikiAdd(); + + @Source("wikipage.png") + ImageResource wikipage(); + + @Source("wikipage_add.png") + ImageResource wikipageAdd(); } Added: trunk/src/main/java/cc/kune/core/client/resources/nav/barter.png =================================================================== (Binary files differ) Property changes on: trunk/src/main/java/cc/kune/core/client/resources/nav/barter.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/main/java/cc/kune/core/client/resources/nav/barter_add.png =================================================================== (Binary files differ) Property changes on: trunk/src/main/java/cc/kune/core/client/resources/nav/barter_add.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/src/main/java/cc/kune/core/server/KuneRackModule.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/KuneRackModule.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/cc/kune/core/server/KuneRackModule.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -22,6 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import cc.kune.barters.server.BarterServerModule; import cc.kune.blogs.server.BlogServerModule; import cc.kune.core.client.rpcservices.ContentService; import cc.kune.core.client.rpcservices.GroupService; @@ -33,8 +34,8 @@ import cc.kune.core.server.manager.file.EntityLogoDownloadManager; import cc.kune.core.server.manager.file.EntityLogoUploadManager; import cc.kune.core.server.manager.file.FileDownloadManager; +import cc.kune.core.server.manager.file.FileGwtUploadServlet; import cc.kune.core.server.manager.file.FileUploadManager; -import cc.kune.core.server.manager.file.FileGwtUploadServlet; import cc.kune.core.server.properties.PropertiesFileName; import cc.kune.core.server.rack.RackBuilder; import cc.kune.core.server.rack.RackModule; @@ -144,6 +145,7 @@ builder.use(new DocumentServerModule()); builder.use(new BlogServerModule()); builder.use(new WikiServerModule()); + builder.use(new BarterServerModule()); // builder.use(new ChatServerModule()); // builder.use(new GalleryServerModule()); builder.use(new RESTServicesModule()); Modified: trunk/src/main/java/cc/kune/core/server/content/ContentManager.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/content/ContentManager.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/cc/kune/core/server/content/ContentManager.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -19,6 +19,7 @@ */ package cc.kune.core.server.content; +import java.net.URL; import java.util.Date; import cc.kune.core.client.errors.DefaultException; @@ -50,6 +51,9 @@ Content createContent(String title, String body, User author, Container container, String typeId); + Content createContent(String title, String body, User author, Container container, String typeId, + URL gadgetUrl); + boolean findIfExistsTitle(Container container, String title); Double getRateAvg(Content content); Modified: trunk/src/main/java/cc/kune/core/server/content/ContentManagerDefault.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/content/ContentManagerDefault.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/cc/kune/core/server/content/ContentManagerDefault.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -19,6 +19,7 @@ */ package cc.kune.core.server.content; +import java.net.URL; import java.util.Date; import java.util.List; @@ -113,6 +114,12 @@ @Override public Content createContent(final String title, final String body, final User author, final Container container, final String typeId) { + return createContent(title, body, author, container, typeId, KuneWaveManager.WITHOUT_GADGET); + } + + @Override + public Content createContent(final String title, final String body, final User author, + final Container container, final String typeId, final URL gadgetUrl) { FilenameUtils.checkBasicFilename(title); final String newtitle = findInexistentTitle(container, title); final Content newContent = new Content(); @@ -125,7 +132,7 @@ revision.setTitle(newtitle); // Duplicate in StateServiceDefault if (newContent.isWave()) { - final WaveRef waveRef = kuneWaveManager.createWave(newtitle, body, + final WaveRef waveRef = kuneWaveManager.createWave(newtitle, body, gadgetUrl, participantUtils.of(author.getShortName())); 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 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/cc/kune/core/server/content/CreationServiceDefault.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -19,52 +19,62 @@ */ package cc.kune.core.server.content; +import java.net.URL; +import cc.kune.core.server.tool.ServerTool; import cc.kune.core.server.tool.ServerToolRegistry; +import cc.kune.core.server.tool.ServerWaveTool; import cc.kune.domain.Container; import cc.kune.domain.Content; import cc.kune.domain.Group; import cc.kune.domain.I18nLanguage; import cc.kune.domain.User; +import cc.kune.wave.server.KuneWaveManager; import com.google.inject.Inject; import com.google.inject.Singleton; @Singleton public class CreationServiceDefault implements CreationService { - private final ContainerManager containerManager; - private final ContentManager contentManager; - private final ServerToolRegistry tools; + private final ContainerManager containerManager; + private final ContentManager contentManager; + private final ServerToolRegistry tools; - @Inject - public CreationServiceDefault(final ContainerManager containerManager, final ContentManager contentManager, - final ServerToolRegistry toolRegistry) { - this.containerManager = containerManager; - this.contentManager = contentManager; - this.tools = toolRegistry; - } + @Inject + public CreationServiceDefault(final ContainerManager containerManager, + final ContentManager contentManager, final ServerToolRegistry toolRegistry) { + this.containerManager = containerManager; + this.contentManager = contentManager; + this.tools = toolRegistry; + } - public Content createContent(final String title, final String body, final User user, final Container container, - final String typeId) { - final String toolName = container.getToolName(); - tools.get(toolName).checkTypesBeforeContentCreation(container.getTypeId(), typeId); - final Content content = contentManager.createContent(title, body, user, container, typeId); - tools.get(toolName).onCreateContent(content, container); - return content; - } + @Override + public Content createContent(final String title, final String body, final User user, + final Container container, final String typeId) { + final String toolName = container.getToolName(); + final ServerTool tool = tools.get(toolName); + tool.checkTypesBeforeContentCreation(container.getTypeId(), typeId); + final URL gagdetUrl = tool instanceof ServerWaveTool ? ((ServerWaveTool) tool).getGadgetUrl() + : KuneWaveManager.WITHOUT_GADGET; + final Content content = contentManager.createContent(title, body, user, container, typeId, gagdetUrl); + tool.onCreateContent(content, container); + return content; + } - public Container createFolder(final Group group, final Long parentFolderId, final String name, - final I18nLanguage language, final String typeId) { - final Container parent = containerManager.find(parentFolderId); - final String toolName = parent.getToolName(); - tools.get(toolName).checkTypesBeforeContainerCreation(parent.getTypeId(), typeId); - final Container child = containerManager.createFolder(group, parent, name, language, typeId); - tools.get(toolName).onCreateContainer(child, parent); - return child; - } + @Override + public Container createFolder(final Group group, final Long parentFolderId, final String name, + final I18nLanguage language, final String typeId) { + final Container parent = containerManager.find(parentFolderId); + final String toolName = parent.getToolName(); + tools.get(toolName).checkTypesBeforeContainerCreation(parent.getTypeId(), typeId); + final Container child = containerManager.createFolder(group, parent, name, language, typeId); + tools.get(toolName).onCreateContainer(child, parent); + return child; + } - public Content saveContent(final User editor, final Content content, final String body) { - return contentManager.save(editor, content, body); - } + @Override + public Content saveContent(final User editor, final Content content, final String body) { + return contentManager.save(editor, content, body); + } } Modified: trunk/src/main/java/cc/kune/core/server/tool/ServerTool.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/tool/ServerTool.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/cc/kune/core/server/tool/ServerTool.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -32,21 +32,21 @@ */ public interface ServerTool { - void checkTypesBeforeContainerCreation(String parentTypeId, String typeId); + void checkTypesBeforeContainerCreation(String parentTypeId, String typeId); - void checkTypesBeforeContentCreation(String parentTypeId, String typeId); + void checkTypesBeforeContentCreation(String parentTypeId, String typeId); - String getName(); + String getName(); - String getRootName(); + String getRootName(); - ServerToolTarget getTarget(); + ServerToolTarget getTarget(); - Group initGroup(User user, Group group, Object... vars); + Group initGroup(User user, Group group, Object... vars); - void onCreateContainer(Container container, Container parent); + void onCreateContainer(Container container, Container parent); - void onCreateContent(Content content, Container parent); + void onCreateContent(Content content, Container parent); - void register(ServerToolRegistry registry); + void register(ServerToolRegistry registry); } Added: trunk/src/main/java/cc/kune/core/server/tool/ServerWaveTool.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/tool/ServerWaveTool.java (rev 0) +++ trunk/src/main/java/cc/kune/core/server/tool/ServerWaveTool.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -0,0 +1,9 @@ +package cc.kune.core.server.tool; + +import java.net.URL; + +public interface ServerWaveTool extends ServerTool { + + URL getGadgetUrl(); + +} Property changes on: trunk/src/main/java/cc/kune/core/server/tool/ServerWaveTool.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: trunk/src/main/java/cc/kune/core/server/utils/UrlUtils.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/utils/UrlUtils.java (rev 0) +++ trunk/src/main/java/cc/kune/core/server/utils/UrlUtils.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -0,0 +1,25 @@ +package cc.kune.core.server.utils; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class UrlUtils { + + private static final Log LOG = LogFactory.getLog(UrlUtils.class); + + public static URL of(final String urlString) { + URL url = null; + try { + url = new URL(urlString); + return url; + } catch (final MalformedURLException e) { + LOG.error("Error creating url with" + urlString); + e.printStackTrace(); + } + return url; + } + +} Property changes on: trunk/src/main/java/cc/kune/core/server/utils/UrlUtils.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: trunk/src/main/java/cc/kune/docs/client/DocsClientTool.java =================================================================== --- trunk/src/main/java/cc/kune/docs/client/DocsClientTool.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/cc/kune/docs/client/DocsClientTool.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -27,7 +27,7 @@ import cc.kune.core.client.i18n.I18nUITranslationService; import cc.kune.core.client.registry.ContentCapabilitiesRegistry; import cc.kune.core.client.resources.nav.NavResources; -import cc.kune.gspace.client.tool.old.FoldableAbstractClientTool; +import cc.kune.gspace.client.tool.FoldableAbstractClientTool; import cc.kune.gspace.client.tool.selector.ToolSelector; import com.google.inject.Inject; Modified: trunk/src/main/java/cc/kune/docs/server/DocumentServerTool.java =================================================================== --- trunk/src/main/java/cc/kune/docs/server/DocumentServerTool.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/cc/kune/docs/server/DocumentServerTool.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -48,106 +48,108 @@ import com.google.inject.Inject; public class DocumentServerTool implements ServerTool { - private final ToolConfigurationManager configurationManager; - private final ContainerManager containerManager; - private final ContentManager contentManager; - private final I18nTranslationService i18n; + private final ToolConfigurationManager configurationManager; + private final ContainerManager containerManager; + private final ContentManager contentManager; + private final I18nTranslationService i18n; - @Inject - public DocumentServerTool(final ContentManager contentManager, final ContainerManager containerManager, - final ToolConfigurationManager configurationManager, final I18nTranslationService translationService) { - this.contentManager = contentManager; - this.containerManager = containerManager; - this.configurationManager = configurationManager; - this.i18n = translationService; - } + @Inject + public DocumentServerTool(final ContentManager contentManager, + final ContainerManager containerManager, final ToolConfigurationManager configurationManager, + final I18nTranslationService translationService) { + this.contentManager = contentManager; + this.containerManager = containerManager; + this.configurationManager = configurationManager; + this.i18n = translationService; + } - void checkContainerTypeId(final String parentTypeId, final String typeId) { - if (typeId.equals(TYPE_FOLDER)) { - // ok valid container - if ((typeId.equals(TYPE_FOLDER) && (parentTypeId.equals(TYPE_ROOT) || parentTypeId.equals(TYPE_FOLDER)))) { - // ok - } else { - throw new ContainerNotPermittedException(); - } - } else { - throw new ContainerNotPermittedException(); - } + void checkContainerTypeId(final String parentTypeId, final String typeId) { + if (typeId.equals(TYPE_FOLDER)) { + // ok valid container + if ((typeId.equals(TYPE_FOLDER) && (parentTypeId.equals(TYPE_ROOT) || parentTypeId.equals(TYPE_FOLDER)))) { + // ok + } else { + throw new ContainerNotPermittedException(); + } + } else { + throw new ContainerNotPermittedException(); } + } - void checkContentTypeId(final String parentTypeId, final String typeId) { - if (typeId.equals(TYPE_DOCUMENT) || typeId.equals(TYPE_UPLOADEDFILE)) { - // ok valid content - if ((typeId.equals(TYPE_DOCUMENT) && (parentTypeId.equals(TYPE_ROOT) || parentTypeId.equals(TYPE_FOLDER))) - || (typeId.equals(TYPE_UPLOADEDFILE) && (parentTypeId.equals(TYPE_ROOT) || parentTypeId.equals(TYPE_FOLDER)))) { - // ok - } else { - throw new ContentNotPermittedException(); - } + void checkContentTypeId(final String parentTypeId, final String typeId) { + if (typeId.equals(TYPE_DOCUMENT) || typeId.equals(TYPE_UPLOADEDFILE)) { + // ok valid content + if ((typeId.equals(TYPE_DOCUMENT) && (parentTypeId.equals(TYPE_ROOT) || parentTypeId.equals(TYPE_FOLDER))) + || (typeId.equals(TYPE_UPLOADEDFILE) && (parentTypeId.equals(TYPE_ROOT) || parentTypeId.equals(TYPE_FOLDER)))) { + // ok + } else { + throw new ContentNotPermittedException(); + } - } else { - throw new ContentNotPermittedException(); - } + } else { + throw new ContentNotPermittedException(); } + } - @Override - public void checkTypesBeforeContainerCreation(final String parentTypeId, final String typeId) { - checkContainerTypeId(parentTypeId, typeId); - } + @Override + public void checkTypesBeforeContainerCreation(final String parentTypeId, final String typeId) { + checkContainerTypeId(parentTypeId, typeId); + } - @Override - public void checkTypesBeforeContentCreation(final String parentTypeId, final String typeId) { - checkContentTypeId(parentTypeId, typeId); - } + @Override + public void checkTypesBeforeContentCreation(final String parentTypeId, final String typeId) { + checkContentTypeId(parentTypeId, typeId); + } - @Override - public String getName() { - return NAME; - } + @Override + public String getName() { + return NAME; + } - @Override - public String getRootName() { - return ROOT_NAME; - } + @Override + public String getRootName() { + return ROOT_NAME; + } - @Override - public ServerToolTarget getTarget() { - return ServerToolTarget.forBoth; - } + @Override + public ServerToolTarget getTarget() { + return ServerToolTarget.forBoth; + } - @Override - public Group initGroup(final User user, final Group group, final Object... otherVars) { - final ToolConfiguration config = new ToolConfiguration(); - final Container rootFolder = containerManager.createRootFolder(group, NAME, ROOT_NAME, TYPE_ROOT); - config.setRoot(rootFolder); - group.setToolConfig(NAME, config); - configurationManager.persist(config); + @Override + public Group initGroup(final User user, final Group group, final Object... otherVars) { + final ToolConfiguration config = new ToolConfiguration(); + final Container rootFolder = containerManager.createRootFolder(group, NAME, ROOT_NAME, TYPE_ROOT); + config.setRoot(rootFolder); + group.setToolConfig(NAME, config); + configurationManager.persist(config); - final boolean hasVars = otherVars.length >= 2; - final String title = hasVars ? (String) otherVars[0] : i18n.t("Document sample"); - final String body = hasVars ? (String) otherVars[1] : i18n.t("This is only a sample of document"); + final boolean hasVars = otherVars.length >= 2; + final String title = hasVars ? (String) otherVars[0] : i18n.t("Document sample"); + final String body = hasVars ? (String) otherVars[1] : i18n.t("This is only a sample of document"); - final Content content = contentManager.createContent(title, body, user, rootFolder, DocsConstants.TYPE_DOCUMENT); - content.addAuthor(user); - content.setLanguage(user.getLanguage()); - content.setTypeId(TYPE_DOCUMENT); - content.setStatus(ContentStatus.publishedOnline); - content.setPublishedOn(new Date()); - group.setDefaultContent(content); - return group; - } + final Content content = contentManager.createContent(title, body, user, rootFolder, + DocsConstants.TYPE_DOCUMENT); + content.addAuthor(user); + content.setLanguage(user.getLanguage()); + content.setTypeId(TYPE_DOCUMENT); + content.setStatus(ContentStatus.publishedOnline); + content.setPublishedOn(new Date()); + group.setDefaultContent(content); + return group; + } - @Override - public void onCreateContainer(final Container container, final Container parent) { - } + @Override + public void onCreateContainer(final Container container, final Container parent) { + } - @Override - public void onCreateContent(final Content content, final Container parent) { - } + @Override + public void onCreateContent(final Content content, final Container parent) { + } - @Override - @Inject - public void register(final ServerToolRegistry registry) { - registry.register(this); - } + @Override + @Inject + public void register(final ServerToolRegistry registry) { + registry.register(this); + } } Modified: trunk/src/main/java/cc/kune/domain/Content.java =================================================================== --- trunk/src/main/java/cc/kune/domain/Content.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/cc/kune/domain/Content.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -52,6 +52,7 @@ import org.hibernate.search.annotations.IndexedEmbedded; import org.hibernate.validator.NotNull; +import cc.kune.barters.shared.BartersConstants; import cc.kune.blogs.shared.BlogsConstants; import cc.kune.core.shared.domain.ContentStatus; import cc.kune.core.shared.domain.utils.StateToken; @@ -261,7 +262,7 @@ @Transient public boolean isWave() { return (typeId.equals(DocsConstants.TYPE_DOCUMENT)) || typeId.equals(WikiConstants.TYPE_WIKIPAGE) - || (typeId.equals(BlogsConstants.TYPE_POST)); + || (typeId.equals(BlogsConstants.TYPE_POST) || typeId.equals(BartersConstants.TYPE_BARTER)); } public void removeAuthor(final User user) { Copied: trunk/src/main/java/cc/kune/gspace/client/tool/AbstractClientTool.java (from rev 1361, trunk/src/main/java/cc/kune/gspace/client/tool/old/AbstractClientTool.java) =================================================================== --- trunk/src/main/java/cc/kune/gspace/client/tool/AbstractClientTool.java (rev 0) +++ trunk/src/main/java/cc/kune/gspace/client/tool/AbstractClientTool.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -0,0 +1,35 @@ +/* + * + * 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.gspace.client.tool; + +import cc.kune.gspace.client.tool.selector.ToolSelector; +import cc.kune.gspace.client.tool.selector.ToolSelectorItemPanel; +import cc.kune.gspace.client.tool.selector.ToolSelectorItemPresenter; + +public abstract class AbstractClientTool { + + public AbstractClientTool(final String shortName, final String longName, final ToolSelector toolSelector) { + final ToolSelectorItemPresenter presenter = new ToolSelectorItemPresenter(shortName, longName, toolSelector); + final ToolSelectorItemPanel panel = new ToolSelectorItemPanel(); + presenter.init(panel); + } + + public abstract String getName(); +} Copied: trunk/src/main/java/cc/kune/gspace/client/tool/FoldableAbstractClientTool.java (from rev 1361, trunk/src/main/java/cc/kune/gspace/client/tool/old/FoldableAbstractClientTool.java) =================================================================== --- trunk/src/main/java/cc/kune/gspace/client/tool/FoldableAbstractClientTool.java (rev 0) +++ trunk/src/main/java/cc/kune/gspace/client/tool/FoldableAbstractClientTool.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -0,0 +1,124 @@ +/* + * + * 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.gspace.client.tool; + +import cc.kune.core.client.registry.ContentCapabilitiesRegistry; +import cc.kune.core.shared.dto.BasicMimeTypeDTO; +import cc.kune.gspace.client.tool.selector.ToolSelector; + +public abstract class FoldableAbstractClientTool extends AbstractClientTool { + + protected final ContentCapabilitiesRegistry contentCapabilitiesRegistry; + + public FoldableAbstractClientTool(final String shortName, final String longName, + final ToolSelector toolSelector, final ContentCapabilitiesRegistry contentCapabilitiesRegistry) { + super(shortName, longName, toolSelector); + this.contentCapabilitiesRegistry = contentCapabilitiesRegistry; + } + + protected void registerAclEditableTypes(final String... typeIds) { + contentCapabilitiesRegistry.getAclEditable().register(typeIds); + } + + protected void registerAuthorableTypes(final String... typeIds) { + contentCapabilitiesRegistry.getAuthorable().register(typeIds); + } + + protected void registerComentableTypes(final String... typeIds) { + contentCapabilitiesRegistry.getComentable().register(typeIds); + } + + public void registerContentTypeIcon(final String typeId, final BasicMimeTypeDTO mimeType, + final String iconUrl) { + contentCapabilitiesRegistry.getIconsRegistry().registerContentTypeIcon(typeId, mimeType, iconUrl); + } + + public void registerContentTypeIcon(final String contentTypeId, final Object icon) { + contentCapabilitiesRegistry.getIconsRegistry().registerContentTypeIcon(contentTypeId, icon); + } + + protected void registerDragableTypes(final String... typeIds) { + contentCapabilitiesRegistry.getDragable().register(typeIds); + } + + protected void registerDropableTypes(final String... typeIds) { + contentCapabilitiesRegistry.getDropable().register(typeIds); + } + + protected void registerEmailSubscribeAbleTypes(final String... typeIds) { + contentCapabilitiesRegistry.getEmailSubscribeAble().register(typeIds); + } + + protected void registerLicensableTypes(final String... typeIds) { + contentCapabilitiesRegistry.getLicensable().register(typeIds); + } + + protected void registerPublishModerableTypes(final String... typeIds) { + contentCapabilitiesRegistry.getPublishModerable().register(typeIds); + } + + protected void registerRateableTypes(final String... typeIds) { + contentCapabilitiesRegistry.getRateable().register(typeIds); + } + + protected void registerRenamableTypes(final String... typeIds) { + contentCapabilitiesRegistry.getRenamable().register(typeIds); + } + + protected void registerTageableTypes(final String... typeIds) { + contentCapabilitiesRegistry.getTageable().register(typeIds); + } + + protected void registerTranslatableTypes(final String... typeIds) { + contentCapabilitiesRegistry.getTranslatable().register(typeIds); + } + + protected void registerUploadTypesAndMimes(final String typeUploadedfile) { + registerContentTypeIcon(typeUploadedfile, new BasicMimeTypeDTO("image"), "images/nav/picture.png"); + registerContentTypeIcon(typeUploadedfile, new BasicMimeTypeDTO("video"), "images/nav/film.png"); + registerContentTypeIcon(typeUploadedfile, new BasicMimeTypeDTO("audio"), "images/nav/music.png"); + registerContentTypeIcon(typeUploadedfile, new BasicMimeTypeDTO("application", "pdf"), + "images/nav/page_pdf.png"); + registerContentTypeIcon(typeUploadedfile, new BasicMimeTypeDTO("application", "zip"), + "images/nav/page_zip.png"); + registerContentTypeIcon(typeUploadedfile, new BasicMimeTypeDTO("application", "zip"), + "images/nav/page_zip.png"); + registerContentTypeIcon(typeUploadedfile, new BasicMimeTypeDTO("text"), "images/nav/page_text.png"); + registerContentTypeIcon(typeUploadedfile, new BasicMimeTypeDTO("application", "msword"), + "images/nav/page_word.png"); + registerContentTypeIcon(typeUploadedfile, new BasicMimeTypeDTO("application", "excel"), + "images/nav/page_excel.png"); + registerContentTypeIcon(typeUploadedfile, new BasicMimeTypeDTO("application", "mspowerpoint"), + "images/nav/page_pps.png"); + registerContentTypeIcon(typeUploadedfile, "images/nav/page.png"); + } + + protected void registerVersionableTypes(final String... typeIds) { + contentCapabilitiesRegistry.getVersionable().register(typeIds); + } + + protected void registerXmppComentableTypes(final String... typeIds) { + contentCapabilitiesRegistry.getXmppComentable().register(typeIds); + } + + protected void registerXmppNotifyCapableTypes(final String... typeIds) { + contentCapabilitiesRegistry.getXmppNotificyCapable().register(typeIds); + } +} Modified: trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItemPanel.java =================================================================== --- trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItemPanel.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItemPanel.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -37,84 +37,89 @@ public class ToolSelectorItemPanel extends Composite implements ToolSelectorItemView { - interface ToolSelectorItemPanelUiBinder extends UiBinder<Widget, ToolSelectorItemPanel> { - } + interface ToolSelectorItemPanelUiBinder extends UiBinder<Widget, ToolSelectorItemPanel> { + } - private static ToolSelectorItemPanelUiBinder uiBinder = GWT.create(ToolSelectorItemPanelUiBinder.class); + private static ToolSelectorItemPanelUiBinder uiBinder = GWT.create(ToolSelectorItemPanelUiBinder.class); - @UiField - Image iconLeft; - @UiField - Image iconRight; - @UiField - InlineLabel label; - @UiField - FocusPanel self; + @UiField + Image iconLeft; + @UiField + Image iconRight; + @UiField + InlineLabel label; + @UiField + FocusPanel self; - public ToolSelectorItemPanel() { - initWidget(uiBinder.createAndBindUi(this)); - } + public ToolSelectorItemPanel() { + initWidget(uiBinder.createAndBindUi(this)); + setVisibleImpl(false); + } - @Override - public Widget asWidget() { - return this; - } + @Override + public Widget asWidget() { + return this; + } - private void focus() { - self.addStyleDependentName("focus"); - self.removeStyleDependentName("nofocus"); - } + private void focus() { + self.addStyleDependentName("focus"); + self.removeStyleDependentName("nofocus"); + } - @Override - public HasClickHandlers getFocus() { - return self; - } + @Override + public HasClickHandlers getFocus() { + return self; + } - @Override - public HasText getLabel() { - return label; - } + @Override + public HasText getLabel() { + return label; + } - @UiHandler("self") - void onSelfMouseOut(final MouseOutEvent event) { - unfocus(); - } + @UiHandler("self") + void onSelfMouseOut(final MouseOutEvent event) { + unfocus(); + } - // public void setTheme(final WsTheme oldTheme, final WsTheme newTheme) { - // if (oldTheme != null) { - // final String oldName = oldTheme.getName(); - // hl.removeStyleDependentName(oldName); - // } - // final String newName = newTheme.getName(); - // hl.addStyleDependentName(newName); - // super.setCornerStyleName(hl.getStyleName()); - // } + // public void setTheme(final WsTheme oldTheme, final WsTheme newTheme) { + // if (oldTheme != null) { + // final String oldName = oldTheme.getName(); + // hl.removeStyleDependentName(oldName); + // } + // final String newName = newTheme.getName(); + // hl.addStyleDependentName(newName); + // super.setCornerStyleName(hl.getStyleName()); + // } - @UiHandler("self") - void onSelfMouseOver(final MouseOverEvent event) { - focus(); - } + @UiHandler("self") + void onSelfMouseOver(final MouseOverEvent event) { + focus(); + } - @Override - public void setSelected(final boolean selected) { - if (selected) { - self.addStyleDependentName("selected"); - self.removeStyleDependentName("notselected"); - iconRight.setVisible(true); - } else { - self.addStyleDependentName("notselected"); - self.removeStyleDependentName("selected"); - iconRight.setVisible(false); - } + @Override + public void setSelected(final boolean selected) { + if (selected) { + self.addStyleDependentName("selected"); + self.removeStyleDependentName("notselected"); + iconRight.setVisible(true); + } else { + self.addStyleDependentName("notselected"); + self.removeStyleDependentName("selected"); + iconRight.setVisible(false); } + } - @Override - public void setVisible(final boolean visible) { - self.setVisible(visible); - } + @Override + public void setVisible(final boolean visible) { + setVisibleImpl(visible); + } - private void unfocus() { - self.addStyleDependentName("nofocus"); - self.removeStyleDependentName("focus"); - } + private void setVisibleImpl(final boolean visible) { + self.setVisible(visible); + } + + private void unfocus() { + self.addStyleDependentName("nofocus"); + self.removeStyleDependentName("focus"); + } } Modified: trunk/src/main/java/cc/kune/wave/server/KuneWaveManager.java =================================================================== --- trunk/src/main/java/cc/kune/wave/server/KuneWaveManager.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/cc/kune/wave/server/KuneWaveManager.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -19,23 +19,30 @@ */ package cc.kune.wave.server; +import java.net.URL; + import org.waveprotocol.wave.model.wave.ParticipantId; import org.waveprotocol.wave.model.waveref.WaveRef; import com.google.wave.api.Wavelet; public interface KuneWaveManager { + public static final URL WITHOUT_GADGET = null; - void addParticipant(WaveRef waveName, String author, String userWhoAdd, String newParticipant); + void addGadget(WaveRef waveName, String author, String gadgetUrl); - WaveRef createWave(String message, ParticipantId participants); + void addParticipant(WaveRef waveName, String author, String userWhoAdd, String newParticipant); - WaveRef createWave(String title, String message, ParticipantId... participantsArray); + WaveRef createWave(String message, ParticipantId participants); - Wavelet fetchWavelet(WaveRef waveRef, String author); + WaveRef createWave(String title, String message, ParticipantId... participantsArray); - boolean isParticipant(Wavelet wavelet, String user); + WaveRef createWave(String title, String message, URL gadgetUrl, ParticipantId... participantsArray); - void setTitle(WaveRef waveName, String title, String author); + Wavelet fetchWavelet(WaveRef waveRef, String author); + boolean isParticipant(Wavelet wavelet, String user); + + void setTitle(WaveRef waveName, String title, String author); + } Modified: trunk/src/main/java/cc/kune/wave/server/KuneWaveManagerDefault.java =================================================================== --- trunk/src/main/java/cc/kune/wave/server/KuneWaveManagerDefault.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/cc/kune/wave/server/KuneWaveManagerDefault.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -19,8 +19,11 @@ */ package cc.kune.wave.server; +import java.net.URL; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; @@ -43,26 +46,39 @@ import cc.kune.common.client.utils.TextUtils; import cc.kune.core.client.errors.DefaultException; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import com.google.inject.Inject; import com.google.inject.name.Named; import com.google.wave.api.ApiIdSerializer; import com.google.wave.api.Blip; import com.google.wave.api.BlipData; import com.google.wave.api.BlipThread; +import com.google.wave.api.Element; +import com.google.wave.api.Gadget; import com.google.wave.api.JsonRpcConstant.ParamsProperty; import com.google.wave.api.JsonRpcResponse; import com.google.wave.api.OperationQueue; import com.google.wave.api.OperationRequest; +import com.google.wave.api.OperationRequest.Parameter; import com.google.wave.api.ProtocolVersion; import com.google.wave.api.Wavelet; import com.google.wave.api.data.converter.EventDataConverterManager; +import com.google.wave.api.impl.DocumentModifyAction; +import com.google.wave.api.impl.DocumentModifyAction.BundledAnnotation; +import com.google.wave.api.impl.DocumentModifyAction.ModifyHow; import com.google.wave.api.impl.WaveletData; public class KuneWaveManagerDefault implements KuneWaveManager { public static final Log LOG = LogFactory.getLog(KuneWaveManagerDefault.class); + // See: DocumentModifyServiceTest + private static final String NO_ANNOTATION_KEY = null; + private static final List<BundledAnnotation> NO_BUNDLED_ANNOTATIONS = Collections.emptyList(); private static final String NO_TITLE = ""; + private static final List<String> NO_VALUES = Collections.<String> emptyList(); + private final ConversationUtil conversationUtil; private final EventDataConverterManager converterManager; private final String domain; @@ -85,6 +101,27 @@ } @Override + public void addGadget(final WaveRef waveName, final String author, final String gadgetUrl) { + // See DocumentModifyServiceTest + final List<Element> elementsIn = Lists.newArrayListWithCapacity(1); + final Map<String, String> properties = Maps.newHashMap(); + properties.put(Gadget.URL, gadgetUrl); + properties.put(Gadget.AUTHOR, participantUtils.of(author).getAddress()); + final Gadget gadget = new Gadget(properties); + + elementsIn.add(gadget); + final Wavelet wavelet = fetchWavelet(waveName, author); + final OperationQueue opQueue = new OperationQueue(); + final Blip rootBlip = wavelet.getRootBlip(); + + opQueue.modifyDocument(rootBlip).addParameter( + Parameter.of(ParamsProperty.MODIFY_ACTION, new DocumentModifyAction(ModifyHow.INSERT, NO_VALUES, + NO_ANNOTATION_KEY, elementsIn, NO_BUNDLED_ANNOTATIONS, false))); + opQueue.modifyDocument(rootBlip).addParameter(Parameter.of(ParamsProperty.INDEX, 1)); + doOperation(author, opQueue, "add gadget"); + } + + @Override public void addParticipant(final WaveRef waveName, final String author, final String userWhoAdds, final String participant) { final Wavelet wavelet = fetchWavelet(waveName, author); @@ -92,26 +129,8 @@ : author; final OperationQueue opQueue = new OperationQueue(); opQueue.addParticipantToWavelet(wavelet, participantUtils.of(participant).toString()); - final OperationContextImpl context = new OperationContextImpl(waveletProvider, - converterManager.getEventDataConverter(ProtocolVersion.DEFAULT), conversationUtil); - final OperationRequest request = opQueue.getPendingOperations().get(0); - OperationUtil.executeOperation(request, operationRegistry, context, participantUtils.of(whoAdd)); - final String reqId = request.getId(); - final JsonRpcResponse response = context.getResponse(reqId); - if (response != null && response.isError()) { - onFailure(context.getResponse(reqId).getErrorMessage()); - } - OperationUtil.submitDeltas(context, waveletProvider, new SubmitRequestListener() { - @Override - public void onFailure(final String arg0) { - KuneWaveManagerDefault.this.onFailure("Wave add participant failed, onFailure: " + arg0); - } + doOperation(whoAdd, opQueue, "add participant"); - @Override - public void onSuccess(final int arg0, final HashedVersion arg1, final long arg2) { - LOG.info("Wave addParticipant success: " + arg1); - } - }); } @Override @@ -122,6 +141,12 @@ @Override public WaveRef createWave(@Nonnull final String title, final String message, @Nonnull final ParticipantId... participantsArray) { + return createWave(title, message, WITHOUT_GADGET, participantsArray); + } + + @Override + public WaveRef createWave(@Nonnull final String title, final String message, final URL gadgetUrl, + @Nonnull final ParticipantId... participantsArray) { String newWaveId = null; String newWaveletId = null; final Set<String> participants = new HashSet<String>(); @@ -134,6 +159,12 @@ opQueue.setTitleOfWavelet(newWavelet, title); final Blip rootBlip = newWavelet.getRootBlip(); rootBlip.append(new com.google.wave.api.Markup(message).getText()); + + if (gadgetUrl != WITHOUT_GADGET) { + final Gadget gadget = new Gadget(gadgetUrl.toString()); + rootBlip.append(gadget); + } + final OperationContextImpl context = new OperationContextImpl(waveletProvider, converterManager.getEventDataConverter(ProtocolVersion.DEFAULT), conversationUtil); for (final OperationRequest req : opQueue.getPendingOperations()) { @@ -178,6 +209,29 @@ return wavename; } + private void doOperation(final String author, final OperationQueue opQueue, final String logComment) { + final OperationContextImpl context = new OperationContextImpl(waveletProvider, + converterManager.getEventDataConverter(ProtocolVersion.DEFAULT), conversationUtil); + final OperationRequest request = opQueue.getPendingOperations().get(0); + OperationUtil.executeOperation(request, operationRegistry, context, participantUtils.of(author)); + final String reqId = request.getId(); + final JsonRpcResponse response = context.getResponse(reqId); + if (response != null && response.isError()) { + onFailure(context.getResponse(reqId).getErrorMessage()); + } + OperationUtil.submitDeltas(context, waveletProvider, new SubmitRequestListener() { + @Override + public void onFailure(final String arg0) { + KuneWaveManagerDefault.this.onFailure("Wave " + logComment + " failed, onFailure: " + arg0); + } + + @Override + public void onSuccess(final int arg0, final HashedVersion arg1, final long arg2) { + LOG.info("Wave " + logComment + " success: " + arg1); + } + }); + } + public void doOperations(final WaveRef waveName, final String author, final OperationQueue opQueue, final SubmitRequestListener listener) { final OperationContextImpl context = new OperationContextImpl(waveletProvider, @@ -245,26 +299,6 @@ final Wavelet wavelet = fetchWavelet(waveName, author); final OperationQueue opQueue = new OperationQueue(); opQueue.setTitleOfWavelet(wavelet, title); - final OperationContextImpl context = new OperationContextImpl(waveletProvider, - converterManager.getEventDataConverter(ProtocolVersion.DEFAULT), conversationUtil); - final OperationRequest request = opQueue.getPendingOperations().get(0); - OperationUtil.executeOperation(request, operationRegistry, context, participantUtils.of(author)); - final String reqId = request.getId(); - final JsonRpcResponse response = context.getResponse(reqId); - if (response != null && response.isError()) { - onFailure(context.getResponse(reqId).getErrorMessage()); - } - OperationUtil.submitDeltas(context, waveletProvider, new SubmitRequestListener() { - @Override - public void onFailure(final String arg0) { - KuneWaveManagerDefault.this.onFailure("Wave set title failed, onFailure: " + arg0); - } - - @Override - public void onSuccess(final int arg0, final HashedVersion arg1, final long arg2) { - LOG.info("Wave set title success: " + arg1); - } - }); + doOperation(author, opQueue, "set title"); } - } Modified: trunk/src/main/java/cc/kune/wiki/client/WikiClientTool.java =================================================================== --- trunk/src/main/java/cc/kune/wiki/client/WikiClientTool.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/cc/kune/wiki/client/WikiClientTool.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -27,7 +27,7 @@ import cc.kune.core.client.i18n.I18nUITranslationService; import cc.kune.core.client.registry.ContentCapabilitiesRegistry; import cc.kune.core.client.resources.nav.NavResources; -import cc.kune.gspace.client.tool.old.FoldableAbstractClientTool; +import cc.kune.gspace.client.tool.FoldableAbstractClientTool; import cc.kune.gspace.client.tool.selector.ToolSelector; import com.google.inject.Inject; Modified: trunk/src/main/java/org/ourproject/kune/chat/server/ChatServerTool.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/chat/server/ChatServerTool.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/org/ourproject/kune/chat/server/ChatServerTool.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -36,81 +36,82 @@ import com.google.inject.Inject; public class ChatServerTool implements ServerTool { - public static final String NAME = "chats"; - public static final String ROOT_NAME = "chat rooms"; - public static final String TYPE_CHAT = ChatClientTool.TYPE_CHAT; - public static final String TYPE_ROOM = ChatClientTool.TYPE_ROOM; - public static final String TYPE_ROOT = ChatClientTool.TYPE_ROOT; - private final ToolConfigurationManager configurationManager; - private final ContainerManager containerManager; + public static final String NAME = "chats"; + public static final String ROOT_NAME = "chat rooms"; + public static final String TYPE_CHAT = ChatClientTool.TYPE_CHAT; + public static final String TYPE_ROOM = ChatClientTool.TYPE_ROOM; + public static final String TYPE_ROOT = ChatClientTool.TYPE_ROOT; + private final ToolConfigurationManager configurationManager; + private final ContainerManager containerManager; - @Inject - public ChatServerTool(final ToolConfigurationManager configurationManager, final ContainerManager containerManager) { - this.configurationManager = configurationManager; - this.containerManager = containerManager; - } + @Inject + public ChatServerTool(final ToolConfigurationManager configurationManager, + final ContainerManager containerManager) { + this.configurationManager = configurationManager; + this.containerManager = containerManager; + } - private void checkContainerTypeId(final String parentTypeId, final String typeId) { - if (typeId.equals(TYPE_ROOM)) { - if (!parentTypeId.equals(TYPE_ROOT)) { - throw new ContainerNotPermittedException(); - } - // ok valid container - } else { - throw new ContainerNotPermittedException(); - } + private void checkContainerTypeId(final String parentTypeId, final String typeId) { + if (typeId.equals(TYPE_ROOM)) { + if (!parentTypeId.equals(TYPE_ROOT)) { + throw new ContainerNotPermittedException(); + } + // ok valid container + } else { + throw new ContainerNotPermittedException(); } + } - @Override - public void checkTypesBeforeContainerCreation(final String parentTypeId, final String typeId) { - checkContainerTypeId(parentTypeId, typeId); - } + @Override + public void checkTypesBeforeContainerCreation(final String parentTypeId, final String typeId) { + checkContainerTypeId(parentTypeId, typeId); + } - @Override - public void checkTypesBeforeContentCreation(final String parentTypeId, final String typeId) { - if (!parentTypeId.equals(TYPE_ROOM)) { - throw new ContainerNotPermittedException(); - } - // in the future chat history checks + @Override + public void checkTypesBeforeContentCreation(final String parentTypeId, final String typeId) { + if (!parentTypeId.equals(TYPE_ROOM)) { + throw new ContainerNotPermittedException(); } + // in the future chat history checks + } - @Override - public String getName() { - return NAME; - } + @Override + public String getName() { + return NAME; + } - @Override - public String getRootName() { - return ROOT_NAME; - } + @Override + public String getRootName() { + return ROOT_NAME; + } - @Override - public ServerToolTarget getTarget() { - return ServerToolTarget.forGroups; - } + @Override + public ServerToolTarget getTarget() { + return ServerToolTarget.forGroups; + } - @Override - public Group initGroup(final User user, final Group group, final Object... otherVars) { - final ToolConfiguration config = new ToolConfiguration(); - final Container container = containerManager.createRootFolder(group, NAME, ROOT_NAME, TYPE_ROOT); - config.setRoot(container); - group.setToolConfig(NAME, config); - configurationManager.persist(config); - return group; - } + @Override + public Group initGroup(final User user, final Group group, final Object... otherVars) { + final ToolConfiguration config = new ToolConfiguration(); + final Container container = containerManager.createRootFolder(group, NAME, ROOT_NAME, TYPE_ROOT); + config.setRoot(container); + group.setToolConfig(NAME, config); + configurationManager.persist(config); + return group; + } - @Override - public void onCreateContainer(final Container container, final Container parent) { - } + @Override + public void onCreateContainer(final Container container, final Container parent) { + } - @Override - public void onCreateContent(final Content content, final Container parent) { - } + @Override + public void onCreateContent(final Content content, final Container parent) { + } - @Override - @Inject - public void register(final ServerToolRegistry registry) { - registry.register(this); - } + @Override + @Inject + public void register(final ServerToolRegistry registry) { + registry.register(this); + } } Modified: trunk/src/main/java/org/ourproject/kune/gallery/server/GalleryServerTool.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/gallery/server/GalleryServerTool.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/main/java/org/ourproject/kune/gallery/server/GalleryServerTool.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -37,99 +37,102 @@ import com.google.inject.Inject; public class GalleryServerTool implements ServerTool { - public static final String NAME = "gallery"; - public static final String ROOT_NAME = "gallery"; - public static final String TYPE_ALBUM = NAME + "." + "album"; - public static final String TYPE_ROOT = NAME + "." + "root"; + public static final String NAME = "gallery"; + public static final String ROOT_NAME = "gallery"; + public static final String TYPE_ALBUM = NAME + "." + "album"; + public static final String TYPE_ROOT = NAME + "." + "root"; - public static final String TYPE_UPLOADEDFILE = NAME + "." + ToolConstants.UPLOADEDFILE_SUFFIX; + public static final String TYPE_UPLOADEDFILE = NAME + "." + ToolConstants.UPLOADEDFILE_SUFFIX; - private final ToolConfigurationManager configurationManager; - private final ContainerManager containerManager; - private final I18nTranslationService i18n; + private final ToolConfigurationManager configurationManager; + private final ContainerManager containerManager; + private final I18nTranslationService i18n; - @Inject - public GalleryServerTool(final ContainerManager containerManager, - final ToolConfigurationManager configurationManager, final I18nTranslationService translationService) { - this.containerManager = containerManager; - this.configurationManager = configurationManager; - this.i18n = translationService; - } + @Inject + public GalleryServerTool(final ContainerManager containerManager, + final ToolConfigurationManager configurationManager, + final I18nTranslationService translationService) { + this.containerManager = containerManager; + this.configurationManager = configurationManager; + this.i18n = translationService; + } - void checkContainerTypeId(final String parentTypeId, final String typeId) { - if (typeId.equals(TYPE_ALBUM)) { - // ok valid container - if ((typeId.equals(TYPE_ALBUM) && (parentTypeId.equals(TYPE_ROOT) || parentTypeId.equals(TYPE_ALBUM)))) { - // ok - } else { - throw new ContainerNotPermittedException(); - } - } else { - throw new ContainerNotPermittedException(); - } + void checkContainerTypeId(final String parentTypeId, final String typeId) { + if (typeId.equals(TYPE_ALBUM)) { + // ok valid container + if ((typeId.equals(TYPE_ALBUM) && (parentTypeId.equals(TYPE_ROOT) || parentTypeId.equals(TYPE_ALBUM)))) { + // ok + } else { + throw new ContainerNotPermittedException(); + } + } else { + throw new ContainerNotPermittedException(); } + } - void checkContentTypeId(final String parentTypeId, final String typeId) { - if (typeId.equals(TYPE_UPLOADEDFILE)) { - // ok valid content - if (typeId.equals(TYPE_UPLOADEDFILE) && (parentTypeId.equals(TYPE_ROOT) || parentTypeId.equals(TYPE_ALBUM))) { - // ok - } else { - throw new ContentNotPermittedException(); - } - } else { - throw new ContentNotPermittedException(); - } + void checkContentTypeId(final String parentTypeId, final String typeId) { + if (typeId.equals(TYPE_UPLOADEDFILE)) { + // ok valid content + if (typeId.equals(TYPE_UPLOADEDFILE) + && (parentTypeId.equals(TYPE_ROOT) || parentTypeId.equals(TYPE_ALBUM))) { + // ok + } else { + throw new ContentNotPermittedException(); + } + } else { + throw new ContentNotPermittedException(); } + } - @Override - public void checkTypesBeforeContainerCreation(final String parentTypeId, final String typeId) { - checkContainerTypeId(parentTypeId, typeId); - } + @Override + public void checkTypesBeforeContainerCreation(final String parentTypeId, final String typeId) { + checkContainerTypeId(parentTypeId, typeId); + } - @Override - public void checkTypesBeforeContentCreation(final String parentTypeId, final String typeId) { - checkContentTypeId(parentTypeId, typeId); - } + @Override + public void checkTypesBeforeContentCreation(final String parentTypeId, final String typeId) { + checkContentTypeId(parentTypeId, typeId); + } - @Override - public String getName() { - return NAME; - } + @Override + public String getName() { + return NAME; + } - @Override - public String getRootName() { - return ROOT_NAME; - } + @Override + public String getRootName() { + return ROOT_NAME; + } - @Override - public ServerToolTarget getTarget() { - return ServerToolTarget.forBoth; - } + @Override + public ServerToolTarget getTarget() { + return ServerToolTarget.forBoth; + } - @Override - public Group initGroup(final User user, final Group group, final Object... otherVars) { - final ToolConfiguration config = new ToolConfiguration(); - final Container rootFolder = containerManager.createRootFolder(group, NAME, ROOT_NAME, TYPE_ROOT); - config.setRoot(rootFolder); - group.setToolConfig(NAME, config); - configurationManager.persist(config); + @Override + public Group initGroup(final User user, final Group group, final Object... otherVars) { + final ToolConfiguration config = new ToolConfiguration(); + final Container rootFolder = containerManager.createRootFolder(group, NAME, ROOT_NAME, TYPE_ROOT); + config.setRoot(rootFolder); + group.setToolConfig(NAME, config); + configurationManager.persist(config); - containerManager.createFolder(group, rootFolder, i18n.t("Album sample"), user.getLanguage(), TYPE_ALBUM); - return group; - } + containerManager.createFolder(group, rootFolder, i18n.t("Album sample"), user.getLanguage(), + TYPE_ALBUM); + return group; + } - @Override - public void onCreateContainer(final Container container, final Container parent) { - } + @Override + public void onCreateContainer(final Container container, final Container parent) { + } - @Override - public void onCreateContent(final Content content, final Container parent) { - } + @Override + public void onCreateContent(final Content content, final Container parent) { + } - @Override - @Inject - public void register(final ServerToolRegistry registry) { - registry.register(this); - } + @Override + @Inject + public void register(final ServerToolRegistry registry) { + registry.register(this); + } } Modified: trunk/src/test/java/cc/kune/wave/server/KuneWaveManagerDefaultTest.java =================================================================== --- trunk/src/test/java/cc/kune/wave/server/KuneWaveManagerDefaultTest.java 2011-05-10 18:55:08 UTC (rev 1370) +++ trunk/src/test/java/cc/kune/wave/server/KuneWaveManagerDefaultTest.java 2011-05-10 19:13:22 UTC (rev 1371) @@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue; import java.io.IOException; +import java.net.URL; import org.junit.Before; import org.junit.Test; @@ -40,6 +41,7 @@ private static final String MESSAGE = "testing"; private static final String NEW_PARTICIPANT = "newparti"; + private static final String TEST_GADGET = "http://wave-api.appspot.com/public/gadgets/areyouin/gadget.xml"; private static final String TITLE = "title"; private static final String TITLENEW = "titleNew"; @Inject @@ -47,6 +49,15 @@ @Inject ParticipantUtils participantUtils; + @Test + public void addGadget() throws DefaultException, IOException { + doLogin(); + final WaveRef waveletName = manager.createWave(TITLE, MESSAGE, + participantUtils.of(getSiteAdminShortName())); + assertNotNull(waveletName); + manager.addGadget(waveletName, getSiteAdminShortName(), TEST_GADGET); + } + private void addParticipant(final String whoAdds) throws IOException { doLogin(); final WaveRef waveletName = manager.createWave(TITLE, MESSAGE, @@ -83,6 +94,17 @@ } @Test + public void createWaveWithGadget() throws DefaultException, IOException { + doLogin(); + final WaveRef waveletName = manager.createWave(TITLE, MESSAGE, new URL(TEST_GADGET), + participantUtils.of(getSiteAdminShortName())); + assertNotNull(waveletName); + final Wavelet fetchWavelet = manager.fetchWavelet(waveletName, getSiteAdminShortName()); + assertNotNull(fetchWavelet); + assertTrue(fetchWavelet.getRootBlip().getContent().contains(MESSAGE)); + } + + @Test public void createWaveWithTitle() throws DefaultException, IOException { doLogin(); final WaveRef waveletName = manager.createWave(TITLE, MESSAGE,
participants (1)
-
Vicente J. Ruiz Jurado