[kune-commits] r1514 - in trunk/src: main/java/cc/kune/common/client/tooltip main/java/cc/kune/common/client/ui/dialogs/tabbed main/java/cc/kune/core/client main/java/cc/kune/core/server main/java/cc/kune/core/server/access main/java/cc/kune/core/server/auth main/java/cc/kune/core/server/rpc main/java/cc/kune/gspace/client/i18n main/java/cc/kune/lists/client/actions test/java/cc/kune/core/server/auth

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Sun Sep 11 14:02:37 CEST 2011


Author: vjrj_
Date: 2011-09-11 14:02:36 +0200 (Sun, 11 Sep 2011)
New Revision: 1514

Added:
   trunk/src/main/java/cc/kune/core/server/access/AccessRightsUtils.java
   trunk/src/main/java/cc/kune/core/server/auth/SuperAdmin.java
   trunk/src/main/java/cc/kune/core/server/auth/SuperAdminMethodInterceptor.java
   trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.java
   trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.ui.xml
   trunk/src/test/java/cc/kune/core/server/auth/SuperAdminMethodInterceptorTest.java
Removed:
   trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.java
   trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.ui.xml
Modified:
   trunk/src/main/java/cc/kune/common/client/tooltip/Tooltip.java
   trunk/src/main/java/cc/kune/common/client/ui/dialogs/tabbed/AbstractTabbedDialogPanel.java
   trunk/src/main/java/cc/kune/core/client/CoreGinModule.java
   trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java
   trunk/src/main/java/cc/kune/core/server/auth/AuthorizatedMethodInterceptor.java
   trunk/src/main/java/cc/kune/core/server/rpc/I18nRPC.java
   trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.ui.xml
   trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPresenter.java
   trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTraslatorSaver.java
   trunk/src/main/java/cc/kune/gspace/client/i18n/SiteOptionsI18nTranslatorAction.java
   trunk/src/main/java/cc/kune/lists/client/actions/NewListAction.java
   trunk/src/main/java/cc/kune/lists/client/actions/NewListPostAction.java
Log:
NEW - # 79: I18n refactorization 
http://kune.ourproject.org/issues/ticket/79

