[kune-commits] r924 - in trunk/src/main/java/org/ourproject/kune: platf/server/content platf/server/init platf/server/manager platf/server/manager/impl platf/server/rpc platf/server/state workspace/client/nohomepage

vjrj vjrj at ourproject.org
Fri Oct 24 12:01:01 CEST 2008


Author: vjrj
Date: 2008-10-24 12:00:58 +0200 (Fri, 24 Oct 2008)
New Revision: 924

Modified:
   trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManager.java
   trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManagerDefault.java
   trunk/src/main/java/org/ourproject/kune/platf/server/content/CreationServiceDefault.java
   trunk/src/main/java/org/ourproject/kune/platf/server/init/DatabaseInitializer.java
   trunk/src/main/java/org/ourproject/kune/platf/server/manager/GroupManager.java
   trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/GroupManagerDefault.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/nohomepage/NoHomePagePanel.java
Log:
Complete - task Tools must me optional and User/Group creation must reflect this 


Modified: trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManager.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManager.java	2008-10-24 01:37:05 UTC (rev 923)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManager.java	2008-10-24 10:00:58 UTC (rev 924)
@@ -70,7 +70,7 @@
 
     String renameContent(User user, Long contentId, String newName) throws DefaultException;
 
-    Content save(User editor, Content descriptor, String content);
+    Content save(User editor, Content content, String body);
 
     SearchResult<Content> search(String search);
 

Modified: trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManagerDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManagerDefault.java	2008-10-24 01:37:05 UTC (rev 923)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/content/ContentManagerDefault.java	2008-10-24 10:00:58 UTC (rev 924)
@@ -145,7 +145,6 @@
             oldRate.setValue(value);
             super.persist(oldRate, Rate.class);
         }
-
     }
 
     public void removeAuthor(final User user, final Long contentId, final String authorShortName)
@@ -164,13 +163,13 @@
         return newTitle;
     }
 
