[kune-commits] r929 - in trunk: .
src/main/java/org/ourproject/kune/chat/server
src/main/java/org/ourproject/kune/docs/client
src/main/java/org/ourproject/kune/docs/server
src/main/java/org/ourproject/kune/platf/client/errors
src/main/java/org/ourproject/kune/platf/client/rpc
src/main/java/org/ourproject/kune/platf/client/services
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/rpc
src/main/java/org/ourproject/kune/platf/server/tool
src/main/java/org/ourproject/kune/workspace/client/ctxnav
src/main/java/org/ourproject/kune/workspace/client/title
src/test/java/org/ourproject/kune/docs
src/test/java/org/ourproject/kune/docs/server
src/test/java/org/ourproject/kune/platf/integration/content
src/test/java/org/ourproject/kune/platf/server
src/test/java/org/ourproject/kune/platf/server/content
src/test/java/org/ourproject/kune/platf/server/manager
vjrj
vjrj at ourproject.org
Sat Oct 25 16:13:45 CEST 2008
Author: vjrj
Date: 2008-10-25 16:13:41 +0200 (Sat, 25 Oct 2008)
New Revision: 929
Added:
trunk/src/main/java/org/ourproject/kune/platf/client/errors/ContentNotPermittedException.java
trunk/src/test/java/org/ourproject/kune/docs/server/
trunk/src/test/java/org/ourproject/kune/docs/server/DocumentServerToolTest.java
trunk/src/test/java/org/ourproject/kune/platf/server/content/
trunk/src/test/java/org/ourproject/kune/platf/server/content/ContentManagerDefaultTest.java
Modified:
trunk/INSTALL
trunk/pom.xml
trunk/src/main/java/org/ourproject/kune/chat/server/ChatServerTool.java
trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java
trunk/src/main/java/org/ourproject/kune/docs/server/DocumentServerTool.java
trunk/src/main/java/org/ourproject/kune/platf/client/rpc/ContentService.java
trunk/src/main/java/org/ourproject/kune/platf/client/rpc/ContentServiceAsync.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java
trunk/src/main/java/org/ourproject/kune/platf/server/content/ContainerManager.java
trunk/src/main/java/org/ourproject/kune/platf/server/content/ContainerManagerDefault.java
trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManager.java
trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManagerDefault.java
trunk/src/main/java/org/ourproject/kune/platf/server/content/CreationService.java
trunk/src/main/java/org/ourproject/kune/platf/server/content/CreationServiceDefault.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/FileUploadManager.java
trunk/src/main/java/org/ourproject/kune/platf/server/rpc/ContentRPC.java
trunk/src/main/java/org/ourproject/kune/platf/server/tool/ServerTool.java
trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigator.java
trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePresenter.java
trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceAddTest.java
trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceSaveTest.java
trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceVariousTest.java
trunk/src/test/java/org/ourproject/kune/platf/server/manager/ContentManagerTest.java
Log:
Complete - task Content save return nothing
Complete - task Container AccessLists (for public wikis) and more contents/actions (blog/posts)
gwt-1.5.3
(drop db recommended)
Modified: trunk/INSTALL
===================================================================
--- trunk/INSTALL 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/INSTALL 2008-10-25 14:13:41 UTC (rev 929)
@@ -4,7 +4,7 @@
For development:
- Install java-jdk (>= 1.5), maven2, mysql (>= 5.0) and for example eclipse
-- Install gwt 1.5.2 and follow Appendix A for maven+gwt configuration
+- Install gwt 1.5.3 and follow Appendix A for maven+gwt configuration
- Compile with maven:
# (in the trunk directory)
mvn compile
@@ -88,9 +88,9 @@
</properties>
</profile>
<profile>
- <id>gwt-1.5.2</id>
+ <id>gwt-1.5.3</id>
<properties>
- <google.webtoolkit.home>/usr/local/lib/gwt/gwt-linux-1.5.2</google.webtoolkit.home>
+ <google.webtoolkit.home>/usr/local/lib/gwt/gwt-linux-1.5.3</google.webtoolkit.home>
<!-- <google.webtoolkit.devjar>gwt-dev-linux</google.webtoolkit.devjar> -->
<!-- you only need this is you are on a mac -->
<google.webtoolkit.extrajvmargs>-Xmx256M</google.webtoolkit.extrajvmargs>
@@ -98,7 +98,7 @@
</profile>
</profiles>
<activeProfiles>
- <activeProfile>gwt-1.5.2</activeProfile>
+ <activeProfile>gwt-1.5.3</activeProfile>
</activeProfiles>
</settings>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/pom.xml 2008-10-25 14:13:41 UTC (rev 929)
@@ -34,13 +34,13 @@
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
- <version>1.5.2</version>
+ <version>1.5.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
- <version>1.5.2</version>
+ <version>1.5.3</version>
</dependency>
<!--
<dependency> <groupId>com.extjs</groupId>
Modified: trunk/src/main/java/org/ourproject/kune/chat/server/ChatServerTool.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/chat/server/ChatServerTool.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/chat/server/ChatServerTool.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -49,6 +49,17 @@
this.containerManager = containerManager;
}
+ public void checkTypesBeforeContainerCreation(String parentTypeId, String typeId) {
+ checkContainerTypeId(parentTypeId, typeId);
+ }
+
+ public void checkTypesBeforeContentCreation(String parentTypeId, String typeId) {
+ if (!parentTypeId.equals(TYPE_ROOM)) {
+ throw new ContainerNotPermittedException();
+ }
+ // in the future chat history checks
+ }
+
public String getName() {
return NAME;
}
@@ -57,6 +68,10 @@
return ROOT_NAME;
}
+ public ServerToolTarget getTarget() {
+ return ServerToolTarget.forGroups;
+ }
+
public Group initGroup(final User user, final Group group) {
final ToolConfiguration config = new ToolConfiguration();
final Container container = containerManager.createRootFolder(group, NAME, ROOT_NAME, TYPE_ROOT);
@@ -66,16 +81,11 @@
return group;
}
- public void onCreateContainer(final Container container, final Container parent, final String typeId) {
- checkTypeId(parent.getTypeId(), typeId);
- container.setTypeId(typeId);
+ public void onCreateContainer(final Container container, final Container parent) {
}
public void onCreateContent(final Content content, final Container parent) {
- if (parent.getTypeId().equals(TYPE_ROOM)) {
- throw new RuntimeException();
- }
- content.setTypeId(TYPE_CHAT);
+
}
@Inject
@@ -83,11 +93,7 @@
registry.register(this);
}
- public ServerToolTarget getTarget() {
- return ServerToolTarget.forGroups;
- }
-
- private void checkTypeId(final String parentTypeId, final String typeId) {
+ private void checkContainerTypeId(final String parentTypeId, final String typeId) {
if (typeId.equals(TYPE_ROOM)) {
if (!parentTypeId.equals(TYPE_ROOT)) {
throw new ContainerNotPermittedException();
Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -119,25 +119,15 @@
i18n.t("New gallery"));
final ActionToolbarMenuAndItemDescriptor<StateToken> addWiki = createFolderAction(TYPE_WIKI,
"images/nav/wiki_add.png", i18n.t("New wiki"), i18n.t("Folder"), i18n.t("New"), i18n.t("wiki"));
+ final ActionToolbarMenuAndItemDescriptor<StateToken> addBlog = createFolderAction(TYPE_BLOG,
+ "images/nav/blog_add.png", i18n.t("New blog"), i18n.t("Folder"), i18n.t("New"), i18n.t("New blog"));
- final ActionToolbarMenuAndItemDescriptor<StateToken> addDoc = new ActionToolbarMenuAndItemDescriptor<StateToken>(
- AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener<StateToken>() {
- public void onEvent(final StateToken token) {
- Site.showProgressProcessing();
- contentServiceProvider.get().addContent(session.getUserHash(),
- session.getCurrentState().getStateToken(), i18n.t("New document"),
- new AsyncCallbackSimple<StateContentDTO>() {
- public void onSuccess(final StateContentDTO state) {
- contextNavigator.setEditOnNextStateChange(true);
- stateManager.setRetrievedState(state);
- }
- });
- }
- });
- addDoc.setTextDescription(i18n.t("New document"));
- addDoc.setParentMenuTitle(i18n.t("Folder"));
- addDoc.setParentSubMenuTitle(i18n.t("New"));
- addDoc.setIconUrl("images/nav/page_add.png");
+ final ActionToolbarMenuAndItemDescriptor<StateToken> addDoc = createDocAction("images/nav/page_add.png",
+ i18n.t("New document"), TYPE_DOCUMENT);
+ final ActionToolbarMenuAndItemDescriptor<StateToken> addWikiPage = createDocAction(
+ "images/nav/wikipage_add.png", i18n.t("New wikipage"), TYPE_WIKIPAGE);
+ final ActionToolbarMenuAndItemDescriptor<StateToken> addPost = createDocAction("images/nav/post_add.png",
+ i18n.t("New post"), TYPE_POST);
final ActionToolbarMenuAndItemDescriptor<StateToken> delContainer = new ActionToolbarMenuAndItemDescriptor<StateToken>(
AccessRolDTO.Administrator, ActionToolbarPosition.topbar, new Listener<StateToken>() {
@@ -347,7 +337,7 @@
public void onEvent(final String html) {
Site.showProgressSaving();
contentServiceProvider.get().save(session.getUserHash(), stateToken, html,
- new AsyncCallback<Integer>() {
+ new AsyncCallback<Object>() {
public void onFailure(final Throwable caught) {
Site.hideProgress();
try {
@@ -361,9 +351,8 @@
}
}
- public void onSuccess(final Integer newVersion) {
+ public void onSuccess(Object param) {
Site.hideProgress();
- session.getContentState().setVersion(newVersion);
session.getContentState().setContent(html);
editor.onSaved();
}
@@ -398,9 +387,12 @@
contentActionRegistry.addAction(setSubmittedForPublishStatus, contentsModerated);
contentActionRegistry.addAction(setInTheDustBinStatus, contentsModerated);
contextActionRegistry.addAction(addDoc, TYPE_ROOT, TYPE_FOLDER);
+ contextActionRegistry.addAction(addPost, TYPE_BLOG);
+ contextActionRegistry.addAction(addWikiPage, TYPE_WIKI);
contextActionRegistry.addAction(addFolder, TYPE_ROOT, TYPE_FOLDER);
+ contextActionRegistry.addAction(addBlog, TYPE_ROOT);
+ contextActionRegistry.addAction(addWiki, TYPE_ROOT);
contextActionRegistry.addAction(addGallery, TYPE_ROOT);
- contextActionRegistry.addAction(addWiki, TYPE_ROOT);
contextActionRegistry.addAction(go, all);
contentActionRegistry.addAction(renameCtn, contents);
contextActionRegistry.addAction(renameCtx, containersNoRoot);
@@ -420,6 +412,29 @@
TYPE_WIKI, TYPE_WIKIPAGE);
}
+ private ActionToolbarMenuAndItemDescriptor<StateToken> createDocAction(String iconUrl, final String description,
+ final String typeId) {
+ final ActionToolbarMenuAndItemDescriptor<StateToken> addDoc = new ActionToolbarMenuAndItemDescriptor<StateToken>(
+ AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener<StateToken>() {
+ public void onEvent(final StateToken token) {
+ Site.showProgressProcessing();
+ contentServiceProvider.get().addContent(session.getUserHash(),
+ session.getCurrentState().getStateToken(), description, typeId,
+ new AsyncCallbackSimple<StateContentDTO>() {
+ public void onSuccess(final StateContentDTO state) {
+ contextNavigator.setEditOnNextStateChange(true);
+ stateManager.setRetrievedState(state);
+ }
+ });
+ }
+ });
+ addDoc.setTextDescription(description);
+ addDoc.setParentMenuTitle(i18n.t("Folder"));
+ addDoc.setParentSubMenuTitle(i18n.t("New"));
+ addDoc.setIconUrl(iconUrl);
+ return addDoc;
+ }
+
private ActionToolbarMenuAndItemDescriptor<StateToken> createFolderAction(final String contentTypeId,
final String iconUrl, final String textDescription, final String parentMenuTitle,
final String parentMenuSubtitle, final String defaultName) {
@@ -479,6 +494,7 @@
final AsyncCallbackSimple<Object> callback = new AsyncCallbackSimple<Object>() {
public void onSuccess(final Object result) {
session.getContentState().setStatus(status);
+ contextNavigator.setItemStatus(stateToken, status);
}
};
if (status.equals(ContentStatusDTO.publishedOnline) || status.equals(ContentStatusDTO.rejected)) {
Modified: trunk/src/main/java/org/ourproject/kune/docs/server/DocumentServerTool.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/server/DocumentServerTool.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/docs/server/DocumentServerTool.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -20,13 +20,16 @@
package org.ourproject.kune.docs.server;
import org.ourproject.kune.platf.client.errors.ContainerNotPermittedException;
+import org.ourproject.kune.platf.client.errors.ContentNotPermittedException;
import org.ourproject.kune.platf.client.services.I18nTranslationService;
import org.ourproject.kune.platf.server.content.ContainerManager;
import org.ourproject.kune.platf.server.content.ContentManager;
+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.ContentStatus;
import org.ourproject.kune.platf.server.domain.Group;
+import org.ourproject.kune.platf.server.domain.GroupListMode;
import org.ourproject.kune.platf.server.domain.ToolConfiguration;
import org.ourproject.kune.platf.server.domain.User;
import org.ourproject.kune.platf.server.manager.ToolConfigurationManager;
@@ -64,6 +67,14 @@
this.i18n = translationService;
}
+ public void checkTypesBeforeContainerCreation(String parentTypeId, String typeId) {
+ checkContainerTypeId(parentTypeId, typeId);
+ }
+
+ public void checkTypesBeforeContentCreation(String parentTypeId, String typeId) {
+ checkContentTypeId(parentTypeId, typeId);
+ }
+
public String getName() {
return NAME;
}
@@ -83,7 +94,8 @@
group.setToolConfig(NAME, config);
configurationManager.persist(config);
final String longName = group.getLongName();
- final Content descriptor = contentManager.createContent(i18n.t("About [%s]", longName), "", user, container);
+ final Content descriptor = contentManager.createContent(i18n.t("About [%s]", longName), "", user, container,
+ DocumentServerTool.TYPE_DOCUMENT);
descriptor.addAuthor(user);
descriptor.setLanguage(user.getLanguage());
descriptor.setTypeId(TYPE_DOCUMENT);
@@ -92,13 +104,20 @@
return group;
}
- public void onCreateContainer(final Container container, final Container parent, final String typeId) {
- checkTypeId(parent.getTypeId(), typeId);
+ public void onCreateContainer(final Container container, final Container parent) {
+ String typeId = container.getTypeId();
container.setTypeId(typeId);
+ if (typeId.equals(TYPE_WIKI)) {
+ AccessLists wikiAcl = new AccessLists();
+ wikiAcl.getAdmins().setMode(GroupListMode.NORMAL);
+ wikiAcl.getAdmins().add(container.getOwner());
+ wikiAcl.getEditors().setMode(GroupListMode.EVERYONE);
+ wikiAcl.getViewers().setMode(GroupListMode.EVERYONE);
+ container.setAccessLists(wikiAcl);
+ }
}
public void onCreateContent(final Content content, final Container parent) {
- content.setTypeId(TYPE_DOCUMENT);
}
@Inject
@@ -106,17 +125,39 @@
registry.register(this);
}
- private void checkTypeId(final String parentTypeId, final String typeId) {
- if (typeId.equals(TYPE_FOLDER) || typeId.equals(TYPE_GALLERY) || typeId.equals(TYPE_WIKI)) {
+ void checkContainerTypeId(final String parentTypeId, final String typeId) {
+ if (typeId.equals(TYPE_FOLDER) || typeId.equals(TYPE_GALLERY) || typeId.equals(TYPE_WIKI)
+ || typeId.equals(TYPE_BLOG)) {
// ok valid container
- if (typeId.equals(TYPE_GALLERY) && !parentTypeId.equals(TYPE_ROOT)) {
+ if ((typeId.equals(TYPE_FOLDER) && (parentTypeId.equals(TYPE_ROOT) || parentTypeId.equals(TYPE_FOLDER)))
+ || (typeId.equals(TYPE_GALLERY) && (parentTypeId.equals(TYPE_ROOT)))
+ || (typeId.equals(TYPE_WIKI) && parentTypeId.equals(TYPE_ROOT))
+ || (typeId.equals(TYPE_BLOG) && parentTypeId.equals(TYPE_ROOT))) {
+ // ok
+ } else {
throw new ContainerNotPermittedException();
}
- if (typeId.equals(TYPE_WIKI) && !parentTypeId.equals(TYPE_ROOT)) {
- throw new ContainerNotPermittedException();
- }
} else {
throw new ContainerNotPermittedException();
}
}
+
+ void checkContentTypeId(final String parentTypeId, final String typeId) {
+ if (typeId.equals(TYPE_DOCUMENT) || typeId.equals(TYPE_WIKIPAGE) || typeId.equals(TYPE_UPLOADEDFILE)
+ || typeId.equals(TYPE_POST)) {
+ // ok valid container
+ if ((typeId.equals(TYPE_DOCUMENT) && (parentTypeId.equals(TYPE_ROOT) || parentTypeId.equals(TYPE_FOLDER)))
+ || (typeId.equals(TYPE_UPLOADEDFILE) && (parentTypeId.equals(TYPE_ROOT)
+ || parentTypeId.equals(TYPE_FOLDER) || parentTypeId.equals(TYPE_GALLERY)))
+ || (typeId.equals(TYPE_WIKIPAGE) && parentTypeId.equals(TYPE_WIKI))
+ || (typeId.equals(TYPE_POST) && parentTypeId.equals(TYPE_BLOG))) {
+ // ok
+ } else {
+ throw new ContentNotPermittedException();
+ }
+
+ } else {
+ throw new ContentNotPermittedException();
+ }
+ }
}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/errors/ContentNotPermittedException.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/errors/ContentNotPermittedException.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/errors/ContentNotPermittedException.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -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 ContentNotPermittedException extends DefaultException {
+ private static final long serialVersionUID = 1L;
+}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/rpc/ContentService.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/rpc/ContentService.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/rpc/ContentService.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -44,7 +44,7 @@
CommentDTO addComment(String userHash, StateToken token, String commentText) throws DefaultException;
- StateContentDTO addContent(String user, StateToken parentToken, String name) throws DefaultException;
+ StateContentDTO addContent(String user, StateToken parentToken, String name, String typeId) throws DefaultException;
StateContainerDTO addFolder(String hash, StateToken parentToken, String typeId, String title)
throws DefaultException;
@@ -67,7 +67,7 @@
String renameContent(String userHash, StateToken token, String newName) throws DefaultException;
- Integer save(String user, StateToken token, String content) throws DefaultException;
+ void save(String user, StateToken token, String content) throws DefaultException;
ContentSimpleDTO setAsDefaultContent(String userHash, StateToken token);
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/rpc/ContentServiceAsync.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/rpc/ContentServiceAsync.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/rpc/ContentServiceAsync.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -43,7 +43,8 @@
void addComment(String userHash, StateToken token, String commentText, AsyncCallback<CommentDTO> asyncCallback);
- void addContent(String user, StateToken parentToken, String name, AsyncCallback<StateContentDTO> callback);
+ void addContent(String user, StateToken parentToken, String name, String typeId,
+ AsyncCallback<StateContentDTO> callback);
void addFolder(String hash, StateToken parentToken, String title, String typeId,
AsyncCallback<StateContainerDTO> callback);
@@ -66,7 +67,7 @@
void renameContent(String userHash, StateToken token, String newName, AsyncCallback<String> asyncCallback);
- void save(String user, StateToken token, String content, AsyncCallback<Integer> asyncCallback);
+ void save(String user, StateToken token, String content, AsyncCallback<?> asyncCallback);
void setAsDefaultContent(String userHash, StateToken token, AsyncCallback<ContentSimpleDTO> asyncCallback);
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -24,6 +24,7 @@
import org.ourproject.kune.platf.client.errors.AlreadyUserMemberException;
import org.ourproject.kune.platf.client.errors.ContainerNotPermittedException;
import org.ourproject.kune.platf.client.errors.ContentNotFoundException;
+import org.ourproject.kune.platf.client.errors.ContentNotPermittedException;
import org.ourproject.kune.platf.client.errors.GroupNotFoundException;
import org.ourproject.kune.platf.client.errors.LastAdminInGroupException;
import org.ourproject.kune.platf.client.errors.SessionExpiredException;
@@ -97,6 +98,10 @@
logException(e);
Site.error(i18n.t("Content not found"));
stateManagerProvider.get().gotoToken("");
+ } catch (final ContentNotPermittedException e) {
+ logException(e);
+ Site.error(i18n.t("Action not permitted in this location"));
+ stateManagerProvider.get().gotoToken("");
} catch (final ContainerNotPermittedException e) {
logException(e);
Site.error(i18n.t("Action not permitted in this location"));
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/content/ContainerManager.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/content/ContainerManager.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/content/ContainerManager.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -27,7 +27,7 @@
public interface ContainerManager {
- Container createFolder(Group group, Container parent, String name, I18nLanguage language);
+ Container createFolder(Group group, Container parent, String name, I18nLanguage language, String typeId);
Container createRootFolder(Group group, String toolName, String name, String type);
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-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/content/ContainerManagerDefault.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -20,7 +20,6 @@
package org.ourproject.kune.platf.server.content;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import javax.persistence.EntityManager;
@@ -49,20 +48,19 @@
}
public Container createFolder(final Group group, final Container parent, final String name,
- final I18nLanguage language) {
+ final I18nLanguage language, String typeId) {
final List<Container> parentAbsolutePath = parent.getAbsolutePath();
final List<Container> childAbsolutePath = new ArrayList<Container>();
- for (final Iterator<Container> iterator = parentAbsolutePath.iterator(); iterator.hasNext();) {
- final Container parentRef = iterator.next();
+ for (Container parentRef : parentAbsolutePath) {
childAbsolutePath.add(parentRef);
}
final Container child = new Container(name, group, parent.getToolName());
childAbsolutePath.add(child);
child.setLanguage(language);
child.setAbsolutePath(childAbsolutePath);
+ child.setTypeId(typeId);
parent.addChild(child);
- // child.setParent(parent);
persist(child);
return child;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManager.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManager.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManager.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -34,7 +34,7 @@
void addAuthor(User user, Long contentId, String authorShortName) throws DefaultException;
- Content createContent(String title, String body, User author, Container container);
+ Content createContent(String title, String body, User author, Container container, String typeId);
void delContent(User user, Long contentId) throws DefaultException;
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-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManagerDefault.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -19,6 +19,8 @@
*/
package org.ourproject.kune.platf.server.content;
+import static org.ourproject.kune.docs.server.DocumentServerTool.TYPE_WIKIPAGE;
+
import java.util.ArrayList;
import java.util.Date;
@@ -77,12 +79,16 @@
content.addAuthor(author);
}
- public Content createContent(final String title, final String body, final User author, final Container container) {
+ public Content createContent(final String title, final String body, final User author, final Container container,
+ String typeId) {
final Content newContent = new Content();
newContent.addAuthor(author);
newContent.setLanguage(author.getLanguage());
- // FIXME: remove this when UI take publishing into account
- newContent.setPublishedOn(new Date());
+ newContent.setTypeId(typeId);
+ if (typeId.equals(TYPE_WIKIPAGE)) {
+ newContent.setStatus(ContentStatus.publishedOnline);
+ newContent.setPublishedOn(new Date());
+ }
container.addContent(newContent);
newContent.setContainer(container);
final Revision revision = new Revision(newContent);
@@ -188,6 +194,13 @@
public void setStatus(final Long contentId, final ContentStatus status) {
final Content content = finder.getContent(contentId);
content.setStatus(status);
+ switch (status) {
+ case publishedOnline:
+ content.setPublishedOn(new Date());
+ break;
+ default:
+ break;
+ }
}
public void setTags(final User user, final Long contentId, final String tags) throws DefaultException {
@@ -208,5 +221,4 @@
}
content.setTags(tagList);
}
-
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/content/CreationService.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/content/CreationService.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/content/CreationService.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -27,7 +27,7 @@
public interface CreationService {
- Content createContent(String title, String body, User user, Container container);
+ Content createContent(String title, String body, User user, Container container, String typeId);
Container createFolder(Group group, Long parentFolderId, String name, I18nLanguage language, String contentTypeId);
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/content/CreationServiceDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/content/CreationServiceDefault.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/content/CreationServiceDefault.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -43,9 +43,11 @@
this.tools = toolRegistry;
}
- public Content createContent(final String title, final String body, final User user, final Container container) {
+ public Content createContent(final String title, final String body, final User user, final Container container,
+ final String typeId) {
final String toolName = container.getToolName();
- final Content content = contentManager.createContent(title, body, user, container);
+ tools.get(toolName).checkTypesBeforeContentCreation(container.getTypeId(), typeId);
+ final Content content = contentManager.createContent(title, body, user, container, typeId);
tools.get(toolName).onCreateContent(content, container);
return content;
}
@@ -54,8 +56,9 @@
final I18nLanguage language, final String typeId) {
final Container parent = containerManager.find(parentFolderId);
final String toolName = parent.getToolName();
- final Container child = containerManager.createFolder(group, parent, name, language);
- tools.get(toolName).onCreateContainer(child, parent, typeId);
+ tools.get(toolName).checkTypesBeforeContainerCreation(parent.getTypeId(), typeId);
+ final Container child = containerManager.createFolder(group, parent, name, language, typeId);
+ tools.get(toolName).onCreateContainer(child, parent);
return child;
}
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-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/domain/Container.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -89,6 +89,9 @@
@OneToMany(cascade = CascadeType.ALL)
private List<ContainerTranslation> containerTranslations;
+ @OneToOne(cascade = CascadeType.ALL)
+ private AccessLists accessLists;
+
public Container() {
this(null, null, null);
}
@@ -120,8 +123,7 @@
@Transient
public AccessLists getAccessLists() {
- // TODO like in Content, do store specific accesslist
- return getOwner().getAccessLists();
+ return hasAccessList() ? accessLists : isLeaf() ? getParent().getAccessLists() : getOwner().getAccessLists();
}
public List<ContainerTranslation> getAliases() {
@@ -183,6 +185,11 @@
}
@Transient
+ public boolean hasAccessList() {
+ return accessLists != null;
+ }
+
+ @Transient
public boolean isLeaf() {
return childs.size() == 0 && contents.size() == 0;
}
@@ -196,6 +203,10 @@
this.absolutePath = absolutePath;
}
+ public void setAccessLists(AccessLists accessLists) {
+ this.accessLists = accessLists;
+ }
+
public void setAliases(final List<ContainerTranslation> containerTranslations) {
this.containerTranslations = containerTranslations;
}
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-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/domain/Content.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -87,7 +87,7 @@
@Basic(optional = true)
private Date deletedOn;
- @Basic(optional = false)
+ @Basic(optional = true)
private Date publishedOn;
private String typeId;
@@ -264,6 +264,7 @@
return version;
}
+ @Transient
public boolean hasAccessList() {
return accessLists != null;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileUploadManager.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileUploadManager.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileUploadManager.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -127,8 +127,7 @@
user, AccessRol.Editor);
final String preview = "Preview of this file (in development)";
final Content content = contentManager.createContent(FileUtils.getFileNameWithoutExtension(file.getName(),
- extension), preview, user, container);
- content.setTypeId(DocumentServerTool.TYPE_UPLOADEDFILE);
+ extension), preview, user, container, DocumentServerTool.TYPE_UPLOADEDFILE);
content.setMimeType(basicMimeType);
content.setFilename(file.getName());
return content;
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/rpc/ContentRPC.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/rpc/ContentRPC.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/rpc/ContentRPC.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -154,14 +154,14 @@
@Authenticated
@Authorizated(actionLevel = ActionLevel.container, accessRolRequired = AccessRol.Editor)
@Transactional(type = TransactionType.READ_WRITE)
- public StateContentDTO addContent(final String userHash, final StateToken parentToken, final String title)
- throws DefaultException {
+ public StateContentDTO addContent(final String userHash, final StateToken parentToken, final String title,
+ final String typeId) throws DefaultException {
final Group group = groupManager.findByShortName(parentToken.getGroup());
final UserSession userSession = getUserSession();
final User user = userSession.getUser();
final Container container = accessService.accessToContainer(ContentUtils.parseId(parentToken.getFolder()),
user, AccessRol.Editor);
- final Content addedContent = creationService.createContent(title, "", user, container);
+ final Content addedContent = creationService.createContent(title, "", user, container, typeId);
final StateContent state = stateService.create(user, addedContent);
return mapStateSiblings(state, user, group);
}
@@ -321,15 +321,13 @@
@Authenticated
@Authorizated(accessRolRequired = AccessRol.Editor)
@Transactional(type = TransactionType.READ_WRITE)
- public Integer save(final String userHash, final StateToken token, final String textContent)
- throws DefaultException {
+ public void save(final String userHash, final StateToken token, final String textContent) throws DefaultException {
final Long contentId = ContentUtils.parseId(token.getDocument());
final UserSession userSession = getUserSession();
final User user = userSession.getUser();
final Content content = accessService.accessToContent(contentId, user, AccessRol.Editor);
- final Content saved = creationService.saveContent(user, content, textContent);
- return saved.getVersion();
+ creationService.saveContent(user, content, textContent);
}
@Authenticated
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/tool/ServerTool.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/tool/ServerTool.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/tool/ServerTool.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -32,17 +32,21 @@
*/
public interface ServerTool {
+ void checkTypesBeforeContainerCreation(String parentTypeId, String typeId);
+
+ void checkTypesBeforeContentCreation(String parentTypeId, String typeId);
+
String getName();
String getRootName();
+ ServerToolTarget getTarget();
+
Group initGroup(User user, Group group);
- void onCreateContainer(Container container, Container parent, String typeId);
+ void onCreateContainer(Container container, Container parent);
void onCreateContent(Content content, Container parent);
void register(ServerToolRegistry registry);
-
- ServerToolTarget getTarget();
}
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-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigator.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -20,6 +20,7 @@
package org.ourproject.kune.workspace.client.ctxnav;
import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.dto.ContentStatusDTO;
import org.ourproject.kune.platf.client.dto.StateContainerDTO;
import org.ourproject.kune.platf.client.dto.StateToken;
@@ -39,6 +40,8 @@
void setEditOnNextStateChange(boolean edit);
+ 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/ContextNavigatorPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -22,6 +22,7 @@
import org.ourproject.kune.platf.client.actions.ActionItem;
import org.ourproject.kune.platf.client.actions.ActionManager;
import org.ourproject.kune.platf.client.actions.MenuItemsContainer;
+import org.ourproject.kune.platf.client.dto.ContentStatusDTO;
import org.ourproject.kune.platf.client.dto.StateToken;
import org.ourproject.kune.platf.client.services.I18nTranslationService;
import org.ourproject.kune.workspace.client.site.Site;
@@ -72,7 +73,8 @@
public void addItem(final ContextNavigatorItem item) {
final String nodeId = item.getId();
- if (treePanel.getNodeById(nodeId) == null) {
+ TreeNode node = treePanel.getNodeById(nodeId);
+ if (node == null) {
final TreeNode child = new TreeNode(item.getText());
child.setId(nodeId);
final String icon = item.getIconUrl();
@@ -124,26 +126,14 @@
}
});
parent.appendChild(child);
- switch (item.getContentStatus()) {
- case publishedOnline:
- child.setCls("k-textnormal");
- break;
- case inTheDustbin:
- case rejected:
- child.setCls("k-textlinethrough");
- break;
- case editingInProgress:
- case submittedForEvaluation:
- child.setCls("k-textunderline");
- break;
- }
+ ContentStatusDTO status = item.getContentStatus();
+ setNodeStatus(child, status);
} else {
Log.error("Error building file tree, parent folder not found");
}
} else {
// the node already created
}
-
}
public void clear() {
@@ -191,6 +181,10 @@
this.fireOnTextChange = fireOnTextChange;
}
+ public void setItemStatus(final String id, ContentStatusDTO status) {
+ setNodeStatus(getNode(id), status);
+ }
+
public void setItemText(final String genId, final String text) {
final TreeNode node = getNode(genId);
node.setText(text);
@@ -296,4 +290,20 @@
return node.getAttribute("href").substring(1);
}
+ private void setNodeStatus(final TreeNode node, ContentStatusDTO status) {
+ switch (status) {
+ case publishedOnline:
+ node.setCls("k-textnormal");
+ break;
+ case inTheDustbin:
+ case rejected:
+ node.setCls("k-textlinethrough");
+ break;
+ case editingInProgress:
+ case submittedForEvaluation:
+ node.setCls("k-textunderline");
+ break;
+ }
+ }
+
}
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-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -184,6 +184,10 @@
editOnNextStateChange = edit;
}
+ 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);
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorView.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorView.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -20,6 +20,7 @@
package org.ourproject.kune.workspace.client.ctxnav;
import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.dto.ContentStatusDTO;
import org.ourproject.kune.platf.client.dto.StateToken;
public interface ContextNavigatorView extends View {
@@ -38,6 +39,8 @@
void setFireOnTextChange(boolean fire);
+ void setItemStatus(String id, ContentStatusDTO status);
+
void setItemText(String id, String text);
void setRootItem(String id, String text, StateToken stateToken);
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-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePresenter.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -154,8 +154,13 @@
private void setState(final StateContentDTO state) {
setContentTitle(state.getTitle(), state.getContentRights().isEditable());
- setContentDateVisible(true);
- setContentDate(state.getPublishedOn());
+ Date publishedOn = state.getPublishedOn();
+ if (publishedOn != null) {
+ setContentDateVisible(true);
+ setContentDate(publishedOn);
+ } else {
+ setContentDateVisible(false);
+ }
final String contentTypeIcon = iconsRegistry.getContentTypeIcon(state.getTypeId(), state.getMimeType());
setIcon(contentTypeIcon);
view.setContentTitleVisible(true);
Added: trunk/src/test/java/org/ourproject/kune/docs/server/DocumentServerToolTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/docs/server/DocumentServerToolTest.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/test/java/org/ourproject/kune/docs/server/DocumentServerToolTest.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -0,0 +1,189 @@
+package org.ourproject.kune.docs.server;
+
+import static org.ourproject.kune.docs.server.DocumentServerTool.TYPE_BLOG;
+import static org.ourproject.kune.docs.server.DocumentServerTool.TYPE_DOCUMENT;
+import static org.ourproject.kune.docs.server.DocumentServerTool.TYPE_FOLDER;
+import static org.ourproject.kune.docs.server.DocumentServerTool.TYPE_GALLERY;
+import static org.ourproject.kune.docs.server.DocumentServerTool.TYPE_POST;
+import static org.ourproject.kune.docs.server.DocumentServerTool.TYPE_ROOT;
+import static org.ourproject.kune.docs.server.DocumentServerTool.TYPE_UPLOADEDFILE;
+import static org.ourproject.kune.docs.server.DocumentServerTool.TYPE_WIKI;
+import static org.ourproject.kune.docs.server.DocumentServerTool.TYPE_WIKIPAGE;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.ourproject.kune.platf.client.errors.ContainerNotPermittedException;
+import org.ourproject.kune.platf.client.errors.ContentNotPermittedException;
+
+public class DocumentServerToolTest { // extends PersistenceTest {
+
+ private DocumentServerTool dcServerTool;
+
+ @Before
+ public void before() {
+ dcServerTool = new DocumentServerTool(null, null, null, null);
+ }
+
+ @Test
+ public void testCreateContainerInCorrectContainer() {
+ dcServerTool.checkContainerTypeId(TYPE_ROOT, TYPE_FOLDER);
+ dcServerTool.checkContainerTypeId(TYPE_FOLDER, TYPE_FOLDER);
+ dcServerTool.checkContainerTypeId(TYPE_ROOT, TYPE_WIKI);
+ dcServerTool.checkContainerTypeId(TYPE_ROOT, TYPE_BLOG);
+ dcServerTool.checkContainerTypeId(TYPE_ROOT, TYPE_GALLERY);
+ }
+
+ @Test(expected = ContainerNotPermittedException.class)
+ public void testCreateContainerInIncorrectContainer1() {
+ dcServerTool.checkContainerTypeId(TYPE_FOLDER, TYPE_WIKI);
+ }
+
+ @Test(expected = ContainerNotPermittedException.class)
+ public void testCreateContainerInIncorrectContainer10() {
+ // At the moment, not permitted (create a gallery_folder)
+ dcServerTool.checkContainerTypeId(TYPE_GALLERY, TYPE_FOLDER);
+ }
+
+ @Test(expected = ContainerNotPermittedException.class)
+ public void testCreateContainerInIncorrectContainer11() {
+ // At the moment, not permitted (create a wiki_folder)
+ dcServerTool.checkContainerTypeId(TYPE_WIKI, TYPE_FOLDER);
+ }
+
+ @Test(expected = ContainerNotPermittedException.class)
+ public void testCreateContainerInIncorrectContainer12() {
+ dcServerTool.checkContainerTypeId(TYPE_BLOG, TYPE_FOLDER);
+ }
+
+ @Test(expected = ContainerNotPermittedException.class)
+ public void testCreateContainerInIncorrectContainer13() {
+ dcServerTool.checkContainerTypeId(TYPE_GALLERY, TYPE_WIKI);
+ }
+
+ @Test(expected = ContainerNotPermittedException.class)
+ public void testCreateContainerInIncorrectContainer14() {
+ dcServerTool.checkContainerTypeId(TYPE_WIKI, TYPE_WIKI);
+ }
+
+ @Test(expected = ContainerNotPermittedException.class)
+ public void testCreateContainerInIncorrectContainer15() {
+ dcServerTool.checkContainerTypeId(TYPE_GALLERY, TYPE_GALLERY);
+ }
+
+ @Test(expected = ContainerNotPermittedException.class)
+ public void testCreateContainerInIncorrectContainer2() {
+ dcServerTool.checkContainerTypeId(TYPE_BLOG, TYPE_WIKI);
+ }
+
+ @Test(expected = ContainerNotPermittedException.class)
+ public void testCreateContainerInIncorrectContainer3() {
+ dcServerTool.checkContainerTypeId(TYPE_FOLDER, TYPE_WIKI);
+ }
+
+ @Test(expected = ContainerNotPermittedException.class)
+ public void testCreateContainerInIncorrectContainer4() {
+ dcServerTool.checkContainerTypeId(TYPE_BLOG, TYPE_GALLERY);
+ }
+
+ @Test(expected = ContainerNotPermittedException.class)
+ public void testCreateContainerInIncorrectContainer5() {
+ dcServerTool.checkContainerTypeId(TYPE_FOLDER, TYPE_GALLERY);
+ }
+
+ @Test(expected = ContainerNotPermittedException.class)
+ public void testCreateContainerInIncorrectContainer6() {
+ dcServerTool.checkContainerTypeId(TYPE_WIKI, TYPE_GALLERY);
+ }
+
+ @Test(expected = ContainerNotPermittedException.class)
+ public void testCreateContainerInIncorrectContainer7() {
+ dcServerTool.checkContainerTypeId(TYPE_BLOG, TYPE_BLOG);
+ }
+
+ @Test(expected = ContainerNotPermittedException.class)
+ public void testCreateContainerInIncorrectContainer8() {
+ dcServerTool.checkContainerTypeId(TYPE_FOLDER, TYPE_BLOG);
+ }
+
+ @Test(expected = ContainerNotPermittedException.class)
+ public void testCreateContainerInIncorrectContainer9() {
+ dcServerTool.checkContainerTypeId(TYPE_GALLERY, TYPE_BLOG);
+ }
+
+ @Test
+ public void testCreateContentInCorrectContainer() {
+ dcServerTool.checkContentTypeId(TYPE_BLOG, TYPE_POST);
+ dcServerTool.checkContentTypeId(TYPE_WIKI, TYPE_WIKIPAGE);
+ dcServerTool.checkContentTypeId(TYPE_ROOT, TYPE_DOCUMENT);
+ dcServerTool.checkContentTypeId(TYPE_FOLDER, TYPE_DOCUMENT);
+ dcServerTool.checkContentTypeId(TYPE_ROOT, TYPE_UPLOADEDFILE);
+ dcServerTool.checkContentTypeId(TYPE_FOLDER, TYPE_UPLOADEDFILE);
+ dcServerTool.checkContentTypeId(TYPE_GALLERY, TYPE_UPLOADEDFILE);
+ }
+
+ @Test(expected = ContentNotPermittedException.class)
+ public void testCreateContentInIncorrectContainer1() {
+ dcServerTool.checkContentTypeId(TYPE_ROOT, TYPE_POST);
+ }
+
+ @Test(expected = ContentNotPermittedException.class)
+ public void testCreateContentInIncorrectContainer10() {
+ dcServerTool.checkContentTypeId(TYPE_ROOT, TYPE_WIKIPAGE);
+ }
+
+ @Test(expected = ContentNotPermittedException.class)
+ public void testCreateContentInIncorrectContainer11() {
+ dcServerTool.checkContentTypeId(TYPE_FOLDER, TYPE_WIKIPAGE);
+ }
+
+ @Test(expected = ContentNotPermittedException.class)
+ public void testCreateContentInIncorrectContainer12() {
+ dcServerTool.checkContentTypeId(TYPE_GALLERY, TYPE_WIKIPAGE);
+ }
+
+ @Test(expected = ContentNotPermittedException.class)
+ public void testCreateContentInIncorrectContainer13() {
+ dcServerTool.checkContentTypeId(TYPE_BLOG, TYPE_WIKIPAGE);
+ }
+
+ @Test(expected = ContentNotPermittedException.class)
+ public void testCreateContentInIncorrectContainer2() {
+ dcServerTool.checkContentTypeId(TYPE_FOLDER, TYPE_POST);
+ }
+
+ @Test(expected = ContentNotPermittedException.class)
+ public void testCreateContentInIncorrectContainer3() {
+ dcServerTool.checkContentTypeId(TYPE_GALLERY, TYPE_POST);
+ }
+
+ @Test(expected = ContentNotPermittedException.class)
+ public void testCreateContentInIncorrectContainer4() {
+ dcServerTool.checkContentTypeId(TYPE_WIKI, TYPE_POST);
+ }
+
+ @Test(expected = ContentNotPermittedException.class)
+ public void testCreateContentInIncorrectContainer5() {
+ dcServerTool.checkContentTypeId(TYPE_GALLERY, TYPE_DOCUMENT);
+ }
+
+ @Test(expected = ContentNotPermittedException.class)
+ public void testCreateContentInIncorrectContainer6() {
+ dcServerTool.checkContentTypeId(TYPE_WIKI, TYPE_DOCUMENT);
+ }
+
+ @Test(expected = ContentNotPermittedException.class)
+ public void testCreateContentInIncorrectContainer7() {
+ dcServerTool.checkContentTypeId(TYPE_BLOG, TYPE_DOCUMENT);
+ }
+
+ @Test(expected = ContentNotPermittedException.class)
+ public void testCreateContentInIncorrectContainer8() {
+ dcServerTool.checkContentTypeId(TYPE_BLOG, TYPE_UPLOADEDFILE);
+ }
+
+ @Test(expected = ContentNotPermittedException.class)
+ public void testCreateContentInIncorrectContainer9() {
+ dcServerTool.checkContentTypeId(TYPE_WIKI, TYPE_UPLOADEDFILE);
+ }
+
+}
\ No newline at end of file
Modified: trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceAddTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceAddTest.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceAddTest.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -8,6 +8,7 @@
import org.junit.Before;
import org.junit.Test;
import org.ourproject.kune.docs.client.DocumentClientTool;
+import org.ourproject.kune.docs.server.DocumentServerTool;
import org.ourproject.kune.platf.client.dto.AccessRightsDTO;
import org.ourproject.kune.platf.client.dto.ContainerDTO;
import org.ourproject.kune.platf.client.dto.ContainerSimpleDTO;
@@ -33,7 +34,8 @@
@Test(expected = UserMustBeLoggedException.class)
public void noLoggedInShouldThrowIllegalAccess() throws ContentNotFoundException, Exception {
defaultContent = getSiteDefaultContent();
- contentService.addContent(session.getHash(), defaultContent.getContainer().getStateToken(), "a name");
+ contentService.addContent(session.getHash(), defaultContent.getContainer().getStateToken(), "a name",
+ DocumentServerTool.TYPE_DOCUMENT);
}
@Test
@@ -47,7 +49,7 @@
final String title = "New Content Title";
final StateContentDTO added = contentService.addContent(session.getHash(),
- defaultContent.getContainer().getStateToken(), title);
+ defaultContent.getContainer().getStateToken(), title, DocumentServerTool.TYPE_DOCUMENT);
assertNotNull(added);
final List<ContentSimpleDTO> contents = added.getContainer().getContents();
assertEquals(title, added.getTitle());
@@ -72,8 +74,8 @@
defaultContent = getSiteDefaultContent();
final ContainerDTO parent = defaultContent.getContainer();
final String title = "folder name";
- final StateContainerDTO newState = contentService.addFolder(session.getHash(), parent.getStateToken(),
- title, DocumentClientTool.TYPE_FOLDER);
+ final StateContainerDTO newState = contentService.addFolder(session.getHash(), parent.getStateToken(), title,
+ DocumentClientTool.TYPE_FOLDER);
assertNotNull(newState);
assertNotNull(newState.getGroupMembers());
assertNotNull(newState.getParticipation());
@@ -96,8 +98,7 @@
defaultContent = getSiteDefaultContent();
final ContainerDTO parent = defaultContent.getContainer();
final String roomName = "testroom";
- final StateContainerDTO newState = contentService.addRoom(session.getHash(), parent.getStateToken(),
- roomName);
+ final StateContainerDTO newState = contentService.addRoom(session.getHash(), parent.getStateToken(), roomName);
assertNotNull(newState);
}
@@ -107,12 +108,12 @@
defaultContent = getSiteDefaultContent();
final ContainerDTO parent = defaultContent.getContainer();
final String title = "folder name";
- final StateContainerDTO newState = contentService.addFolder(session.getHash(), parent.getStateToken(),
- title, DocumentClientTool.TYPE_FOLDER);
+ final StateContainerDTO newState = contentService.addFolder(session.getHash(), parent.getStateToken(), title,
+ DocumentClientTool.TYPE_FOLDER);
assertNotNull(newState);
- final StateContainerDTO newState2 = contentService.addFolder(session.getHash(), parent.getStateToken(),
- title, DocumentClientTool.TYPE_FOLDER);
+ final StateContainerDTO newState2 = contentService.addFolder(session.getHash(), parent.getStateToken(), title,
+ DocumentClientTool.TYPE_FOLDER);
assertNotNull(newState2);
final ContainerDTO parentAgain = getSiteDefaultContent().getContainer();
Modified: trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceSaveTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceSaveTest.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceSaveTest.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -23,8 +23,7 @@
public void testSaveAndRetrieve() throws Exception {
final String text = "Lorem ipsum dolor sit amet";
final int version = defaultContent.getVersion();
- final int versionRetrieved = contentService.save(getHash(), defaultContent.getStateToken(), text);
- assertEquals(version + 1, versionRetrieved);
+ contentService.save(getHash(), defaultContent.getStateToken(), text);
final StateContentDTO again = (StateContentDTO) contentService.getContent(getHash(),
defaultContent.getStateToken());
assertEquals(text, again.getContent());
@@ -36,10 +35,8 @@
@Test
public void testSaveAndRetrieveBig() throws Exception {
final String text = TestDomainHelper.createBigText();
- ;
final int version = defaultContent.getVersion();
- final int currentVersion = contentService.save(getHash(), defaultContent.getStateToken(), text);
- assertEquals(version + 1, currentVersion);
+ contentService.save(getHash(), defaultContent.getStateToken(), text);
final StateContentDTO again = (StateContentDTO) contentService.getContent(getHash(),
defaultContent.getStateToken());
assertEquals(version + 1, again.getVersion());
Modified: trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceVariousTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceVariousTest.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceVariousTest.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -10,6 +10,7 @@
import org.junit.Ignore;
import org.junit.Test;
import org.ourproject.kune.docs.client.DocumentClientTool;
+import org.ourproject.kune.docs.server.DocumentServerTool;
import org.ourproject.kune.platf.client.dto.ContainerDTO;
import org.ourproject.kune.platf.client.dto.ContentSimpleDTO;
import org.ourproject.kune.platf.client.dto.StateContainerDTO;
@@ -78,8 +79,8 @@
final String oldTitle = "some title";
String newTitle = "folder new name";
- final StateContainerDTO newState = contentService.addFolder(session.getHash(),
- defaultContent.getStateToken(), oldTitle, DocumentClientTool.TYPE_FOLDER);
+ final StateContainerDTO newState = contentService.addFolder(session.getHash(), defaultContent.getStateToken(),
+ oldTitle, DocumentClientTool.TYPE_FOLDER);
final ContainerDTO newFolder = newState.getContainer();
@@ -93,8 +94,7 @@
final StateToken newFolderToken = new StateToken(groupShortName, defaultContent.getStateToken().getTool(),
newFolder.getId().toString(), null);
- StateContainerDTO folderAgain = (StateContainerDTO) contentService.getContent(getHash(),
- newFolderToken);
+ StateContainerDTO folderAgain = (StateContainerDTO) contentService.getContent(getHash(), newFolderToken);
assertEquals(newTitle, folderAgain.getContainer().getName());
@@ -176,8 +176,8 @@
doLogin();
defaultContent = getSiteDefaultContent();
- final StateContainerDTO added = contentService.addContent(session.getHash(),
- defaultContent.getStateToken(), "New Content Title");
+ final StateContainerDTO added = contentService.addContent(session.getHash(), defaultContent.getStateToken(),
+ "New Content Title", DocumentServerTool.TYPE_DOCUMENT);
assertNotNull(added);
final ContentSimpleDTO newDefContent = contentService.setAsDefaultContent(session.getHash(),
Added: 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-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/test/java/org/ourproject/kune/platf/server/content/ContentManagerDefaultTest.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -0,0 +1,13 @@
+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);
+ }
+
+}
Modified: trunk/src/test/java/org/ourproject/kune/platf/server/manager/ContentManagerTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/server/manager/ContentManagerTest.java 2008-10-25 14:13:11 UTC (rev 928)
+++ trunk/src/test/java/org/ourproject/kune/platf/server/manager/ContentManagerTest.java 2008-10-25 14:13:41 UTC (rev 929)
@@ -8,6 +8,7 @@
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
+import org.ourproject.kune.docs.server.DocumentServerTool;
import org.ourproject.kune.platf.server.PersistenceTest;
import org.ourproject.kune.platf.server.content.ContentManager;
import org.ourproject.kune.platf.server.domain.BasicMimeType;
@@ -95,14 +96,18 @@
@Test
public void testUTF8Persist() {
final Container container = Mockito.mock(Container.class);
- final Content cnt = contentManager.createContent("汉语/漢語", "汉语/漢語", user, container);
+ Mockito.stub(container.getTypeId()).toReturn(DocumentServerTool.TYPE_FOLDER);
+ final Content cnt = contentManager.createContent("汉语/漢語", "汉语/漢語", user, container,
+ DocumentServerTool.TYPE_DOCUMENT);
final Content newCnt = contentManager.find(cnt.getId());
assertEquals("汉语/漢語", newCnt.getTitle());
}
private void createContentWithMime(final String mimetype) {
final Container container = Mockito.mock(Container.class);
- final Content cnt = contentManager.createContent("title", "body", user, container);
+ Mockito.stub(container.getTypeId()).toReturn(DocumentServerTool.TYPE_FOLDER);
+ final Content cnt = contentManager.createContent("title", "body", user, container,
+ DocumentServerTool.TYPE_UPLOADEDFILE);
cnt.setMimeType(new BasicMimeType(mimetype));
persist(cnt);
final Content newCnt = contentManager.find(cnt.getId());
More information about the kune-commits
mailing list