Modified: trunk/src/main/java/cc/kune/common/client/tooltip/Tooltip.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/tooltip/Tooltip.java	2011-09-07 21:37:23 UTC (rev 1513)
+++ trunk/src/main/java/cc/kune/common/client/tooltip/Tooltip.java	2011-09-11 12:02:36 UTC (rev 1514)
@@ -57,22 +57,19 @@
   private static final int WIDTH_NOT_DEFINED = -1;
 
   public static Tooltip to(final Widget widget, final String text) {
-    if (TextUtils.notEmpty(text)) {
-      final Tooltip tip = new Tooltip();
-      tip.to(widget);
-      tip.setText(text);
-      widget.addAttachHandler(new Handler() {
-        @Override
-        public void onAttachOrDetach(final AttachEvent event) {
-          if (!event.isAttached()) {
-            tip.hide();
-          }
+    final Tooltip tip = new Tooltip();
+    tip.to(widget);
+    tip.setText(text);
+    widget.addAttachHandler(new Handler() {
+      @Override
+      public void onAttachOrDetach(final AttachEvent event) {
+        if (!event.isAttached()) {
+          tip.hide();
         }
+      }
 
-      });
-      return tip;
-    }
-    return null;
+    });
+    return tip;
   }
 
   public static Tooltip to(final Widget widget, final Widget withContent) {
@@ -85,16 +82,20 @@
   HTMLPanel arrow;
   @UiField
   HTMLPanel arrowBorder;
+  private boolean containsText;
   @UiField
   FlowPanel content;
   @UiField
   FlowPanel flow;
   private Widget ofWidget;
+  private final Label textLabel;
   private final TooltipTimers timers;
   @UiField
   InlineLabel title;
+
   @UiField
   HTMLPanel tooltip;
+
   private int width = WIDTH_NOT_DEFINED;
 
   public Tooltip() {
@@ -120,6 +121,7 @@
     outTimer.configure(hideExecuter);
     securityTimer.configure(hideExecuter);
     timers = new TooltipTimers(overTimer, outTimer, securityTimer);
+    textLabel = new Label();
   }
 
   protected int getHeight() {
@@ -145,11 +147,14 @@
   private void setContent(final Widget widget) {
     content.clear();
     content.add(widget);
+    containsText = false;
   }
 
   public void setText(final String text) {
     content.clear();
-    content.add(new Label(text));
+    content.add(textLabel);
+    textLabel.setText(text);
+    containsText = true;
   }
 
   public void setWidth(final int width) {
@@ -158,7 +163,8 @@
 
   @Override
   public void show() {
-    if (!Tooltip.this.isShowing() && ofWidget.isAttached() && ofWidget.isVisible()) {
+    if (!Tooltip.this.isShowing() && ofWidget.isAttached() && ofWidget.isVisible()
+        && (!containsText || TextUtils.notEmpty(textLabel.getText()))) {
       Tooltip.super.show();
       if (Tooltip.current != null) {
         Tooltip.current.hide();

Modified: trunk/src/main/java/cc/kune/common/client/ui/dialogs/tabbed/AbstractTabbedDialogPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/ui/dialogs/tabbed/AbstractTabbedDialogPanel.java	2011-09-07 21:37:23 UTC (rev 1513)
+++ trunk/src/main/java/cc/kune/common/client/ui/dialogs/tabbed/AbstractTabbedDialogPanel.java	2011-09-11 12:02:36 UTC (rev 1514)
@@ -144,12 +144,11 @@
     }
     messageErrorBar = new MessageToolbar(images, errorLabelId);
     tabPanel = new TabLayoutPanel(25, Unit.PX);
-    tabPanel.addStyleName("oc-noselec");
+    tabPanel.addStyleName("oc-noselect");
+    dialog.getInnerPanel().add(tabPanel);
     tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
       @Override
       public void onSelection(final SelectionEvent<Integer> event) {
-        // dialog.recalculateSize();
-        dialog.showCentered();
         Scheduler.get().scheduleDeferred(new ScheduledCommand() {
           @Override
           public void execute() {
@@ -165,7 +164,6 @@
     if (height != NO_SIZE) {
       tabPanel.setHeight(String.valueOf(height) + "px");
     }
-    dialog.getInnerPanel().add(tabPanel);
     tabPanel.addStyleName("k-tabpanel-aditionalpadding");
     tabPanel.addStyleName("k-tabs");
     dialog.getFirstBtn().addClickHandler(new ClickHandler() {

Modified: trunk/src/main/java/cc/kune/core/client/CoreGinModule.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/CoreGinModule.java	2011-09-07 21:37:23 UTC (rev 1513)
+++ trunk/src/main/java/cc/kune/core/client/CoreGinModule.java	2011-09-11 12:02:36 UTC (rev 1514)
@@ -75,8 +75,8 @@
 import cc.kune.core.client.sitebar.SitebarSignOutLink.BeforeSignOut;
 import cc.kune.core.client.sitebar.logo.SiteLogoPresenter;
 import cc.kune.core.client.sitebar.logo.SiteLogoViewImpl;
+import cc.kune.core.client.sitebar.spaces.SpaceSelectorPanel;
 import cc.kune.core.client.sitebar.spaces.SpaceSelectorPresenter;
-import cc.kune.core.client.sitebar.spaces.SpaceSelectorPanel;
 import cc.kune.core.client.sn.GroupSNPanel;
 import cc.kune.core.client.sn.GroupSNPresenter;
 import cc.kune.core.client.sn.UserSNPanel;

Modified: trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java	2011-09-07 21:37:23 UTC (rev 1513)
+++ trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java	2011-09-11 12:02:36 UTC (rev 1514)
@@ -30,6 +30,7 @@
 import cc.kune.core.client.rpcservices.UserService;
 import cc.kune.core.server.access.AccessRightsService;
 import cc.kune.core.server.access.AccessRightsServiceDefault;
+import cc.kune.core.server.access.AccessRightsUtils;
 import cc.kune.core.server.access.AccessService;
 import cc.kune.core.server.access.AccessServiceDefault;
 import cc.kune.core.server.access.FinderService;
@@ -40,6 +41,8 @@
 import cc.kune.core.server.auth.AuthorizatedMethodInterceptor;
 import cc.kune.core.server.auth.SessionService;
 import cc.kune.core.server.auth.SessionServiceDefault;
+import cc.kune.core.server.auth.SuperAdmin;
+import cc.kune.core.server.auth.SuperAdminMethodInterceptor;
 import cc.kune.core.server.content.ContainerManager;
 import cc.kune.core.server.content.ContainerManagerDefault;
 import cc.kune.core.server.content.ContentManager;
@@ -176,11 +179,13 @@
     bind(EntityLogoUploadManager.class);
     bind(EntityLogoDownloadManager.class);
     bind(ParticipantUtils.class);
-
+    requestStaticInjection(AccessRightsUtils.class);
     bindInterceptor(Matchers.any(), Matchers.annotatedWith(Authenticated.class),
         outermostCall(new AuthenticatedMethodInterceptor()));
     bindInterceptor(Matchers.any(), Matchers.annotatedWith(Authorizated.class),
         outermostCall(new AuthorizatedMethodInterceptor()));
+    bindInterceptor(Matchers.any(), Matchers.annotatedWith(SuperAdmin.class),
+        outermostCall(new SuperAdminMethodInterceptor()));
   }
 
 }

Added: trunk/src/main/java/cc/kune/core/server/access/AccessRightsUtils.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/access/AccessRightsUtils.java	                        (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/access/AccessRightsUtils.java	2011-09-11 12:02:36 UTC (rev 1514)
@@ -0,0 +1,30 @@
+package cc.kune.core.server.access;
+
+import cc.kune.core.shared.domain.AccessRol;
+import cc.kune.core.shared.domain.utils.AccessRights;
+import cc.kune.domain.Group;
+import cc.kune.domain.User;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+ at Singleton
+public class AccessRightsUtils {
+
+  @Inject
+  private static AccessRightsService rightsService;
+
+  public static boolean correctMember(final User user, final Group group, final AccessRol memberType) {
+
+    final AccessRights accessRights = rightsService.get(user, group.getSocialNetwork().getAccessLists());
+
+    switch (memberType) {
+    case Administrator:
+      return accessRights.isAdministrable();
+    case Editor:
+      return accessRights.isEditable();
+    default:
+      return accessRights.isVisible();
+    }
+  }
+}

Modified: trunk/src/main/java/cc/kune/core/server/auth/AuthorizatedMethodInterceptor.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/auth/AuthorizatedMethodInterceptor.java	2011-09-07 21:37:23 UTC (rev 1513)
+++ trunk/src/main/java/cc/kune/core/server/auth/AuthorizatedMethodInterceptor.java	2011-09-11 12:02:36 UTC (rev 1514)
@@ -26,12 +26,11 @@
 
 import cc.kune.core.client.errors.AccessViolationException;
 import cc.kune.core.server.UserSession;
-import cc.kune.core.server.access.AccessRightsService;
+import cc.kune.core.server.access.AccessRightsUtils;
 import cc.kune.core.server.access.AccessService;
 import cc.kune.core.server.content.ContentUtils;
 import cc.kune.core.server.manager.GroupManager;
 import cc.kune.core.shared.domain.AccessRol;
-import cc.kune.core.shared.domain.utils.AccessRights;
 import cc.kune.core.shared.domain.utils.StateToken;
 import cc.kune.domain.Container;
 import cc.kune.domain.Content;
@@ -45,84 +44,67 @@
 @Singleton
 public class AuthorizatedMethodInterceptor implements MethodInterceptor {
 
-    @Inject
-    private Provider<UserSession> userSessionProvider;
-    @Inject
-    private Provider<GroupManager> groupManagerProvider;
-    @Inject
-    private Provider<AccessRightsService> accessRightsServiceProvider;
-    @Inject
-    private Provider<AccessService> accessServiceProvider;
+  @Inject
+  private Provider<AccessService> accessServiceProvider;
+  @Inject
+  private Provider<GroupManager> groupManagerProvider;
+  @Inject
+  private Provider<UserSession> userSessionProvider;
 
-    public Object invoke(final MethodInvocation invocation) throws Throwable {
-        final Object[] arguments = invocation.getArguments();
-        final StateToken token = (StateToken) arguments[1];
+  @Override
+  public Object invoke(final MethodInvocation invocation) throws Throwable {
+    final Object[] arguments = invocation.getArguments();
+    final StateToken token = (StateToken) arguments[1];
 
-        final UserSession userSession = userSessionProvider.get();
-        final GroupManager groupManager = groupManagerProvider.get();
-        final AccessService accessService = accessServiceProvider.get();
+    final UserSession userSession = userSessionProvider.get();
+    final GroupManager groupManager = groupManagerProvider.get();
+    final AccessService accessService = accessServiceProvider.get();
 
-        final Authorizated authoAnnotation = invocation.getStaticPart().getAnnotation(Authorizated.class);
-        final AccessRol accessRol = authoAnnotation.accessRolRequired();
-        final ActionLevel actionLevel = authoAnnotation.actionLevel();
-        final boolean mustBeMember = authoAnnotation.mustCheckMembership();
+    final Authorizated authoAnnotation = invocation.getStaticPart().getAnnotation(Authorizated.class);
+    final AccessRol accessRol = authoAnnotation.accessRolRequired();
+    final ActionLevel actionLevel = authoAnnotation.actionLevel();
+    final boolean mustBeMember = authoAnnotation.mustCheckMembership();
 
-        final User user = userSession.getUser();
-        Group group = Group.NO_GROUP;
-        try {
-            group = groupManager.findByShortName(token.getGroup());
-        } catch (final NoResultException e) {
-            // continue, and check later
-        }
+    final User user = userSession.getUser();
+    Group group = Group.NO_GROUP;
+    try {
+      group = groupManager.findByShortName(token.getGroup());
+    } catch (final NoResultException e) {
+      // continue, and check later
+    }
 
-        switch (actionLevel) {
-        case content:
-        default:
-            final Content content = accessService.accessToContent(ContentUtils.parseId(token.getDocument()), user,
-                    accessRol);
-            if (!content.getContainer().getOwner().equals(group)) {
-                throw new AccessViolationException();
-            }
-            if (!content.getContainer().getId().equals(ContentUtils.parseId(token.getFolder()))) {
-                throw new AccessViolationException();
-            }
-            if (!content.getContainer().getToolName().equals(token.getTool())) {
-                throw new AccessViolationException();
-            }
-        case container:
-            final Container container = accessService.accessToContainer(ContentUtils.parseId(token.getFolder()), user,
-                    accessRol);
-            if (!container.getOwner().equals(group)) {
-                throw new AccessViolationException();
-            }
-        case tool:
-        case group:
-            break;
-        }
-
-        if (mustBeMember) {
-            if (!correctMember(user, group, accessRol)) {
-                throw new AccessViolationException();
-            }
-        }
-
-        return invocation.proceed();
+    switch (actionLevel) {
+    case content:
+    default:
+      final Content content = accessService.accessToContent(ContentUtils.parseId(token.getDocument()),
+          user, accessRol);
+      if (!content.getContainer().getOwner().equals(group)) {
+        throw new AccessViolationException();
+      }
+      if (!content.getContainer().getId().equals(ContentUtils.parseId(token.getFolder()))) {
+        throw new AccessViolationException();
+      }
+      if (!content.getContainer().getToolName().equals(token.getTool())) {
+        throw new AccessViolationException();
+      }
+    case container:
+      final Container container = accessService.accessToContainer(
+          ContentUtils.parseId(token.getFolder()), user, accessRol);
+      if (!container.getOwner().equals(group)) {
+        throw new AccessViolationException();
+      }
+    case tool:
+    case group:
+      break;
     }
 
-    private boolean correctMember(final User user, final Group group, final AccessRol memberType)
-            throws AccessViolationException {
-
-        final AccessRights accessRights = accessRightsServiceProvider.get().get(user,
-                group.getSocialNetwork().getAccessLists());
-
-        switch (memberType) {
-        case Administrator:
-            return accessRights.isAdministrable();
-        case Editor:
-            return accessRights.isEditable();
-        default:
-            return accessRights.isVisible();
-        }
+    if (mustBeMember) {
+      if (!AccessRightsUtils.correctMember(user, group, accessRol)) {
+        throw new AccessViolationException();
+      }
     }
 
+    return invocation.proceed();
+  }
+
 }

Added: trunk/src/main/java/cc/kune/core/server/auth/SuperAdmin.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/auth/SuperAdmin.java	                        (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/auth/SuperAdmin.java	2011-09-11 12:02:36 UTC (rev 1514)
@@ -0,0 +1,40 @@
+/*
+ *
+ * Copyright (C) 2007-2011 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 cc.kune.core.server.auth;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import cc.kune.core.shared.domain.AccessRol;
+
+import com.google.inject.BindingAnnotation;
+
+/**
+ * Use in *RPC methods to check if user is superadmin
+ * 
+ * The first param in the method must be the userHash
+ */
+ at BindingAnnotation
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface SuperAdmin {
+
+  AccessRol rol() default AccessRol.Administrator;
+
+}

Added: trunk/src/main/java/cc/kune/core/server/auth/SuperAdminMethodInterceptor.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/auth/SuperAdminMethodInterceptor.java	                        (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/auth/SuperAdminMethodInterceptor.java	2011-09-11 12:02:36 UTC (rev 1514)
@@ -0,0 +1,93 @@
+/*
+ *
+ * Copyright (C) 2007-2011 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 cc.kune.core.server.auth;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.aopalliance.intercept.MethodInterceptor;
+import org.aopalliance.intercept.MethodInvocation;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import cc.kune.core.client.errors.AccessViolationException;
+import cc.kune.core.client.errors.SessionExpiredException;
+import cc.kune.core.client.errors.UserMustBeLoggedException;
+import cc.kune.core.server.UserSession;
+import cc.kune.core.server.access.AccessRightsUtils;
+import cc.kune.core.server.properties.KuneProperties;
+import cc.kune.core.shared.domain.AccessRol;
+import cc.kune.domain.Group;
+import cc.kune.domain.User;
+import cc.kune.domain.finders.GroupFinder;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
+public class SuperAdminMethodInterceptor implements MethodInterceptor {
+
+  public static final Log LOG = LogFactory.getLog(SuperAdminMethodInterceptor.class);
+
+  @Inject
+  Provider<GroupFinder> groupFinder;
+  @Inject
+  Provider<KuneProperties> kuneProperties;
+  @Inject
+  Provider<HttpServletRequest> requestProvider;
+  @Inject
+  Provider<SessionService> sessionServiceProvider;
+  private Group siteGroup;
+  @Inject
+  Provider<UserSession> userSessionProvider;
+
+  @Override
+  public Object invoke(final MethodInvocation invocation) throws Throwable {
+    final Object[] arguments = invocation.getArguments();
+    // Some browsers getCookie returns "null" as String instead of null
+    final String userHash = arguments[0] == null || arguments[0].equals("null") ? null
+        : (String) arguments[0];
+
+    LOG.info("Method: " + invocation.getMethod().getName());
+    LOG.info("Userhash received: " + userHash);
+    LOG.info("--------------------------------------------------------------------------------");
+    final UserSession userSession = userSessionProvider.get();
+
+    final SuperAdmin authAnnotation = invocation.getStaticPart().getAnnotation(SuperAdmin.class);
+    final AccessRol rol = authAnnotation.rol();
+
+    if (siteGroup == null) {
+      siteGroup = groupFinder.get().findByShortName(
+          kuneProperties.get().get(KuneProperties.DEFAULT_SITE_SHORT_NAME));
+    }
+
+    if (userHash == null) {
+      throw new UserMustBeLoggedException();
+    } else if (userSession.isUserNotLoggedIn()) {
+      LOG.info("Session expired (not logged in server and mandatory)");
+      throw new SessionExpiredException();
+    } else {
+      User user = userSession.getUser();
+      if (!AccessRightsUtils.correctMember(user, siteGroup, rol)) {
+        throw new AccessViolationException();
+      }
+    }
+    final Object result = invocation.proceed();
+    return result;
+  }
+}

Modified: trunk/src/main/java/cc/kune/core/server/rpc/I18nRPC.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/rpc/I18nRPC.java	2011-09-07 21:37:23 UTC (rev 1513)
+++ trunk/src/main/java/cc/kune/core/server/rpc/I18nRPC.java	2011-09-11 12:02:36 UTC (rev 1514)
@@ -30,9 +30,11 @@
 import cc.kune.core.client.rpcservices.I18nService;
 import cc.kune.core.server.UserSession;
 import cc.kune.core.server.auth.Authenticated;
+import cc.kune.core.server.auth.SuperAdmin;
 import cc.kune.core.server.manager.I18nLanguageManager;
 import cc.kune.core.server.manager.I18nTranslationManager;
 import cc.kune.core.server.mapper.Mapper;
+import cc.kune.core.shared.domain.AccessRol;
 import cc.kune.core.shared.dto.I18nLanguageDTO;
 import cc.kune.core.shared.dto.I18nTranslationDTO;
 import cc.kune.domain.I18nLanguage;
@@ -139,6 +141,7 @@
   @Override
   @Authenticated
   @Transactional
+  @SuperAdmin(rol = AccessRol.Editor)
   public String setTranslation(final String userHash, final Long id, final String translation)
       throws DefaultException {
     return i18nTranslationManager.setTranslation(id, translation);

Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.ui.xml
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.ui.xml	2011-09-07 21:37:23 UTC (rev 1513)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.ui.xml	2011-09-11 12:02:36 UTC (rev 1514)
@@ -32,7 +32,8 @@
           <s:RangeLabelPager ui:field='rangeLabelPager'/>
         </td>
         <td class='{style.formCell}' valign='top' align='center'>
-          <s:I18nTranslatorForm ui:field='translatorForm'/>
+          <s:I18nTranslatorForm
+           ui:field='translatorForm'/>
           <br/>
         </td>
       </tr>

Deleted: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.java	2011-09-07 21:37:23 UTC (rev 1513)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.java	2011-09-11 12:02:36 UTC (rev 1514)
@@ -1,186 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package cc.kune.gspace.client.i18n;
-
-import cc.kune.common.client.tooltip.Tooltip;
-import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
-import cc.kune.core.shared.dto.I18nTranslationDTO;
-import cc.kune.core.shared.i18n.I18nTranslationService;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.event.dom.client.BlurEvent;
-import com.google.gwt.event.dom.client.ChangeEvent;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.KeyPressEvent;
-import com.google.gwt.uibinder.client.UiBinder;
-import com.google.gwt.uibinder.client.UiField;
-import com.google.gwt.uibinder.client.UiHandler;
-import com.google.gwt.user.client.Timer;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.PushButton;
-import com.google.gwt.user.client.ui.TextArea;
-import com.google.gwt.user.client.ui.Widget;
-
-/**
- * A form used for editing contacts.
- */
-public class I18nTranslatorForm extends Composite {
-
-  interface Binder extends UiBinder<Widget, I18nTranslatorForm> {
-  }
-
-  private static Binder uiBinder = GWT.create(Binder.class);
-  @UiField
-  PushButton copyIcon;
-  private I18nTranslationDataProvider dataProvider;
-  private I18nTranslationService i18n;
-  private I18nTranslationDTO item;
-  @UiField
-  Label keyboardRecomendation;
-  @UiField
-  Label keyboardRecomendationTitle;
-  private final Timer keyboardTimer;
-  @UiField
-  Label noteForTranslators;
-  @UiField
-  Label noteForTranslatorsTittle;
-  private I18nTraslatorSaver saver;
-  @UiField
-  Label toLanguageTitle;
-  @UiField
-  Label toTranslate;
-  @UiField
-  Label toTranslateTitle;
-  @UiField
-  TextArea translation;
-
-  public I18nTranslatorForm() {
-    initWidget(uiBinder.createAndBindUi(this));
-    keyboardTimer = new Timer() {
-      @Override
-      public void run() {
-        update();
-      }
-    };
-  }
-
-  private void copyTranslation() {
-    translation.setText(toTranslate.getText());
-  }
-
-  public void focusToTranslate() {
-    translation.setFocus(true);
-  }
-
-  @UiHandler("translation")
-  void handleBlur(final BlurEvent event) {
-    update();
-  }
-
-  @UiHandler("copyIcon")
-  void handleClickOnCopyIcon(final ClickEvent e) {
-    copyTranslation();
-    translation.setFocus(true);
-    updateWithTimer();
-  }
-
-  @UiHandler("translation")
-  void handleKeyPress(final ChangeEvent event) {
-    updateWithTimer();
-  }
-
-  @UiHandler("translation")
-  void handleKeyPress(final KeyPressEvent event) {
-    if (event.isAltKeyDown()
-        && event.getNativeEvent().getKeyCode() == com.google.gwt.event.dom.client.KeyCodes.KEY_PAGEUP) {
-      saveIfNeeded();
-      dataProvider.selectPrevious();
-    } else if (event.isAltKeyDown()
-        && event.getNativeEvent().getKeyCode() == com.google.gwt.event.dom.client.KeyCodes.KEY_PAGEDOWN) {
-      saveIfNeeded();
-      dataProvider.selectNext();
-    } else if (event.isAltKeyDown() && event.getCharCode() == 'v') {
-      copyTranslation();
-      event.stopPropagation();
-      updateWithTimer();
-    }
-  }
-
-  public void init(final I18nTranslationDataProvider dataProvider, final I18nTranslationService i18n,
-      final I18nTraslatorSaver saver) {
-    this.dataProvider = dataProvider;
-    this.i18n = i18n;
-    this.saver = saver;
-    Tooltip.to(copyIcon, i18n.t("Copy the text to translate"));
-    toTranslateTitle.setText(i18n.t("translate this:"));
-    noteForTranslatorsTittle.setText(i18n.t("Notes:"));
-    keyboardRecomendationTitle.setText(i18n.t("Tip:"));
-    keyboardRecomendation.setText(i18n.t("Pulse Alt+PageUp or Alt+PageDown to move up/down in the list while translating, and Alt-V to copy the original text. The translations are autosaved"));
-  }
-
-  private void saveIfNeeded() {
-    keyboardTimer.cancel();
-    final String newTranslation = translation.getText();
-    if (item != null && !item.getText().equals(newTranslation)) {
-      saver.save(new I18nTranslationDTO(item.getId(), item.getTrKey(), newTranslation));
-    }
-  }
-
-  public void setInfo(final I18nTranslationDTO item) {
-    saveIfNeeded();
-    this.item = item;
-    final String[] splitted = splitNT(item.getTrKey());
-    toTranslate.setText(splitted[0]);
-    final boolean hasNT = splitted.length > 1;
-    noteForTranslators.setVisible(hasNT);
-    noteForTranslatorsTittle.setVisible(hasNT);
-    if (hasNT) {
-      noteForTranslators.setText(splitted[1]);
-    }
-    translation.setText(item.getText());
-  }
-
-  public void setToLanguage(final I18nLanguageSimpleDTO language) {
-    toLanguageTitle.setText(i18n.tWithNT("to [%s]:", "For example, 'to Spanish':",
-        language.getEnglishName()));
-  }
-
-  private String[] splitNT(final String textWithNT) {
-    String[] nt;
-    final String[] splitted = textWithNT.split(" \\[%NT ");
-    if (splitted.length > 1) {
-      nt = splitted[1].split("\\]$");
-      splitted[1] = nt[0];
-    }
-    return splitted;
-  }
-
-  private void update() {
-    keyboardTimer.cancel();
-    if (item != null) {
-      item.setText(translation.getText());
-      item.setDirty(true);
-      dataProvider.refreshDisplays();
-      saveIfNeeded();
-    }
-  }
-
-  private void updateWithTimer() {
-    keyboardTimer.cancel();
-    keyboardTimer.schedule(3000);
-  }
-}

Added: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.java	                        (rev 0)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.java	2011-09-11 12:02:36 UTC (rev 1514)
@@ -0,0 +1,180 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package cc.kune.gspace.client.i18n;
+
+import cc.kune.common.client.tooltip.Tooltip;
+import cc.kune.common.client.utils.TextUtils;
+import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
+import cc.kune.core.shared.dto.I18nTranslationDTO;
+import cc.kune.core.shared.i18n.I18nTranslationService;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.BlurEvent;
+import com.google.gwt.event.dom.client.ChangeEvent;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.KeyPressEvent;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.uibinder.client.UiHandler;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.PushButton;
+import com.google.gwt.user.client.ui.TextArea;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * A form used for editing contacts.
+ */
+public class I18nTranslatorForm extends Composite {
+
+  interface Binder extends UiBinder<Widget, I18nTranslatorForm> {
+  }
+
+  private static Binder uiBinder = GWT.create(Binder.class);
+  @UiField
+  PushButton copyIcon;
+  private I18nTranslationDataProvider dataProvider;
+  private I18nTranslationService i18n;
+  private I18nTranslationDTO item;
+  @UiField
+  Label keyboardRecomendation;
+  @UiField
+  Label keyboardRecomendationTitle;
+  private final Timer keyboardTimer;
+  @UiField
+  Label noteForTranslators;
+  @UiField
+  Label noteForTranslatorsTittle;
+  private I18nTraslatorSaver saver;
+  @UiField
+  Label toLanguageTitle;
+  @UiField
+  Label toTranslate;
+  @UiField
+  Label toTranslateTitle;
+  @UiField
+  TextArea translation;
+
+  public I18nTranslatorForm() {
+    initWidget(uiBinder.createAndBindUi(this));
+    keyboardTimer = new Timer() {
+      @Override
+      public void run() {
+        saveIfNeeded();
+      }
+    };
+  }
+
+  private void copyTranslation() {
+    translation.setText(toTranslate.getText());
+  }
+
+  public void focusToTranslate() {
+    translation.setFocus(true);
+  }
+
+  @UiHandler("translation")
+  void handleBlur(final BlurEvent event) {
+    saveIfNeeded();
+  }
+
+  @UiHandler("copyIcon")
+  void handleClickOnCopyIcon(final ClickEvent e) {
+    copyTranslation();
+    translation.setFocus(true);
+    updateWithTimer();
+  }
+
+  @UiHandler("translation")
+  void handleKeyPress(final ChangeEvent event) {
+    updateWithTimer();
+  }
+
+  @UiHandler("translation")
+  void handleKeyPress(final KeyPressEvent event) {
+    if (event.isAltKeyDown()
+        && event.getNativeEvent().getKeyCode() == com.google.gwt.event.dom.client.KeyCodes.KEY_PAGEUP) {
+      saveIfNeeded();
+      dataProvider.selectPrevious();
+    } else if (event.isAltKeyDown()
+        && event.getNativeEvent().getKeyCode() == com.google.gwt.event.dom.client.KeyCodes.KEY_PAGEDOWN) {
+      saveIfNeeded();
+      dataProvider.selectNext();
+    } else if (event.isAltKeyDown() && event.getCharCode() == 'v') {
+      copyTranslation();
+      event.stopPropagation();
+      updateWithTimer();
+    }
+  }
+
+  public void init(final I18nTranslationDataProvider dataProvider, final I18nTranslationService i18n,
+      final I18nTraslatorSaver saver) {
+    this.dataProvider = dataProvider;
+    this.i18n = i18n;
+    this.saver = saver;
+    Tooltip.to(copyIcon, i18n.t("Copy the text to translate"));
+    toTranslateTitle.setText(i18n.t("translate this:"));
+    noteForTranslatorsTittle.setText(i18n.t("Notes:"));
+    keyboardRecomendationTitle.setText(i18n.t("Tip:"));
+    keyboardRecomendation.setText(i18n.t("Pulse Alt+PageUp or Alt+PageDown to move up/down in the list while translating, and Alt-V to copy the original text. The translations are autosaved"));
+  }
+
+  private void saveIfNeeded() {
+    keyboardTimer.cancel();
+    final String newTranslation = translation.getText();
+    if (item != null && TextUtils.notEmpty(newTranslation) && !newTranslation.equals(item.getText())) {
+      item.setText(translation.getText());
+      item.setDirty(true);
+      dataProvider.refreshDisplays();
+      saver.save(new I18nTranslationDTO(item.getId(), item.getTrKey(), newTranslation));
+    }
+  }
+
+  public void setInfo(final I18nTranslationDTO item) {
+    saveIfNeeded();
+    this.item = item;
+    final String[] splitted = splitNT(item.getTrKey());
+    toTranslate.setText(splitted[0]);
+    final boolean hasNT = splitted.length > 1;
+    noteForTranslators.setVisible(hasNT);
+    noteForTranslatorsTittle.setVisible(hasNT);
+    if (hasNT) {
+      noteForTranslators.setText(splitted[1]);
+    }
+    translation.setText(item.getText());
+  }
+
+  public void setToLanguage(final I18nLanguageSimpleDTO language) {
+    toLanguageTitle.setText(i18n.tWithNT("to [%s]:", "For example, 'to Spanish':",
+        language.getEnglishName()));
+  }
+
+  private String[] splitNT(final String textWithNT) {
+    String[] nt;
+    final String[] splitted = textWithNT.split(" \\[%NT ");
+    if (splitted.length > 1) {
+      nt = splitted[1].split("\\]$");
+      splitted[1] = nt[0];
+    }
+    return splitted;
+  }
+
+  private void updateWithTimer() {
+    keyboardTimer.cancel();
+    keyboardTimer.schedule(3000);
+  }
+}

Deleted: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.ui.xml
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.ui.xml	2011-09-07 21:37:23 UTC (rev 1513)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.ui.xml	2011-09-11 12:02:36 UTC (rev 1514)
@@ -1,102 +0,0 @@
-<!DOCTYPE ui:UiBinder SYSTEM 'http://dl.google.com/gwt/DTD/xhtml.ent'>
-<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
-  xmlns:g='urn:import:com.google.gwt.user.client.ui' xmlns:d='urn:import:com.google.gwt.user.datepicker.client'
-  ui:generateFormat='com.google.gwt.i18n.rebind.format.PropertiesFormat'
-  ui:generateLocales='default'>
-
-  <ui:with field='res' type='cc.kune.core.client.resources.CoreResources'/>
-
-  <ui:style>
-    .titles {
-      font-size: bold;
-      text-align: right;
-      padding-right: 10px;
-      vertical-align: top;
-    }
-
-    .table {
-      display: table;
-    }
-
-    .copyicon {
-      vertical-align: top;
-      height: 10px !important;
-      -webkit-border-bottom-right-radius: 5px;
-      -moz-border-radius-bottomright: 5px;
-      border-bottom-right-radius: 5px;
-      -webkit-border-bottom-left-radius: 5px;
-      -moz-border-radius-bottomleft: 5px;
-      border-bottom-left-radius: 5px;
-    }
-
-    .row {
-      display: table-row;
-      margin: 5px 5px 15px 5px;
-    }
-
-    .cell {
-      display: table-cell;
-      padding: 5px;
-    }
-
-    .tip {
-      width: 180px;
-      padding: 5px;
-      font-size: 9px;
-      vertical-align: top;
-    }
-
-    .toTranslate {
-      width: 180px;
-      height: 95px;
-      border: 1px dashed #BBBBBB;
-    }
-
-    div.toTranslate {
-      -moz-border-radius: 3px;
-      -webkit-border-radius: 3px;
-      border-radius: 3px;
-      padding: 3px;
-    }
-
-    .toTranlateLabel {
-      height: 95px !important;
-      overflow-y: scroll;
-    }
-  </ui:style>
-  <g:FlowPanel addStyleNames="{style.table}">
-    <g:FlowPanel addStyleNames="{style.row}">
-      <g:Label ui:field="toTranslateTitle" addStyleNames="{style.titles} {style.cell}"/>
-      <g:FlowPanel addStyleNames="{style.cell}" styleName="{style.toTranslate}">
-        <g:Label ui:field="toTranslate" styleName="{style.toTranlateLabel}"/>
-      </g:FlowPanel>
-      <g:Label addStyleNames="{style.row}"/>
-    </g:FlowPanel>
-    <g:FlowPanel addStyleNames="{style.row}">
-      <g:Label ui:field="toLanguageTitle" addStyleNames="{style.titles} {style.cell}"/>
-      <g:TextArea ui:field='translation' addStyleNames="{style.cell}"
-        visibleLines="5"/>
-      <g:FlowPanel styleName="k-button"
-        addStyleNames="{style.cell} {style.copyicon} k-button k-btn k-5corners">
-        <g:PushButton ui:field='copyIcon' enabled='true'>
-          <g:upFace image='{res.arrowUndo}'/>
-          <g:upHoveringFace/>
-          <g:downFace/>
-          <g:downHoveringFace/>
-        </g:PushButton>
-      </g:FlowPanel>
-    </g:FlowPanel>
-    <g:FlowPanel addStyleNames="{style.row}">
-      <g:Label ui:field="noteForTranslatorsTittle" visible="false"
-        addStyleNames="{style.titles} {style.cell}"/>
-      <g:Label ui:field="noteForTranslators" addStyleNames="{style.cell}"/>
-      <g:Label addStyleNames="{style.row}"/>
-    </g:FlowPanel>
-    <g:FlowPanel addStyleNames="{style.row}">
-      <g:Label ui:field="keyboardRecomendationTitle"
-        addStyleNames="{style.titles} {style.cell}"/>
-      <g:Label ui:field="keyboardRecomendation" addStyleNames="{style.cell} {style.tip}"/>
-      <g:Label addStyleNames="{style.row}"/>
-    </g:FlowPanel>
-  </g:FlowPanel>
-</ui:UiBinder>

Added: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.ui.xml
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.ui.xml	                        (rev 0)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.ui.xml	2011-09-11 12:02:36 UTC (rev 1514)
@@ -0,0 +1,102 @@
+<!DOCTYPE ui:UiBinder SYSTEM 'http://dl.google.com/gwt/DTD/xhtml.ent'>
+<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
+  xmlns:g='urn:import:com.google.gwt.user.client.ui' xmlns:d='urn:import:com.google.gwt.user.datepicker.client'
+  ui:generateFormat='com.google.gwt.i18n.rebind.format.PropertiesFormat'
+  ui:generateLocales='default'>
+
+  <ui:with field='res' type='cc.kune.core.client.resources.CoreResources'/>
+
+  <ui:style>
+    .titles {
+      font-size: bold;
+      text-align: right;
+      padding-right: 10px;
+      vertical-align: top;
+    }
+
+    .table {
+      display: table;
+    }
+
+    .copyicon {
+      vertical-align: top;
+      height: 10px !important;
+      -webkit-border-bottom-right-radius: 5px;
+      -moz-border-radius-bottomright: 5px;
+      border-bottom-right-radius: 5px;
+      -webkit-border-bottom-left-radius: 5px;
+      -moz-border-radius-bottomleft: 5px;
+      border-bottom-left-radius: 5px;
+    }
+
+    .row {
+      display: table-row;
+      margin: 5px 5px 15px 5px;
+    }
+
+    .cell {
+      display: table-cell;
+      padding: 5px;
+    }
+
+    .tip {
+      width: 180px;
+      padding: 5px;
+      font-size: 9px;
+      vertical-align: top;
+    }
+
+    .toTranslate {
+      width: 180px;
+      height: 95px;
+      border: 1px dashed #BBBBBB;
+    }
+
+    div.toTranslate {
+      -moz-border-radius: 3px;
+      -webkit-border-radius: 3px;
+      border-radius: 3px;
+      padding: 3px;
+    }
+
+    .toTranlateLabel {
+      height: 95px !important;
+      overflow-y: scroll;
+    }
+  </ui:style>
+  <g:FlowPanel addStyleNames="{style.table}">
+    <g:FlowPanel addStyleNames="{style.row}">
+      <g:Label ui:field="toTranslateTitle" addStyleNames="{style.titles} {style.cell}"/>
+      <g:FlowPanel addStyleNames="{style.cell}" styleName="{style.toTranslate}">
+        <g:Label ui:field="toTranslate" styleName="{style.toTranlateLabel}"/>
+      </g:FlowPanel>
+      <g:Label addStyleNames="{style.row}"/>
+    </g:FlowPanel>
+    <g:FlowPanel addStyleNames="{style.row}">
+      <g:Label ui:field="toLanguageTitle" addStyleNames="{style.titles} {style.cell}"/>
+      <g:TextArea ui:field='translation' addStyleNames="{style.cell}"
+        visibleLines="5"/>
+      <g:FlowPanel styleName="k-button"
+        addStyleNames="{style.cell} {style.copyicon} k-button k-btn k-5corners">
+        <g:PushButton ui:field='copyIcon' enabled='true'>
+          <g:upFace image='{res.arrowUndo}'/>
+          <g:upHoveringFace/>
+          <g:downFace/>
+          <g:downHoveringFace/>
+        </g:PushButton>
+      </g:FlowPanel>
+    </g:FlowPanel>
+    <g:FlowPanel addStyleNames="{style.row}">
+      <g:Label ui:field="noteForTranslatorsTittle" visible="false"
+        addStyleNames="{style.titles} {style.cell}"/>
+      <g:Label ui:field="noteForTranslators" addStyleNames="{style.cell}"/>
+      <g:Label addStyleNames="{style.row}"/>
+    </g:FlowPanel>
+    <g:FlowPanel addStyleNames="{style.row}">
+      <g:Label ui:field="keyboardRecomendationTitle"
+        addStyleNames="{style.titles} {style.cell}"/>
+      <g:Label ui:field="keyboardRecomendation" addStyleNames="{style.cell} {style.tip}"/>
+      <g:Label addStyleNames="{style.row}"/>
+    </g:FlowPanel>
+  </g:FlowPanel>
+</ui:UiBinder>

Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPresenter.java	2011-09-07 21:37:23 UTC (rev 1513)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPresenter.java	2011-09-11 12:02:36 UTC (rev 1514)
@@ -1,6 +1,5 @@
 package cc.kune.gspace.client.i18n;
 
-import cc.kune.common.client.notify.NotifyUser;
 import cc.kune.common.client.ui.dialogs.tabbed.AbstractTabbedDialog;
 import cc.kune.common.client.ui.dialogs.tabbed.AbstractTabbedDialogPresenter;
 import cc.kune.core.client.i18n.I18nUITranslationService;
@@ -31,7 +30,6 @@
 
   }
 
-  private final I18nUITranslationService i18n;
   private final Session session;
 
   @Inject
@@ -39,7 +37,6 @@
       final Session session, final I18nUITranslationService i18n, final I18nTranslatorView view) {
     super(eventBus, view, proxy);
     this.session = session;
-    this.i18n = i18n;
   }
 
   public void doClose() {
@@ -64,14 +61,8 @@
 
   @Override
   public void show() {
-    NotifyUser.showProgressLoading();
-    if (session.isLogged()) {
-      final I18nLanguageDTO userLang = session.getCurrentLanguage();
-      getView().setLanguage(new I18nLanguageSimpleDTO(userLang.getCode(), userLang.getEnglishName()));
-      getView().show();
-    } else {
-      NotifyUser.info(i18n.t("Sign in or register to help with the translation"));
-    }
-    NotifyUser.hideProgress();
+    final I18nLanguageDTO userLang = session.getCurrentLanguage();
+    getView().setLanguage(new I18nLanguageSimpleDTO(userLang.getCode(), userLang.getEnglishName()));
+    getView().show();
   }
 }

Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTraslatorSaver.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTraslatorSaver.java	2011-09-07 21:37:23 UTC (rev 1513)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTraslatorSaver.java	2011-09-11 12:02:36 UTC (rev 1514)
@@ -1,6 +1,7 @@
 package cc.kune.gspace.client.i18n;
 
 import cc.kune.common.client.notify.NotifyUser;
+import cc.kune.core.client.errors.AccessViolationException;
 import cc.kune.core.client.i18n.I18nUITranslationService;
 import cc.kune.core.client.rpcservices.I18nServiceAsync;
 import cc.kune.core.client.state.Session;
@@ -32,7 +33,13 @@
           @Override
           public void onFailure(final Throwable caught) {
             NotifyUser.hideProgress();
-            NotifyUser.error(i18n.t("Server error saving the translation"));
+            if (caught instanceof AccessViolationException) {
+              NotifyUser.error(
+                  i18n.t("Only to authorized translators"),
+                  i18n.t("To help with the translation of this software please contact before with this site administrators"));
+            } else {
+              NotifyUser.error(i18n.t("Server error saving the translation"));
+            }
           }
 
           @Override

Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/SiteOptionsI18nTranslatorAction.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/SiteOptionsI18nTranslatorAction.java	2011-09-07 21:37:23 UTC (rev 1513)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/SiteOptionsI18nTranslatorAction.java	2011-09-11 12:02:36 UTC (rev 1514)
@@ -19,12 +19,17 @@
  */
 package cc.kune.gspace.client.i18n;
 
-import cc.kune.common.client.actions.AbstractExtendedAction;
 import cc.kune.common.client.actions.Action;
 import cc.kune.common.client.actions.ActionEvent;
 import cc.kune.common.client.actions.ui.descrip.MenuItemDescriptor;
+import cc.kune.common.client.notify.NotifyUser;
+import cc.kune.core.client.actions.RolActionAutoUpdated;
 import cc.kune.core.client.resources.CoreResources;
 import cc.kune.core.client.sitebar.SitebarActionsPresenter;
+import cc.kune.core.client.state.AccessRightsClientManager;
+import cc.kune.core.client.state.Session;
+import cc.kune.core.client.state.StateManager;
+import cc.kune.core.shared.dto.AccessRolDTO;
 import cc.kune.core.shared.i18n.I18nTranslationService;
 
 import com.google.inject.Inject;
@@ -32,14 +37,18 @@
 import com.google.inject.Singleton;
 
 @Singleton
-public class SiteOptionsI18nTranslatorAction extends AbstractExtendedAction {
+public class SiteOptionsI18nTranslatorAction extends RolActionAutoUpdated {
+  private final I18nTranslationService i18n;
   private I18nTranslator translator;
   private final Provider<I18nTranslator> translatorProv;
 
   @Inject
-  public SiteOptionsI18nTranslatorAction(final I18nTranslationService i18n, final CoreResources img,
-      final Provider<I18nTranslator> translatorProv, final SitebarActionsPresenter siteOptions) {
-    super();
+  public SiteOptionsI18nTranslatorAction(final StateManager stateManager, final Session session,
+      final AccessRightsClientManager rightsManager, final I18nTranslationService i18n,
+      final CoreResources img, final Provider<I18nTranslator> translatorProv,
+      final SitebarActionsPresenter siteOptions) {
+    super(stateManager, session, rightsManager, AccessRolDTO.Viewer, true, true, true);
+    this.i18n = i18n;
     this.translatorProv = translatorProv;
     putValue(Action.NAME, i18n.t("Help with the translation"));
     putValue(Action.SMALL_ICON, img.language());
@@ -48,10 +57,15 @@
 
   @Override
   public void actionPerformed(final ActionEvent event) {
-    if (translator == null) {
-      translator = translatorProv.get();
+    NotifyUser.showProgressLoading();
+    if (session.isLogged()) {
+      if (translator == null) {
+        translator = translatorProv.get();
+      }
+      translator.show();
+    } else {
+      NotifyUser.info(i18n.t("Sign in or register to help with the translation"));
     }
-    translator.show();
-    // item.setPosition(1);
+    NotifyUser.hideProgress();
   }
 }

Modified: trunk/src/main/java/cc/kune/lists/client/actions/NewListAction.java
===================================================================
--- trunk/src/main/java/cc/kune/lists/client/actions/NewListAction.java	2011-09-07 21:37:23 UTC (rev 1513)
+++ trunk/src/main/java/cc/kune/lists/client/actions/NewListAction.java	2011-09-11 12:02:36 UTC (rev 1514)
@@ -67,21 +67,23 @@
     diag.getFirstBtn().addClickHandler(new ClickHandler() {
       @Override
       public void onClick(final ClickEvent event) {
-        NotifyUser.showProgressProcessing();
-        diag.hide();
-        listsService.get().createList(session.getUserHash(), session.getCurrentStateToken(),
-            diag.getTextFieldValue(), ListsConstants.TYPE_LIST, true,
-            new AsyncCallbackSimple<StateContainerDTO>() {
-              @Override
-              public void onSuccess(final StateContainerDTO state) {
-                stateManager.setRetrievedStateAndGo(state);
-                NotifyUser.hideProgress();
+        if (diag.isValid()) {
+          NotifyUser.showProgressProcessing();
+          diag.hide();
+          listsService.get().createList(session.getUserHash(), session.getCurrentStateToken(),
+              diag.getTextFieldValue(), ListsConstants.TYPE_LIST, true,
+              new AsyncCallbackSimple<StateContainerDTO>() {
+                @Override
+                public void onSuccess(final StateContainerDTO state) {
+                  stateManager.setRetrievedStateAndGo(state);
+                  NotifyUser.hideProgress();
 
-                NotifyUser.info(i18n.t("List created"));
-                folderViewer.highlightTitle();
-              }
-            });
-        cache.removeContent(session.getCurrentStateToken());
+                  NotifyUser.info(i18n.t("List created"));
+                  folderViewer.highlightTitle();
+                }
+              });
+          cache.removeContent(session.getCurrentStateToken());
+        }
       }
     });
 

Modified: trunk/src/main/java/cc/kune/lists/client/actions/NewListPostAction.java
===================================================================
--- trunk/src/main/java/cc/kune/lists/client/actions/NewListPostAction.java	2011-09-07 21:37:23 UTC (rev 1513)
+++ trunk/src/main/java/cc/kune/lists/client/actions/NewListPostAction.java	2011-09-11 12:02:36 UTC (rev 1514)
@@ -73,20 +73,22 @@
       diag.getFirstBtn().addClickHandler(new ClickHandler() {
         @Override
         public void onClick(final ClickEvent event) {
-          NotifyUser.showProgressProcessing();
-          diag.hide();
-          listsService.get().newPost(session.getUserHash(),
-              session.getCurrentStateToken().copy().clearDocument(), diag.getTextFieldValue(),
-              new AsyncCallbackSimple<StateContentDTO>() {
-                @Override
-                public void onSuccess(final StateContentDTO state) {
-                  stateManager.setRetrievedStateAndGo(state);
-                  NotifyUser.hideProgress();
-                  NotifyUser.info(i18n.t("Post created. Edit it"));
-                  folderViewer.highlightTitle();
-                }
-              });
-          cache.removeContent(session.getCurrentStateToken());
+          if (diag.isValid()) {
+            NotifyUser.showProgressProcessing();
+            diag.hide();
+            listsService.get().newPost(session.getUserHash(),
+                session.getCurrentStateToken().copy().clearDocument(), diag.getTextFieldValue(),
+                new AsyncCallbackSimple<StateContentDTO>() {
+                  @Override
+                  public void onSuccess(final StateContentDTO state) {
+                    stateManager.setRetrievedStateAndGo(state);
+                    NotifyUser.hideProgress();
+                    NotifyUser.info(i18n.t("Post created. Edit it"));
+                    folderViewer.highlightTitle();
+                  }
+                });
+            cache.removeContent(session.getCurrentStateToken());
+          }
         }
       });
     } else {

Added: trunk/src/test/java/cc/kune/core/server/auth/SuperAdminMethodInterceptorTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/server/auth/SuperAdminMethodInterceptorTest.java	                        (rev 0)
+++ trunk/src/test/java/cc/kune/core/server/auth/SuperAdminMethodInterceptorTest.java	2011-09-11 12:02:36 UTC (rev 1514)
@@ -0,0 +1,54 @@
+package cc.kune.core.server.auth;
+
+import java.lang.reflect.AccessibleObject;
+
+import org.aopalliance.intercept.MethodInvocation;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import cc.kune.core.client.errors.AccessViolationException;
+import cc.kune.core.server.integration.IntegrationTest;
+import cc.kune.core.server.integration.IntegrationTestHelper;
+import cc.kune.core.shared.domain.AccessRol;
+
+import com.google.inject.persist.Transactional;
+
+public class SuperAdminMethodInterceptorTest extends IntegrationTest {
+
+  private MethodInvocation invocation;
+  private SuperAdmin superAdminAnnotation;
+  private SuperAdminMethodInterceptor superAdminInterceptor;
+
+  @Transactional
+  @Before
+  public void before() {
+    superAdminInterceptor = new SuperAdminMethodInterceptor();
+    new IntegrationTestHelper(this, superAdminInterceptor);
+    invocation = Mockito.mock(MethodInvocation.class);
+    final AccessibleObject accessibleObject = Mockito.mock(AccessibleObject.class);
+    Mockito.when(invocation.getMethod()).thenReturn(this.getClass().getMethods()[0]);
+    Mockito.when(invocation.getStaticPart()).thenReturn(accessibleObject);
+    superAdminAnnotation = Mockito.mock(SuperAdmin.class);
+    Mockito.when(accessibleObject.getAnnotation(SuperAdmin.class)).thenReturn(superAdminAnnotation);
+  }
+
+  private void invoke() throws Throwable {
+    Mockito.when(superAdminAnnotation.rol()).thenReturn(AccessRol.Administrator);
+    final Object[] arguments = { getHash() };
+    Mockito.when(invocation.getArguments()).thenReturn(arguments);
+    superAdminInterceptor.invoke(invocation);
+  }
+
+  @Test(expected = AccessViolationException.class)
+  public void notMemberThrowsExcep() throws Throwable {
+    doLoginWithDummyUser();
+    invoke();
+  }
+
+  @Test
+  public void superAdminDoTheJob() throws Throwable {
+    doLogin();
+    invoke();
+  }
+}




More information about the kune-commits mailing list