-    public Content save(final User editor, final Content descriptor, final String content) {
-        final Revision revision = new Revision(descriptor);
+    public Content save(final User editor, final Content content, final String body) {
+        final Revision revision = new Revision(content);
         revision.setEditor(editor);
-        revision.setTitle(descriptor.getTitle());
-        revision.setBody(content);
-        descriptor.addRevision(revision);
-        return persist(descriptor);
+        revision.setTitle(content.getTitle());
+        revision.setBody(body);
+        content.addRevision(revision);
+        return persist(content);
     }
 
     public SearchResult<Content> search(final String search) {

Modified: trunk/src/main/java/org/ourproject/kune/platf/server/content/CreationServiceDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/content/CreationServiceDefault.java	2008-10-24 01:37:05 UTC (rev 923)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/content/CreationServiceDefault.java	2008-10-24 10:00:58 UTC (rev 924)
@@ -79,8 +79,8 @@
         return child;
     }
 
-    public Content saveContent(final User editor, final Content descriptor, final String content) {
-        return contentManager.save(editor, descriptor, content);
+    public Content saveContent(final User editor, final Content content, final String body) {
+        return contentManager.save(editor, content, body);
     }
 
 }

Modified: trunk/src/main/java/org/ourproject/kune/platf/server/init/DatabaseInitializer.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/init/DatabaseInitializer.java	2008-10-24 01:37:05 UTC (rev 923)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/init/DatabaseInitializer.java	2008-10-24 10:00:58 UTC (rev 924)
@@ -107,7 +107,7 @@
 
     public void initConditional() throws Exception {
         try {
-            groupManager.getDefaultGroup();
+            groupManager.getSiteDefaultGroup();
         } catch (final NoResultException e) {
             initDatabase();
         }

Modified: trunk/src/main/java/org/ourproject/kune/platf/server/manager/GroupManager.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/manager/GroupManager.java	2008-10-24 01:37:05 UTC (rev 923)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/GroupManager.java	2008-10-24 10:00:58 UTC (rev 924)
@@ -69,7 +69,7 @@
 
     List<String> findEnabledTools(Long id);
 
-    Group getDefaultGroup();
+    Group getSiteDefaultGroup();
 
     /**
      * IMPORTANT: returns null if userId is null

Modified: trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/GroupManagerDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/GroupManagerDefault.java	2008-10-24 01:37:05 UTC (rev 923)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/GroupManagerDefault.java	2008-10-24 10:00:58 UTC (rev 924)
@@ -179,7 +179,7 @@
         return finder.findEnabledTools(id);
     }
 
-    public Group getDefaultGroup() {
+    public Group getSiteDefaultGroup() {
         final String shortName = properties.getDefaultSiteShortName();
         return findByShortName(shortName);
     }

Modified: trunk/src/main/java/org/ourproject/kune/platf/server/rpc/ContentRPC.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/rpc/ContentRPC.java	2008-10-24 01:37:05 UTC (rev 923)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/rpc/ContentRPC.java	2008-10-24 10:00:58 UTC (rev 924)
@@ -241,9 +241,6 @@
         contentManager.delContent(user, contentId);
     }
 
-    // Not using @Authorizated because accessService is doing this job and is
-    // more complex than other access checks (we use getContent to get default
-    // contents for instance)
     @Authenticated(mandatory = false)
     @Transactional(type = TransactionType.READ_ONLY)
     public StateAbstractDTO getContent(final String userHash, final StateToken token) throws DefaultException {
@@ -253,27 +250,16 @@
         final boolean userIsLoggedIn = userSession.isUserLoggedIn();
         if (userIsLoggedIn) {
             defaultGroup = groupManager.getGroupOfUserWithId(user.getId());
-            // if (groupManager.findEnabledTools(defaultGroup.getId()).size() ==
-            // 0) {
-            // defaultGroup = groupManager.getDefaultGroup();
-            // }
+            if (groupManager.findEnabledTools(defaultGroup.getId()).size() == 0) {
+                // Groups with no homepage
+                defaultGroup = groupManager.getSiteDefaultGroup();
+            }
         } else {
-            defaultGroup = groupManager.getDefaultGroup();
+            defaultGroup = groupManager.getSiteDefaultGroup();
         }
         try {
             final Content content = finderService.getContent(token, defaultGroup);
-            Long id = content.getId();
-            if (id != null) {
-                // Content
-                accessService.accessToContent(id, user, AccessRol.Viewer);
-                return mapStateSiblings(stateService.create(user, content), user, content.getContainer().getOwner());
-            } else {
-                // Container
-                final Container container = content.getContainer();
-                accessService.accessToContainer(container.getId(), user, AccessRol.Viewer);
-                // this getContainer....
-                return mapStateSiblings(stateService.create(user, container), user, container.getOwner());
-            }
+            return getContentOrDefContent(userHash, content.getStateToken(), user, content);
         } catch (final NoResultException e) {
             throw new ContentNotFoundException();
         } catch (final ToolNotFoundException e) {
@@ -362,8 +348,8 @@
         final UserSession userSession = getUserSession();
         final User user = userSession.getUser();
         final Content content = accessService.accessToContent(contentId, user, AccessRol.Editor);
-        final Content descriptor = creationService.saveContent(user, content, textContent);
-        return descriptor.getVersion();
+        final Content saved = creationService.saveContent(user, content, textContent);
+        return saved.getVersion();
     }
 
     @Authenticated
@@ -449,6 +435,21 @@
         return container;
     }
 
+    @Authenticated(mandatory = false)
+    @Authorizated(accessRolRequired = AccessRol.Viewer)
+    private StateAbstractDTO getContentOrDefContent(String userHash, StateToken stateToken, final User user,
+            final Content content) {
+        Long id = content.getId();
+        if (id != null) {
+            // Content
+            return mapStateSiblings(stateService.create(user, content), user, content.getContainer().getOwner());
+        } else {
+            // Container
+            final Container container = content.getContainer();
+            return mapStateSiblings(stateService.create(user, container), user, container.getOwner());
+        }
+    }
+
     private List<TagResultDTO> getSummaryTags(final Group group) {
         return mapper.mapList(tagManager.getSummaryByGroup(group), TagResultDTO.class);
     }

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-10-24 01:37:05 UTC (rev 923)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/state/StateServiceDefault.java	2008-10-24 10:00:58 UTC (rev 924)
@@ -139,7 +139,7 @@
         state.setEnabledTools(groupManager.findEnabledTools(group.getId()));
         setSocialNetwork(state, userLogged, group);
         state.setStateToken(group.getStateToken());
-        state.setTitle(i18n.t("This user doesn't have a homepage"));
+        state.setTitle("<h2>" + i18n.t("This user doesn't have a homepage") + "</h2>");
         return state;
     }
 

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/nohomepage/NoHomePagePanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/nohomepage/NoHomePagePanel.java	2008-10-24 01:37:05 UTC (rev 923)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/nohomepage/NoHomePagePanel.java	2008-10-24 10:00:58 UTC (rev 924)
@@ -43,7 +43,5 @@
         EntityWorkspace ew = ws.getEntityWorkspace();
         ew.setContent(noHomepageCtnLabel);
         ew.setContext(noHomepageCtxLabel);
-        ew.getContextTopBar().removeAll();
-        ew.getContextBottomBar().removeAll();
     }
 }




More information about the kune-commits mailing list