[kune-commits] r870 - in trunk/src:
main/java/org/ourproject/kune/docs/client
main/java/org/ourproject/kune/platf/server/access
main/java/org/ourproject/kune/platf/server/rpc
main/java/org/ourproject/kune/platf/server/state
main/java/org/ourproject/kune/workspace/client/ctxnav
test/java/org/ourproject/kune/platf/integration/content
vjrj
vjrj at ourproject.org
Sat Sep 13 12:27:27 CEST 2008
Author: vjrj
Date: 2008-09-13 12:27:22 +0200 (Sat, 13 Sep 2008)
New Revision: 870
Modified:
trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java
trunk/src/main/java/org/ourproject/kune/platf/server/access/Access.java
trunk/src/main/java/org/ourproject/kune/platf/server/access/AccessServiceDefault.java
trunk/src/main/java/org/ourproject/kune/platf/server/rpc/ContentRPC.java
trunk/src/main/java/org/ourproject/kune/platf/server/state/StateServiceDefault.java
trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java
trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceAddTest.java
Log:
some Access fixes
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-13 03:32:44 UTC (rev 869)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java 2008-09-13 10:27:22 UTC (rev 870)
@@ -104,7 +104,6 @@
public void onSuccess(final StateDTO state) {
contextNavigator.setState(state);
stateManager.setRetrievedState(state);
- stateManager.reload();
contextNavigator.editItem(state.getStateToken());
}
});
@@ -124,7 +123,6 @@
public void onSuccess(final StateDTO state) {
contextNavigator.setState(state);
stateManager.setRetrievedState(state);
- stateManager.reload();
contextNavigator.editItem(state.getStateToken());
}
});
@@ -186,7 +184,6 @@
public void onEvent(StateToken stateToken) {
stateManager.reload();
contextNavigator.selectItem(stateToken);
-
}
});
refresh.setIconUrl("images/nav/refresh.png");
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/access/Access.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/access/Access.java 2008-09-13 03:32:44 UTC (rev 869)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/access/Access.java 2008-09-13 10:27:22 UTC (rev 870)
@@ -40,21 +40,6 @@
setFolder(container);
}
- public Container getFolder() {
- return container;
- }
-
- public void setContent(final Content descriptor) {
- this.content = descriptor;
- contentAccessLists = descriptor != null ? getContentAccessList(descriptor) : null;
- }
-
- public void setFolder(final Container container) {
- this.container = container;
- folderAccessLists = container != null ? getFolderAccessLists(container) : null;
- groupAccessLists = folderAccessLists;
- }
-
public Content getContent() {
return content;
}
@@ -63,26 +48,47 @@
return contentAccessLists;
}
- public AccessLists getFolderAccessLists() {
- return folderAccessLists;
+ public AccessRights getContentRights() {
+ return contentRights;
}
- public AccessLists getGroupAccessLists() {
- return groupAccessLists;
+ public Container getFolder() {
+ return container;
}
- public AccessRights getContentRights() {
- return contentRights;
+ public AccessLists getFolderAccessLists() {
+ return folderAccessLists;
}
public AccessRights getFolderRights() {
return folderRights;
}
+ public AccessLists getGroupAccessLists() {
+ return groupAccessLists;
+ }
+
public AccessRights getGroupRights() {
return groupRights;
}
+ public boolean hasContentRights() {
+ return contentRights != null;
+ }
+
+ public boolean hasFolderRights() {
+ return folderRights != null;
+ }
+
+ public boolean hasGroupRights() {
+ return groupRights != null;
+ }
+
+ public void setContent(final Content descriptor) {
+ this.content = descriptor;
+ contentAccessLists = descriptor != null ? getContentAccessList(descriptor) : null;
+ }
+
public void setContentRights(final AccessRights accessRights) {
this.contentRights = accessRights;
if (equalsAccessLists()) {
@@ -90,6 +96,17 @@
}
}
+ public void setContentWidthFolderRights(final Content content) {
+ setContent(content);
+ this.contentRights = folderRights;
+ }
+
+ public void setFolder(final Container container) {
+ this.container = container;
+ folderAccessLists = container != null ? getFolderAccessLists(container) : null;
+ groupAccessLists = folderAccessLists;
+ }
+
public void setFolderRights(final AccessRights accessRights) {
this.folderRights = accessRights;
if (equalsAccessLists()) {
@@ -101,18 +118,6 @@
this.groupRights = accessRights;
}
- public boolean hasContentRights() {
- return contentRights != null;
- }
-
- public boolean hasFolderRights() {
- return folderRights != null;
- }
-
- public boolean hasGroupRights() {
- return groupRights != null;
- }
-
private boolean equalsAccessLists() {
if (contentAccessLists == folderAccessLists) {
return true;
@@ -128,7 +133,7 @@
if (descriptor.hasAccessList()) {
accessLists = descriptor.getAccessLists();
} else {
- SocialNetwork socialNetwork = descriptor.getContainer().getOwner().getSocialNetwork();
+ final SocialNetwork socialNetwork = descriptor.getContainer().getOwner().getSocialNetwork();
accessLists = socialNetwork.getAccessLists();
}
return accessLists;
@@ -138,9 +143,4 @@
return container.getOwner().getSocialNetwork().getAccessLists();
}
- public void setContentWidthFolderRights(final Content content) {
- this.content = content;
- this.contentRights = folderRights;
- }
-
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/access/AccessServiceDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/access/AccessServiceDefault.java 2008-09-13 03:32:44 UTC (rev 869)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/access/AccessServiceDefault.java 2008-09-13 10:27:22 UTC (rev 870)
@@ -79,6 +79,7 @@
}
final Access access = new Access(null, folder);
addFolderRights(access, user);
+ addGroupRights(access, user);
return check(access, access.getFolderRights(), accessType);
}
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-13 03:32:44 UTC (rev 869)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/rpc/ContentRPC.java 2008-09-13 10:27:22 UTC (rev 870)
@@ -150,9 +150,11 @@
final Group group = groupManager.findByShortName(groupShortName);
final UserSession userSession = getUserSession();
final User user = userSession.getUser();
+ final boolean userIsLoggedIn = userSession.isUserLoggedIn();
final Access access = accessService.getFolderAccess(group, parentFolderId, user, AccessType.EDIT);
access.setContentWidthFolderRights(creationService.createContent(title, "", user, access.getFolder()));
final State state = stateService.create(access);
+ completeState(user, userIsLoggedIn, group, state);
return mapState(state, user, group);
}
@@ -164,7 +166,10 @@
final Group group = groupManager.findByShortName(groupShortName);
final UserSession userSession = getUserSession();
final User user = userSession.getUser();
- return mapState(createFolder(groupShortName, parentFolderId, title), user, group);
+ final boolean userIsLoggedIn = userSession.isUserLoggedIn();
+ final State state = createFolder(groupShortName, parentFolderId, title);
+ completeState(user, userIsLoggedIn, group, state);
+ return mapState(state, user, group);
}
@Authenticated
@@ -175,13 +180,16 @@
final Group group = groupManager.findByShortName(groupShortName);
final UserSession userSession = getUserSession();
final User user = userSession.getUser();
+ final boolean userIsLoggedIn = userSession.isUserLoggedIn();
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);
+ final State state = createFolder(groupShortName, parentFolderId, roomName);
+ completeState(user, userIsLoggedIn, group, state);
+ return mapState(state, user, group);
} catch (final ContentNotFoundException e) {
xmppManager.destroyRoom(connection, roomName);
throw new ContentNotFoundException();
@@ -230,19 +238,8 @@
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));
+ completeState(user, userIsLoggedIn, group, state);
return mapState(state, user, group);
}
@@ -381,6 +378,22 @@
return mapper.map(comment, CommentDTO.class);
}
+ private void completeState(final User user, final boolean userIsLoggedIn, final Group group, final State state) {
+ 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));
+ }
+
+ state.setGroupTags(tagManager.getSummaryByGroup(group));
+ state.setGroupMembers(socialNetworkManager.find(user, group));
+ state.setParticipation(socialNetworkManager.findParticipation(user, group));
+ }
+
private State createFolder(final String groupShortName, final Long parentFolderId, final String title)
throws DefaultException {
final UserSession userSession = getUserSession();
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-13 03:32:44 UTC (rev 869)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/state/StateServiceDefault.java 2008-09-13 10:27:22 UTC (rev 870)
@@ -30,6 +30,7 @@
@Singleton
public class StateServiceDefault implements StateService {
+
public State create(final Access access) {
final Content content = access.getContent();
final Container container = content.getContainer();
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-13 03:32:44 UTC (rev 869)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java 2008-09-13 10:27:22 UTC (rev 870)
@@ -205,7 +205,9 @@
final TreeNode item = getNode(id);
if (item != null) {
item.select();
- // Errore item.ensureVisible();
+ if (item.getParentNode() != null) {
+ item.ensureVisible();
+ }
if (item.getChildNodes().length > 0) {
item.expand();
}
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-13 03:32:44 UTC (rev 869)
+++ trunk/src/test/java/org/ourproject/kune/platf/integration/content/ContentServiceAddTest.java 2008-09-13 10:27:22 UTC (rev 870)
@@ -41,7 +41,8 @@
defaultContent = getDefaultContent();
assertEquals(1, defaultContent.getFolder().getContents().size());
final AccessRightsDTO cntRights = defaultContent.getContentRights();
- final AccessRightsDTO ctxRight = defaultContent.getFolderRights();
+ final AccessRightsDTO ctxRights = defaultContent.getFolderRights();
+ final AccessRightsDTO groupRights = defaultContent.getGroupRights();
final String title = "New Content Title";
final StateDTO added = contentService.addContent(session.getHash(), groupName, defaultContent.getFolder()
@@ -51,12 +52,17 @@
assertEquals(title, added.getTitle());
assertEquals(2, contents.size());
assertEquals(cntRights, added.getContentRights());
- assertEquals(ctxRight, added.getFolderRights());
+ assertEquals(ctxRights, added.getFolderRights());
+ assertEquals(groupRights, added.getGroupRights());
+ assertNotNull(added.getGroupMembers());
+ assertNotNull(added.getParticipation());
+ assertNotNull(added.getAccessLists());
final StateToken newState = added.getStateToken();
final StateDTO sameAgain = contentService.getContent(session.getHash(), groupName, newState);
assertNotNull(sameAgain);
assertEquals(2, sameAgain.getFolder().getContents().size());
+
}
@Test
@@ -67,6 +73,9 @@
final String title = "folder name";
final StateDTO newState = contentService.addFolder(session.getHash(), groupName, parent.getId(), title);
assertNotNull(newState);
+ assertNotNull(newState.getGroupMembers());
+ assertNotNull(newState.getParticipation());
+ assertNotNull(newState.getAccessLists());
final ContainerDTO parentAgain = getDefaultContent().getFolder();
final ContainerSimpleDTO child = parentAgain.getChilds().get(0);
More information about the kune-commits
mailing list