[kune-commits] r867 - in trunk: . img/nav-icons
src/main/java/org/ourproject/kune/docs/client
src/main/java/org/ourproject/kune/platf/client/dto
src/main/java/org/ourproject/kune/platf/client/state
src/main/java/org/ourproject/kune/platf/public/images/nav
src/main/java/org/ourproject/kune/platf/server
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/rpc
src/main/java/org/ourproject/kune/platf/server/state
src/main/java/org/ourproject/kune/platf/server/users
src/main/java/org/ourproject/kune/workspace/client/ctxnav
src/main/resources
src/test/java/org/ourproject/kune/platf/client/state
src/test/java/org/ourproject/kune/platf/integration/content
src/test/java/org/ourproject/kune/platf/server/mapper
vjrj
vjrj at ourproject.org
Fri Sep 12 10:06:34 CEST 2008
Author: vjrj
Date: 2008-09-12 10:06:29 +0200 (Fri, 12 Sep 2008)
New Revision: 867
Added:
trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContainerSimpleDTO.java
Removed:
trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContainerSimpleDTO.java
Modified:
trunk/img/nav-icons/upload.gif
trunk/img/nav-icons/upload.png
trunk/pom.xml
trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java
trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContainerDTO.java
trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContentDTO.java
trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContentStatusDTO.java
trunk/src/main/java/org/ourproject/kune/platf/client/dto/StateDTO.java
trunk/src/main/java/org/ourproject/kune/platf/client/dto/StateToken.java
trunk/src/main/java/org/ourproject/kune/platf/client/state/StateManagerDefault.java
trunk/src/main/java/org/ourproject/kune/platf/public/images/nav/upload.gif
trunk/src/main/java/org/ourproject/kune/platf/public/images/nav/upload.png
trunk/src/main/java/org/ourproject/kune/platf/server/PlatformServerModule.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/domain/Container.java
trunk/src/main/java/org/ourproject/kune/platf/server/domain/Content.java
trunk/src/main/java/org/ourproject/kune/platf/server/domain/HasStateToken.java
trunk/src/main/java/org/ourproject/kune/platf/server/rpc/ContentRPC.java
trunk/src/main/java/org/ourproject/kune/platf/server/rpc/GroupRPC.java
trunk/src/main/java/org/ourproject/kune/platf/server/state/State.java
trunk/src/main/java/org/ourproject/kune/platf/server/state/StateServiceDefault.java
trunk/src/main/java/org/ourproject/kune/platf/server/users/UserInfoServiceDefault.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/resources/dozerBeanMapping.xml
trunk/src/test/java/org/ourproject/kune/platf/client/state/StateTokenTest.java
trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceAddTest.java
trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceGetTest.java
trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceVariousTest.java
trunk/src/test/java/org/ourproject/kune/platf/server/mapper/MapperTest.java
Log:
More context adjusts
Modified: trunk/img/nav-icons/upload.gif
===================================================================
(Binary files differ)
Modified: trunk/img/nav-icons/upload.png
===================================================================
(Binary files differ)
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/pom.xml 2008-09-12 08:06:29 UTC (rev 867)
@@ -54,7 +54,7 @@
<dependency>
<groupId>com.gwtextux</groupId>
<artifactId>gwtextux</artifactId>
- <version>0.3.0</version>
+ <version>0.3.0b</version>
</dependency>
<dependency>
<groupId>com.allen_sauer.gwt.log.gwt-log</groupId>
Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -153,7 +153,7 @@
session.getCurrentState().getGroup().getShortName(), token.getDocument(),
new AsyncCallbackSimple<String>() {
public void onSuccess(final String result) {
- final StateToken parent = token.clone().setDocument(null);
+ final StateToken parent = token.clone().clearDocument();
stateManager.gotoToken(parent);
}
});
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContainerDTO.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContainerDTO.java 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContainerDTO.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -25,71 +25,80 @@
import com.google.gwt.user.client.rpc.IsSerializable;
public class ContainerDTO implements IsSerializable {
- private Long parentFolderId;
private Long id;
private String name;
+ private String typeId;
+ private StateToken stateToken;
+ private Long parentFolderId;
private ContainerSimpleDTO[] absolutePath;
- private String typeId;
- private List<ContainerDTO> childs;
+ private List<ContainerSimpleDTO> childs;
private List<ContentDTO> contents;
public ContainerDTO() {
}
- public Long getParentFolderId() {
- return parentFolderId;
+ public ContainerSimpleDTO[] getAbsolutePath() {
+ return absolutePath;
}
- public void setParentFolderId(final Long parentFolderId) {
- this.parentFolderId = parentFolderId;
+ public List<ContainerSimpleDTO> getChilds() {
+ return childs;
}
+ public List<ContentDTO> getContents() {
+ return contents;
+ }
+
public Long getId() {
- return id;
+ return id;
}
public String getName() {
- return name;
+ return name;
}
- public void setName(final String name) {
- this.name = name;
+ public Long getParentFolderId() {
+ return parentFolderId;
}
- public ContainerSimpleDTO[] getAbsolutePath() {
- return absolutePath;
+ public StateToken getStateToken() {
+ return stateToken;
}
+ public String getTypeId() {
+ return typeId;
+ }
+
public void setAbsolutePath(final ContainerSimpleDTO[] absolutePath) {
- this.absolutePath = absolutePath;
+ this.absolutePath = absolutePath;
}
- public void setId(final Long id) {
- this.id = id;
+ public void setChilds(final List<ContainerSimpleDTO> childs) {
+ this.childs = childs;
}
- public List<ContainerDTO> getChilds() {
- return childs;
+ public void setContents(final List<ContentDTO> contents) {
+ this.contents = contents;
}
- public void setChilds(final List<ContainerDTO> childs) {
- this.childs = childs;
+ public void setId(final Long id) {
+ this.id = id;
}
- public List<ContentDTO> getContents() {
- return contents;
+ public void setName(final String name) {
+ this.name = name;
}
- public void setContents(final List<ContentDTO> contents) {
- this.contents = contents;
+ public void setParentFolderId(final Long parentFolderId) {
+ this.parentFolderId = parentFolderId;
}
- public String getTypeId() {
- return typeId;
+ public void setStateToken(final StateToken stateToken) {
+ this.stateToken = stateToken;
}
public void setTypeId(final String typeId) {
- this.typeId = typeId;
+ this.typeId = typeId;
}
}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContainerSimpleDTO.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContainerSimpleDTO.java 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContainerSimpleDTO.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -1,66 +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.client.dto;
-
-import com.google.gwt.user.client.rpc.IsSerializable;
-
-public class ContainerSimpleDTO implements IsSerializable {
- private Long parentFolderId;
- private Long id;
- private String name;
- private String typeId;
-
- public ContainerSimpleDTO() {
- }
-
- public Long getParentFolderId() {
- return parentFolderId;
- }
-
- public void setParentFolderId(final Long parentFolderId) {
- this.parentFolderId = parentFolderId;
- }
-
- public Long getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(final String name) {
- this.name = name;
- }
-
- public void setId(final Long id) {
- this.id = id;
- }
-
- public String getTypeId() {
- return typeId;
- }
-
- public void setTypeId(final String typeId) {
- this.typeId = typeId;
- }
-
-}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContainerSimpleDTO.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContainerSimpleDTO.java 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContainerSimpleDTO.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -0,0 +1,79 @@
+/*
+ *
+ * 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.dto;
+
+import com.google.gwt.user.client.rpc.IsSerializable;
+
+/**
+ * A item can be both a container or a content
+ *
+ */
+public class ContainerSimpleDTO implements IsSerializable {
+ private Long id;
+ private String name;
+ private String typeId;
+ private StateToken stateToken;
+ private Long parentFolderId;
+
+ public ContainerSimpleDTO() {
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Long getParentFolderId() {
+ return parentFolderId;
+ }
+
+ public StateToken getStateToken() {
+ return stateToken;
+ }
+
+ public String getTypeId() {
+ return typeId;
+ }
+
+ public void setId(final Long id) {
+ this.id = id;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public void setParentFolderId(final Long parentFolderId) {
+ this.parentFolderId = parentFolderId;
+ }
+
+ public void setStateToken(final StateToken stateToken) {
+ this.stateToken = stateToken;
+ }
+
+ public void setTypeId(final String typeId) {
+ this.typeId = typeId;
+ }
+
+}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContentDTO.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContentDTO.java 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContentDTO.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -27,29 +27,56 @@
private Long id;
private String title;
private String typeId;
+ private StateToken stateToken;
+ private ContentStatusDTO status;
+ private AccessRightsDTO rights;
public Long getId() {
- return id;
+ return id;
}
- public void setId(final Long id) {
- this.id = id;
+ public AccessRightsDTO getRights() {
+ return rights;
}
- public String getTitle() {
- return title;
+ public StateToken getStateToken() {
+ return stateToken;
}
- public void setTitle(final String title) {
- this.title = title;
+ public ContentStatusDTO getStatus() {
+ return status;
}
+ public String getTitle() {
+ return title;
+ }
+
public String getTypeId() {
- return typeId;
+ return typeId;
}
+ public void setId(final Long id) {
+ this.id = id;
+ }
+
+ public void setRights(final AccessRightsDTO rights) {
+ this.rights = rights;
+ }
+
+ public void setStateToken(final StateToken stateToken) {
+ this.stateToken = stateToken;
+ }
+
+ public void setStatus(final ContentStatusDTO status) {
+ this.status = status;
+ }
+
+ public void setTitle(final String title) {
+ this.title = title;
+ }
+
public void setTypeId(final String typeId) {
- this.typeId = typeId;
+ this.typeId = typeId;
}
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContentStatusDTO.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContentStatusDTO.java 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContentStatusDTO.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -1,5 +1,7 @@
package org.ourproject.kune.platf.client.dto;
-public enum ContentStatusDTO {
- publicVisible, nonPublicVisible, markForDelection
+import com.google.gwt.user.client.rpc.IsSerializable;
+
+public enum ContentStatusDTO implements IsSerializable {
+ editingInProgress, submittedForEvaluation, publishedOnline, rejected, inTheDustbin
}
\ No newline at end of file
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/dto/StateDTO.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/dto/StateDTO.java 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/dto/StateDTO.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -38,6 +38,7 @@
private AccessRightsDTO contentRights;
private AccessRightsDTO folderRights;
private AccessRightsDTO groupRights;
+ private ContentStatusDTO status;
private boolean isRateable;
private Double rate;
private Integer rateByUsers;
@@ -51,224 +52,237 @@
private List<TagResultDTO> groupTags;
private SocialNetworkDTO groupMembers;
private ParticipationDataDTO participation;
+ private StateToken stateToken;
public StateDTO() {
- this(null, null, null);
+ this(null, null, null);
}
public StateDTO(final String docRef, final String title, final String content) {
- this.documentId = docRef;
- this.title = title;
- this.content = content;
+ this.documentId = docRef;
+ this.title = title;
+ this.content = content;
}
- public int getVersion() {
- return version;
+ public AccessListsDTO getAccessLists() {
+ return accessLists;
}
- public void setVersion(final int version) {
- this.version = version;
+ public List<UserSimpleDTO> getAuthors() {
+ return authors;
}
- public void setDocumentId(final String docRef) {
- this.documentId = docRef;
+ public String getContent() {
+ return content;
}
- public void setContent(final String content) {
- this.content = content;
+ public AccessRightsDTO getContentRights() {
+ return this.contentRights;
}
+ public Double getCurrentUserRate() {
+ return currentUserRate;
+ }
+
public String getDocumentId() {
- return documentId;
+ return documentId;
}
- public String getContent() {
- return content;
+ public ContainerDTO getFolder() {
+ return folder;
}
- public String getTitle() {
- return title;
+ public AccessRightsDTO getFolderRights() {
+ return folderRights;
}
- public void setTitle(final String title) {
- this.title = title;
+ public GroupDTO getGroup() {
+ return this.group;
}
- public String getToolName() {
- return toolName;
+ public SocialNetworkDTO getGroupMembers() {
+ return groupMembers;
}
- public void setToolName(final String toolName) {
- this.toolName = toolName;
+ public AccessRightsDTO getGroupRights() {
+ return groupRights;
}
- public GroupDTO getGroup() {
- return this.group;
+ public List<TagResultDTO> getGroupTags() {
+ return groupTags;
}
- public void setGroup(final GroupDTO group) {
- this.group = group;
+ public I18nLanguageDTO getLanguage() {
+ return language;
}
- public AccessRightsDTO getContentRights() {
- return this.contentRights;
+ public LicenseDTO getLicense() {
+ return license;
}
- public void setContentRights(final AccessRightsDTO accessRights) {
- this.contentRights = accessRights;
+ public ParticipationDataDTO getParticipation() {
+ return participation;
}
- public ContainerDTO getFolder() {
- return folder;
+ public Date getPublishedOn() {
+ return publishedOn;
}
- public void setFolder(final ContainerDTO folder) {
- this.folder = folder;
+ public Double getRate() {
+ return rate;
}
- public StateToken getStateToken() {
- return new StateToken(group.getShortName(), toolName, folder.getId().toString(), getDocumentId());
+ public Integer getRateByUsers() {
+ return rateByUsers;
}
- // FIXME: maybe a tag in the content showing the type, think about this
- public boolean hasDocument() {
- return documentId != null;
+ public SocialNetworkDTO getSocialNetwork() {
+ return socialNetwork;
}
- public AccessListsDTO getAccessLists() {
- return accessLists;
+ public StateToken getStateToken() {
+ return stateToken;
}
- public void setAccessLists(final AccessListsDTO accessLists) {
- this.accessLists = accessLists;
+ public ContentStatusDTO getStatus() {
+ return status;
}
- public Double getRate() {
- return rate;
+ public String getTags() {
+ return tags;
}
- public void setRate(final Double rate) {
- this.rate = rate;
+ public String getTitle() {
+ return title;
}
- public Integer getRateByUsers() {
- return rateByUsers;
+ public String getToolName() {
+ return toolName;
}
- public void setRateByUsers(final Integer rateByUsers) {
- this.rateByUsers = rateByUsers;
+ public String getTypeId() {
+ return typeId;
}
- public AccessRightsDTO getFolderRights() {
- return folderRights;
+ public int getVersion() {
+ return version;
}
- public void setFolderRights(final AccessRightsDTO folderRights) {
- this.folderRights = folderRights;
+ // FIXME: maybe a tag in the content showing the type, think about this
+ public boolean hasDocument() {
+ return documentId != null;
}
- public String getTypeId() {
- return typeId;
+ public boolean isRateable() {
+ return isRateable;
}
- public void setTypeId(final String typeId) {
- this.typeId = typeId;
+ public void setAccessLists(final AccessListsDTO accessLists) {
+ this.accessLists = accessLists;
}
- public LicenseDTO getLicense() {
- return license;
+ public void setAuthors(final List<UserSimpleDTO> authors) {
+ this.authors = authors;
}
- public void setLicense(final LicenseDTO license) {
- this.license = license;
+ public void setContent(final String content) {
+ this.content = content;
}
- public SocialNetworkDTO getSocialNetwork() {
- return socialNetwork;
+ public void setContentRights(final AccessRightsDTO accessRights) {
+ this.contentRights = accessRights;
}
- public void setSocialNetwork(final SocialNetworkDTO socialNetwork) {
- this.socialNetwork = socialNetwork;
+ public void setCurrentUserRate(final Double currentUserRate) {
+ this.currentUserRate = currentUserRate;
}
- public AccessRightsDTO getGroupRights() {
- return groupRights;
+ public void setDocumentId(final String docRef) {
+ this.documentId = docRef;
}
- public void setGroupRights(final AccessRightsDTO groupRights) {
- this.groupRights = groupRights;
+ public void setFolder(final ContainerDTO folder) {
+ this.folder = folder;
}
- public Double getCurrentUserRate() {
- return currentUserRate;
+ public void setFolderRights(final AccessRightsDTO folderRights) {
+ this.folderRights = folderRights;
}
- public void setCurrentUserRate(final Double currentUserRate) {
- this.currentUserRate = currentUserRate;
+ public void setGroup(final GroupDTO group) {
+ this.group = group;
}
- public boolean isRateable() {
- return isRateable;
+ public void setGroupMembers(final SocialNetworkDTO groupMembers) {
+ this.groupMembers = groupMembers;
}
- public void setRateable(final boolean isRateable) {
- this.isRateable = isRateable;
+ public void setGroupRights(final AccessRightsDTO groupRights) {
+ this.groupRights = groupRights;
}
- public I18nLanguageDTO getLanguage() {
- return language;
+ public void setGroupTags(final List<TagResultDTO> groupTags) {
+ this.groupTags = groupTags;
}
public void setLanguage(final I18nLanguageDTO language) {
- this.language = language;
+ this.language = language;
}
- public Date getPublishedOn() {
- return publishedOn;
+ public void setLicense(final LicenseDTO license) {
+ this.license = license;
}
+ public void setParticipation(final ParticipationDataDTO participation) {
+ this.participation = participation;
+ }
+
public void setPublishedOn(final Date publishedOn) {
- this.publishedOn = publishedOn;
+ this.publishedOn = publishedOn;
}
- public List<UserSimpleDTO> getAuthors() {
- return authors;
+ public void setRate(final Double rate) {
+ this.rate = rate;
}
- public void setAuthors(final List<UserSimpleDTO> authors) {
- this.authors = authors;
+ public void setRateable(final boolean isRateable) {
+ this.isRateable = isRateable;
}
- public String getTags() {
- return tags;
+ public void setRateByUsers(final Integer rateByUsers) {
+ this.rateByUsers = rateByUsers;
}
- public void setTags(final String tags) {
- this.tags = tags;
+ public void setSocialNetwork(final SocialNetworkDTO socialNetwork) {
+ this.socialNetwork = socialNetwork;
}
- public List<TagResultDTO> getGroupTags() {
- return groupTags;
+ public void setStateToken(final StateToken stateToken) {
+ this.stateToken = stateToken;
}
- public void setGroupTags(final List<TagResultDTO> groupTags) {
- this.groupTags = groupTags;
+ public void setStatus(final ContentStatusDTO status) {
+ this.status = status;
}
- public SocialNetworkDTO getGroupMembers() {
- return groupMembers;
+ public void setTags(final String tags) {
+ this.tags = tags;
}
- public void setGroupMembers(final SocialNetworkDTO groupMembers) {
- this.groupMembers = groupMembers;
+ public void setTitle(final String title) {
+ this.title = title;
}
- public ParticipationDataDTO getParticipation() {
- return participation;
+ public void setToolName(final String toolName) {
+ this.toolName = toolName;
}
- public void setParticipation(final ParticipationDataDTO participation) {
- this.participation = participation;
+ public void setTypeId(final String typeId) {
+ this.typeId = typeId;
}
+ public void setVersion(final int version) {
+ this.version = version;
+ }
+
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/dto/StateToken.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/dto/StateToken.java 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/dto/StateToken.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -56,22 +56,17 @@
}
public StateToken(final String encoded) {
- String[] splitted;
- if (encoded != null && encoded.length() > 0) {
- splitted = encoded.split("\\.");
- } else {
- splitted = EMPTY;
- }
- setGroup(conditionalAssign(0, splitted));
- setTool(conditionalAssign(1, splitted));
- setFolder(conditionalAssign(2, splitted));
- setDocument(conditionalAssign(3, splitted));
+ parse(encoded);
}
public StateToken(final String group, final String tool) {
this(group, tool, null, null);
}
+ public StateToken(final String group, final String tool, final Long folder) {
+ this(group, tool, folder == null ? null : folder.toString(), null);
+ }
+
public StateToken(final String group, final String tool, final String folder, final String document) {
this.setGroup(group);
this.setTool(tool);
@@ -80,10 +75,41 @@
encoded = null;
}
+ public StateToken clearDocument() {
+ this.document = null;
+ encoded = null;
+ return this;
+ }
+
+ public StateToken clearFolder() {
+ this.folder = null;
+ encoded = null;
+ return this;
+ }
+
public StateToken clone() {
return new StateToken(this.getEncoded());
}
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ final StateToken other = (StateToken) obj;
+ if (getEncoded() == null) {
+ if (other.getEncoded() != null) {
+ return false;
+ }
+ } else if (!getEncoded().equals(other.getEncoded())) {
+ return false;
+ }
+ return true;
+ }
+
public String getDocument() {
return document;
}
@@ -159,12 +185,28 @@
return getDocument() != null;
}
+ public StateToken setDocument(final Long document) {
+ this.document = document == null ? null : document.toString();
+ encoded = null;
+ return this;
+ }
+
public StateToken setDocument(final String document) {
this.document = document;
encoded = null;
return this;
}
+ public void setEncoded(final String encoded) {
+ parse(encoded);
+ }
+
+ public StateToken setFolder(final Long folder) {
+ this.folder = folder == null ? null : folder.toString();
+ encoded = null;
+ return this;
+ }
+
public StateToken setFolder(final String folder) {
this.folder = folder;
encoded = null;
@@ -194,4 +236,18 @@
return null;
}
}
+
+ private void parse(final String encoded) {
+ String[] splitted;
+ if (encoded != null && encoded.length() > 0) {
+ splitted = encoded.split("\\.");
+ } else {
+ splitted = EMPTY;
+ }
+ setGroup(conditionalAssign(0, splitted));
+ setTool(conditionalAssign(1, splitted));
+ setFolder(conditionalAssign(2, splitted));
+ setDocument(conditionalAssign(3, splitted));
+ }
+
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/state/StateManagerDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/state/StateManagerDefault.java 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/state/StateManagerDefault.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -78,8 +78,8 @@
}
public void gotoContainer(final Long containerId) {
- final StateToken newStateToken = session.getCurrentState().getStateToken();
- newStateToken.setDocument(null);
+ final StateToken newStateToken = session.getCurrentState().getStateToken().clone();
+ newStateToken.clearDocument();
newStateToken.setFolder(containerId.toString());
gotoToken(newStateToken);
}
@@ -203,9 +203,9 @@
private void onHistoryChanged(final StateToken newState) {
contentProvider.getContent(session.getUserHash(), newState, new AsyncCallbackSimple<StateDTO>() {
public void onSuccess(final StateDTO newState) {
+ loadContent(newState);
session.setCurrent(newState);
checkGroupAndToolChange(oldState, newState);
- loadContent(newState);
oldState = newState;
}
});
Modified: trunk/src/main/java/org/ourproject/kune/platf/public/images/nav/upload.gif
===================================================================
(Binary files differ)
Modified: trunk/src/main/java/org/ourproject/kune/platf/public/images/nav/upload.png
===================================================================
(Binary files differ)
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/PlatformServerModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/PlatformServerModule.java 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/PlatformServerModule.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -54,6 +54,7 @@
import org.ourproject.kune.platf.server.content.CreationService;
import org.ourproject.kune.platf.server.content.CreationServiceDefault;
import org.ourproject.kune.platf.server.i18n.I18nTranslationServiceDefault;
+import org.ourproject.kune.platf.server.manager.FileManager;
import org.ourproject.kune.platf.server.manager.GroupManager;
import org.ourproject.kune.platf.server.manager.I18nCountryManager;
import org.ourproject.kune.platf.server.manager.I18nLanguageManager;
@@ -64,6 +65,7 @@
import org.ourproject.kune.platf.server.manager.TagManager;
import org.ourproject.kune.platf.server.manager.ToolConfigurationManager;
import org.ourproject.kune.platf.server.manager.UserManager;
+import org.ourproject.kune.platf.server.manager.impl.FileManagerDefault;
import org.ourproject.kune.platf.server.manager.impl.FileUploadManagerRevisited;
import org.ourproject.kune.platf.server.manager.impl.GroupManagerDefault;
import org.ourproject.kune.platf.server.manager.impl.I18nCountryManagerDefault;
@@ -133,6 +135,7 @@
bind(I18nTranslationManager.class).to(I18nTranslationManagerDefault.class);
bind(TagManager.class).to(TagManagerDefault.class);
bind(CommentManager.class).to(CommentManagerDefault.class);
+ bind(FileManager.class).to(FileManagerDefault.class);
}
private void bindRPC() {
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-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManager.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -34,7 +34,7 @@
public void addAuthor(User user, Long contentId, String authorShortName) throws DefaultException;
- public Content createContent(String title, String body, User user, Container container);
+ public Content createContent(String title, String body, User author, Container container);
public 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-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManagerDefault.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -38,6 +38,7 @@
import org.ourproject.kune.platf.server.access.FinderService;
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.I18nLanguage;
import org.ourproject.kune.platf.server.domain.Rate;
import org.ourproject.kune.platf.server.domain.Revision;
@@ -78,14 +79,14 @@
content.addAuthor(author);
}
- 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 author, final Container container) {
final Content descriptor = new Content();
- descriptor.addAuthor(user);
- descriptor.setLanguage(user.getLanguage());
+ descriptor.addAuthor(author);
+ descriptor.setLanguage(author.getLanguage());
// FIXME: remove this when UI take publishing into account
descriptor.setPublishedOn(new Date());
+ container.addContent(descriptor);
descriptor.setContainer(container);
- container.addContent(descriptor);
final Revision revision = new Revision(descriptor);
revision.setTitle(title);
revision.setBody(body);
@@ -95,9 +96,8 @@
public void delContent(final User user, final Long contentId) throws DefaultException {
final Content content = finder.getContent(contentId);
- content.setMarkForDeletion(true);
+ content.setStatus(ContentStatus.inTheDustbin);
content.setDeletedOn(new Date());
- // FIXME: Maybe set only visible for admins
}
public Double getRateAvg(final Content content) {
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-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/domain/Container.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -45,11 +45,12 @@
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.annotations.Store;
+import org.ourproject.kune.platf.client.dto.StateToken;
@Entity
@Indexed
@Table(name = "containers")
-public class Container implements HasId {
+public class Container implements HasId, HasStateToken {
@Id
@GeneratedValue
@DocumentId
@@ -89,140 +90,150 @@
@OneToMany(cascade = CascadeType.ALL)
private List<ContainerTranslation> containerTranslations;
- public Container(final String title, final Group group, final String toolName) {
- this.name = title;
- owner = group;
- this.toolName = toolName;
- this.contents = new HashSet<Content>();
- this.childs = new HashSet<Container>();
- this.absolutePath = new ArrayList<Container>();
- }
-
public Container() {
- this(null, null, null);
+ this(null, null, null);
}
- public String getName() {
- return name;
+ public Container(final String title, final Group group, final String toolName) {
+ this.name = title;
+ owner = group;
+ this.toolName = toolName;
+ this.contents = new HashSet<Content>();
+ this.childs = new HashSet<Container>();
+ this.absolutePath = new ArrayList<Container>();
}
- public void setName(final String name) {
- this.name = name;
+ public void addChild(final Container child) {
+ // childs.size();
+ // childs.add(container);
+ child.setParent(this);
+ childs.add(child);
}
- public Long getParentFolderId() {
- return parent != null ? parent.getId() : null;
+ public void addContent(final Content descriptor) {
+ // FIXME: something related with lazy initialization (workaround using
+ // size())
+ contents.size();
+ contents.add(descriptor);
}
- public Container getParent() {
- return parent;
+ public List<Container> getAbsolutePath() {
+ return absolutePath;
}
- public Long getId() {
- return id;
+ public List<ContainerTranslation> getAliases() {
+ return containerTranslations;
}
- public void setId(final Long id) {
- this.id = id;
+ public Set<Container> getChilds() {
+ return childs;
}
- public void setParent(final Container parent) {
- this.parent = parent;
+ public List<ContainerTranslation> getContainerTranslations() {
+ return containerTranslations;
}
- public Set<Container> getChilds() {
- return childs;
+ public Set<Content> getContents() {
+ return contents;
}
- public void setChilds(final Set<Container> childs) {
- this.childs = childs;
+ public Long getId() {
+ return id;
}
- public List<ContainerTranslation> getAliases() {
- return containerTranslations;
+ public I18nLanguage getLanguage() {
+ return language;
}
- public void setAliases(final List<ContainerTranslation> containerTranslations) {
- this.containerTranslations = containerTranslations;
+ public String getName() {
+ return name;
}
public Group getOwner() {
- return owner;
+ return owner;
}
- public void setOwner(final Group owner) {
- this.owner = owner;
+ public Container getParent() {
+ return parent;
}
- public String getToolName() {
- return toolName;
+ public Long getParentFolderId() {
+ return parent != null ? parent.getId() : null;
}
- public void setToolName(final String toolName) {
- this.toolName = toolName;
+ @Transient
+ public StateToken getStateToken() {
+ return new StateToken(getOwner().getShortName(), getToolName(), getId());
}
- public void addContent(final Content descriptor) {
- // FIXME: something related with lazy initialization (workaround using
- // size())
- contents.size();
- contents.add(descriptor);
+ @Transient
+ public String getStateTokenEncoded() {
+ return getStateToken().getEncoded();
}
- public String getTypeId() {
- return typeId;
+ public String getToolName() {
+ return toolName;
}
- public void setTypeId(final String typeId) {
- this.typeId = typeId;
+ public String getTypeId() {
+ return typeId;
}
- public Set<Content> getContents() {
- return contents;
+ @Transient
+ public boolean isLeaf() {
+ return childs.size() == 0 && contents.size() == 0;
}
- public void addChild(final Container child) {
- // childs.size();
- // childs.add(container);
- child.setParent(this);
- childs.add(child);
+ @Transient
+ public boolean isRoot() {
+ return parent == null;
}
- public I18nLanguage getLanguage() {
- return language;
+ public void setAbsolutePath(final List<Container> absolutePath) {
+ this.absolutePath = absolutePath;
}
- public void setLanguage(final I18nLanguage language) {
- this.language = language;
+ public void setAliases(final List<ContainerTranslation> containerTranslations) {
+ this.containerTranslations = containerTranslations;
}
- public List<ContainerTranslation> getContainerTranslations() {
- return containerTranslations;
+ public void setChilds(final Set<Container> childs) {
+ this.childs = childs;
}
public void setContainerTranslations(final List<ContainerTranslation> containerTranslations) {
- this.containerTranslations = containerTranslations;
+ this.containerTranslations = containerTranslations;
}
public void setContents(final HashSet<Content> contents) {
- this.contents = contents;
+ this.contents = contents;
}
- public List<Container> getAbsolutePath() {
- return absolutePath;
+ public void setId(final Long id) {
+ this.id = id;
}
- public void setAbsolutePath(final List<Container> absolutePath) {
- this.absolutePath = absolutePath;
+ public void setLanguage(final I18nLanguage language) {
+ this.language = language;
}
- @Transient
- public boolean isLeaf() {
- return childs.size() == 0 && contents.size() == 0;
+ public void setName(final String name) {
+ this.name = name;
}
- @Transient
- public boolean isRoot() {
- return parent == null;
+ public void setOwner(final Group owner) {
+ this.owner = owner;
}
+
+ public void setParent(final Container parent) {
+ this.parent = parent;
+ }
+
+ public void setToolName(final String toolName) {
+ this.toolName = toolName;
+ }
+
+ public void setTypeId(final String typeId) {
+ this.typeId = typeId;
+ }
}
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-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/domain/Content.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -29,7 +29,10 @@
import javax.persistence.Basic;
import javax.persistence.CascadeType;
+import javax.persistence.Column;
import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@@ -49,13 +52,13 @@
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.validator.NotNull;
+import org.ourproject.kune.platf.client.dto.StateToken;
@Entity
@Table(name = "contents")
@Indexed
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Content implements HasStateToken {
- private static final String TOKEN_SEPARATOR = ".";
@Id
@DocumentId
@@ -82,8 +85,6 @@
@Basic(optional = true)
private Date deletedOn;
- private boolean markForDeletion;
-
@Basic(optional = false)
private Date publishedOn;
@@ -113,199 +114,207 @@
@OneToMany(mappedBy = "content", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private Set<Comment> comments;
+ @Enumerated(EnumType.STRING)
+ @Column(nullable = false)
+ private ContentStatus status;
+
public Content() {
- translations = new ArrayList<ContentTranslation>();
- authors = new ArrayList<User>();
- tags = new ArrayList<Tag>();
- comments = new HashSet<Comment>();
- this.createdOn = System.currentTimeMillis();
- this.lastRevision = new Revision(this);
- accessLists = null;
- markForDeletion = false;
+ translations = new ArrayList<ContentTranslation>();
+ authors = new ArrayList<User>();
+ tags = new ArrayList<Tag>();
+ comments = new HashSet<Comment>();
+ this.createdOn = System.currentTimeMillis();
+ this.lastRevision = new Revision(this);
+ accessLists = null;
+ status = ContentStatus.publishedOnline;
}
- public Set<Comment> getComments() {
- return comments;
+ public void addAuthor(final User user) {
+ if (!this.authors.contains(user)) {
+ this.authors.add(user);
+ }
}
- public void setComments(final Set<Comment> comments) {
- this.comments = comments;
+ public void addComment(final Comment comment) {
+ // FIXME: something related with lazy initialization (workaround using
+ // size())
+ comments.size();
+ comments.add(comment);
}
- public void addComment(final Comment comment) {
- // FIXME: something related with lazy initialization (workaround using
- // size())
- comments.size();
- comments.add(comment);
+ public void addRevision(final Revision revision) {
+ if (lastRevision == null) {
+ lastRevision = revision;
+ } else {
+ revision.setPrevious(lastRevision);
+ lastRevision = revision;
+ }
}
- public Long getId() {
- return id;
+ public AccessLists getAccessLists() {
+ return accessLists;
}
- public void setId(final Long id) {
- this.id = id;
+ public List<User> getAuthors() {
+ return authors;
}
- public int getVersion() {
- return version;
+ public Set<Comment> getComments() {
+ return comments;
}
- public void setVersion(final int version) {
- this.version = version;
+ public Container getContainer() {
+ return container;
}
- public AccessLists getAccessLists() {
- return accessLists;
+ public Long getCreatedOn() {
+ return createdOn;
}
- public void setAccessLists(final AccessLists accessLists) {
- this.accessLists = accessLists;
+ public Date getDeletedOn() {
+ return deletedOn;
}
- public List<Tag> getTags() {
- return tags;
+ public Long getId() {
+ return id;
}
- public void setTags(final List<Tag> tags) {
- this.tags = tags;
+ public I18nLanguage getLanguage() {
+ return language;
}
+ public Revision getLastRevision() {
+ return lastRevision;
+ }
+
public License getLicense() {
- return license;
+ return license;
}
- public void setLicense(final License license) {
- this.license = license;
+ public Group getOwner(final Group group) {
+ return container.getOwner();
}
- public Revision getLastRevision() {
- return lastRevision;
+ public Date getPublishedOn() {
+ return publishedOn;
}
- public void setLastRevision(final Revision revision) {
- this.lastRevision = revision;
+ @Transient
+ public StateToken getStateToken() {
+ return getContainer().getStateToken().clone().setDocument(getId());
}
- public List<ContentTranslation> getTranslations() {
- return translations;
+ @Transient
+ public String getStateTokenEncoded() {
+ return getStateToken().getEncoded();
}
- public void setTranslations(final List<ContentTranslation> translations) {
- this.translations = translations;
+ public ContentStatus getStatus() {
+ return status;
}
- public Long getCreatedOn() {
- return createdOn;
+ public List<Tag> getTags() {
+ return tags;
}
- public void setCreatedOn(final Long createdOn) {
- this.createdOn = createdOn;
+ public String getTagsAsString() {
+ String tagConcatenated = "";
+ for (final Iterator<Tag> iterator = tags.iterator(); iterator.hasNext();) {
+ final Tag tag = iterator.next();
+ tagConcatenated = tagConcatenated + tag.getName();
+ if (iterator.hasNext()) {
+ tagConcatenated = tagConcatenated + " ";
+ }
+ }
+ return tagConcatenated;
}
- public Date getPublishedOn() {
- return publishedOn;
+ public String getTitle() {
+ return lastRevision.getTitle();
}
- public void setPublishedOn(final Date publishedOn) {
- this.publishedOn = publishedOn;
+ public List<ContentTranslation> getTranslations() {
+ return translations;
}
- public Container getContainer() {
- return container;
+ public String getTypeId() {
+ return typeId;
}
- public void setContainer(final Container container) {
- this.container = container;
+ public int getVersion() {
+ return version;
}
- public void addRevision(final Revision revision) {
- if (lastRevision == null) {
- lastRevision = revision;
- } else {
- revision.setPrevious(lastRevision);
- lastRevision = revision;
- }
+ public boolean hasAccessList() {
+ return accessLists != null;
}
- public String getTitle() {
- return lastRevision.getTitle();
+ public void removeAuthor(final User user) {
+ this.authors.remove(user);
}
- public String getTypeId() {
- return typeId;
+ public void setAccessLists(final AccessLists accessLists) {
+ this.accessLists = accessLists;
}
- public void setTypeId(final String typeId) {
- this.typeId = typeId;
+ public void setAuthors(final List<User> authors) {
+ this.authors = authors;
}
- public boolean hasAccessList() {
- return accessLists != null;
+ public void setComments(final Set<Comment> comments) {
+ this.comments = comments;
}
- public I18nLanguage getLanguage() {
- return language;
+ public void setContainer(final Container container) {
+ this.container = container;
}
- public void setLanguage(final I18nLanguage language) {
- this.language = language;
+ public void setCreatedOn(final Long createdOn) {
+ this.createdOn = createdOn;
}
- @Transient
- public String getStateToken() {
- return getContainer().getOwner().getShortName() + TOKEN_SEPARATOR + getContainer().getToolName()
- + TOKEN_SEPARATOR + getContainer().getId() + TOKEN_SEPARATOR + getId();
+ public void setDeletedOn(final Date date) {
+ this.deletedOn = date;
}
- public List<User> getAuthors() {
- return authors;
+ public void setId(final Long id) {
+ this.id = id;
}
- public void setAuthors(final List<User> authors) {
- this.authors = authors;
+ public void setLanguage(final I18nLanguage language) {
+ this.language = language;
}
- public void addAuthor(final User user) {
- if (!this.authors.contains(user)) {
- this.authors.add(user);
- }
+ public void setLastRevision(final Revision revision) {
+ this.lastRevision = revision;
}
- public void removeAuthor(final User user) {
- this.authors.remove(user);
+ public void setLicense(final License license) {
+ this.license = license;
}
- public String getTagsAsString() {
- String tagConcatenated = "";
- for (Iterator<Tag> iterator = tags.iterator(); iterator.hasNext();) {
- Tag tag = iterator.next();
- tagConcatenated = tagConcatenated + tag.getName();
- if (iterator.hasNext()) {
- tagConcatenated = tagConcatenated + " ";
- }
- }
- return tagConcatenated;
+ public void setPublishedOn(final Date publishedOn) {
+ this.publishedOn = publishedOn;
}
- public Date getDeletedOn() {
- return deletedOn;
+ public void setStatus(final ContentStatus status) {
+ this.status = status;
}
- public void setDeletedOn(final Date date) {
- this.deletedOn = date;
+ public void setTags(final List<Tag> tags) {
+ this.tags = tags;
}
- public boolean isMarkForDeletion() {
- return markForDeletion;
+ public void setTranslations(final List<ContentTranslation> translations) {
+ this.translations = translations;
}
- public void setMarkForDeletion(final boolean markForDeletion) {
- this.markForDeletion = markForDeletion;
+ public void setTypeId(final String typeId) {
+ this.typeId = typeId;
}
- public Group getOwner(final Group group) {
- return container.getOwner();
+ public void setVersion(final int version) {
+ this.version = version;
}
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/domain/HasStateToken.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/domain/HasStateToken.java 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/domain/HasStateToken.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -19,9 +19,10 @@
*/
package org.ourproject.kune.platf.server.domain;
+import org.ourproject.kune.platf.client.dto.StateToken;
public interface HasStateToken {
- String getStateToken();
+ StateToken getStateToken();
}
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-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/rpc/ContentRPC.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -27,7 +27,9 @@
import org.ourproject.kune.chat.server.managers.ChatConnection;
import org.ourproject.kune.chat.server.managers.XmppManager;
+import org.ourproject.kune.platf.client.dto.AccessRightsDTO;
import org.ourproject.kune.platf.client.dto.CommentDTO;
+import org.ourproject.kune.platf.client.dto.ContentDTO;
import org.ourproject.kune.platf.client.dto.I18nLanguageDTO;
import org.ourproject.kune.platf.client.dto.StateDTO;
import org.ourproject.kune.platf.client.dto.StateToken;
@@ -40,6 +42,7 @@
import org.ourproject.kune.platf.client.rpc.ContentService;
import org.ourproject.kune.platf.server.UserSession;
import org.ourproject.kune.platf.server.access.Access;
+import org.ourproject.kune.platf.server.access.AccessRightsService;
import org.ourproject.kune.platf.server.access.AccessService;
import org.ourproject.kune.platf.server.access.AccessType;
import org.ourproject.kune.platf.server.auth.Authenticated;
@@ -48,6 +51,7 @@
import org.ourproject.kune.platf.server.content.ContainerManager;
import org.ourproject.kune.platf.server.content.ContentManager;
import org.ourproject.kune.platf.server.content.CreationService;
+import org.ourproject.kune.platf.server.domain.AccessLists;
import org.ourproject.kune.platf.server.domain.Comment;
import org.ourproject.kune.platf.server.domain.Container;
import org.ourproject.kune.platf.server.domain.Content;
@@ -80,118 +84,125 @@
private final TagManager tagManager;
private final SocialNetworkManager socialNetworkManager;
private final CommentManager commentManager;
+ private final AccessRightsService rightsService;
@Inject
public ContentRPC(final Provider<UserSession> userSessionProvider, final AccessService accessService,
- final StateService stateService, final CreationService creationService, final GroupManager groupManager,
- final XmppManager xmppManager, final ContentManager contentManager,
- final ContainerManager containerManager, final TagManager tagManager,
- final SocialNetworkManager socialNetworkManager, final CommentManager commentManager, final Mapper mapper) {
- this.userSessionProvider = userSessionProvider;
- this.accessService = accessService;
- this.stateService = stateService;
- this.creationService = creationService;
- this.groupManager = groupManager;
- this.xmppManager = xmppManager;
- this.contentManager = contentManager;
- this.containerManager = containerManager;
- this.tagManager = tagManager;
- this.socialNetworkManager = socialNetworkManager;
- this.commentManager = commentManager;
- this.mapper = mapper;
+ final AccessRightsService rightsService, final StateService stateService,
+ final CreationService creationService, final GroupManager groupManager, final XmppManager xmppManager,
+ final ContentManager contentManager, final ContainerManager containerManager, final TagManager tagManager,
+ final SocialNetworkManager socialNetworkManager, final CommentManager commentManager, final Mapper mapper) {
+ this.userSessionProvider = userSessionProvider;
+ this.accessService = accessService;
+ this.rightsService = rightsService;
+ this.stateService = stateService;
+ this.creationService = creationService;
+ this.groupManager = groupManager;
+ this.xmppManager = xmppManager;
+ this.contentManager = contentManager;
+ this.containerManager = containerManager;
+ this.tagManager = tagManager;
+ this.socialNetworkManager = socialNetworkManager;
+ this.commentManager = commentManager;
+ this.mapper = mapper;
}
@Authenticated
@Authorizated(accessTypeRequired = AccessType.EDIT, checkContent = true)
@Transactional(type = TransactionType.READ_WRITE)
public void addAuthor(final String userHash, final String groupShortName, final String documentId,
- final String authorShortName) throws DefaultException {
- final Long contentId = parseId(documentId);
- final UserSession userSession = getUserSession();
- final User user = userSession.getUser();
- contentManager.addAuthor(user, contentId, authorShortName);
+ final String authorShortName) throws DefaultException {
+ final Long contentId = parseId(documentId);
+ final UserSession userSession = getUserSession();
+ final User user = userSession.getUser();
+ contentManager.addAuthor(user, contentId, authorShortName);
}
@Authenticated
@Authorizated(accessTypeRequired = AccessType.READ)
@Transactional(type = TransactionType.READ_WRITE)
public CommentDTO addComment(final String userHash, final String groupShortName, final String documentId,
- final Long parentCommentId, final String commentText) throws DefaultException {
- final UserSession userSession = getUserSession();
- final User author = userSession.getUser();
- final Long contentId = parseId(documentId);
- Comment comment = commentManager.addComment(author, contentId, commentText, parentCommentId);
- return mapper.map(comment, CommentDTO.class);
+ final Long parentCommentId, final String commentText) throws DefaultException {
+ final UserSession userSession = getUserSession();
+ final User author = userSession.getUser();
+ final Long contentId = parseId(documentId);
+ final Comment comment = commentManager.addComment(author, contentId, commentText, parentCommentId);
+ return mapper.map(comment, CommentDTO.class);
}
@Authenticated
@Authorizated(accessTypeRequired = AccessType.READ)
@Transactional(type = TransactionType.READ_WRITE)
public CommentDTO addComment(final String userHash, final String groupShortName, final String documentId,
- final String commentText) throws DefaultException {
- final UserSession userSession = getUserSession();
- final User author = userSession.getUser();
- final Long contentId = parseId(documentId);
- Comment comment = commentManager.addComment(author, contentId, commentText);
- return mapper.map(comment, CommentDTO.class);
+ final String commentText) throws DefaultException {
+ final UserSession userSession = getUserSession();
+ final User author = userSession.getUser();
+ final Long contentId = parseId(documentId);
+ final Comment comment = commentManager.addComment(author, contentId, commentText);
+ return mapper.map(comment, CommentDTO.class);
}
@Authenticated
@Authorizated(accessTypeRequired = AccessType.EDIT)
@Transactional(type = TransactionType.READ_WRITE)
public StateDTO addContent(final String userHash, final String groupShortName, final Long parentFolderId,
- final String title) throws DefaultException {
- final Group group = groupManager.findByShortName(groupShortName);
- final UserSession userSession = getUserSession();
- final User user = userSession.getUser();
- final Access access = accessService.getFolderAccess(group, parentFolderId, user, AccessType.EDIT);
- access.setContentWidthFolderRights(creationService.createContent(title, "", user, access.getFolder()));
- final State state = stateService.create(access);
- return mapper.map(state, StateDTO.class);
+ final String title) throws DefaultException {
+ final Group group = groupManager.findByShortName(groupShortName);
+ final UserSession userSession = getUserSession();
+ final User user = userSession.getUser();
+ final Access access = accessService.getFolderAccess(group, parentFolderId, user, AccessType.EDIT);
+ access.setContentWidthFolderRights(creationService.createContent(title, "", user, access.getFolder()));
+ final State state = stateService.create(access);
+ return mapState(state, user, group);
}
@Authenticated
@Authorizated(accessTypeRequired = AccessType.EDIT)
@Transactional(type = TransactionType.READ_WRITE)
public StateDTO addFolder(final String userHash, final String groupShortName, final Long parentFolderId,
- final String title) throws DefaultException {
- return createFolder(groupShortName, parentFolderId, title);
+ final String title) throws DefaultException {
+ final Group group = groupManager.findByShortName(groupShortName);
+ final UserSession userSession = getUserSession();
+ final User user = userSession.getUser();
+ return mapState(createFolder(groupShortName, parentFolderId, title), user, group);
}
@Authenticated
@Authorizated(accessTypeRequired = AccessType.EDIT)
@Transactional(type = TransactionType.READ_WRITE)
public StateDTO addRoom(final String userHash, final String groupShortName, final Long parentFolderId,
- final String roomName) throws DefaultException {
- final UserSession userSession = getUserSession();
- final String userShortName = userSession.getUser().getShortName();
- final ChatConnection connection = xmppManager.login(userShortName, userSession.getUser().getPassword(),
- userHash);
- xmppManager.createRoom(connection, roomName, userShortName + userHash);
- xmppManager.disconnect(connection);
- try {
- return createFolder(groupShortName, parentFolderId, roomName);
- } catch (final ContentNotFoundException e) {
- xmppManager.destroyRoom(connection, roomName);
- throw new ContentNotFoundException();
- } catch (final AccessViolationException e) {
- xmppManager.destroyRoom(connection, roomName);
- throw new AccessViolationException();
- } catch (final GroupNotFoundException e) {
- xmppManager.destroyRoom(connection, roomName);
- throw new GroupNotFoundException();
- }
+ final String roomName) throws DefaultException {
+ final Group group = groupManager.findByShortName(groupShortName);
+ final UserSession userSession = getUserSession();
+ final User user = userSession.getUser();
+ final String userShortName = user.getShortName();
+ final ChatConnection connection = xmppManager.login(userShortName, userSession.getUser().getPassword(),
+ userHash);
+ xmppManager.createRoom(connection, roomName, userShortName + userHash);
+ xmppManager.disconnect(connection);
+ try {
+ return mapState(createFolder(groupShortName, parentFolderId, roomName), user, group);
+ } catch (final ContentNotFoundException e) {
+ xmppManager.destroyRoom(connection, roomName);
+ throw new ContentNotFoundException();
+ } catch (final AccessViolationException e) {
+ xmppManager.destroyRoom(connection, roomName);
+ throw new AccessViolationException();
+ } catch (final GroupNotFoundException e) {
+ xmppManager.destroyRoom(connection, roomName);
+ throw new GroupNotFoundException();
+ }
}
@Authenticated
@Authorizated(accessTypeRequired = AccessType.ADMIN, checkContent = true)
@Transactional(type = TransactionType.READ_WRITE)
public void delContent(final String userHash, final String groupShortName, final String documentId)
- throws DefaultException {
- final Long contentId = parseId(documentId);
- final UserSession userSession = getUserSession();
- final User user = userSession.getUser();
- contentManager.delContent(user, contentId);
+ throws DefaultException {
+ final Long contentId = parseId(documentId);
+ final UserSession userSession = getUserSession();
+ final User user = userSession.getUser();
+ contentManager.delContent(user, contentId);
}
// Not using @Authorizated because accessService is doing this job and is
@@ -200,225 +211,236 @@
@Authenticated(mandatory = false)
@Transactional(type = TransactionType.READ_ONLY)
public StateDTO getContent(final String userHash, final String groupShortName, final StateToken token)
- throws DefaultException {
- Group defaultGroup;
- final UserSession userSession = getUserSession();
- final User user = userSession.getUser();
- final boolean userIsLoggedIn = userSession.isUserLoggedIn();
- if (userIsLoggedIn) {
- defaultGroup = groupManager.getGroupOfUserWithId(user.getId());
- } else {
- defaultGroup = groupManager.getDefaultGroup();
- }
- Access access;
- try {
- access = accessService.getAccess(user, token, defaultGroup, AccessType.READ);
- } catch (final NoResultException e) {
- throw new ContentNotFoundException();
- } catch (final ToolNotFoundException e) {
- throw new ContentNotFoundException();
- }
- final State state = stateService.create(access);
- if (state.isRateable()) {
- final Long contentId = parseId(state.getDocumentId());
- final Content content = contentManager.find(contentId);
- if (userIsLoggedIn) {
- state.setCurrentUserRate(contentManager.getRateContent(user, content));
- }
- state.setRate(contentManager.getRateAvg(content));
- state.setRateByUsers(contentManager.getRateByUsers(content));
- }
- final Group group = state.getGroup();
- state.setGroupTags(tagManager.getSummaryByGroup(group));
- state.setGroupMembers(socialNetworkManager.find(user, group));
- state.setParticipation(socialNetworkManager.findParticipation(user, group));
- return mapper.map(state, StateDTO.class);
+ throws DefaultException {
+ Group defaultGroup;
+ final UserSession userSession = getUserSession();
+ final User user = userSession.getUser();
+ final boolean userIsLoggedIn = userSession.isUserLoggedIn();
+ if (userIsLoggedIn) {
+ defaultGroup = groupManager.getGroupOfUserWithId(user.getId());
+ } else {
+ defaultGroup = groupManager.getDefaultGroup();
+ }
+ Access access;
+ try {
+ access = accessService.getAccess(user, token, defaultGroup, AccessType.READ);
+ } catch (final NoResultException e) {
+ throw new ContentNotFoundException();
+ } catch (final ToolNotFoundException e) {
+ throw new ContentNotFoundException();
+ }
+ final State state = stateService.create(access);
+ if (state.isRateable()) {
+ final Long contentId = parseId(state.getDocumentId());
+ final Content content = contentManager.find(contentId);
+ if (userIsLoggedIn) {
+ state.setCurrentUserRate(contentManager.getRateContent(user, content));
+ }
+ state.setRate(contentManager.getRateAvg(content));
+ state.setRateByUsers(contentManager.getRateByUsers(content));
+ }
+ final Group group = state.getGroup();
+ state.setGroupTags(tagManager.getSummaryByGroup(group));
+ state.setGroupMembers(socialNetworkManager.find(user, group));
+ state.setParticipation(socialNetworkManager.findParticipation(user, group));
+ return mapState(state, user, group);
}
@Authenticated(mandatory = false)
@Authorizated(accessTypeRequired = AccessType.READ)
@Transactional(type = TransactionType.READ_ONLY)
public List<TagResultDTO> getSummaryTags(final String userHash, final String groupShortName) {
- final Group group = groupManager.findByShortName(groupShortName);
- return getSummaryTags(group);
+ final Group group = groupManager.findByShortName(groupShortName);
+ return getSummaryTags(group);
}
@Authenticated
@Authorizated(accessTypeRequired = AccessType.READ)
@Transactional(type = TransactionType.READ_WRITE)
public CommentDTO markCommentAsAbuse(final String userHash, final String groupShortName, final String documentId,
- final Long commentId) throws DefaultException {
- final UserSession userSession = getUserSession();
- final User informer = userSession.getUser();
- final Long contentId = parseId(documentId);
- Comment comment = commentManager.markAsAbuse(informer, contentId, commentId);
- return mapper.map(comment, CommentDTO.class);
+ final Long commentId) throws DefaultException {
+ final UserSession userSession = getUserSession();
+ final User informer = userSession.getUser();
+ final Long contentId = parseId(documentId);
+ final Comment comment = commentManager.markAsAbuse(informer, contentId, commentId);
+ return mapper.map(comment, CommentDTO.class);
}
@Authenticated
@Authorizated(accessTypeRequired = AccessType.READ, checkContent = true)
@Transactional(type = TransactionType.READ_WRITE)
public void rateContent(final String userHash, final String groupShortName, final String documentId,
- final Double value) throws DefaultException {
- final UserSession userSession = getUserSession();
- final User rater = userSession.getUser();
- final Long contentId = parseId(documentId);
+ final Double value) throws DefaultException {
+ final UserSession userSession = getUserSession();
+ final User rater = userSession.getUser();
+ final Long contentId = parseId(documentId);
- if (userSession.isUserLoggedIn()) {
- contentManager.rateContent(rater, contentId, value);
- } else {
- throw new AccessViolationException();
- }
+ if (userSession.isUserLoggedIn()) {
+ contentManager.rateContent(rater, contentId, value);
+ } else {
+ throw new AccessViolationException();
+ }
}
@Authenticated
@Authorizated(accessTypeRequired = AccessType.EDIT, checkContent = true)
@Transactional(type = TransactionType.READ_WRITE)
public void removeAuthor(final String userHash, final String groupShortName, final String documentId,
- final String authorShortName) throws DefaultException {
- final Long contentId = parseId(documentId);
- final UserSession userSession = getUserSession();
- final User user = userSession.getUser();
- contentManager.removeAuthor(user, contentId, authorShortName);
+ final String authorShortName) throws DefaultException {
+ final Long contentId = parseId(documentId);
+ final UserSession userSession = getUserSession();
+ final User user = userSession.getUser();
+ contentManager.removeAuthor(user, contentId, authorShortName);
}
@Authenticated
@Authorizated(accessTypeRequired = AccessType.EDIT)
@Transactional(type = TransactionType.READ_WRITE)
public String rename(final String userHash, final String groupShortName, final String token, final String newName)
- throws DefaultException {
- String result;
- final UserSession userSession = getUserSession();
- final User user = userSession.getUser();
- final StateToken stateToken = new StateToken(token);
- final Group group = groupManager.findByShortName(groupShortName);
- if (stateToken.isComplete()) {
- try {
- final Content content = accessService.accessToContent(parseId(stateToken.getDocument()), user,
- AccessType.EDIT);
- if (!content.getContainer().getOwner().equals(group)) {
- throw new AccessViolationException();
- }
- } catch (final NoResultException e) {
- throw new AccessViolationException();
- }
- result = renameContent(stateToken.getDocument(), newName);
- } else {
- result = renameFolder(groupShortName, parseId(stateToken.getFolder()), newName);
- }
- return result;
+ throws DefaultException {
+ String result;
+ final UserSession userSession = getUserSession();
+ final User user = userSession.getUser();
+ final StateToken stateToken = new StateToken(token);
+ final Group group = groupManager.findByShortName(groupShortName);
+ if (stateToken.isComplete()) {
+ try {
+ final Content content = accessService.accessToContent(parseId(stateToken.getDocument()), user,
+ AccessType.EDIT);
+ if (!content.getContainer().getOwner().equals(group)) {
+ throw new AccessViolationException();
+ }
+ } catch (final NoResultException e) {
+ throw new AccessViolationException();
+ }
+ result = renameContent(stateToken.getDocument(), newName);
+ } else {
+ result = renameFolder(groupShortName, parseId(stateToken.getFolder()), newName);
+ }
+ return result;
}
@Authenticated
@Authorizated(accessTypeRequired = AccessType.EDIT, checkContent = true)
@Transactional(type = TransactionType.READ_WRITE)
public Integer save(final String userHash, final String groupShortName, final String documentId,
- final String textContent) throws DefaultException {
+ final String textContent) throws DefaultException {
- final Long contentId = parseId(documentId);
- final UserSession userSession = getUserSession();
- final User user = userSession.getUser();
- final Content content = accessService.accessToContent(contentId, user, AccessType.EDIT);
- final Content descriptor = creationService.saveContent(user, content, textContent);
- return descriptor.getVersion();
+ final Long contentId = parseId(documentId);
+ final UserSession userSession = getUserSession();
+ final User user = userSession.getUser();
+ final Content content = accessService.accessToContent(contentId, user, AccessType.EDIT);
+ final Content descriptor = creationService.saveContent(user, content, textContent);
+ return descriptor.getVersion();
}
@Authenticated
@Authorizated(accessTypeRequired = AccessType.EDIT, checkContent = true)
@Transactional(type = TransactionType.READ_WRITE)
public I18nLanguageDTO setLanguage(final String userHash, final String groupShortName, final String documentId,
- final String languageCode) throws DefaultException {
- final Long contentId = parseId(documentId);
- final UserSession userSession = getUserSession();
- final User user = userSession.getUser();
- return mapper.map(contentManager.setLanguage(user, contentId, languageCode), I18nLanguageDTO.class);
+ final String languageCode) throws DefaultException {
+ final Long contentId = parseId(documentId);
+ final UserSession userSession = getUserSession();
+ final User user = userSession.getUser();
+ return mapper.map(contentManager.setLanguage(user, contentId, languageCode), I18nLanguageDTO.class);
}
@Authenticated
@Authorizated(accessTypeRequired = AccessType.EDIT, checkContent = true)
@Transactional(type = TransactionType.READ_WRITE)
public void setPublishedOn(final String userHash, final String groupShortName, final String documentId,
- final Date publishedOn) throws DefaultException {
- final Long contentId = parseId(documentId);
- final UserSession userSession = getUserSession();
- final User user = userSession.getUser();
- contentManager.setPublishedOn(user, contentId, publishedOn);
+ final Date publishedOn) throws DefaultException {
+ final Long contentId = parseId(documentId);
+ final UserSession userSession = getUserSession();
+ final User user = userSession.getUser();
+ contentManager.setPublishedOn(user, contentId, publishedOn);
}
@Authenticated
@Authorizated(accessTypeRequired = AccessType.EDIT, checkContent = true)
@Transactional(type = TransactionType.READ_WRITE)
public List<TagResultDTO> setTags(final String userHash, final String groupShortName, final String documentId,
- final String tags) throws DefaultException {
- final Long contentId = parseId(documentId);
- final UserSession userSession = getUserSession();
- final User user = userSession.getUser();
- final Group group = groupManager.findByShortName(groupShortName);
- contentManager.setTags(user, contentId, tags);
- return getSummaryTags(group);
+ final String tags) throws DefaultException {
+ final Long contentId = parseId(documentId);
+ final UserSession userSession = getUserSession();
+ final User user = userSession.getUser();
+ final Group group = groupManager.findByShortName(groupShortName);
+ contentManager.setTags(user, contentId, tags);
+ return getSummaryTags(group);
}
@Authenticated
@Authorizated(accessTypeRequired = AccessType.READ)
@Transactional(type = TransactionType.READ_WRITE)
public CommentDTO voteComment(final String userHash, final String groupShortName, final String documentId,
- final Long commentId, final boolean votePositive) throws DefaultException {
- final UserSession userSession = getUserSession();
- final User voter = userSession.getUser();
- final Long contentId = parseId(documentId);
- Comment comment = commentManager.vote(voter, contentId, commentId, votePositive);
- return mapper.map(comment, CommentDTO.class);
+ final Long commentId, final boolean votePositive) throws DefaultException {
+ final UserSession userSession = getUserSession();
+ final User voter = userSession.getUser();
+ final Long contentId = parseId(documentId);
+ final Comment comment = commentManager.vote(voter, contentId, commentId, votePositive);
+ return mapper.map(comment, CommentDTO.class);
}
- private StateDTO createFolder(final String groupShortName, final Long parentFolderId, final String title)
- throws DefaultException {
- final UserSession userSession = getUserSession();
- final User user = userSession.getUser();
- final Group group = groupManager.findByShortName(groupShortName);
+ private State createFolder(final String groupShortName, final Long parentFolderId, final String title)
+ throws DefaultException {
+ final UserSession userSession = getUserSession();
+ final User user = userSession.getUser();
+ final Group group = groupManager.findByShortName(groupShortName);
- Access access = accessService.getFolderAccess(group, parentFolderId, user, AccessType.EDIT);
+ Access access = accessService.getFolderAccess(group, parentFolderId, user, AccessType.EDIT);
- final Container container = creationService.createFolder(group, parentFolderId, title, user.getLanguage());
- final String toolName = container.getToolName();
- // Trying not to enter in new folder:
- // final StateToken token = new StateToken(group.getShortName(),
- // toolName, container.getId().toString(), null);
- final StateToken token = new StateToken(group.getShortName(), toolName, parentFolderId.toString(), null);
- access = accessService.getAccess(user, token, group, AccessType.READ);
- final State state = stateService.create(access);
- return mapper.map(state, StateDTO.class);
+ final Container container = creationService.createFolder(group, parentFolderId, title, user.getLanguage());
+ final String toolName = container.getToolName();
+ // Trying not to enter in new folder:
+ // final StateToken token = new StateToken(group.getShortName(),
+ // toolName, container.getId().toString(), null);
+ final StateToken token = new StateToken(group.getShortName(), toolName, parentFolderId.toString(), null);
+ access = accessService.getAccess(user, token, group, AccessType.READ);
+ final State state = stateService.create(access);
+ return state;
}
private List<TagResultDTO> getSummaryTags(final Group group) {
- return mapper.mapList(tagManager.getSummaryByGroup(group), TagResultDTO.class);
+ return mapper.mapList(tagManager.getSummaryByGroup(group), TagResultDTO.class);
}
private UserSession getUserSession() {
- return userSessionProvider.get();
+ return userSessionProvider.get();
}
+ private StateDTO mapState(final State state, final User user, final Group group) {
+ final StateDTO stateDTO = mapper.map(state, StateDTO.class);
+ final AccessLists groupAccesList = group.getSocialNetwork().getAccessLists();
+ for (final ContentDTO siblingDTO : stateDTO.getFolder().getContents()) {
+ final Content sibling = contentManager.find(siblingDTO.getId());
+ final AccessLists lists = sibling.hasAccessList() ? sibling.getAccessLists() : groupAccesList;
+ siblingDTO.setRights(mapper.map(rightsService.get(user, lists), AccessRightsDTO.class));
+ }
+ return stateDTO;
+ }
+
private Long parseId(final String documentId) throws ContentNotFoundException {
- try {
- return new Long(documentId);
- } catch (final NumberFormatException e) {
- throw new ContentNotFoundException();
- }
+ try {
+ return new Long(documentId);
+ } catch (final NumberFormatException e) {
+ throw new ContentNotFoundException();
+ }
}
private String renameContent(final String documentId, final String newName) throws ContentNotFoundException,
- DefaultException {
- final Long contentId = parseId(documentId);
- final UserSession userSession = getUserSession();
- final User user = userSession.getUser();
- return contentManager.renameContent(user, contentId, newName);
+ DefaultException {
+ final Long contentId = parseId(documentId);
+ final UserSession userSession = getUserSession();
+ final User user = userSession.getUser();
+ return contentManager.renameContent(user, contentId, newName);
}
private String renameFolder(final String groupShortName, final Long folderId, final String newName)
- throws DefaultException {
- final Group group = groupManager.findByShortName(groupShortName);
- final UserSession userSession = getUserSession();
- final User user = userSession.getUser();
- final Access folderAccess = accessService.getFolderAccess(group, folderId, user, AccessType.EDIT);
- return containerManager.renameFolder(group, folderAccess.getFolder(), newName);
+ throws DefaultException {
+ final Group group = groupManager.findByShortName(groupShortName);
+ final UserSession userSession = getUserSession();
+ final User user = userSession.getUser();
+ final Access folderAccess = accessService.getFolderAccess(group, folderId, user, AccessType.EDIT);
+ return containerManager.renameFolder(group, folderAccess.getFolder(), newName);
}
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/rpc/GroupRPC.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/rpc/GroupRPC.java 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/rpc/GroupRPC.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -81,7 +81,7 @@
final Group newGroup = groupManager.createGroup(group, user);
final Long defContentId = newGroup.getDefaultContent().getId();
contentManager.setTags(user, defContentId, groupDTO.getTags());
- return new StateToken(newGroup.getDefaultContent().getStateToken());
+ return newGroup.getDefaultContent().getStateToken();
}
private UserSession getUserSession() {
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/state/State.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/state/State.java 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/state/State.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -23,10 +23,12 @@
import java.util.Date;
import java.util.List;
+import org.ourproject.kune.platf.client.dto.StateToken;
import org.ourproject.kune.platf.server.ParticipationData;
import org.ourproject.kune.platf.server.access.AccessRights;
import org.ourproject.kune.platf.server.domain.AccessLists;
import org.ourproject.kune.platf.server.domain.Container;
+import org.ourproject.kune.platf.server.domain.ContentStatus;
import org.ourproject.kune.platf.server.domain.Group;
import org.ourproject.kune.platf.server.domain.I18nLanguage;
import org.ourproject.kune.platf.server.domain.License;
@@ -45,6 +47,7 @@
private AccessRights contentRights;
private AccessRights folderRights;
private AccessRights groupRights;
+ private ContentStatus status;
private boolean isRateable;
private Double rate;
private Integer rateByUsers;
@@ -58,200 +61,217 @@
private List<TagResult> groupTags;
private SocialNetwork groupMembers;
private ParticipationData participation;
+ private StateToken stateToken;
- public SocialNetwork getGroupMembers() {
- return groupMembers;
+ public State() {
}
- public void setGroupMembers(final SocialNetwork groupMembers) {
- this.groupMembers = groupMembers;
+ public AccessLists getAccessLists() {
+ return accessLists;
}
- public ParticipationData getParticipation() {
- return participation;
+ public List<User> getAuthors() {
+ return authors;
}
- public void setParticipation(final ParticipationData participation) {
- this.participation = participation;
+ public String getContent() {
+ return content;
}
- public State() {
+ public AccessRights getContentRights() {
+ return contentRights;
}
- public AccessLists getAccessLists() {
- return accessLists;
+ public Double getCurrentUserRate() {
+ return currentUserRate;
}
- public void setAccessLists(final AccessLists accessLists) {
- this.accessLists = accessLists;
+ public String getDocumentId() {
+ return documentId;
}
- public AccessRights getContentRights() {
- return contentRights;
+ public Container getFolder() {
+ return container;
}
- public String getDocumentId() {
- return documentId;
+ public AccessRights getFolderRights() {
+ return folderRights;
}
- public void setDocumentId(final String docRef) {
- this.documentId = docRef;
+ public Group getGroup() {
+ return group;
}
- public AccessRights getFolderRights() {
- return folderRights;
+ public SocialNetwork getGroupMembers() {
+ return groupMembers;
}
- public void setFolderRights(final AccessRights folderRights) {
- this.folderRights = folderRights;
+ public AccessRights getGroupRights() {
+ return groupRights;
}
- public String getContent() {
- return content;
+ public List<TagResult> getGroupTags() {
+ return groupTags;
}
- public void setContent(final String content) {
- this.content = content;
+ public I18nLanguage getLanguage() {
+ return language;
}
- public String getTitle() {
- return title;
+ public License getLicense() {
+ return license;
}
- public void setTitle(final String title) {
- this.title = title;
+ public ParticipationData getParticipation() {
+ return participation;
}
- public String getToolName() {
- return toolName;
+ public Date getPublishedOn() {
+ return publishedOn;
}
- public void setToolName(final String toolName) {
- this.toolName = toolName;
+ public Double getRate() {
+ return rate;
}
- public Group getGroup() {
- return group;
+ public Integer getRateByUsers() {
+ return rateByUsers;
}
- public void setGroup(final Group group) {
- this.group = group;
+ public StateToken getStateToken() {
+ return stateToken;
}
- public void setContentRights(final AccessRights accessRights) {
- this.contentRights = accessRights;
+ public ContentStatus getStatus() {
+ return status;
}
- public Container getFolder() {
- return container;
+ public String getTags() {
+ return tags;
}
- public void setFolder(final Container container) {
- this.container = container;
+ public String getTitle() {
+ return title;
}
- public Double getRate() {
- return rate;
+ public String getToolName() {
+ return toolName;
}
- public void setRate(final Double rate) {
- if (rate != null) {
- this.rate = rate;
- } else {
- this.rate = 0d;
- }
+ public String getTypeId() {
+ return typeId;
}
- public Integer getRateByUsers() {
- return rateByUsers;
+ public boolean isRateable() {
+ return isRateable;
}
- public void setRateByUsers(final Long rateByUsers) {
- if (rateByUsers != null) {
- this.rateByUsers = rateByUsers.intValue();
- } else {
- this.rateByUsers = 0;
- }
+ public void setAccessLists(final AccessLists accessLists) {
+ this.accessLists = accessLists;
}
- public void setTypeId(final String typeId) {
- this.typeId = typeId;
+ public void setAuthors(final List<User> authors) {
+ this.authors = authors;
}
- public String getTypeId() {
- return typeId;
+ public void setContent(final String content) {
+ this.content = content;
}
- public License getLicense() {
- return license;
+ public void setContentRights(final AccessRights accessRights) {
+ this.contentRights = accessRights;
}
- public void setLicense(final License license) {
- this.license = license;
+ public void setCurrentUserRate(final Double currentUserRate) {
+ this.currentUserRate = currentUserRate;
}
- public AccessRights getGroupRights() {
- return groupRights;
+ public void setDocumentId(final String docRef) {
+ this.documentId = docRef;
}
- public void setGroupRights(final AccessRights groupRights) {
- this.groupRights = groupRights;
+ public void setFolder(final Container container) {
+ this.container = container;
}
- public Double getCurrentUserRate() {
- return currentUserRate;
+ public void setFolderRights(final AccessRights folderRights) {
+ this.folderRights = folderRights;
}
- public void setCurrentUserRate(final Double currentUserRate) {
- this.currentUserRate = currentUserRate;
+ public void setGroup(final Group group) {
+ this.group = group;
}
- public boolean isRateable() {
- return isRateable;
+ public void setGroupMembers(final SocialNetwork groupMembers) {
+ this.groupMembers = groupMembers;
}
- public void setIsRateable(final boolean isRateable) {
- this.isRateable = isRateable;
+ public void setGroupRights(final AccessRights groupRights) {
+ this.groupRights = groupRights;
}
- public I18nLanguage getLanguage() {
- return language;
+ public void setGroupTags(final List<TagResult> groupTags) {
+ this.groupTags = groupTags;
}
+ public void setIsRateable(final boolean isRateable) {
+ this.isRateable = isRateable;
+ }
+
public void setLanguage(final I18nLanguage language) {
- this.language = language;
+ this.language = language;
}
- public Date getPublishedOn() {
- return publishedOn;
+ public void setLicense(final License license) {
+ this.license = license;
}
+ public void setParticipation(final ParticipationData participation) {
+ this.participation = participation;
+ }
+
public void setPublishedOn(final Date publishedOn) {
- this.publishedOn = publishedOn;
+ this.publishedOn = publishedOn;
}
- public List<User> getAuthors() {
- return authors;
+ public void setRate(final Double rate) {
+ if (rate != null) {
+ this.rate = rate;
+ } else {
+ this.rate = 0d;
+ }
}
- public void setAuthors(final List<User> authors) {
- this.authors = authors;
+ public void setRateByUsers(final Long rateByUsers) {
+ if (rateByUsers != null) {
+ this.rateByUsers = rateByUsers.intValue();
+ } else {
+ this.rateByUsers = 0;
+ }
}
- public String getTags() {
- return tags;
+ public void setStateToken(final StateToken stateToken) {
+ this.stateToken = stateToken;
}
+ public void setStatus(final ContentStatus status) {
+ this.status = status;
+ }
+
public void setTags(final String tags) {
- this.tags = tags;
+ this.tags = tags;
}
- public List<TagResult> getGroupTags() {
- return groupTags;
+ public void setTitle(final String title) {
+ this.title = title;
}
- public void setGroupTags(final List<TagResult> groupTags) {
- this.groupTags = groupTags;
+ public void setToolName(final String toolName) {
+ this.toolName = toolName;
}
+ public void setTypeId(final String typeId) {
+ this.typeId = typeId;
+ }
+
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/state/StateServiceDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/state/StateServiceDefault.java 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/state/StateServiceDefault.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -31,45 +31,48 @@
@Singleton
public class StateServiceDefault implements StateService {
public State create(final Access access) {
- final Content content = access.getContent();
- final Container container = content.getContainer();
- final State state = new State();
+ final Content content = access.getContent();
+ final Container container = content.getContainer();
+ final State state = new State();
- final Long documentId = content.getId();
- if (documentId != null) {
- state.setTypeId(content.getTypeId());
- state.setDocumentId(documentId.toString());
- state.setIsRateable(true);
- state.setLanguage(content.getLanguage());
- state.setPublishedOn(content.getPublishedOn());
- state.setAuthors(content.getAuthors());
- state.setTags(content.getTagsAsString());
- } else {
- state.setTypeId(container.getTypeId());
- state.setDocumentId(null);
- state.setIsRateable(false);
- state.setLanguage(container.getLanguage());
- }
- final Revision revision = content.getLastRevision();
- final char[] text = revision.getBody();
- state.setContent(text == null ? null : new String(text));
- if (documentId != null) {
- state.setTitle(revision.getTitle());
- } else {
- state.setTitle(container.getName());
- }
- state.setToolName(container.getToolName());
- state.setGroup(container.getOwner());
- state.setFolder(container);
- state.setAccessLists(access.getContentAccessLists());
- state.setContentRights(access.getContentRights());
- state.setFolderRights(access.getFolderRights());
- state.setGroupRights(access.getGroupRights());
- License contentLicense = content.getLicense();
- if (contentLicense == null) {
- contentLicense = container.getOwner().getDefaultLicense();
- }
- state.setLicense(contentLicense);
- return state;
+ final Long documentId = content.getId();
+ if (documentId != null) {
+ state.setTypeId(content.getTypeId());
+ state.setDocumentId(documentId.toString());
+ state.setIsRateable(true);
+ state.setLanguage(content.getLanguage());
+ state.setPublishedOn(content.getPublishedOn());
+ state.setAuthors(content.getAuthors());
+ state.setTags(content.getTagsAsString());
+ state.setStatus(content.getStatus());
+ state.setStateToken(content.getStateToken());
+ } else {
+ state.setTypeId(container.getTypeId());
+ state.setDocumentId(null);
+ state.setIsRateable(false);
+ state.setLanguage(container.getLanguage());
+ state.setStateToken(container.getStateToken());
+ }
+ final Revision revision = content.getLastRevision();
+ final char[] text = revision.getBody();
+ state.setContent(text == null ? null : new String(text));
+ if (documentId != null) {
+ state.setTitle(revision.getTitle());
+ } else {
+ state.setTitle(container.getName());
+ }
+ state.setToolName(container.getToolName());
+ state.setGroup(container.getOwner());
+ state.setFolder(container);
+ state.setAccessLists(access.getContentAccessLists());
+ state.setContentRights(access.getContentRights());
+ state.setFolderRights(access.getFolderRights());
+ state.setGroupRights(access.getGroupRights());
+ License contentLicense = content.getLicense();
+ if (contentLicense == null) {
+ contentLicense = container.getOwner().getDefaultLicense();
+ }
+ state.setLicense(contentLicense);
+ return state;
}
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/users/UserInfoServiceDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/users/UserInfoServiceDefault.java 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/users/UserInfoServiceDefault.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -62,7 +62,7 @@
final Content defaultContent = userGroup.getDefaultContent();
if (defaultContent != null) {
- info.setHomePage(defaultContent.getStateToken());
+ info.setHomePage(defaultContent.getStateToken().toString());
}
}
return info;
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-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -88,12 +88,14 @@
child.setAllowDrag(item.isDraggable());
child.setAllowDrop(item.isDroppable());
switch (item.getContentStatus()) {
- case publicVisible:
+ case publishedOnline:
child.enable();
break;
- case markForDelection:
+ case inTheDustbin:
+ case rejected:
child.setCls("k-linethrough");
- case nonPublicVisible:
+ case editingInProgress:
+ case submittedForEvaluation:
child.disable();
break;
}
@@ -125,9 +127,6 @@
}
} else {
// the node already created
- if (contextMenus.get(nodeId) == null && item.getActionCollection() != null) {
- createItemMenu(nodeId, item.getActionCollection(), item.getStateToken());
- }
}
}
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-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -163,39 +163,54 @@
}
public void setState(final StateDTO state) {
- final StateToken stateToken = state.getStateToken().clone();
- final String treeId = genId(stateToken);
-
final ContainerDTO container = state.getFolder();
- createTreePath(stateToken, container.getAbsolutePath());
- boolean visible = false;
- AccessRightsDTO rights = null;
+ createTreePath(state.getStateToken(), container.getAbsolutePath(), state.getFolderRights());
- String containerTreeId;
-
if (state.hasDocument()) {
- rights = state.getContentRights();
- visible = rights.isVisible();
- containerTreeId = genId(stateToken.clone().setDocument(null));
+ addItem(state.getTitle(), state.getTypeId(), state.getStatus(), state.getStateToken(), container
+ .getStateToken(), state.getContentRights());
} else {
- rights = state.getFolderRights();
- visible = rights.isVisible();
- final Long folderId = container.getParentFolderId();
- containerTreeId = genId(stateToken.clone().setDocument(null).setFolder(
- folderId == null ? null : folderId.toString()));
+ addItem(container.getName(), container.getTypeId(), ContentStatusDTO.publishedOnline, container
+ .getStateToken(), container.getStateToken().clone().setFolder(container.getParentFolderId()), state
+ .getFolderRights());
}
- // here check deletion mark
+ for (final ContentDTO content : container.getContents()) {
+ addItem(content.getTitle(), content.getTypeId(), content.getStatus(), content.getStateToken(), content
+ .getStateToken().clone().clearDocument(), content.getRights());
+ }
+ for (final ContainerSimpleDTO siblingFolder : container.getChilds()) {
+ addItem(siblingFolder.getName(), siblingFolder.getTypeId(), ContentStatusDTO.publishedOnline, siblingFolder
+ .getStateToken(), siblingFolder.getStateToken().clone()
+ .setFolder(siblingFolder.getParentFolderId()), state.getFolderRights());
+ }
+ view.selectItem(genId(state.getStateToken()));
+ }
+
+ private void addItem(final String title, final String contentTypeId, final ContentStatusDTO status,
+ final StateToken stateToken, final StateToken parentStateToken, final AccessRightsDTO rights) {
final ActionCollection<StateToken> topActions = new ActionCollection<StateToken>();
final ActionCollection<StateToken> itemActions = new ActionCollection<StateToken>();
final ActionCollection<StateToken> bottomActions = new ActionCollection<StateToken>();
+ createItemActions(rights, contentTypeId, topActions, itemActions, bottomActions);
+
+ view.setTopActions(stateToken, topActions);
+ view.setBottomActions(stateToken, bottomActions);
+ final ContextNavigatorItem item = new ContextNavigatorItem(genId(stateToken), genId(parentStateToken),
+ getContentTypeIcon(contentTypeId), title, status, stateToken, isDraggable(contentTypeId, rights
+ .isAdministrable()), isDroppable(contentTypeId, rights.isAdministrable()), itemActions);
+ view.addItem(item);
+ }
+
+ private void createItemActions(final AccessRightsDTO rights, final String contentTypeId,
+ final ActionCollection<StateToken> topActions, final ActionCollection<StateToken> itemActions,
+ final ActionCollection<StateToken> bottomActions) {
boolean add = false;
- final String contentId = state.getTypeId();
- for (final ActionDescriptor<StateToken> action : actions.get(contentId)) {
+ for (final ActionDescriptor<StateToken> action : actions.get(contentTypeId)) {
switch (action.getAccessRol()) {
case Administrator:
add = rights.isAdministrable();
@@ -225,64 +240,18 @@
}
}
}
-
- view.setTopActions(stateToken, topActions);
- view.setBottomActions(stateToken, bottomActions);
-
- final ContextNavigatorItem item = new ContextNavigatorItem(treeId, containerTreeId,
- getContentTypeIcon(contentId), state.getTitle(), visible ? ContentStatusDTO.publicVisible
- : ContentStatusDTO.nonPublicVisible, stateToken, isDraggable(contentId, rights
- .isAdministrable()), isDroppable(contentId, rights.isAdministrable()), itemActions);
- view.addItem(item);
-
- for (final ContentDTO content : container.getContents()) {
- final StateToken siblingToken = stateToken.clone().setDocument(content.getId().toString());
- final StateToken siblingParentToken = stateToken.clone().setDocument(null);
- // TODO: rights not correct
- final String contentTypeId = content.getTypeId();
- final ContextNavigatorItem sibling = new ContextNavigatorItem(genId(siblingToken),
- genId(siblingParentToken), getContentTypeIcon(contentTypeId), content.getTitle(),
- ContentStatusDTO.publicVisible, siblingToken, isDraggable(contentTypeId, rights.isAdministrable()),
- isDroppable(contentTypeId, rights.isAdministrable()), null);
- view.addItem(sibling);
-
- }
-
- for (final ContainerDTO siblingFolder : container.getChilds()) {
- final StateToken siblingToken = stateToken.clone().setDocument(null).setFolder(
- siblingFolder.getId().toString());
- final StateToken siblingParentToken = stateToken.clone().setDocument(null).setFolder(
- siblingFolder.getParentFolderId().toString());
- // TODO: rights not correct
- final String containerTypeId = container.getTypeId();
- final ContextNavigatorItem sibling = new ContextNavigatorItem(genId(siblingToken),
- genId(siblingParentToken), getContentTypeIcon(containerTypeId), siblingFolder.getName(),
- ContentStatusDTO.publicVisible, siblingToken,
- isDraggable(containerTypeId, rights.isAdministrable()), isDroppable(containerTypeId, rights
- .isAdministrable()), null);
- view.addItem(sibling);
- }
- view.selectItem(treeId);
}
- private void addItem(final String title, final String contentTypeId, final StateToken token,
+ private void createTreePath(final StateToken state, final ContainerSimpleDTO[] absolutePath,
final AccessRightsDTO rights) {
-
- }
-
- private void createTreePath(final StateToken state, final ContainerSimpleDTO[] absolutePath) {
for (int i = 0; i < absolutePath.length; i++) {
final ContainerSimpleDTO folder = absolutePath[i];
- final String parentFolderId = folder.getParentFolderId() == null ? null : folder.getParentFolderId()
- .toString();
- final StateToken folderStateToken = state.clone().setDocument(null).setFolder(folder.getId().toString());
- final StateToken parentStateToken = state.clone().setDocument(null).setFolder(parentFolderId);
+ final StateToken folderStateToken = folder.getStateToken();
+ final StateToken parentStateToken = state.clone().clearDocument().setFolder(folder.getParentFolderId());
+
if (folder.getParentFolderId() != null) {
- // Bad rights, draggable/droppable
- final ContextNavigatorItem parent = new ContextNavigatorItem(genId(folderStateToken),
- genId(parentStateToken), getContentTypeIcon(folder.getTypeId()), folder.getName(),
- ContentStatusDTO.publicVisible, folderStateToken, false, true, null);
- view.addItem(parent);
+ addItem(folder.getName(), folder.getTypeId(), ContentStatusDTO.publishedOnline, folderStateToken,
+ parentStateToken, rights);
} else {
// create root folder
view.setRootItem(genId(folderStateToken), i18n.t("contents"), folderStateToken);
Modified: trunk/src/main/resources/dozerBeanMapping.xml
===================================================================
--- trunk/src/main/resources/dozerBeanMapping.xml 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/main/resources/dozerBeanMapping.xml 2008-09-12 08:06:29 UTC (rev 867)
@@ -102,7 +102,6 @@
<field>
<a>authors</a>
<b>authors</b>
-
<a-hint>
org.ourproject.kune.platf.client.dto.UserSimpleDTO
</a-hint>
@@ -114,13 +113,30 @@
<a-hint>org.ourproject.kune.platf.client.dto.TagResultDTO</a-hint>
<b-hint>org.ourproject.kune.platf.server.domain.TagResult</b-hint>
</field>
-
</mapping>
+
+ <mapping>
+ <class-a>org.ourproject.kune.platf.client.dto.StateToken</class-a>
+ <class-b>org.ourproject.kune.platf.client.dto.StateToken</class-b>
+ <field>
+ <a>encoded</a>
+ <b>encoded</b>
+ </field>
+ </mapping>
<mapping>
<class-a>org.ourproject.kune.platf.client.dto.LicenseDTO</class-a>
<class-b>org.ourproject.kune.platf.server.domain.License</class-b>
</mapping>
+
+ <mapping>
+ <class-a>org.ourproject.kune.platf.client.dto.ContainerSimpleDTO</class-a>
+ <class-b>org.ourproject.kune.platf.server.domain.Container</class-b>
+ <field>
+ <a get-method="getStateToken">stateToken</a>
+ <b>stateToken</b>
+ </field>
+ </mapping>
<mapping>
<class-a>org.ourproject.kune.platf.client.dto.ContentDTO</class-a>
@@ -129,6 +145,10 @@
<a>title</a>
<b>lastRevision.title</b>
</field>
+ <field>
+ <a get-method="getStateToken">stateToken</a>
+ <b>stateToken</b>
+ </field>
</mapping>
<mapping type="one-way">
@@ -143,7 +163,7 @@
<b>shortName</b>
</field>
<field>
- <a get-method="getStateToken">link</a>
+ <a get-method="getStateTokenEncoded">link</a>
<b>link</b>
</field>
</mapping>
@@ -170,9 +190,14 @@
<field>
<a>childs</a>
<b>childs</b>
- <a-hint>org.ourproject.kune.platf.client.dto.ContainerDTO</a-hint>
+ <a-hint>org.ourproject.kune.platf.client.dto.ContainerSimpleDTO</a-hint>
<b-hint>org.ourproject.kune.platf.server.domain.Container</b-hint>
</field>
+
+ <field>
+ <a get-method="getStateToken">stateToken</a>
+ <b>stateToken</b>
+ </field>
</mapping>
<mapping>
@@ -292,5 +317,15 @@
<class-a>org.ourproject.kune.platf.client.dto.ChatUserParamsDTO</class-a>
<class-b>org.ourproject.kune.platf.server.domain.ChatUserParams</class-b>
</mapping>
-
+
+ <mapping>
+ <class-a>org.ourproject.kune.platf.client.dto.ContentStatusDTO</class-a>
+ <class-b>org.ourproject.kune.platf.server.domain.ContentStatus</class-b>
+ </mapping>
+
+ <mapping>
+ <class-a>org.ourproject.kune.platf.client.dto.AccessRolDTO</class-a>
+ <class-b>org.ourproject.kune.platf.server.access.AccessRol</class-b>
+ </mapping>
+
</mappings>
\ No newline at end of file
Modified: trunk/src/test/java/org/ourproject/kune/platf/client/state/StateTokenTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/client/state/StateTokenTest.java 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/state/StateTokenTest.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -1,5 +1,7 @@
package org.ourproject.kune.platf.client.state;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import org.junit.Test;
@@ -9,10 +11,31 @@
@Test
public void checkAllEmpty() {
- StateToken token = new StateToken("");
+ final StateToken token = new StateToken("");
assertNull(token.getGroup());
assertNull(token.getTool());
assertNull(token.getFolder());
assertNull(token.getDocument());
}
+
+ @Test
+ public void checkEquals() {
+ final StateToken token1 = new StateToken("abc", "da", "1", "1");
+ final StateToken token2 = new StateToken("abc", "da", "1", "1");
+ assertEquals(token1, token2);
+ }
+
+ @Test
+ public void checkEqualsEncoded() {
+ final StateToken token1 = new StateToken("abc.da.1.1");
+ final StateToken token2 = new StateToken("abc.da.1.1");
+ assertEquals(token1, token2);
+ }
+
+ @Test
+ public void checkNoEquals() {
+ final StateToken token1 = new StateToken("abc", "da", "1", "1");
+ final StateToken token2 = new StateToken("abc", "da", 1l);
+ assertFalse(token1.equals(token2));
+ }
}
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-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceAddTest.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -9,6 +9,7 @@
import org.junit.Test;
import org.ourproject.kune.platf.client.dto.AccessRightsDTO;
import org.ourproject.kune.platf.client.dto.ContainerDTO;
+import org.ourproject.kune.platf.client.dto.ContainerSimpleDTO;
import org.ourproject.kune.platf.client.dto.ContentDTO;
import org.ourproject.kune.platf.client.dto.StateDTO;
import org.ourproject.kune.platf.client.dto.StateToken;
@@ -68,8 +69,7 @@
assertNotNull(newState);
final ContainerDTO parentAgain = getDefaultContent().getFolder();
- final ContainerDTO child = parentAgain.getChilds().get(0);
- assertEquals(parent.getAbsolutePath().length + 1, child.getAbsolutePath().length);
+ final ContainerSimpleDTO child = parentAgain.getChilds().get(0);
assertEquals(parent.getId(), child.getParentFolderId());
assertEquals(parent.getId(), parentAgain.getId());
Modified: trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceGetTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceGetTest.java 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceGetTest.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -67,8 +67,7 @@
@Test(expected = ContentNotFoundException.class)
public void nonExistentContent4() throws Exception {
final StateDTO stateDTO = getDefaultContent();
- stateDTO.setDocumentId("foofoo");
- contentService.getContent(null, groupName, stateDTO.getStateToken());
+ contentService.getContent(null, groupName, stateDTO.getStateToken().clone().setDocument("dadaas"));
}
@Test(expected = ContentNotFoundException.class)
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-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceVariousTest.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -7,6 +7,7 @@
import org.junit.Before;
import org.junit.Test;
import org.ourproject.kune.platf.client.dto.ContainerDTO;
+import org.ourproject.kune.platf.client.dto.ContainerSimpleDTO;
import org.ourproject.kune.platf.client.dto.StateDTO;
import org.ourproject.kune.platf.client.dto.StateToken;
import org.ourproject.kune.platf.client.dto.TagResultDTO;
@@ -65,7 +66,7 @@
String newTitle = "folder new name";
final StateDTO newState = contentService.addFolder(session.getHash(), groupShortName, folder.getId(), oldTitle);
- final ContainerDTO newFolder = newState.getFolder().getChilds().get(0);
+ final ContainerSimpleDTO newFolder = newState.getFolder().getChilds().get(0);
assertEquals(oldTitle, newFolder.getName());
@@ -166,7 +167,7 @@
String newTitle = "folder new name";
final StateDTO newState = contentService.addFolder(session.getHash(), groupShortName, folder.getId(), oldTitle);
- final ContainerDTO newFolder = newState.getFolder().getChilds().get(0);
+ final ContainerSimpleDTO newFolder = newState.getFolder().getChilds().get(0);
assertEquals(oldTitle, newFolder.getName());
Modified: trunk/src/test/java/org/ourproject/kune/platf/server/mapper/MapperTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/server/mapper/MapperTest.java 2008-09-10 04:51:49 UTC (rev 866)
+++ trunk/src/test/java/org/ourproject/kune/platf/server/mapper/MapperTest.java 2008-09-12 08:06:29 UTC (rev 867)
@@ -19,6 +19,7 @@
import org.ourproject.kune.platf.client.dto.LicenseDTO;
import org.ourproject.kune.platf.client.dto.LinkDTO;
import org.ourproject.kune.platf.client.dto.StateDTO;
+import org.ourproject.kune.platf.client.dto.StateToken;
import org.ourproject.kune.platf.server.TestDomainHelper;
import org.ourproject.kune.platf.server.TestHelper;
import org.ourproject.kune.platf.server.access.AccessRights;
@@ -37,6 +38,8 @@
import com.google.inject.Inject;
public class MapperTest {
+ private static final String TESTTOOL = "docs";
+ private static final String TESTGROUPSHORTNAME = "grouptest";
@Inject
Mapper mapper;
@Inject
@@ -49,7 +52,7 @@
@Test
public void testCommentMapper() {
- final Content d = createTestContent();
+ final Content d = createDefContent();
final Comment comment = new Comment();
comment.setContent(d);
comment.setText("Some text");
@@ -84,24 +87,23 @@
@Test
public void testContentDescriptorMapping() {
- final Content d = new Content();
- d.setId(1l);
- final Revision revision = new Revision(d);
- revision.setTitle("title");
- d.addRevision(revision);
+ final Content d = createDefContent();
+ final StateToken expectedToken = new StateToken(TESTGROUPSHORTNAME, TESTTOOL, "1", "1");
+ assertEquals(expectedToken, d.getStateToken());
final ContentDTO dto = mapper.map(d, ContentDTO.class);
assertEquals(1, (long) dto.getId());
assertEquals("title", dto.getTitle());
+ assertEquals(expectedToken, dto.getStateToken());
}
@Test
public void testContentDescriptorToLinkMapping() {
- final Content d = createTestContent();
+ final Content d = createDefContent();
final LinkDTO dto = mapper.map(d, LinkDTO.class);
assertEquals("title", dto.getLongName());
- assertEquals("grouptest", dto.getShortName());
+ assertEquals(TESTGROUPSHORTNAME, dto.getShortName());
assertEquals("grouptest.docs.1.1", dto.getLink());
}
@@ -131,13 +133,15 @@
@Test
public void testFolderMapping() {
- final Container container = new Container();
- container.addChild(new Container());
- container.addChild(new Container());
- container.addContent(new Content());
- container.addContent(new Content());
- container.addContent(new Content());
- final Container containerChild = new Container();
+ final Container container = createDefContainer();
+ final StateToken expectedToken = new StateToken(TESTGROUPSHORTNAME, TESTTOOL, 1l);
+ assertEquals(expectedToken, container.getStateToken());
+ container.addChild(createDefContainer());
+ container.addChild(createDefContainer());
+ container.addContent(createDefContent());
+ container.addContent(createDefContent());
+ container.addContent(createDefContent());
+ final Container containerChild = createDefContainer();
container.addChild(containerChild);
final List<Container> absolutePathChild = new ArrayList<Container>();
absolutePathChild.add(container);
@@ -147,7 +151,11 @@
assertEquals(3, dto.getChilds().size());
assertEquals(3, dto.getContents().size());
assertTrue(dto.getContents().get(0) instanceof ContentDTO);
- assertTrue(dto.getChilds().get(0) instanceof ContainerDTO);
+ assertTrue(dto.getChilds().get(0) instanceof ContainerSimpleDTO);
+ assertEquals(new StateToken(TESTGROUPSHORTNAME, TESTTOOL), dto.getChilds().get(0).getStateToken().clone()
+ .clearFolder());
+ assertEquals(expectedToken, dto.getContents().get(0).getStateToken().clone().clearDocument());
+ assertEquals(expectedToken, dto.getStateToken());
final ContainerDTO dtoChild = mapper.map(containerChild, ContainerDTO.class);
assertTrue(dtoChild.getAbsolutePath()[0] instanceof ContainerSimpleDTO);
@@ -200,6 +208,17 @@
}
@Test
+ public void testStateTokenInStateMap() {
+ final StateToken stateToken = new StateToken(TESTGROUPSHORTNAME, TESTTOOL, "1", "2");
+ final StateToken stateTokenMapped = mapper.map(stateToken, StateToken.class);
+ assertEquals(stateToken, stateTokenMapped);
+ final State state = new State();
+ state.setStateToken(stateToken);
+ final StateDTO stateDTO = mapper.map(state, StateDTO.class);
+ assertEquals(stateToken, stateDTO.getStateToken());
+ }
+
+ @Test
public void testUserToLinkMappping() {
final User user = new User("shortName", "longName", "", "", null, null, null);
final LinkDTO dto = mapper.map(user, LinkDTO.class);
@@ -232,13 +251,21 @@
}
}
- private Content createTestContent() {
- final Group group = new Group("grouptest", "This is a group Test");
+ private Container createDefContainer() {
+ return createDefContainer(createDeGroup());
+ }
+
+ private Container createDefContainer(final Group group) {
final Container container = new Container();
container.setId(1l);
- container.setToolName("docs");
+ container.setToolName(TESTTOOL);
container.setOwner(group);
container.setName("folder");
+ return container;
+ }
+
+ private Content createDefContent() {
+ final Container container = createDefContainer(createDeGroup());
final Content d = new Content();
d.setId(1l);
final Revision revision = new Revision(d);
@@ -247,4 +274,9 @@
d.setContainer(container);
return d;
}
+
+ private Group createDeGroup() {
+ final Group group = new Group(TESTGROUPSHORTNAME, "This is a group Test");
+ return group;
+ }
}
More information about the kune-commits
mailing list