[kune-commits] r839 - in trunk/src:
main/java/org/ourproject/kune/app/public
main/java/org/ourproject/kune/app/public/css
main/java/org/ourproject/kune/platf/client/dto
main/java/org/ourproject/kune/platf/client/services
main/java/org/ourproject/kune/platf/server/domain
main/java/org/ourproject/kune/platf/server/mapper
main/java/org/ourproject/kune/platf/server/rpc
main/java/org/ourproject/kune/platf/server/users
main/java/org/ourproject/kune/workspace/client/search main/resources
test/java/org/ourproject/kune/platf/server/mapper
vjrj
vjrj at ourproject.org
Sat Aug 9 20:40:40 CEST 2008
Author: vjrj
Date: 2008-08-09 20:40:32 +0200 (Sat, 09 Aug 2008)
New Revision: 839
Added:
trunk/src/main/java/org/ourproject/kune/platf/client/dto/ChatUserParamsDTO.java
trunk/src/main/java/org/ourproject/kune/platf/client/dto/CustomPropertiesDTO.java
Modified:
trunk/src/main/java/org/ourproject/kune/app/public/Kune.html
trunk/src/main/java/org/ourproject/kune/app/public/css/all.css
trunk/src/main/java/org/ourproject/kune/app/public/css/workspace.css
trunk/src/main/java/org/ourproject/kune/platf/client/dto/UserInfoDTO.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java
trunk/src/main/java/org/ourproject/kune/platf/server/domain/CustomProperties.java
trunk/src/main/java/org/ourproject/kune/platf/server/mapper/DozerMapper.java
trunk/src/main/java/org/ourproject/kune/platf/server/mapper/Mapper.java
trunk/src/main/java/org/ourproject/kune/platf/server/rpc/UserRPC.java
trunk/src/main/java/org/ourproject/kune/platf/server/users/UserInfo.java
trunk/src/main/java/org/ourproject/kune/platf/server/users/UserInfoServiceDefault.java
trunk/src/main/java/org/ourproject/kune/workspace/client/search/SiteSearcherPanel.java
trunk/src/main/resources/dozerBeanMapping.xml
trunk/src/test/java/org/ourproject/kune/platf/server/mapper/MapperTest.java
Log:
Complete - task 1: User parameters Server
Modified: trunk/src/main/java/org/ourproject/kune/app/public/Kune.html
===================================================================
--- trunk/src/main/java/org/ourproject/kune/app/public/Kune.html 2008-08-09 14:49:34 UTC (rev 838)
+++ trunk/src/main/java/org/ourproject/kune/app/public/Kune.html 2008-08-09 18:40:32 UTC (rev 839)
@@ -18,7 +18,24 @@
<link rel="shortcut icon" href="images/favicon.ico" />
<title>Kune</title>
+<style type="text/css">
+#kuneprogresspanel {
+ position: absolute;
+ top: 2px;
+ left: 2px;
+ z-index: 30000;
+}
+
+.kune-Progress {
+ background: #E5FF80;
+ border: 1px solid #E5FF80;
+ white-space: nowrap;
+ height: 16px;
+ padding: 0 3px;
+}
+
+</style>
</head>
<body>
<script type="text/javascript" language="javascript"
Modified: trunk/src/main/java/org/ourproject/kune/app/public/css/all.css
===================================================================
--- trunk/src/main/java/org/ourproject/kune/app/public/css/all.css 2008-08-09 14:49:34 UTC (rev 838)
+++ trunk/src/main/java/org/ourproject/kune/app/public/css/all.css 2008-08-09 18:40:32 UTC (rev 839)
@@ -1908,21 +1908,6 @@
/* Sitebar */
-#kuneprogresspanel {
- position: absolute;
- top: 2px;
- left: 2px;
- z-index: 30000;
-}
-
-.kune-Progress {
- background: #E5FF80;
- border: 1px solid #E5FF80;
- white-space: nowrap;
- height: 16px;
- padding: 0 3px;
-}
-
.kune-SiteBarPanel .kune-IconHyperlink {
white-space: nowrap;
}
Modified: trunk/src/main/java/org/ourproject/kune/app/public/css/workspace.css
===================================================================
--- trunk/src/main/java/org/ourproject/kune/app/public/css/workspace.css 2008-08-09 14:49:34 UTC (rev 838)
+++ trunk/src/main/java/org/ourproject/kune/app/public/css/workspace.css 2008-08-09 18:40:32 UTC (rev 839)
@@ -1,20 +1,5 @@
/* Sitebar */
-#kuneprogresspanel {
- position: absolute;
- top: 2px;
- left: 2px;
- z-index: 30000;
-}
-
-.kune-Progress {
- background: #E5FF80;
- border: 1px solid #E5FF80;
- white-space: nowrap;
- height: 16px;
- padding: 0 3px;
-}
-
.kune-SiteBarPanel .kune-IconHyperlink {
white-space: nowrap;
}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/dto/ChatUserParamsDTO.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/dto/ChatUserParamsDTO.java 2008-08-09 14:49:34 UTC (rev 838)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/dto/ChatUserParamsDTO.java 2008-08-09 18:40:32 UTC (rev 839)
@@ -0,0 +1,61 @@
+package org.ourproject.kune.platf.client.dto;
+
+import com.calclab.emite.client.im.roster.RosterManager;
+import com.calclab.emite.client.im.roster.RosterManager.SubscriptionMode;
+import com.google.gwt.user.client.rpc.IsSerializable;
+
+public class ChatUserParamsDTO implements IsSerializable {
+
+ private String avatar;
+
+ private boolean publishRoster;
+
+ private SubscriptionMode subscriptionMode;
+
+ private String chatColor;
+
+ public ChatUserParamsDTO() {
+ this(null, false, SubscriptionMode.autoAcceptAll, null);
+ };
+
+ public ChatUserParamsDTO(final String avatar, final boolean publishRoster, final SubscriptionMode subscriptionMode,
+ final String chatColor) {
+ this.avatar = avatar;
+ this.publishRoster = publishRoster;
+ this.subscriptionMode = subscriptionMode;
+ this.chatColor = chatColor;
+ }
+
+ public String getAvatar() {
+ return avatar;
+ }
+
+ public String getChatColor() {
+ return chatColor;
+ }
+
+ public RosterManager.SubscriptionMode getSubscriptionMode() {
+ return subscriptionMode;
+ }
+
+ public boolean isPublishRoster() {
+ return publishRoster;
+ }
+
+ public void setAvatar(final String avatar) {
+ this.avatar = avatar;
+ }
+
+ public void setChatColor(final String chatColor) {
+ this.chatColor = chatColor;
+ }
+
+ public void setPublishRoster(final boolean publishRoster) {
+ this.publishRoster = publishRoster;
+ }
+
+ public void setSubscriptionMode(final RosterManager.SubscriptionMode subscriptionMode) {
+ this.subscriptionMode = subscriptionMode;
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/dto/CustomPropertiesDTO.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/dto/CustomPropertiesDTO.java 2008-08-09 14:49:34 UTC (rev 838)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/dto/CustomPropertiesDTO.java 2008-08-09 18:40:32 UTC (rev 839)
@@ -0,0 +1,37 @@
+package org.ourproject.kune.platf.client.dto;
+
+import java.util.HashMap;
+
+import com.google.gwt.user.client.rpc.IsSerializable;
+
+public class CustomPropertiesDTO implements IsSerializable {
+
+ private HashMap<Class<?>, Object> data;
+
+ public CustomPropertiesDTO() {
+ data = new HashMap<Class<?>, Object>();
+ }
+
+ public HashMap<Class<?>, Object> getData() {
+ return data;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T getData(final Class<T> type) {
+ return (T) data.get(type);
+ }
+
+ public <T> boolean hasPropertie(final Class<T> type) {
+ return data.containsKey(type);
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T setData(final Class<T> type, final T value) {
+ return (T) data.put(type, value);
+ }
+
+ public void setData(final HashMap<Class<?>, Object> data) {
+ this.data = data;
+ }
+
+}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/dto/UserInfoDTO.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/dto/UserInfoDTO.java 2008-08-09 14:49:34 UTC (rev 838)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/dto/UserInfoDTO.java 2008-08-09 18:40:32 UTC (rev 839)
@@ -34,6 +34,7 @@
private I18nCountryDTO country;
private List<GroupDTO> groupsIsAdmin;
private List<GroupDTO> groupsIsCollab;
+ private CustomPropertiesDTO customProperties;
public String getChatName() {
return chatName;
@@ -47,6 +48,10 @@
return country;
}
+ public CustomPropertiesDTO getCustomProperties() {
+ return customProperties;
+ }
+
public List<GroupDTO> getGroupsIsAdmin() {
return groupsIsAdmin;
}
@@ -88,6 +93,10 @@
this.country = country;
}
+ public void setCustomProperties(final CustomPropertiesDTO customProperties) {
+ this.customProperties = customProperties;
+ }
+
public void setGroupsIsAdmin(final List<GroupDTO> groupsIsAdmin) {
this.groupsIsAdmin = groupsIsAdmin;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java 2008-08-09 14:49:34 UTC (rev 838)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java 2008-08-09 18:40:32 UTC (rev 839)
@@ -71,7 +71,7 @@
logException(e);
Site.error(i18n.t("You don't have rights to do that"));
} catch (final SessionExpiredException e) {
- logException(e, true);
+ logException(e);
doSessionExpired();
} catch (final UserMustBeLoggedException e) {
logException(e);
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/domain/CustomProperties.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/domain/CustomProperties.java 2008-08-09 14:49:34 UTC (rev 838)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/domain/CustomProperties.java 2008-08-09 18:40:32 UTC (rev 839)
@@ -22,12 +22,16 @@
private Long id;
@Lob
- private final HashMap<Class<?>, Object> data;
+ private HashMap<Class<?>, Object> data;
public CustomProperties() {
data = new HashMap<Class<?>, Object>();
}
+ public HashMap<Class<?>, Object> getData() {
+ return data;
+ }
+
@SuppressWarnings("unchecked")
public <T> T getData(final Class<T> type) {
return (T) data.get(type);
@@ -46,6 +50,10 @@
return (T) data.put(type, value);
}
+ public void setData(final HashMap<Class<?>, Object> data) {
+ this.data = data;
+ }
+
public void setId(final Long id) {
this.id = id;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/mapper/DozerMapper.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/mapper/DozerMapper.java 2008-08-09 14:49:34 UTC (rev 838)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/mapper/DozerMapper.java 2008-08-09 18:40:32 UTC (rev 839)
@@ -21,12 +21,15 @@
package org.ourproject.kune.platf.server.mapper;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import net.sf.dozer.util.mapping.DozerBeanMapperSingletonWrapper;
import net.sf.dozer.util.mapping.MapperIF;
+import org.ourproject.kune.platf.client.dto.CustomPropertiesDTO;
import org.ourproject.kune.platf.client.dto.SearchResultDTO;
+import org.ourproject.kune.platf.server.domain.CustomProperties;
import org.ourproject.kune.platf.server.manager.impl.SearchResult;
import com.google.inject.Singleton;
@@ -53,6 +56,20 @@
return dest;
}
+ public CustomPropertiesDTO mapProperties(final CustomProperties customProperties) throws ClassNotFoundException {
+ final CustomPropertiesDTO customPropertiesDTO = new CustomPropertiesDTO();
+ final HashMap<Class<?>, Object> dataMapped = new HashMap<Class<?>, Object>();
+ for (final Class<?> c : customProperties.getData().keySet()) {
+ final Object object = customProperties.getData(c);
+ final Class<?> destClassName = Class.forName("org.ourproject.kune.platf.client.dto." + c.getSimpleName()
+ + "DTO");
+ final Object objectMapped = map(object, destClassName);
+ dataMapped.put(destClassName, objectMapped);
+ }
+ customPropertiesDTO.setData(dataMapped);
+ return customPropertiesDTO;
+ }
+
@SuppressWarnings("unchecked")
public <K, T> SearchResultDTO<T> mapSearchResult(final SearchResult<K> result, final Class<T> type) {
final SearchResultDTO<T> resultDTO = new SearchResultDTO<T>();
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/mapper/Mapper.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/mapper/Mapper.java 2008-08-09 14:49:34 UTC (rev 838)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/mapper/Mapper.java 2008-08-09 18:40:32 UTC (rev 839)
@@ -22,7 +22,9 @@
import java.util.List;
+import org.ourproject.kune.platf.client.dto.CustomPropertiesDTO;
import org.ourproject.kune.platf.client.dto.SearchResultDTO;
+import org.ourproject.kune.platf.server.domain.CustomProperties;
import org.ourproject.kune.platf.server.manager.impl.SearchResult;
public interface Mapper {
@@ -30,5 +32,7 @@
<T> List<T> mapList(List<?> list, Class<T> type);
+ CustomPropertiesDTO mapProperties(CustomProperties customProperties) throws ClassNotFoundException;
+
<K, T> SearchResultDTO<T> mapSearchResult(SearchResult<K> result, Class<T> type);
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/rpc/UserRPC.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/rpc/UserRPC.java 2008-08-09 14:49:34 UTC (rev 838)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/rpc/UserRPC.java 2008-08-09 18:40:32 UTC (rev 839)
@@ -111,7 +111,14 @@
private UserInfoDTO loadUserInfo(final User user) throws DefaultException {
final UserInfo userInfo = userInfoService.buildInfo(user, getUserSession().getHash());
- return mapper.map(userInfo, UserInfoDTO.class);
+ final UserInfoDTO map = mapper.map(userInfo, UserInfoDTO.class);
+ try {
+ map.setCustomProperties(mapper.mapProperties(userInfo.getCustomProperties()));
+ } catch (final ClassNotFoundException e) {
+ e.printStackTrace();
+ throw new DefaultException("Class not found during mapping userInfo");
+ }
+ return map;
}
private UserInfoDTO loginUser(final User user) throws DefaultException {
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/users/UserInfo.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/users/UserInfo.java 2008-08-09 14:49:34 UTC (rev 838)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/users/UserInfo.java 2008-08-09 18:40:32 UTC (rev 839)
@@ -21,6 +21,7 @@
import java.util.List;
+import org.ourproject.kune.platf.server.domain.CustomProperties;
import org.ourproject.kune.platf.server.domain.Group;
import org.ourproject.kune.platf.server.domain.I18nCountry;
import org.ourproject.kune.platf.server.domain.I18nLanguage;
@@ -36,6 +37,7 @@
private String userHash;
private I18nLanguage language;
private I18nCountry country;
+ private CustomProperties customProperties;
public String getChatName() {
return chatName;
@@ -49,6 +51,10 @@
return country;
}
+ public CustomProperties getCustomProperties() {
+ return customProperties;
+ }
+
public List<Group> getGroupsIsAdmin() {
return groupsIsAdmin;
}
@@ -89,6 +95,10 @@
this.country = country;
}
+ public void setCustomProperties(final CustomProperties customProperties) {
+ this.customProperties = customProperties;
+ }
+
public void setGroupsIsAdmin(final List<Group> groupsIsAdmin) {
this.groupsIsAdmin = groupsIsAdmin;
}
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-08-09 14:49:34 UTC (rev 838)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/users/UserInfoServiceDefault.java 2008-08-09 18:40:32 UTC (rev 839)
@@ -53,6 +53,7 @@
info.setLanguage(language);
info.setCountry(user.getCountry());
info.setUserHash(userHash);
+ info.setCustomProperties(user.getCustomProperties());
final Group userGroup = user.getUserGroup();
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/search/SiteSearcherPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/search/SiteSearcherPanel.java 2008-08-09 14:49:34 UTC (rev 838)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/search/SiteSearcherPanel.java 2008-08-09 18:40:32 UTC (rev 839)
@@ -143,7 +143,7 @@
groupsPanel.addListener(new PanelListenerAdapter() {
public void onActivate(final Panel panel) {
- dialog.setTitle(i18n.t("Search users & groups"));
+ dialog.setTitle(i18n.t("Search users and groups"));
presenter.doSearch(SiteSearcherType.group_user);
}
});
Modified: trunk/src/main/resources/dozerBeanMapping.xml
===================================================================
--- trunk/src/main/resources/dozerBeanMapping.xml 2008-08-09 14:49:34 UTC (rev 838)
+++ trunk/src/main/resources/dozerBeanMapping.xml 2008-08-09 18:40:32 UTC (rev 839)
@@ -287,5 +287,19 @@
<b>name</b>
</field>
</mapping>
+
+ <mapping>
+ <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.CustomPropertiesDTO</class-a>
+ <class-b>org.ourproject.kune.platf.server.domain.CustomProperties</class-b>
+ <field>
+ <a>data</a>
+ <b>data</b>
+ </field>
+ </mapping>
+
</mappings>
\ No newline at end of file
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-08-09 14:49:34 UTC (rev 838)
+++ trunk/src/test/java/org/ourproject/kune/platf/server/mapper/MapperTest.java 2008-08-09 18:40:32 UTC (rev 839)
@@ -10,21 +10,26 @@
import org.junit.Before;
import org.junit.Test;
+import org.ourproject.kune.platf.client.dto.ChatUserParamsDTO;
import org.ourproject.kune.platf.client.dto.CommentDTO;
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.CustomPropertiesDTO;
import org.ourproject.kune.platf.client.dto.GroupDTO;
import org.ourproject.kune.platf.client.dto.GroupListDTO;
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.UserInfoDTO;
import org.ourproject.kune.platf.server.TestDomainHelper;
import org.ourproject.kune.platf.server.TestHelper;
import org.ourproject.kune.platf.server.access.AccessRights;
+import org.ourproject.kune.platf.server.domain.ChatUserParams;
import org.ourproject.kune.platf.server.domain.Comment;
import org.ourproject.kune.platf.server.domain.Container;
import org.ourproject.kune.platf.server.domain.Content;
+import org.ourproject.kune.platf.server.domain.CustomProperties;
import org.ourproject.kune.platf.server.domain.Group;
import org.ourproject.kune.platf.server.domain.GroupList;
import org.ourproject.kune.platf.server.domain.GroupListMode;
@@ -33,7 +38,9 @@
import org.ourproject.kune.platf.server.domain.User;
import org.ourproject.kune.platf.server.manager.GroupManager;
import org.ourproject.kune.platf.server.state.State;
+import org.ourproject.kune.platf.server.users.UserInfo;
+import com.calclab.emite.client.im.roster.RosterManager.SubscriptionMode;
import com.google.inject.Inject;
public class MapperTest {
@@ -42,6 +49,30 @@
@Inject
GroupManager groupManager;
+ @Test
+ public void customPropertiesInUserInfoMappping() {
+ final UserInfo userInfo = new UserInfo();
+ final ChatUserParams userChatParams = new ChatUserParams("avatar", true, SubscriptionMode.autoAcceptAll,
+ "color");
+ final CustomProperties customProperties = new CustomProperties();
+ customProperties.setData(ChatUserParams.class, userChatParams);
+ userInfo.setCustomProperties(customProperties);
+ final UserInfoDTO map = mapper.map(userInfo, UserInfoDTO.class);
+ final ChatUserParamsDTO data = map.getCustomProperties().getData(ChatUserParamsDTO.class);
+ assertEquals("avatar", data.getAvatar());
+ }
+
+ @Test
+ public void customPropertiesMappping() throws ClassNotFoundException {
+ final ChatUserParams userChatParams = new ChatUserParams("avatar", true, SubscriptionMode.autoAcceptAll,
+ "color");
+ final CustomProperties customProperties = new CustomProperties();
+ customProperties.setData(ChatUserParams.class, userChatParams);
+ final CustomPropertiesDTO map = mapper.mapProperties(customProperties);
+ final ChatUserParamsDTO data = map.getData(ChatUserParamsDTO.class);
+ assertEquals("avatar", data.getAvatar());
+ }
+
@Before
public void inject() {
TestHelper.inject(this);
More information about the kune-commits
mailing list