[kune-commits] r989 - in trunk: .
src/main/java/org/ourproject/kune/blogs/client/cnt
src/main/java/org/ourproject/kune/chat/client/cnt
src/main/java/org/ourproject/kune/docs/client
src/main/java/org/ourproject/kune/docs/client/cnt
src/main/java/org/ourproject/kune/gallery/client/cnt
src/main/java/org/ourproject/kune/platf/client
src/main/java/org/ourproject/kune/platf/client/actions
src/main/java/org/ourproject/kune/platf/client/actions/toolbar
src/main/java/org/ourproject/kune/platf/client/errors
src/main/java/org/ourproject/kune/platf/client/services
src/main/java/org/ourproject/kune/platf/client/ui
src/main/java/org/ourproject/kune/platf/server/access
src/main/java/org/ourproject/kune/platf/server/content
src/main/java/org/ourproject/kune/platf/server/domain
src/main/java/org/ourproject/kune/platf/server/manager/file
src/main/java/org/ourproject/kune/platf/server/utils
src/main/java/org/ourproject/kune/wiki/client/cnt
src/main/java/org/ourproject/kune/workspace/client
src/main/java/org/ourproject/kune/workspace/client/cnt
src/main/java/org/ourproject/kune/workspace/client/ctxnav
src/main/java/org/ourproject/kune/workspace/client/newgroup
src/main/java/org/ourproject/kune/workspace/client/nohomepage
src/main/java/org/ourproject/kune/workspace/client/signin
src/main/java/org/ourproject/kune/workspace/client/socialnet
src/main/java/org/ourproject/kune/workspace/client/title
src/test/java/org/ourproject/kune/platf/integration/selenium
src/test/java/org/ourproject/kune/platf/server/content
src/test/java/org/ourproject/kune/platf/server/manager/file
vjrj
vjrj at ourproject.org
Wed Dec 10 02:36:09 CET 2008
Author: vjrj
Date: 2008-12-10 02:36:03 +0100 (Wed, 10 Dec 2008)
New Revision: 989
Added:
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuRadioDescriptor.java
trunk/src/main/java/org/ourproject/kune/platf/client/errors/NameInUseException.java
trunk/src/main/java/org/ourproject/kune/platf/client/errors/NameNotPermittedException.java
trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManagerUtils.java
trunk/src/main/java/org/ourproject/kune/platf/server/utils/FilenameUtils.java
trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/RadioMustBeChecked.java
trunk/src/main/java/org/ourproject/kune/workspace/client/title/RenameAction.java
trunk/src/test/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManagerTest.java
Removed:
trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManagerAbstract.java
Modified:
trunk/CREDITS
trunk/src/main/java/org/ourproject/kune/blogs/client/cnt/BlogFolderContentPresenter.java
trunk/src/main/java/org/ourproject/kune/blogs/client/cnt/BlogViewerPresenter.java
trunk/src/main/java/org/ourproject/kune/chat/client/cnt/ChatRoomPresenter.java
trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java
trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocFolderContentPanel.java
trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocFolderContentPresenter.java
trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentViewerPresenter.java
trunk/src/main/java/org/ourproject/kune/gallery/client/cnt/GalleryFolderContentPresenter.java
trunk/src/main/java/org/ourproject/kune/gallery/client/cnt/GalleryViewerPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/PlatfMessages.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneWorkspaceModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/AbstractLabel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/EditableClickListener.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/EditableIconLabel.java
trunk/src/main/java/org/ourproject/kune/platf/server/access/FinderService.java
trunk/src/main/java/org/ourproject/kune/platf/server/access/FinderServiceDefault.java
trunk/src/main/java/org/ourproject/kune/platf/server/content/ContainerManagerDefault.java
trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManagerDefault.java
trunk/src/main/java/org/ourproject/kune/platf/server/domain/Container.java
trunk/src/main/java/org/ourproject/kune/platf/server/domain/Content.java
trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/EntityLogoDownloadManager.java
trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManager.java
trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileUtils.java
trunk/src/main/java/org/ourproject/kune/wiki/client/cnt/WikiFolderContentPresenter.java
trunk/src/main/java/org/ourproject/kune/wiki/client/cnt/WikiViewerPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java
trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceMessages.java
trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/AbstractContentView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigator.java
trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/newgroup/NewGroupPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/nohomepage/NoHomePagePanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/signin/RegisterForm.java
trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/GroupMembersSummaryPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePresenter.java
trunk/src/test/java/org/ourproject/kune/platf/integration/selenium/SignInSeleniumTest.java
trunk/src/test/java/org/ourproject/kune/platf/server/content/ContentManagerDefaultTest.java
Log:
Incomplete - task Content name verifications
Complete - task ActionDescriptionRadio
Complete - task pdf to img for previews
Complete - task When empty doc show "Edit this doc" message
Modified: trunk/CREDITS
===================================================================
--- trunk/CREDITS 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/CREDITS 2008-12-10 01:36:03 UTC (rev 989)
@@ -10,7 +10,7 @@
Contributors
--------------------------------------------------------------------------------
-* Thanks to Samer Hassan for all the feedback and ideas.
+* Thanks to Samer Hassan for all the feedback, ideas and help with translations.
* Antonio Martins, Jéferson Assumção, Moacir Gadotti and the Instituto Paulo
Freire staff.
* Daniel Jiménez for the initial help
Modified: trunk/src/main/java/org/ourproject/kune/blogs/client/cnt/BlogFolderContentPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/blogs/client/cnt/BlogFolderContentPresenter.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/blogs/client/cnt/BlogFolderContentPresenter.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -40,7 +40,7 @@
public BlogFolderContentPresenter(StateManager stateManager, Session session, ActionContentToolbar toolbar,
final ActionRegistry<StateToken> actionRegistry, I18nTranslationService i18n,
Provider<FileDownloadUtils> downloadProvider) {
- super(BlogClientTool.NAME, stateManager, session, toolbar, actionRegistry, downloadProvider);
+ super(BlogClientTool.NAME, stateManager, session, toolbar, actionRegistry, downloadProvider, i18n);
this.i18n = i18n;
}
Modified: trunk/src/main/java/org/ourproject/kune/blogs/client/cnt/BlogViewerPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/blogs/client/cnt/BlogViewerPresenter.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/blogs/client/cnt/BlogViewerPresenter.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -36,7 +36,7 @@
public BlogViewerPresenter(StateManager stateManager, Session session, I18nUITranslationService i18n,
ActionContentToolbar toolbar, ContentActionRegistry actionRegistry,
Provider<FileDownloadUtils> downloadProvider) {
- super(BlogClientTool.NAME, stateManager, session, toolbar, actionRegistry, downloadProvider);
+ super(BlogClientTool.NAME, stateManager, session, toolbar, actionRegistry, downloadProvider, i18n);
}
public void init(BlogViewerView view) {
Modified: trunk/src/main/java/org/ourproject/kune/chat/client/cnt/ChatRoomPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/chat/client/cnt/ChatRoomPresenter.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/chat/client/cnt/ChatRoomPresenter.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -41,7 +41,7 @@
public ChatRoomPresenter(StateManager stateManager, Session session, I18nUITranslationService i18n,
ActionContentToolbar toolbar, final ActionRegistry<StateToken> actionRegistry,
Provider<FileDownloadUtils> downloadProvider) {
- super(ChatClientTool.NAME, stateManager, session, toolbar, actionRegistry, downloadProvider);
+ super(ChatClientTool.NAME, stateManager, session, toolbar, actionRegistry, downloadProvider, i18n);
this.i18n = i18n;
}
Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -108,7 +108,7 @@
public DocFolderContent create() {
final DocFolderContentPresenter presenter = new DocFolderContentPresenter($(StateManager.class),
$(Session.class), $(ActionContentToolbar.class), $(ContentActionRegistry.class),
- $$(FileDownloadUtils.class));
+ $$(FileDownloadUtils.class), $(I18nTranslationService.class));
final DocFolderContentView view = new DocFolderContentPanel($(WorkspaceSkeleton.class),
$(I18nTranslationService.class));
presenter.init(view);
Modified: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocFolderContentPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocFolderContentPanel.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocFolderContentPanel.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -27,5 +27,6 @@
public DocFolderContentPanel(WorkspaceSkeleton ws, I18nTranslationService i18n) {
super(ws, i18n);
+ setInfo("");
}
}
Modified: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocFolderContentPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocFolderContentPresenter.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocFolderContentPresenter.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -23,6 +23,7 @@
import org.ourproject.kune.platf.client.actions.ActionRegistry;
import org.ourproject.kune.platf.client.actions.toolbar.ActionContentToolbar;
import org.ourproject.kune.platf.client.dto.StateToken;
+import org.ourproject.kune.platf.client.services.I18nTranslationService;
import org.ourproject.kune.platf.client.state.Session;
import org.ourproject.kune.platf.client.state.StateManager;
import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
@@ -33,8 +34,9 @@
public class DocFolderContentPresenter extends FoldableContentPresenter implements DocFolderContent {
public DocFolderContentPresenter(StateManager stateManager, Session session, ActionContentToolbar toolbar,
- final ActionRegistry<StateToken> actionRegistry, Provider<FileDownloadUtils> downloadProvider) {
- super(DocumentClientTool.NAME, stateManager, session, toolbar, actionRegistry, downloadProvider);
+ final ActionRegistry<StateToken> actionRegistry, Provider<FileDownloadUtils> downloadProvider,
+ I18nTranslationService i18n) {
+ super(DocumentClientTool.NAME, stateManager, session, toolbar, actionRegistry, downloadProvider, i18n);
}
public void init(final DocFolderContentView view) {
Modified: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentViewerPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentViewerPresenter.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentViewerPresenter.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -36,7 +36,7 @@
public DocumentViewerPresenter(StateManager stateManager, Session session, I18nUITranslationService i18n,
ActionContentToolbar toolbar, ContentActionRegistry actionRegistry,
Provider<FileDownloadUtils> downloadProvider) {
- super(DocumentClientTool.NAME, stateManager, session, toolbar, actionRegistry, downloadProvider);
+ super(DocumentClientTool.NAME, stateManager, session, toolbar, actionRegistry, downloadProvider, i18n);
}
public void init(DocumentViewerView view) {
Modified: trunk/src/main/java/org/ourproject/kune/gallery/client/cnt/GalleryFolderContentPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/gallery/client/cnt/GalleryFolderContentPresenter.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/gallery/client/cnt/GalleryFolderContentPresenter.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -44,7 +44,7 @@
public GalleryFolderContentPresenter(StateManager stateManager, Session session, ActionContentToolbar toolbar,
final ActionRegistry<StateToken> actionRegistry, I18nTranslationService i18n,
Provider<FileDownloadUtils> downloadUtils, Provider<FileDownloadUtils> downloadProvider) {
- super(GalleryClientTool.NAME, stateManager, session, toolbar, actionRegistry, downloadProvider);
+ super(GalleryClientTool.NAME, stateManager, session, toolbar, actionRegistry, downloadProvider, i18n);
this.i18n = i18n;
this.downloadUtils = downloadUtils;
}
Modified: trunk/src/main/java/org/ourproject/kune/gallery/client/cnt/GalleryViewerPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/gallery/client/cnt/GalleryViewerPresenter.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/gallery/client/cnt/GalleryViewerPresenter.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -36,7 +36,7 @@
public GalleryViewerPresenter(StateManager stateManager, Session session, I18nUITranslationService i18n,
ActionContentToolbar toolbar, ContentActionRegistry actionRegistry,
Provider<FileDownloadUtils> downloadProvider) {
- super(GalleryClientTool.NAME, stateManager, session, toolbar, actionRegistry, downloadProvider);
+ super(GalleryClientTool.NAME, stateManager, session, toolbar, actionRegistry, downloadProvider, i18n);
}
public void init(GalleryViewerView view) {
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/PlatfMessages.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/PlatfMessages.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/PlatfMessages.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -9,7 +9,7 @@
String NAME_IN_USE = "This name in already in use. Please try with a different name";
String INCORRECT_NICKNAME_EMAIL_OR_PASSWORD = "The nickname/email or password is incorrect";
String YOUR_HOMEPAGE = "Your homepage";
- String USER_DON_T_HAVE_A_HOMEPAGE = "This user does not have a homepage";
+ String USER_DOESN_T_HAVE_A_HOMEPAGE = "This user does not have a homepage";
String ENT_LOGO_SELECTOR_NORMAL_TITLE = "Logo";
String ENT_LOGO_SELECTOR_PERSON_TITLE = "Avatar";
String ENT_OPTIONS_GROUP_TITLE = "Group options";
Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuRadioDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuRadioDescriptor.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuRadioDescriptor.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -0,0 +1,26 @@
+package org.ourproject.kune.platf.client.actions;
+
+import org.ourproject.kune.platf.client.dto.AccessRolDTO;
+import org.ourproject.kune.workspace.client.socialnet.RadioMustBeChecked;
+
+import com.calclab.suco.client.listener.Listener;
+
+public class ActionToolbarMenuRadioDescriptor<T> extends ActionToolbarMenuDescriptor<T> {
+ private final String group;
+ private final RadioMustBeChecked mustBeChecked;
+
+ public ActionToolbarMenuRadioDescriptor(AccessRolDTO accessRol, ActionToolbarPosition toolbarPosition,
+ Listener<T> onPerformCall, String group, RadioMustBeChecked mustBeChecked) {
+ super(accessRol, toolbarPosition, onPerformCall);
+ this.group = group;
+ this.mustBeChecked = mustBeChecked;
+ }
+
+ public String getGroup() {
+ return group;
+ }
+
+ public boolean mustBeChecked() {
+ return mustBeChecked.mustBeChecked();
+ }
+}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -9,6 +9,7 @@
import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator;
import org.ourproject.kune.platf.client.actions.ActionToolbarDescriptor;
import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionToolbarMenuRadioDescriptor;
import org.ourproject.kune.platf.client.actions.ActionToolbarPosition;
import org.ourproject.kune.workspace.client.skel.SimpleToolbar;
import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
@@ -21,6 +22,7 @@
import com.gwtext.client.widgets.ToolbarButton;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.menu.BaseItem;
+import com.gwtext.client.widgets.menu.CheckItem;
import com.gwtext.client.widgets.menu.Item;
import com.gwtext.client.widgets.menu.Menu;
import com.gwtext.client.widgets.menu.MenuItem;
@@ -169,12 +171,23 @@
private Item createToolbarMenu(final ActionToolbarPosition toolBarPos, final String menuTitle,
final String menuSubTitle, final ActionItem<T> actionItem, String id) {
final ActionToolbarMenuDescriptor<T> action = (ActionToolbarMenuDescriptor<T>) actionItem.getAction();
- final Item item = new Item(action.getText(), new BaseItemListenerAdapter() {
+ final Item item;
+ if (action instanceof ActionToolbarMenuRadioDescriptor) {
+ CheckItem checkItem = new CheckItem(action.getText());
+ ActionToolbarMenuRadioDescriptor<T> radioDescriptor = (ActionToolbarMenuRadioDescriptor<T>) action;
+ checkItem.setGroup(radioDescriptor.getGroup());
+ checkItem.setChecked(radioDescriptor.mustBeChecked());
+ item = checkItem;
+ } else {
+ item = new Item(action.getText());
+ }
+ BaseItemListenerAdapter clickListener = new BaseItemListenerAdapter() {
@Override
public void onClick(BaseItem item, EventObject e) {
actionManagerProvider.get().doAction(actionItem);
}
- });
+ };
+ item.addListener(clickListener);
item.setIcon(action.getIconUrl());
item.setTitle(action.getToolTip());
if (id != null) {
Added: trunk/src/main/java/org/ourproject/kune/platf/client/errors/NameInUseException.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/errors/NameInUseException.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/errors/NameInUseException.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -0,0 +1,24 @@
+/*
+ *
+ * Copyright (C) 2007-2008 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 org.ourproject.kune.platf.client.errors;
+
+public class NameInUseException extends DefaultException {
+ private static final long serialVersionUID = 1L;
+}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/errors/NameNotPermittedException.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/errors/NameNotPermittedException.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/errors/NameNotPermittedException.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -0,0 +1,24 @@
+/*
+ *
+ * Copyright (C) 2007-2008 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 org.ourproject.kune.platf.client.errors;
+
+public class NameNotPermittedException extends DefaultException {
+ private static final long serialVersionUID = 1L;
+}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -121,7 +121,7 @@
import org.ourproject.kune.workspace.client.tags.TagsSummary;
import org.ourproject.kune.workspace.client.themes.WsThemePresenter;
import org.ourproject.kune.workspace.client.title.EntitySubTitle;
-import org.ourproject.kune.workspace.client.title.EntityTitle;
+import org.ourproject.kune.workspace.client.title.RenameAction;
import com.calclab.suco.client.ioc.decorator.NoDecoration;
import com.calclab.suco.client.ioc.decorator.Singleton;
@@ -486,10 +486,9 @@
@Override
public ContextNavigator create() {
final ContextNavigatorPresenter presenter = new ContextNavigatorPresenter($(StateManager.class),
- $(Session.class), $$(ContentServiceAsync.class), i18n, $(EntityTitle.class),
- $(ContentIconsRegistry.class), $(ContentCapabilitiesRegistry.class),
- $(ActionContextToolbar.class), $(ContextActionRegistry.class), $$(FileDownloadUtils.class),
- true);
+ $(Session.class), $$(ContentServiceAsync.class), i18n, $(ContentIconsRegistry.class),
+ $(ContentCapabilitiesRegistry.class), $(ActionContextToolbar.class),
+ $(ContextActionRegistry.class), $$(FileDownloadUtils.class), true, $(RenameAction.class));
final ContextNavigatorPanel panel = new ContextNavigatorPanel(presenter, i18n,
$(WorkspaceSkeleton.class), $(ActionManager.class));
presenter.init(panel);
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneWorkspaceModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneWorkspaceModule.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneWorkspaceModule.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -42,7 +42,6 @@
import org.ourproject.kune.platf.client.ui.rate.RateItPresenter;
import org.ourproject.kune.platf.client.ui.rate.RatePanel;
import org.ourproject.kune.platf.client.ui.rate.RatePresenter;
-import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator;
import org.ourproject.kune.workspace.client.entityheader.EntityHeader;
import org.ourproject.kune.workspace.client.entityheader.EntityHeaderPanel;
import org.ourproject.kune.workspace.client.entityheader.EntityHeaderPresenter;
@@ -123,8 +122,10 @@
import org.ourproject.kune.workspace.client.title.EntityTitle;
import org.ourproject.kune.workspace.client.title.EntityTitlePanel;
import org.ourproject.kune.workspace.client.title.EntityTitlePresenter;
+import org.ourproject.kune.workspace.client.title.RenameAction;
import com.calclab.suco.client.ioc.decorator.NoDecoration;
+import com.calclab.suco.client.ioc.decorator.Singleton;
import com.calclab.suco.client.ioc.module.AbstractModule;
import com.calclab.suco.client.ioc.module.Factory;
@@ -282,9 +283,9 @@
register(ApplicationComponentGroup.class, new Factory<EntityTitle>(EntityTitle.class) {
@Override
public EntityTitle create() {
- final EntityTitlePresenter presenter = new EntityTitlePresenter($(KuneErrorHandler.class),
- $(StateManager.class), $(Session.class), $$(ContentServiceAsync.class),
- $$(ContextNavigator.class), $(ContentIconsRegistry.class), $(RenamableRegistry.class));
+ final EntityTitlePresenter presenter = new EntityTitlePresenter($(StateManager.class),
+ $(Session.class), $(ContentIconsRegistry.class), $(RenamableRegistry.class),
+ $(RenameAction.class));
final EntityTitlePanel panel = new EntityTitlePanel($(WorkspaceSkeleton.class), presenter);
presenter.init(panel);
return presenter;
@@ -458,5 +459,13 @@
}
});
+ register(Singleton.class, new Factory<RenameAction>(RenameAction.class) {
+ @Override
+ public RenameAction create() {
+ return new RenameAction($(I18nTranslationService.class), $(Session.class),
+ $$(ContentServiceAsync.class));
+ }
+ });
+
}
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/AbstractLabel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/AbstractLabel.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/AbstractLabel.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -56,4 +56,6 @@
void setTitle(final String title);
+ void setVisible(boolean visible);
+
}
\ No newline at end of file
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/EditableClickListener.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/EditableClickListener.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/EditableClickListener.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -21,6 +21,7 @@
public interface EditableClickListener {
+ @Deprecated
void onEdited(String text);
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/EditableIconLabel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/EditableIconLabel.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/EditableIconLabel.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -19,13 +19,17 @@
*/
package org.ourproject.kune.platf.client.ui;
+import com.calclab.suco.client.listener.Event2;
+import com.calclab.suco.client.listener.Listener2;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
+import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FocusListener;
+import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.MouseListenerAdapter;
+import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
-import com.gwtext.client.widgets.MessageBox;
-import com.gwtext.client.widgets.MessageBoxConfig;
public class EditableIconLabel extends Composite {
@@ -36,10 +40,15 @@
private EditableClickListener editableListener;
private MouseListenerAdapter mouseOverListener;
private final AbstractLabel label;
+ @SuppressWarnings("unused")
private String renameDialogTitle;
+ @SuppressWarnings("unused")
private String renameDialogLabel;
private String doubleClickToRenameLabel;
private String clickToRenameLabel;
+ private Event2<String, String> onEdit;
+ private TextBox editor;
+ private HorizontalPanel hp;
public EditableIconLabel(final AbstractImagePrototype icon, final String text, final boolean useDoubleClick,
final EditableClickListener editableListenerOrig) {
@@ -51,6 +60,7 @@
final boolean useDoubleClick, final EditableClickListener editableListenerOrig) {
label = new IconHyperlink(icon, text, targetHistoryToken);
init(text, useDoubleClick, editableListenerOrig);
+ this.onEdit = new Event2<String, String>("onEdit");
}
public EditableIconLabel(final EditableClickListener editableListener) {
@@ -61,6 +71,7 @@
final EditableClickListener editableListenerOrig) {
label = new LabelWrapper(text, wordWrap);
init(text, useDoubleClick, editableListenerOrig);
+ this.onEdit = new Event2<String, String>("onEdit");
}
public EditableIconLabel(final String text, final boolean useDoubleClick,
@@ -80,6 +91,10 @@
return label.getText();
}
+ public void onEdit(final Listener2<String, String> slot) {
+ onEdit.add(slot);
+ }
+
public void restoreOldText() {
label.setText(oldText);
this.currentText = this.oldText;
@@ -116,10 +131,12 @@
this.editableListener = editableListener;
}
+ @Deprecated
public void setRenameDialogLabel(final String renameDialogLabel) {
this.renameDialogLabel = renameDialogLabel;
}
+ @Deprecated
public void setRenameDialogTitle(final String renameDialogTitle) {
this.renameDialogTitle = renameDialogTitle;
}
@@ -130,21 +147,33 @@
label.setText(text);
}
+ private void afterEdit() {
+ String text = editor.getText();
+ onEdit.fire(currentText, text);
+ editor.setVisible(false);
+ label.setVisible(true);
+ label.removeStyleDependentName("high");
+ }
+
private void init(final String text, final boolean useDoubleClick, final EditableClickListener editableListenerOrig) {
doubleClickToRenameLabel = "Double click to rename";
clickToRenameLabel = "Click to rename";
renameDialogLabel = "Write a new name:";
renameDialogTitle = "Rename";
- initWidget((Widget) label);
+ hp = new HorizontalPanel();
+ hp.add((Widget) label);
+ initWidget(hp);
this.currentText = text;
this.oldText = text;
this.useDoubleClick = useDoubleClick;
this.editableListener = editableListenerOrig;
+ this.onEdit = new Event2<String, String>("onEdit");
this.listener = new ClickListener() {
public void onClick(final Widget sender) {
- showEditableDialog();
+ showEditor();
}
};
+
mouseOverListener = new MouseListenerAdapter() {
@Override
public void onMouseEnter(final Widget sender) {
@@ -169,30 +198,30 @@
label.removeMouseListener(mouseOverListener);
}
- private void showEditableDialog() {
- MessageBox.show(new MessageBoxConfig() {
- {
- // i18n
- setClosable(true);
- setModal(true);
- setWidth(300);
- setDefaultTextHeight(2);
- setButtons(MessageBox.OKCANCEL);
- setTitle(renameDialogTitle);
- setMsg(renameDialogLabel);
- setCallback(new MessageBox.PromptCallback() {
- public void execute(final String btnID, final String text) {
- if (btnID.equals("ok") && text != null) {
- editableListener.onEdited(text);
- } else {
- // Do nothing
- }
- }
- });
- setMultiline(true);
- setValue(currentText);
- }
- });
+ private void showEditor() {
+ int hpWidth = hp.getParent().getOffsetWidth();
+ label.setVisible(false);
+ if (editor == null) {
+ editor = new TextBox();
+ hp.add(editor);
+ editor.addFocusListener(new FocusListener() {
+ public void onFocus(Widget sender) {
+ }
+
+ public void onLostFocus(Widget sender) {
+ afterEdit();
+ }
+ });
+ editor.addChangeListener(new ChangeListener() {
+ public void onChange(Widget sender) {
+ afterEdit();
+ }
+ });
+ }
+ editor.setPixelSize(hpWidth, 22);
+ editor.setText(currentText);
+ editor.setVisible(true);
+ editor.setFocus(true);
}
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/access/FinderService.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/access/FinderService.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/access/FinderService.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -30,14 +30,14 @@
public interface FinderService {
+ Comment getComment(Long commentId) throws DefaultException;
+
Content getContent(Long contentId) throws DefaultException;
Content getContent(StateToken token, Group defaultGroup) throws DefaultException;
Container getFolder(Long folderId) throws DefaultException;
- Comment getComment(Long commentId) throws DefaultException;
-
Rate getRate(User user, Content content);
Double getRateAvg(Content content);
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/access/FinderServiceDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/access/FinderServiceDefault.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/access/FinderServiceDefault.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -131,11 +131,11 @@
private Content findByContentReference(final String groupName, final String toolName, final Long folderId,
final Long contentId) throws ContentNotFoundException {
- final Content descriptor = contentManager.find(contentId);
- if (descriptor == null) {
+ final Content content = contentManager.find(contentId);
+ if (content == null) {
throw new ContentNotFoundException();
}
- final Container container = descriptor.getContainer();
+ final Container container = content.getContainer();
if (!container.getId().equals(folderId)) {
throw new ContentNotFoundException();
@@ -146,7 +146,7 @@
if (!container.getOwner().getShortName().equals(groupName)) {
throw new ContentNotFoundException();
}
- return descriptor;
+ return content;
}
private Content findByFolderReference(final String groupName, final Long folderId) {
@@ -186,9 +186,9 @@
}
private Content generateFolderFakeContent(final Container container) {
- final Content descriptor = new Content();
- descriptor.setContainer(container);
- return descriptor;
+ final Content content = new Content();
+ content.setContainer(container);
+ return content;
}
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/content/ContainerManagerDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/content/ContainerManagerDefault.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/content/ContainerManagerDefault.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -29,12 +29,16 @@
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.search.Query;
import org.ourproject.kune.platf.client.errors.DefaultException;
+import org.ourproject.kune.platf.client.errors.NameInUseException;
import org.ourproject.kune.platf.server.domain.AccessLists;
import org.ourproject.kune.platf.server.domain.Container;
+import org.ourproject.kune.platf.server.domain.Content;
import org.ourproject.kune.platf.server.domain.Group;
import org.ourproject.kune.platf.server.domain.I18nLanguage;
+import org.ourproject.kune.platf.server.manager.file.FileUtils;
import org.ourproject.kune.platf.server.manager.impl.DefaultManager;
import org.ourproject.kune.platf.server.manager.impl.SearchResult;
+import org.ourproject.kune.platf.server.utils.FilenameUtils;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -43,13 +47,20 @@
@Singleton
public class ContainerManagerDefault extends DefaultManager<Container, Long> implements ContainerManager {
+ private final Container containerFinder;
+ private final Content contentFinder;
+
@Inject
- public ContainerManagerDefault(final Provider<EntityManager> provider) {
+ public ContainerManagerDefault(Content contentFinder, Container containerFinder,
+ final Provider<EntityManager> provider) {
super(provider, Container.class);
+ this.contentFinder = contentFinder;
+ this.containerFinder = containerFinder;
}
public Container createFolder(final Group group, final Container parent, final String name,
final I18nLanguage language, String typeId) {
+ findInexistentName(parent, name);
final List<Container> parentAbsolutePath = parent.getAbsolutePath();
final List<Container> childAbsolutePath = new ArrayList<Container>();
@@ -77,12 +88,17 @@
public String renameFolder(final Group group, final Container container, final String newName)
throws DefaultException {
+ FilenameUtils.checkBasicFilename(newName);
+ String newNameWithoutNT = FilenameUtils.chomp(newName);
if (container.isRoot()) {
throw new RuntimeException("Root folder cannot be renamed");
}
- container.setName(newName);
+ if (findIfExistsTitle(container.getParent(), newNameWithoutNT)) {
+ throw new NameInUseException();
+ }
+ container.setName(newNameWithoutNT);
persist(container);
- return newName;
+ return newNameWithoutNT;
}
public SearchResult<Container> search(final String search) {
@@ -105,4 +121,19 @@
persist(container);
}
+ /** Duplicate code in ContentMD **/
+ private boolean findIfExistsTitle(Container container, String title) {
+ return (contentFinder.findIfExistsTitle(container, title) > 0)
+ || (containerFinder.findIfExistsTitle(container, title) > 0);
+ }
+
+ /** Duplicate code in ContentMD **/
+ private String findInexistentName(Container container, String title) {
+ String initialTitle = new String(title);
+ while (findIfExistsTitle(container, initialTitle)) {
+ initialTitle = FileUtils.getNextSequentialFileName(initialTitle);
+ }
+ return initialTitle;
+ }
+
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManagerDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManagerDefault.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManagerDefault.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -31,6 +31,7 @@
import org.apache.lucene.search.Query;
import org.ourproject.kune.platf.client.errors.DefaultException;
import org.ourproject.kune.platf.client.errors.I18nNotFoundException;
+import org.ourproject.kune.platf.client.errors.NameInUseException;
import org.ourproject.kune.platf.client.errors.UserNotFoundException;
import org.ourproject.kune.platf.client.ui.TextUtils;
import org.ourproject.kune.platf.server.access.FinderService;
@@ -44,8 +45,10 @@
import org.ourproject.kune.platf.server.domain.Tag;
import org.ourproject.kune.platf.server.domain.User;
import org.ourproject.kune.platf.server.manager.TagManager;
+import org.ourproject.kune.platf.server.manager.file.FileUtils;
import org.ourproject.kune.platf.server.manager.impl.DefaultManager;
import org.ourproject.kune.platf.server.manager.impl.SearchResult;
+import org.ourproject.kune.platf.server.utils.FilenameUtils;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -58,11 +61,16 @@
private final User userFinder;
private final I18nLanguage languageFinder;
private final TagManager tagManager;
+ private final Content contentFinder;
+ private final Container containerFinder;
@Inject
- public ContentManagerDefault(final Provider<EntityManager> provider, final FinderService finder,
- final User userFinder, final I18nLanguage languageFinder, final TagManager tagManager) {
+ public ContentManagerDefault(final Content contentFinder, final Container containerFinder,
+ final Provider<EntityManager> provider, final FinderService finder, final User userFinder,
+ final I18nLanguage languageFinder, final TagManager tagManager) {
super(provider, Content.class);
+ this.contentFinder = contentFinder;
+ this.containerFinder = containerFinder;
this.finder = finder;
this.userFinder = userFinder;
this.languageFinder = languageFinder;
@@ -80,6 +88,8 @@
public Content createContent(final String title, final String body, final User author, final Container container,
String typeId) {
+ FilenameUtils.checkBasicFilename(title);
+ String newtitle = findInexistentTitle(container, title);
final Content newContent = new Content();
newContent.addAuthor(author);
newContent.setLanguage(author.getLanguage());
@@ -87,7 +97,7 @@
container.addContent(newContent);
newContent.setContainer(container);
final Revision revision = new Revision(newContent);
- revision.setTitle(title);
+ revision.setTitle(newtitle);
revision.setBody(body);
newContent.addRevision(revision);
return persist(newContent);
@@ -142,8 +152,13 @@
}
public String renameContent(final User user, final Long contentId, final String newTitle) throws DefaultException {
+ String newTitleWithoutNL = FilenameUtils.chomp(newTitle);
+ FilenameUtils.checkBasicFilename(newTitleWithoutNL);
final Content content = finder.getContent(contentId);
- content.getLastRevision().setTitle(newTitle);
+ if (findIfExistsTitle(content.getContainer(), newTitleWithoutNL)) {
+ throw new NameInUseException();
+ }
+ content.getLastRevision().setTitle(newTitleWithoutNL);
return newTitle;
}
@@ -219,4 +234,17 @@
}
content.setTags(tagList);
}
+
+ private boolean findIfExistsTitle(Container container, String title) {
+ return (contentFinder.findIfExistsTitle(container, title) > 0)
+ || (containerFinder.findIfExistsTitle(container, title) > 0);
+ }
+
+ private String findInexistentTitle(Container container, String title) {
+ String initialTitle = new String(title);
+ while (findIfExistsTitle(container, initialTitle)) {
+ initialTitle = FileUtils.getNextSequentialFileName(initialTitle);
+ }
+ return initialTitle;
+ }
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/domain/Container.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/domain/Container.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/domain/Container.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -46,6 +46,9 @@
import org.hibernate.search.annotations.Store;
import org.ourproject.kune.platf.client.dto.StateToken;
+import com.google.inject.name.Named;
+import com.wideplay.warp.persist.dao.Finder;
+
@Entity
@Indexed
@Table(name = "containers")
@@ -117,6 +120,11 @@
contents.add(descriptor);
}
+ @Finder(query = "SELECT COUNT(*) FROM Container c WHERE c.parent = :container AND c.name = :title")
+ public Long findIfExistsTitle(@Named("container") Container container, @Named("title") String title) {
+ return null;
+ }
+
public List<Container> getAbsolutePath() {
return absolutePath;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/domain/Content.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/domain/Content.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/domain/Content.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -54,6 +54,9 @@
import org.hibernate.validator.NotNull;
import org.ourproject.kune.platf.client.dto.StateToken;
+import com.google.inject.name.Named;
+import com.wideplay.warp.persist.dao.Finder;
+
@Entity
@Table(name = "contents")
@Indexed
@@ -161,6 +164,11 @@
}
}
+ @Finder(query = "select count(*) from Container ctx, Content ctn where ctn.container.id = ctx.id and ctx = :container and ctn.lastRevision.title = :title")
+ public Long findIfExistsTitle(@Named("container") Container container, @Named("title") String title) {
+ return null;
+ }
+
@Transient
public AccessLists getAccessLists() {
return hasAccessList() ? accessLists : getContainer().getAccessLists();
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/EntityLogoDownloadManager.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/EntityLogoDownloadManager.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/EntityLogoDownloadManager.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -21,6 +21,7 @@
import java.io.IOException;
import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -31,7 +32,7 @@
import com.google.inject.Inject;
-public class EntityLogoDownloadManager extends FileDownloadManagerAbstract {
+public class EntityLogoDownloadManager extends HttpServlet {
private static final long serialVersionUID = 1L;
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManager.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManager.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManager.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -24,6 +24,7 @@
import java.io.OutputStream;
import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -48,14 +49,22 @@
* http://www.onjava.com/pub/a/onjava/excerpt/jebp_3/index1.html?page=1
*
*/
-public class FileDownloadManager extends FileDownloadManagerAbstract {
+public class FileDownloadManager extends HttpServlet {
+ static final String RESP_HEADER_ATTACHMENT_FILENAME = "attachment; filename=\"";
+ static final String RESP_HEADER_CONTEND_DISP = "Content-Disposition";
+ static final String RESP_HEADER_END = "\"";
+
+ static final String APPLICATION_X_DOWNLOAD = "application/x-download";
+
private static final long serialVersionUID = 1L;
@Inject
ContentManager contentManager;
@Inject
KuneProperties kuneProperties;
+ @Inject
+ FileUtils fileUtils;
@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException,
@@ -65,24 +74,31 @@
final StateToken stateToken = new StateToken(req.getParameter(FileParams.TOKEN));
final String downloadS = req.getParameter(FileParams.DOWNLOAD);
String imageSizeS = req.getParameter(FileParams.IMGSIZE);
- final ImageSize imgsize = imageSizeS == null ? null : ImageSize.valueOf(imageSizeS);
- final boolean download = downloadS != null && downloadS.equals("true") ? true : false;
final Content cnt = getContentForDownload(userHash, stateToken);
+ String absFilename = buildResponse(cnt, stateToken, downloadS, imageSizeS, resp, fileUtils);
+ final OutputStream out = resp.getOutputStream();
+ FileDownloadManagerUtils.returnFile(absFilename, out);
+ }
+
+ String buildResponse(final Content cnt, final StateToken stateToken, final String downloadS, String imageSizeS,
+ final HttpServletResponse resp, FileUtils fileUtils) throws FileNotFoundException, IOException {
+ final ImageSize imgsize = imageSizeS == null ? null : ImageSize.valueOf(imageSizeS);
+ final boolean download = downloadS != null && downloadS.equals("true") ? true : false;
final String absDir = kuneProperties.get(KuneProperties.UPLOAD_LOCATION) + FileUtils.toDir(stateToken);
String filename = cnt.getFilename();
+ String title = cnt.getTitle();
String extension = FileUtils.getFileNameExtension(filename, true);
BasicMimeType mimeType = cnt.getMimeType();
- boolean isPdfAndNotDownload = mimeType.isPdf() && !download;
- if (mimeType.isImage() || isPdfAndNotDownload) {
+ boolean isPdfAndNotDownload = mimeType != null && mimeType.isPdf() && !download;
+ if (mimeType != null && (mimeType.isImage() || isPdfAndNotDownload)) {
String imgsizePrefix = imgsize == null ? "" : "." + imgsize;
String filenameWithoutExtension = FileUtils.getFileNameWithoutExtension(filename, extension);
String filenameResized = filenameWithoutExtension + imgsizePrefix
+ (isPdfAndNotDownload ? ".png" : extension);
- if (new File(absDir + filenameResized).exists()) {
- // thumb can fail
+ if (fileUtils.exist(absDir + filenameResized)) {
filename = filenameResized;
}
}
@@ -95,26 +111,18 @@
final String absFilename = absDir + filename;
- doBuildResp(resp, absFilename, cnt.getTitle(), mimeType, extension, download);
- }
+ final File file = new File(absFilename);
- private void doBuildResp(final HttpServletResponse resp, final String filename, final String otherName,
- final BasicMimeType mimeType, final String extension, final boolean download) throws FileNotFoundException,
- IOException {
- final File file = new File(filename);
-
resp.setContentLength((int) file.length());
if (mimeType == null || download) {
- resp.setContentType("application/x-download");
+ resp.setContentType(APPLICATION_X_DOWNLOAD);
} else if (mimeType.isImage()) {
resp.setContentType(mimeType.toString());
} else {
- resp.setContentType("application/x-download");
+ resp.setContentType(APPLICATION_X_DOWNLOAD);
}
- resp.setHeader("Content-Disposition", "attachment; filename=\"" + otherName + extension + "\"");
-
- final OutputStream out = resp.getOutputStream();
- returnFile(filename, out);
+ resp.setHeader(RESP_HEADER_CONTEND_DISP, RESP_HEADER_ATTACHMENT_FILENAME + title + extension + RESP_HEADER_END);
+ return absFilename;
}
@Authenticated(mandatory = false)
Deleted: trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManagerAbstract.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManagerAbstract.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManagerAbstract.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -1,49 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2008 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 org.ourproject.kune.platf.server.manager.file;
-
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import javax.servlet.http.HttpServlet;
-
-public abstract class FileDownloadManagerAbstract extends HttpServlet {
-
- private static final long serialVersionUID = 1L;
-
- public void returnFile(final String filename, final OutputStream out) throws FileNotFoundException, IOException {
- InputStream in = null;
- try {
- in = new BufferedInputStream(new FileInputStream(filename));
- final byte[] buf = new byte[4 * 1024]; // 4K buffer
- int bytesRead;
- while ((bytesRead = in.read(buf)) != -1) {
- out.write(buf, 0, bytesRead);
- }
- } finally {
- if (in != null) {
- in.close();
- }
- }
- }
-}
Copied: trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManagerUtils.java (from rev 985, trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManagerAbstract.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManagerAbstract.java 2008-12-05 17:53:45 UTC (rev 985)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManagerUtils.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -0,0 +1,48 @@
+/*
+ *
+ * Copyright (C) 2007-2008 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 org.ourproject.kune.platf.server.manager.file;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class FileDownloadManagerUtils {
+
+ private static final long serialVersionUID = 1L;
+
+ public static void returnFile(final String filename, final OutputStream out) throws FileNotFoundException,
+ IOException {
+ InputStream in = null;
+ try {
+ in = new BufferedInputStream(new FileInputStream(filename));
+ final byte[] buf = new byte[4 * 1024]; // 4K buffer
+ int bytesRead;
+ while ((bytesRead = in.read(buf)) != -1) {
+ out.write(buf, 0, bytesRead);
+ }
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ }
+ }
+}
Property changes on: trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManagerUtils.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileUtils.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileUtils.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileUtils.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -128,4 +128,8 @@
public static String toDir(final StateToken stateToken) {
return SLASH + stateToken.getGroup() + SLASH + stateToken.getTool() + SLASH + stateToken.getFolder() + SLASH;
}
+
+ public boolean exist(String file) {
+ return new File(file).exists();
+ }
}
Added: trunk/src/main/java/org/ourproject/kune/platf/server/utils/FilenameUtils.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/utils/FilenameUtils.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/utils/FilenameUtils.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -0,0 +1,22 @@
+package org.ourproject.kune.platf.server.utils;
+
+import org.apache.commons.lang.StringUtils;
+import org.ourproject.kune.platf.client.errors.NameNotPermittedException;
+
+public class FilenameUtils {
+
+ /**
+ * Check filename is not empty, or '.', or '..'
+ *
+ * @param filename
+ */
+ public static void checkBasicFilename(String filename) {
+ if (filename.length() == 0 || filename.equals(".") || filename.equals("..")) {
+ throw new NameNotPermittedException();
+ }
+ }
+
+ public static String chomp(String filename) {
+ return StringUtils.chomp(filename);
+ }
+}
Modified: trunk/src/main/java/org/ourproject/kune/wiki/client/cnt/WikiFolderContentPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/wiki/client/cnt/WikiFolderContentPresenter.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/wiki/client/cnt/WikiFolderContentPresenter.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -41,7 +41,7 @@
public WikiFolderContentPresenter(StateManager stateManager, Session session, ActionContentToolbar toolbar,
final ActionRegistry<StateToken> actionRegistry, I18nTranslationService i18n,
Provider<FileDownloadUtils> downloadProvider) {
- super(WikiClientTool.NAME, stateManager, session, toolbar, actionRegistry, downloadProvider);
+ super(WikiClientTool.NAME, stateManager, session, toolbar, actionRegistry, downloadProvider, i18n);
this.i18n = i18n;
}
Modified: trunk/src/main/java/org/ourproject/kune/wiki/client/cnt/WikiViewerPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/wiki/client/cnt/WikiViewerPresenter.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/wiki/client/cnt/WikiViewerPresenter.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -36,7 +36,7 @@
public WikiViewerPresenter(StateManager stateManager, Session session, I18nUITranslationService i18n,
ActionContentToolbar toolbar, ContentActionRegistry actionRegistry,
Provider<FileDownloadUtils> downloadProvider) {
- super(WikiClientTool.NAME, stateManager, session, toolbar, actionRegistry, downloadProvider);
+ super(WikiClientTool.NAME, stateManager, session, toolbar, actionRegistry, downloadProvider, i18n);
}
public void init(WikiViewerView view) {
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -7,6 +7,7 @@
import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator;
import org.ourproject.kune.platf.client.actions.ActionToolbarMenuAndItemDescriptor;
import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionToolbarMenuRadioDescriptor;
import org.ourproject.kune.platf.client.actions.ActionToolbarPosition;
import org.ourproject.kune.platf.client.actions.ContentActionRegistry;
import org.ourproject.kune.platf.client.actions.ContextActionRegistry;
@@ -36,6 +37,7 @@
import org.ourproject.kune.workspace.client.entityheader.EntityHeader;
import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService;
import org.ourproject.kune.workspace.client.site.Site;
+import org.ourproject.kune.workspace.client.socialnet.RadioMustBeChecked;
import com.calclab.suco.client.ioc.Provider;
import com.calclab.suco.client.listener.Listener;
@@ -101,18 +103,18 @@
}
protected void createContentModeratedActions(String parentMenuTitle, final String... contentsModerated) {
- final ActionToolbarMenuDescriptor<StateToken> setPublishStatus = createSetStatusAction(
+ final ActionToolbarMenuRadioDescriptor<StateToken> setPublishStatus = createSetStatusAction(
AccessRolDTO.Administrator, i18n.t("Published online"), parentMenuTitle,
ContentStatusDTO.publishedOnline);
- final ActionToolbarMenuDescriptor<StateToken> setEditionInProgressStatus = createSetStatusAction(
+ final ActionToolbarMenuRadioDescriptor<StateToken> setEditionInProgressStatus = createSetStatusAction(
AccessRolDTO.Administrator, i18n.t("Editing in progress"), parentMenuTitle,
ContentStatusDTO.editingInProgress);
- final ActionToolbarMenuDescriptor<StateToken> setRejectStatus = createSetStatusAction(
+ final ActionToolbarMenuRadioDescriptor<StateToken> setRejectStatus = createSetStatusAction(
AccessRolDTO.Administrator, i18n.t("Rejected"), parentMenuTitle, ContentStatusDTO.rejected);
- final ActionToolbarMenuDescriptor<StateToken> setSubmittedForPublishStatus = createSetStatusAction(
+ final ActionToolbarMenuRadioDescriptor<StateToken> setSubmittedForPublishStatus = createSetStatusAction(
AccessRolDTO.Administrator, i18n.t("Submitted for publish"), parentMenuTitle,
ContentStatusDTO.publishedOnline);
- final ActionToolbarMenuDescriptor<StateToken> setInTheDustBinStatus = createSetStatusAction(
+ final ActionToolbarMenuRadioDescriptor<StateToken> setInTheDustBinStatus = createSetStatusAction(
AccessRolDTO.Administrator, i18n.t("In the rubbish bin"), parentMenuTitle, ContentStatusDTO.inTheDustbin);
contentActionRegistry.addAction(setPublishStatus, contentsModerated);
contentActionRegistry.addAction(setEditionInProgressStatus, contentsModerated);
@@ -431,9 +433,9 @@
return setAsDefGroupContent;
}
- protected ActionToolbarMenuAndItemDescriptor<StateToken> createSetStatusAction(final AccessRolDTO rol,
+ protected ActionToolbarMenuRadioDescriptor<StateToken> createSetStatusAction(final AccessRolDTO rol,
final String textDescription, String parentMenuTitle, final ContentStatusDTO status) {
- final ActionToolbarMenuAndItemDescriptor<StateToken> action = new ActionToolbarMenuAndItemDescriptor<StateToken>(
+ final ActionToolbarMenuRadioDescriptor<StateToken> action = new ActionToolbarMenuRadioDescriptor<StateToken>(
rol, ActionToolbarPosition.topbar, new Listener<StateToken>() {
public void onEvent(final StateToken stateToken) {
final AsyncCallbackSimple<Object> callback = new AsyncCallbackSimple<Object>() {
@@ -449,6 +451,14 @@
contentServiceProvider.get().setStatus(session.getUserHash(), stateToken, status, callback);
}
}
+ }, "ContentRadioStatus", new RadioMustBeChecked() {
+ public boolean mustBeChecked() {
+ if (session.getContainerState() instanceof StateContentDTO) {
+ ContentStatusDTO currentStatus = session.getContentState().getStatus();
+ return status.equals(currentStatus);
+ }
+ return false;
+ }
});
action.setTextDescription(textDescription);
action.setParentMenuTitle(parentMenuTitle);
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceMessages.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceMessages.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceMessages.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -2,7 +2,7 @@
public interface WorkspaceMessages {
String REGISTER_A_NEW_GROUP_TITLE = "Register a new Group";
- String MUST_BE_BETWEEN_3_AND_15 = "The name must be between 3 and 15 lowercase characters. It can only contain Western characters, numbers, and dashes";
+ String FIELD_MUST_BE_BETWEEN_3_AND_15 = "The name must be between 3 and 15 lowercase characters. It can only contain Western characters, numbers, and dashes";
String NAME_IN_ALREADY_IN_USE = "This name is already in use. Please try with a different name";
String REGISTER_TO_CREATE_A_GROUP = "Please, sign in or register to create a group";
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/AbstractContentView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/AbstractContentView.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/AbstractContentView.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -14,6 +14,8 @@
void setInfo(String info);
+ void setInfoMessage(String text);
+
void setNoPreview();
void setWidgetAsContent(final Widget widget, boolean setDefMargins);
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPanel.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPanel.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -18,21 +18,21 @@
private static final String DEF_CONTENT_MARGINS_STYLE = "kune-Margin-7-trbl";
private final I18nTranslationService i18n;
- private final RoundedPanel previewPanel;
- private final IconLabel previewLabel;
+ private final RoundedPanel messagePanel;
+ private final IconLabel messageLabel;
public FoldableContentPanel(final WorkspaceSkeleton ws, I18nTranslationService i18n) {
super(ws);
this.i18n = i18n;
- previewLabel = new IconLabel(Images.App.getInstance().info(), "");
- previewLabel.addStyleName("k-preview-msg-lab");
- previewPanel = new RoundedPanel(previewLabel, RoundedPanel.ALL, 2);
- previewPanel.setCornerStyleName("k-preview-msg");
- previewPanel.addStyleName("kune-Margin-7-b");
+ messageLabel = new IconLabel(Images.App.getInstance().info(), "");
+ messageLabel.addStyleName("k-preview-msg-lab");
+ messagePanel = new RoundedPanel(messageLabel, RoundedPanel.ALL, 2);
+ messagePanel.setCornerStyleName("k-preview-msg");
+ messagePanel.addStyleName("kune-Margin-7-b");
}
public void setContent(String content, boolean showPreviewMsg) {
- final VerticalPanel vp = createPreviewVp(showPreviewMsg);
+ final VerticalPanel vp = createMessageVp(showPreviewMsg);
final HTML html = new HTML(content);
vp.add(html);
setWidgetAsContent(vp, true);
@@ -42,6 +42,12 @@
setLabel(info);
}
+ public void setInfoMessage(String text) {
+ VerticalPanel vp = createMessageVp(true);
+ messageLabel.setText(text);
+ setWidgetAsContent(vp, true);
+ }
+
public void setLabel(String text) {
Label label = new Label(text);
setDefStyle(label);
@@ -49,7 +55,7 @@
}
public void setNoPreview() {
- VerticalPanel vp = createPreviewVp(true);
+ VerticalPanel vp = createMessageVp(true);
setNoPreviewLabelMsg();
setWidgetAsContent(vp, true);
}
@@ -68,7 +74,7 @@
}
public void showImage(String imageUrl, String imageResizedUrl, boolean showPreviewMsg) {
- final VerticalPanel vp = createPreviewVp(showPreviewMsg);
+ final VerticalPanel vp = createMessageVp(showPreviewMsg);
final Image imgOrig = new Image(imageUrl);
final Image imgResized = new Image(imageResizedUrl);
KuneUiUtils.setQuickTip(imgOrig, i18n.t("Click to zoom out"));
@@ -94,11 +100,11 @@
Image.prefetch(imageUrl);
}
- private VerticalPanel createPreviewVp(boolean showPreviewMsg) {
+ private VerticalPanel createMessageVp(boolean showMsg) {
final VerticalPanel vp = new VerticalPanel();
- if (showPreviewMsg) {
+ if (showMsg) {
setDefPreviewMsg();
- vp.add(previewPanel);
+ vp.add(messagePanel);
}
return vp;
}
@@ -109,7 +115,7 @@
}
private void setDefPreviewMsg() {
- previewLabel.setText(i18n.t("This is only a preview, download it to get the complete file"));
+ messageLabel.setText(i18n.t("This is only a preview, download it to get the complete file"));
}
private void setDefStyle(final Widget widget) {
@@ -118,6 +124,6 @@
}
private void setNoPreviewLabelMsg() {
- previewLabel.setText(i18n.t("Preview not available"));
+ messageLabel.setText(i18n.t("Preview not available"));
}
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -9,6 +9,7 @@
import org.ourproject.kune.platf.client.dto.StateContainerDTO;
import org.ourproject.kune.platf.client.dto.StateContentDTO;
import org.ourproject.kune.platf.client.dto.StateToken;
+import org.ourproject.kune.platf.client.services.I18nTranslationService;
import org.ourproject.kune.platf.client.state.Session;
import org.ourproject.kune.platf.client.state.StateManager;
import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
@@ -24,15 +25,17 @@
protected final Session session;
private final ActionContentToolbar toolbar;
private final Provider<FileDownloadUtils> downloadProvider;
+ private final I18nTranslationService i18n;
public FoldableContentPresenter(final String toolName, StateManager stateManager, Session session,
final ActionContentToolbar toolbar, ActionRegistry<StateToken> actionRegistry,
- Provider<FileDownloadUtils> downloadProvider) {
+ Provider<FileDownloadUtils> downloadProvider, I18nTranslationService i18n) {
this.toolName = toolName;
this.session = session;
this.toolbar = toolbar;
this.actionRegistry = actionRegistry;
this.downloadProvider = downloadProvider;
+ this.i18n = i18n;
stateManager.onStateChanged(new Listener<StateAbstractDTO>() {
public void onEvent(final StateAbstractDTO state) {
setState(state);
@@ -71,7 +74,11 @@
view.setNoPreview();
}
} else {
- view.setRawContent(contentBody);
+ if ((contentBody == null || contentBody.length() == 0) && state.getContentRights().isEditable()) {
+ view.setInfoMessage(i18n.t("There is currently no text in this page, you can edit this page"));
+ } else {
+ view.setRawContent(contentBody);
+ }
}
view.attach();
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigator.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigator.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigator.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -41,10 +41,9 @@
void setEditOnNextStateChange(boolean edit);
+ void setFireOnTextChange(boolean visible);
+
void setItemStatus(StateToken stateToken, ContentStatusDTO status);
- void setItemText(StateToken stateToken, String name);
-
void setState(StateContainerDTO state, boolean selectItem);
-
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -47,13 +47,12 @@
import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
import org.ourproject.kune.platf.client.ui.download.ImageSize;
import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService;
-import org.ourproject.kune.workspace.client.site.Site;
-import org.ourproject.kune.workspace.client.title.EntityTitle;
+import org.ourproject.kune.workspace.client.title.RenameAction;
import com.calclab.suco.client.ioc.Provider;
import com.calclab.suco.client.listener.Listener;
import com.calclab.suco.client.listener.Listener0;
-import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.calclab.suco.client.listener.Listener2;
public class ContextNavigatorPresenter implements ContextNavigator {
@@ -63,7 +62,6 @@
private final Provider<ContentServiceAsync> contentServiceProvider;
private final I18nUITranslationService i18n;
private final HashMap<StateToken, ActionItemCollection<StateToken>> actionsByItem;
- private final EntityTitle entityTitle;
private boolean editOnNextStateChange;
private final ContentIconsRegistry contentIconsRegistry;
private final ActionRegistry<StateToken> actionRegistry;
@@ -71,30 +69,31 @@
private final Provider<FileDownloadUtils> downloadUtilsProvider;
private final boolean useGenericImageIcon;
private final ContentCapabilitiesRegistry capabilitiesRegistry;
+ private final RenameAction renameAction;
public ContextNavigatorPresenter(final StateManager stateManager, final Session session,
final Provider<ContentServiceAsync> contentServiceProvider, final I18nUITranslationService i18n,
- final EntityTitle entityTitle, final ContentIconsRegistry contentIconsRegistry,
- ContentCapabilitiesRegistry capabilitiesRegistry, final ActionToolbar<StateToken> toolbar,
- final ActionRegistry<StateToken> actionRegistry, Provider<FileDownloadUtils> downloadUtilsProvider,
- boolean useGenericImageIcon) {
+ final ContentIconsRegistry contentIconsRegistry, ContentCapabilitiesRegistry capabilitiesRegistry,
+ final ActionToolbar<StateToken> toolbar, final ActionRegistry<StateToken> actionRegistry,
+ Provider<FileDownloadUtils> downloadUtilsProvider, boolean useGenericImageIcon, RenameAction renameAction) {
this.stateManager = stateManager;
this.session = session;
this.contentServiceProvider = contentServiceProvider;
this.i18n = i18n;
- this.entityTitle = entityTitle;
this.contentIconsRegistry = contentIconsRegistry;
this.capabilitiesRegistry = capabilitiesRegistry;
this.actionRegistry = actionRegistry;
this.toolbar = toolbar;
this.downloadUtilsProvider = downloadUtilsProvider;
this.useGenericImageIcon = useGenericImageIcon;
+ this.renameAction = renameAction;
actionsByItem = new HashMap<StateToken, ActionItemCollection<StateToken>>();
editOnNextStateChange = false;
+ confRenameListener();
}
public void attach() {
- // FIXME At the moment detach (removeFromParent) destroy the gwt-eext
+ // FIXME At the moment detach (removeFromParent) destroy the gwt-ext
// TreePanel and the widget must be recreated (cannot be attached again
// like in gwt)
setState(session.getCurrentState(), true);
@@ -143,32 +142,7 @@
}
public void onItemRename(final String token, final String newName, final String oldName) {
- if (!newName.equals(oldName)) {
- Site.showProgress(i18n.t("Renaming"));
- final StateToken stateToken = new StateToken(token);
- final AsyncCallback<String> asyncCallback = new AsyncCallback<String>() {
- public void onFailure(final Throwable caught) {
- view.setFireOnTextChange(false);
- setItemText(stateToken, oldName);
- view.setFireOnTextChange(true);
- Site.error(i18n.t("Error renaming"));
- Site.hideProgress();
- }
-
- public void onSuccess(final String result) {
- Site.hideProgress();
- if (session.getCurrentState().getStateToken().getEncoded().equals(token)) {
- // I have to update EntityTitle
- entityTitle.setContentTitle(newName);
- }
- }
- };
- if (stateToken.isComplete()) {
- contentServiceProvider.get().renameContent(session.getUserHash(), stateToken, newName, asyncCallback);
- } else {
- contentServiceProvider.get().renameContainer(session.getUserHash(), stateToken, newName, asyncCallback);
- }
- }
+ renameAction.rename(new StateToken(token), oldName, newName);
}
public void refresh(final StateToken stateToken) {
@@ -190,14 +164,14 @@
editOnNextStateChange = edit;
}
+ public void setFireOnTextChange(boolean visible) {
+ view.setFireOnTextChange(visible);
+ }
+
public void setItemStatus(final StateToken stateToken, ContentStatusDTO status) {
view.setItemStatus(genId(stateToken), status);
}
- public void setItemText(final StateToken stateToken, final String name) {
- view.setItemText(genId(stateToken), name);
- }
-
public void setState(final StateContainerDTO state, final boolean select) {
setStateContainer(state, select);
}
@@ -288,6 +262,25 @@
return toolbarActions;
}
+ private void confRenameListener() {
+ Listener2<StateToken, String> onSuccess = new Listener2<StateToken, String>() {
+ public void onEvent(StateToken token, String newName) {
+ view.setFireOnTextChange(false);
+ setItemText(token, newName);
+ view.setFireOnTextChange(true);
+ }
+ };
+ renameAction.onSuccess(onSuccess);
+ Listener2<StateToken, String> onFail = new Listener2<StateToken, String>() {
+ public void onEvent(StateToken token, String oldName) {
+ view.setFireOnTextChange(false);
+ setItemText(token, oldName);
+ view.setFireOnTextChange(true);
+ }
+ };
+ renameAction.onFail(onFail);
+ }
+
private void createChildItems(final ContainerDTO container, final AccessRightsDTO containerRights) {
for (final ContentSimpleDTO content : container.getContents()) {
addItem(content.getTitle(), content.getTypeId(), content.getMimeType(), content.getStatus(),
@@ -340,6 +333,10 @@
}
}
+ private void setItemText(final StateToken stateToken, final String name) {
+ view.setItemText(genId(stateToken), name);
+ }
+
private void setState(final StateAbstractDTO state, boolean select) {
if (state instanceof StateContainerDTO) {
setState((StateContainerDTO) state, select);
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/newgroup/NewGroupPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/newgroup/NewGroupPanel.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/newgroup/NewGroupPanel.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -235,9 +235,9 @@
shortNameField.setMaxLength(15);
shortNameField.setAllowBlank(false);
shortNameField.setRegex("^[a-z0-9_\\-]+$");
- shortNameField.setMinLengthText(i18n.t(WorkspaceMessages.MUST_BE_BETWEEN_3_AND_15));
- shortNameField.setMaxLengthText(i18n.t(WorkspaceMessages.MUST_BE_BETWEEN_3_AND_15));
- shortNameField.setRegexText(i18n.t(WorkspaceMessages.MUST_BE_BETWEEN_3_AND_15));
+ shortNameField.setMinLengthText(i18n.t(WorkspaceMessages.FIELD_MUST_BE_BETWEEN_3_AND_15));
+ shortNameField.setMaxLengthText(i18n.t(WorkspaceMessages.FIELD_MUST_BE_BETWEEN_3_AND_15));
+ shortNameField.setRegexText(i18n.t(WorkspaceMessages.FIELD_MUST_BE_BETWEEN_3_AND_15));
shortNameField.setValidationDelay(1000);
form.add(shortNameField);
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/nohomepage/NoHomePagePanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/nohomepage/NoHomePagePanel.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/nohomepage/NoHomePagePanel.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -33,7 +33,7 @@
public NoHomePagePanel(final NoHomePagePresenter presenter, final WorkspaceSkeleton ws, I18nTranslationService i18n) {
this.ws = ws;
- noHomepageCtnLabel = new Label(i18n.t(PlatfMessages.USER_DON_T_HAVE_A_HOMEPAGE));
+ noHomepageCtnLabel = new Label(i18n.t(PlatfMessages.USER_DOESN_T_HAVE_A_HOMEPAGE));
noHomepageCtnLabel.ensureDebugId(NO_HOME_PAGE_LABEL);
noHomepageCtnLabel.setStyleName("kune-Content-Main");
noHomepageCtnLabel.addStyleName("kune-Margin-7-trbl");
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/signin/RegisterForm.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/signin/RegisterForm.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/signin/RegisterForm.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -72,9 +72,9 @@
shortNameRegField.setMinLength(3);
shortNameRegField.setMaxLength(15);
shortNameRegField.setRegex("^[a-z0-9_\\-]+$");
- shortNameRegField.setMinLengthText(i18n.t(WorkspaceMessages.MUST_BE_BETWEEN_3_AND_15));
- shortNameRegField.setMaxLengthText(i18n.t(WorkspaceMessages.MUST_BE_BETWEEN_3_AND_15));
- shortNameRegField.setRegexText(i18n.t(WorkspaceMessages.MUST_BE_BETWEEN_3_AND_15));
+ shortNameRegField.setMinLengthText(i18n.t(WorkspaceMessages.FIELD_MUST_BE_BETWEEN_3_AND_15));
+ shortNameRegField.setMaxLengthText(i18n.t(WorkspaceMessages.FIELD_MUST_BE_BETWEEN_3_AND_15));
+ shortNameRegField.setRegexText(i18n.t(WorkspaceMessages.FIELD_MUST_BE_BETWEEN_3_AND_15));
shortNameRegField.setValidationEvent(false);
add(shortNameRegField);
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPresenter.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPresenter.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -26,13 +26,14 @@
import org.ourproject.kune.platf.client.actions.ActionEnableCondition;
import org.ourproject.kune.platf.client.actions.ActionMenuItemDescriptor;
import org.ourproject.kune.platf.client.actions.ActionToolbarButtonAndItemDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionToolbarMenuRadioDescriptor;
import org.ourproject.kune.platf.client.actions.ActionToolbarPosition;
import org.ourproject.kune.platf.client.actions.GroupActionRegistry;
import org.ourproject.kune.platf.client.actions.UserActionRegistry;
import org.ourproject.kune.platf.client.actions.toolbar.ActionBuddiesSummaryToolbar;
import org.ourproject.kune.platf.client.dto.AccessRightsDTO;
import org.ourproject.kune.platf.client.dto.AccessRolDTO;
+import org.ourproject.kune.platf.client.dto.SocialNetworkDataDTO;
import org.ourproject.kune.platf.client.dto.StateAbstractDTO;
import org.ourproject.kune.platf.client.dto.UserBuddiesDataDTO;
import org.ourproject.kune.platf.client.dto.UserBuddiesVisibilityDTO;
@@ -52,6 +53,8 @@
public class BuddiesSummaryPresenter extends SocialNetworkPresenter implements BuddiesSummary {
+ public static final String BUDDIES_VISIBILITY_GROUP = "k-bsp-bud-visib";
+
private BuddiesSummaryView view;
private final StateManager stateManager;
private final UserActionRegistry actionRegistry;
@@ -145,7 +148,7 @@
}
private void createSetBuddiesVisibilityAction(String textDescription, final UserBuddiesVisibilityDTO visibility) {
- ActionToolbarMenuDescriptor<UserSimpleDTO> buddiesVisibilityAction = new ActionToolbarMenuDescriptor<UserSimpleDTO>(
+ ActionToolbarMenuRadioDescriptor<UserSimpleDTO> buddiesVisibilityAction = new ActionToolbarMenuRadioDescriptor<UserSimpleDTO>(
AccessRolDTO.Administrator, ActionToolbarPosition.bottombar, new Listener<UserSimpleDTO>() {
public void onEvent(UserSimpleDTO parameter) {
userServiceAsync.get().setBuddiesVisibility(session.getUserHash(),
@@ -156,6 +159,15 @@
}
});
}
+ }, BUDDIES_VISIBILITY_GROUP, new RadioMustBeChecked() {
+ public boolean mustBeChecked() {
+ StateAbstractDTO currentState = session.getCurrentState();
+ if (currentState.getGroup().isPersonal()) {
+ SocialNetworkDataDTO socialNetworkData = currentState.getSocialNetworkData();
+ return socialNetworkData.getUserBuddiesVisibility().equals(visibility);
+ }
+ return false;
+ }
});
buddiesVisibilityAction.setTextDescription(textDescription);
buddiesVisibilityAction.setParentMenuTitle(i18n.t("Options"));
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/GroupMembersSummaryPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/GroupMembersSummaryPresenter.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/GroupMembersSummaryPresenter.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -22,6 +22,7 @@
import org.ourproject.kune.chat.client.ChatEngine;
import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionToolbarMenuRadioDescriptor;
import org.ourproject.kune.platf.client.actions.ActionToolbarPosition;
import org.ourproject.kune.platf.client.actions.GroupActionRegistry;
import org.ourproject.kune.platf.client.actions.toolbar.ActionGroupSummaryToolbar;
@@ -59,6 +60,8 @@
public class GroupMembersSummaryPresenter extends SocialNetworkPresenter implements GroupMembersSummary {
+ public static final String MEMBERS_VISIBILITY_GROUP = "k-gmsp-memb-visib";
+
private GroupMembersSummaryView view;
private final I18nUITranslationService i18n;
private final GridGroup adminCategory;
@@ -176,7 +179,7 @@
}
private void createSetMembersVisibilityAction(String textDescription, final SocialNetworkVisibilityDTO visibility) {
- ActionToolbarMenuDescriptor<StateToken> showMembers = new ActionToolbarMenuDescriptor<StateToken>(
+ ActionToolbarMenuRadioDescriptor<StateToken> showMembers = new ActionToolbarMenuRadioDescriptor<StateToken>(
AccessRolDTO.Administrator, ActionToolbarPosition.bottombar, new Listener<StateToken>() {
public void onEvent(StateToken parameter) {
groupServiceProvider.get().setSocialNetworkVisibility(session.getUserHash(),
@@ -187,6 +190,15 @@
}
});
}
+ }, MEMBERS_VISIBILITY_GROUP, new RadioMustBeChecked() {
+ public boolean mustBeChecked() {
+ StateAbstractDTO currentState = session.getCurrentState();
+ if (!currentState.getGroup().isPersonal()) {
+ SocialNetworkDataDTO socialNetworkData = currentState.getSocialNetworkData();
+ return socialNetworkData.getSocialNetworkVisibility().equals(visibility);
+ }
+ return false;
+ }
});
showMembers.setTextDescription(textDescription);
showMembers.setParentMenuTitle(i18n.t("Options"));
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/RadioMustBeChecked.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/RadioMustBeChecked.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/RadioMustBeChecked.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -0,0 +1,5 @@
+package org.ourproject.kune.workspace.client.socialnet;
+
+public interface RadioMustBeChecked {
+ boolean mustBeChecked();
+}
\ No newline at end of file
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePanel.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePanel.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -24,6 +24,7 @@
import org.ourproject.kune.workspace.client.skel.SimpleToolbar;
import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
+import com.calclab.suco.client.listener.Listener2;
import com.google.gwt.user.client.ui.Image;
public class EntityTitlePanel implements EntityTitleView {
@@ -34,11 +35,16 @@
public EntityTitlePanel(final WorkspaceSkeleton ws, final EntityTitlePresenter presenter) {
icon = new Image();
titleLabel = new EditableIconLabel(new EditableClickListener() {
- public void onEdited(final String text) {
- presenter.onTitleRename(text);
+ public void onEdited(final String newName) {
}
});
+ titleLabel.onEdit(new Listener2<String, String>() {
+ public void onEvent(String oldName, String newName) {
+ presenter.onTitleRename(oldName, newName);
+ }
+ });
+
final SimpleToolbar wsTitle = ws.getEntityWorkspace().getTitleComponent();
wsTitle.add(icon);
wsTitle.add(titleLabel);
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePresenter.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePresenter.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -26,37 +26,27 @@
import org.ourproject.kune.platf.client.dto.StateContentDTO;
import org.ourproject.kune.platf.client.dto.StateToken;
import org.ourproject.kune.platf.client.registry.RenamableRegistry;
-import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
-import org.ourproject.kune.platf.client.services.KuneErrorHandler;
import org.ourproject.kune.platf.client.state.Session;
import org.ourproject.kune.platf.client.state.StateManager;
-import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator;
-import org.ourproject.kune.workspace.client.site.Site;
-import com.calclab.suco.client.ioc.Provider;
import com.calclab.suco.client.listener.Listener;
-import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.calclab.suco.client.listener.Listener2;
public class EntityTitlePresenter implements EntityTitle {
private EntityTitleView view;
- private final KuneErrorHandler errorHandler;
- private final Provider<ContentServiceAsync> contentServiceProvider;
private final Session session;
- private final Provider<ContextNavigator> contextNavigatorProvider;
private final ContentIconsRegistry iconsRegistry;
private final RenamableRegistry renamableContentRegistry;
+ private final RenameAction renameAction;
- public EntityTitlePresenter(final KuneErrorHandler errorHandler, final StateManager stateManager,
- final Session session, final Provider<ContentServiceAsync> contentServiceProvider,
- final Provider<ContextNavigator> contextNavigatorProvider, final ContentIconsRegistry iconsRegistry,
- RenamableRegistry renamableContentRegistry) {
- this.errorHandler = errorHandler;
+ public EntityTitlePresenter(final StateManager stateManager, final Session session,
+ final ContentIconsRegistry iconsRegistry, RenamableRegistry renamableContentRegistry,
+ RenameAction renameAction) {
this.session = session;
- this.contentServiceProvider = contentServiceProvider;
- this.contextNavigatorProvider = contextNavigatorProvider;
this.iconsRegistry = iconsRegistry;
this.renamableContentRegistry = renamableContentRegistry;
+ this.renameAction = renameAction;
stateManager.onStateChanged(new Listener<StateAbstractDTO>() {
public void onEvent(final StateAbstractDTO state) {
if (state instanceof StateContentDTO) {
@@ -69,6 +59,7 @@
}
}
});
+ createRenameListeners();
}
public View getView() {
@@ -87,27 +78,24 @@
view.setContentTitleVisible(true);
}
- protected void onTitleRename(final String newName) {
- Site.showProgressSaving();
- final StateToken stateToken = session.getCurrentState().getStateToken();
- final AsyncCallback<String> asyncCallback = new AsyncCallback<String>() {
- public void onFailure(final Throwable caught) {
- view.restoreOldTitle();
- errorHandler.process(caught);
- }
+ protected void onTitleRename(final String oldName, final String newName) {
+ final StateToken token = session.getCurrentState().getStateToken();
+ renameAction.rename(token, oldName, newName);
+ }
- public void onSuccess(final String result) {
- Site.hideProgress();
- view.setContentTitle(result);
- contextNavigatorProvider.get().setItemText(stateToken, newName);
+ private void createRenameListeners() {
+ Listener2<StateToken, String> onSuccess = new Listener2<StateToken, String>() {
+ public void onEvent(StateToken token, String newName) {
+ view.setContentTitle(newName);
}
};
- if (stateToken.isComplete()) {
- contentServiceProvider.get().renameContent(session.getUserHash(), stateToken, newName, asyncCallback);
- } else {
- contentServiceProvider.get().renameContainer(session.getUserHash(), stateToken, newName, asyncCallback);
- }
- Site.hideProgress();
+ renameAction.onSuccess(onSuccess);
+ Listener2<StateToken, String> onFail = new Listener2<StateToken, String>() {
+ public void onEvent(StateToken token, String oldName) {
+ view.setContentTitle(oldName);
+ }
+ };
+ renameAction.onFail(onFail);
}
private void setContentTitle(final String title, final boolean editable) {
@@ -140,5 +128,4 @@
setIcon(contentTypeIcon);
view.setContentTitleVisible(true);
}
-
}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/title/RenameAction.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/title/RenameAction.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/title/RenameAction.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -0,0 +1,71 @@
+package org.ourproject.kune.workspace.client.title;
+
+import org.ourproject.kune.platf.client.dto.StateToken;
+import org.ourproject.kune.platf.client.errors.NameInUseException;
+import org.ourproject.kune.platf.client.errors.NameNotPermittedException;
+import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
+import org.ourproject.kune.platf.client.services.I18nTranslationService;
+import org.ourproject.kune.platf.client.state.Session;
+import org.ourproject.kune.workspace.client.site.Site;
+
+import com.calclab.suco.client.ioc.Provider;
+import com.calclab.suco.client.listener.Event2;
+import com.calclab.suco.client.listener.Listener2;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+public class RenameAction {
+ private final I18nTranslationService i18n;
+ private final Provider<ContentServiceAsync> contentService;
+ private final Session session;
+ private final Event2<StateToken, String> onSuccess;
+ private final Event2<StateToken, String> onFail;
+
+ public RenameAction(I18nTranslationService i18n, Session session, Provider<ContentServiceAsync> contentService) {
+ this.i18n = i18n;
+ this.session = session;
+ this.contentService = contentService;
+ this.onSuccess = new Event2<StateToken, String>("onSuccess");
+ this.onFail = new Event2<StateToken, String>("onFail");
+ }
+
+ public void onFail(final Listener2<StateToken, String> slot) {
+ onFail.add(slot);
+ }
+
+ public void onSuccess(final Listener2<StateToken, String> slot) {
+ onSuccess.add(slot);
+ }
+
+ public void rename(final StateToken token, final String oldName, final String newName) {
+ if (!newName.equals(oldName)) {
+ Site.showProgress(i18n.t("Renaming"));
+ final AsyncCallback<String> asyncCallback = new AsyncCallback<String>() {
+ public void onFailure(final Throwable caught) {
+ Site.hideProgress();
+ try {
+ throw caught;
+ } catch (final NameInUseException e) {
+ Site.error(i18n.tWithNT("This name already exists",
+ "Used when a file or a folder with the same name already exists"));
+ } catch (final NameNotPermittedException e) {
+ Site.error(i18n.tWithNT("This name is not permitted",
+ "Used when a file or a folder has a not permitted name"));
+ } catch (final Throwable e) {
+ Site.error(i18n.t("Error renaming"));
+ }
+ onFail.fire(token, oldName);
+ }
+
+ public void onSuccess(final String finalNewName) {
+ Site.hideProgress();
+ onSuccess.fire(token, finalNewName);
+ }
+ };
+ if (token.isComplete()) {
+ contentService.get().renameContent(session.getUserHash(), token, newName, asyncCallback);
+ } else {
+ contentService.get().renameContainer(session.getUserHash(), token, newName, asyncCallback);
+ }
+ }
+ }
+}
Modified: trunk/src/test/java/org/ourproject/kune/platf/integration/selenium/SignInSeleniumTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/integration/selenium/SignInSeleniumTest.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/test/java/org/ourproject/kune/platf/integration/selenium/SignInSeleniumTest.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -51,7 +51,7 @@
click(RegisterPanel.WELCOME_OK_BUTTON);
clickOnPushButton(gid(SiteUserMenuPanel.LOGGED_USER_MENU));
click(linkId(PlatfMessages.YOUR_HOMEPAGE));
- waitForTextInside(gid(NoHomePagePanel.NO_HOME_PAGE_LABEL), PlatfMessages.USER_DON_T_HAVE_A_HOMEPAGE);
+ waitForTextInside(gid(NoHomePagePanel.NO_HOME_PAGE_LABEL), PlatfMessages.USER_DOESN_T_HAVE_A_HOMEPAGE);
}
@Test
Modified: trunk/src/test/java/org/ourproject/kune/platf/server/content/ContentManagerDefaultTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/server/content/ContentManagerDefaultTest.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/test/java/org/ourproject/kune/platf/server/content/ContentManagerDefaultTest.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -1,13 +1,12 @@
package org.ourproject.kune.platf.server.content;
-
public class ContentManagerDefaultTest {// extends PersistenceTest {
ContentManagerDefault manager;
// @Before
public void before() {
- manager = new ContentManagerDefault(null, null, null, null, null);
+ manager = new ContentManagerDefault(null, null, null, null, null, null, null);
}
}
Added: trunk/src/test/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManagerTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManagerTest.java 2008-12-06 19:36:56 UTC (rev 988)
+++ trunk/src/test/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManagerTest.java 2008-12-10 01:36:03 UTC (rev 989)
@@ -0,0 +1,181 @@
+package org.ourproject.kune.platf.server.manager.file;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.ourproject.kune.platf.client.dto.StateToken;
+import org.ourproject.kune.platf.client.ui.download.ImageSize;
+import org.ourproject.kune.platf.integration.IntegrationTestHelper;
+import org.ourproject.kune.platf.server.domain.BasicMimeType;
+import org.ourproject.kune.platf.server.domain.Content;
+import org.ourproject.kune.platf.server.properties.KuneProperties;
+
+import com.google.inject.Inject;
+
+public class FileDownloadManagerTest {
+
+ private static final String SOMETITLE = "Sometitle";
+
+ @Inject
+ FileDownloadManager fileDownloadManager;
+
+ @Inject
+ KuneProperties kuneProperties;
+
+ private HttpServletResponse resp;
+ private Content content;
+
+ private String uploadLocation;
+
+ private FileUtils fileUtils;
+
+ private StateToken stateToken;
+
+ private String filename;
+
+ @Before
+ public void create() throws IOException {
+ new IntegrationTestHelper(this);
+ content = Mockito.mock(Content.class);
+ resp = Mockito.mock(HttpServletResponse.class);
+ ServletOutputStream oStream = Mockito.mock(ServletOutputStream.class);
+
+ Mockito.stub(resp.getOutputStream()).toReturn(oStream);
+ uploadLocation = kuneProperties.get(KuneProperties.UPLOAD_LOCATION);
+
+ fileUtils = Mockito.mock(FileUtils.class);
+ Mockito.stub(fileUtils.exist(Mockito.anyString())).toReturn(true);
+ stateToken = new StateToken("test.test.1.1");
+ filename = "somefile";
+
+ Mockito.stub(content.getTitle()).toReturn(SOMETITLE);
+ }
+
+ @Test
+ public void fileWithNoExtensionDownloadTest() throws Exception {
+ throw new Exception("TODO");
+ }
+
+ @Test
+ public void testJpgThumbDownload() throws IOException {
+ String extension = ".jpg";
+ contentStub(new BasicMimeType("image", "jpg"), filename, extension);
+ String subExt = ImageSize.thumb.toString();
+ String absFile = fileDownloadManager.buildResponse(content, stateToken, "false", subExt, resp, fileUtils);
+ assertEquals(uploadLocation + FileUtils.toDir(stateToken) + filename + "." + subExt + extension, absFile);
+ Mockito.verify(resp).setContentType("image/jpg");
+ Mockito.verify(resp).setHeader(
+ FileDownloadManager.RESP_HEADER_CONTEND_DISP,
+ FileDownloadManager.RESP_HEADER_ATTACHMENT_FILENAME + SOMETITLE + extension
+ + FileDownloadManager.RESP_HEADER_END);
+ }
+
+ @Test
+ public void testPdfDownload1() throws IOException {
+ String extension = ".pdf";
+ contentStub(new BasicMimeType("application", "pdf"), filename, extension);
+ String absFile = fileDownloadManager.buildResponse(content, stateToken, "true", ImageSize.ico.toString(), resp,
+ fileUtils);
+ assertEquals(uploadLocation + FileUtils.toDir(stateToken) + filename + extension, absFile);
+ Mockito.verify(resp).setContentType(FileDownloadManager.APPLICATION_X_DOWNLOAD);
+ Mockito.verify(resp).setHeader(
+ FileDownloadManager.RESP_HEADER_CONTEND_DISP,
+ FileDownloadManager.RESP_HEADER_ATTACHMENT_FILENAME + SOMETITLE + extension
+ + FileDownloadManager.RESP_HEADER_END);
+ }
+
+ @Test
+ public void testPdfDownload2() throws IOException {
+ String pngExtension = ".png";
+ contentStub(new BasicMimeType("application", "pdf"), filename, ".pdf");
+ String subExt = ImageSize.ico.toString();
+ String absFile = fileDownloadManager.buildResponse(content, stateToken, "false", subExt, resp, fileUtils);
+ assertEquals(uploadLocation + FileUtils.toDir(stateToken) + filename + "." + subExt + pngExtension, absFile);
+ Mockito.verify(resp).setContentType("image/png");
+ Mockito.verify(resp).setHeader(
+ FileDownloadManager.RESP_HEADER_CONTEND_DISP,
+ FileDownloadManager.RESP_HEADER_ATTACHMENT_FILENAME + SOMETITLE + pngExtension
+ + FileDownloadManager.RESP_HEADER_END);
+ }
+
+ @Test
+ public void testPdfDownload3() throws IOException {
+ String pngExtension = ".png";
+ contentStub(new BasicMimeType("application", "pdf"), filename, ".pdf");
+ String subExt = ImageSize.sized.toString();
+ String absFile = fileDownloadManager.buildResponse(content, stateToken, "false", subExt, resp, fileUtils);
+ assertEquals(uploadLocation + FileUtils.toDir(stateToken) + filename + "." + subExt + pngExtension, absFile);
+ Mockito.verify(resp).setContentType("image/png");
+ Mockito.verify(resp).setHeader(
+ FileDownloadManager.RESP_HEADER_CONTEND_DISP,
+ FileDownloadManager.RESP_HEADER_ATTACHMENT_FILENAME + SOMETITLE + pngExtension
+ + FileDownloadManager.RESP_HEADER_END);
+ }
+
+ @Test
+ public void testPdfDownload4() throws IOException {
+ String pngExtension = ".png";
+ contentStub(new BasicMimeType("application", "pdf"), filename, ".pdf");
+ String subExt = ImageSize.thumb.toString();
+ String absFile = fileDownloadManager.buildResponse(content, stateToken, "false", subExt, resp, fileUtils);
+ assertEquals(uploadLocation + FileUtils.toDir(stateToken) + filename + "." + subExt + pngExtension, absFile);
+ Mockito.verify(resp).setContentType("image/png");
+ Mockito.verify(resp).setHeader(
+ FileDownloadManager.RESP_HEADER_CONTEND_DISP,
+ FileDownloadManager.RESP_HEADER_ATTACHMENT_FILENAME + SOMETITLE + pngExtension
+ + FileDownloadManager.RESP_HEADER_END);
+ }
+
+ @Test
+ public void testPdfDownloadNullMime() throws IOException {
+ String extension = ".pdf";
+ contentStub(null, filename, extension);
+ String absFile = fileDownloadManager.buildResponse(content, stateToken, "true", ImageSize.ico.toString(), resp,
+ fileUtils);
+ assertEquals(uploadLocation + FileUtils.toDir(stateToken) + filename + extension, absFile);
+ Mockito.verify(resp).setContentType(FileDownloadManager.APPLICATION_X_DOWNLOAD);
+ Mockito.verify(resp).setHeader(
+ FileDownloadManager.RESP_HEADER_CONTEND_DISP,
+ FileDownloadManager.RESP_HEADER_ATTACHMENT_FILENAME + SOMETITLE + extension
+ + FileDownloadManager.RESP_HEADER_END);
+ }
+
+ @Test
+ public void testPngDownload1() throws IOException {
+ String extension = ".png";
+ contentStub(new BasicMimeType("image", "png"), filename, extension);
+ String absFile = fileDownloadManager.buildResponse(content, stateToken, "true", null, resp, fileUtils);
+ assertEquals(uploadLocation + FileUtils.toDir(stateToken) + filename + extension, absFile);
+ Mockito.verify(resp).setContentType(FileDownloadManager.APPLICATION_X_DOWNLOAD);
+ Mockito.verify(resp).setHeader(
+ FileDownloadManager.RESP_HEADER_CONTEND_DISP,
+ FileDownloadManager.RESP_HEADER_ATTACHMENT_FILENAME + SOMETITLE + extension
+ + FileDownloadManager.RESP_HEADER_END);
+ }
+
+ @Test
+ public void testPngDownload2() throws IOException {
+ String extension = ".png";
+ contentStub(new BasicMimeType("image", "png"), filename, extension);
+ String subExt = ImageSize.thumb.toString();
+ String absFile = fileDownloadManager.buildResponse(content, stateToken, "false", subExt, resp, fileUtils);
+ assertEquals(uploadLocation + FileUtils.toDir(stateToken) + filename + "." + subExt + extension, absFile);
+ Mockito.verify(resp).setContentType("image/png");
+ Mockito.verify(resp).setHeader(
+ FileDownloadManager.RESP_HEADER_CONTEND_DISP,
+ FileDownloadManager.RESP_HEADER_ATTACHMENT_FILENAME + SOMETITLE + extension
+ + FileDownloadManager.RESP_HEADER_END);
+ }
+
+ private void contentStub(BasicMimeType mimeType, String filename, String extension) {
+ Mockito.stub(content.getMimeType()).toReturn(mimeType);
+ Mockito.stub(content.getFilename()).toReturn(filename + extension);
+ }
+}
More information about the kune-commits
mailing list