You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2016/07/20 14:58:10 UTC

[16/43] syncope git commit: [SYNCOPE-898] provides the possibility to specify the destination realm

[SYNCOPE-898] provides the possibility to specify the destination realm


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/46e642ea
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/46e642ea
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/46e642ea

Branch: refs/heads/2_0_NO_JAXB
Commit: 46e642eaf3a3375f2d51f422e0f91ded5cf74e19
Parents: 0656bc0
Author: fmartelli <fa...@gmail.com>
Authored: Fri Jul 8 13:20:23 2016 +0200
Committer: fmartelli <fa...@gmail.com>
Committed: Fri Jul 8 13:20:23 2016 +0200

----------------------------------------------------------------------
 .../console/commons/AnyTypeComparator.java      |  6 +-
 .../client/console/commons/GroupComparator.java | 37 ++++++++++
 .../client/console/rest/GroupRestClient.java    | 24 +++++--
 .../console/tasks/TemplatesTogglePanel.java     |  2 +-
 .../console/wizards/any/AnyObjectDetails.java   |  2 +-
 .../any/AnyObjectTemplateWizardBuilder.java     |  6 +-
 .../console/wizards/any/AnyWizardBuilder.java   |  8 ++-
 .../client/console/wizards/any/Details.java     | 17 ++++-
 .../console/wizards/any/GroupDetails.java       |  2 +-
 .../wizards/any/GroupTemplateWizardBuilder.java |  7 +-
 .../client/console/wizards/any/Groups.java      | 75 ++++++++++----------
 .../client/console/wizards/any/UserDetails.java |  6 +-
 .../wizards/any/UserTemplateWizardBuilder.java  |  7 +-
 .../client/console/wizards/any/Details.html     |  3 +
 .../console/wizards/any/Details.properties      | 22 ++++++
 .../console/wizards/any/Details_it.properties   | 22 ++++++
 .../wizards/any/Details_pt_BR.properties        | 22 ++++++
 .../console/wizards/any/Details_ru.properties   | 26 +++++++
 .../console/wizards/any/UserDetails.properties  | 21 ------
 .../wizards/any/UserDetails_it.properties       | 21 ------
 .../wizards/any/UserDetails_pt_BR.properties    | 21 ------
 .../wizards/any/UserDetails_ru.properties       | 25 -------
 .../syncope/fit/console/RealmsITCase.java       | 10 ++-
 23 files changed, 244 insertions(+), 148 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/java/org/apache/syncope/client/console/commons/AnyTypeComparator.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/AnyTypeComparator.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/AnyTypeComparator.java
index d19d205..06dcb13 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/commons/AnyTypeComparator.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/commons/AnyTypeComparator.java
@@ -18,12 +18,15 @@
  */
 package org.apache.syncope.client.console.commons;
 
+import java.io.Serializable;
 import java.util.Comparator;
 import org.apache.commons.collections4.ComparatorUtils;
 import org.apache.syncope.common.lib.to.AnyTypeTO;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
 
-public class AnyTypeComparator implements Comparator<AnyTypeTO> {
+public class AnyTypeComparator implements Comparator<AnyTypeTO>, Serializable {
+
+    private static final long serialVersionUID = -8227715253094467138L;
 
     @Override
     public int compare(final AnyTypeTO o1, final AnyTypeTO o2) {
@@ -41,5 +44,4 @@ public class AnyTypeComparator implements Comparator<AnyTypeTO> {
         }
         return ComparatorUtils.<String>naturalComparator().compare(o1.getKey(), o2.getKey());
     }
-
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/java/org/apache/syncope/client/console/commons/GroupComparator.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/GroupComparator.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/GroupComparator.java
new file mode 100644
index 0000000..b45633f
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/commons/GroupComparator.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.syncope.client.console.commons;
+
+import java.io.Serializable;
+import java.util.Comparator;
+import org.apache.syncope.common.lib.to.GroupTO;
+
+public class GroupComparator implements Comparator<GroupTO>, Serializable {
+
+    private static final long serialVersionUID = 3584905855352863080L;
+
+    @Override
+    public int compare(final GroupTO left, final GroupTO right) {
+        return left == null || left.getName() == null
+                ? -1
+                : right == null || right.getName() == null
+                ? 1
+                : left.getName().compareTo(right.getName());
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/java/org/apache/syncope/client/console/rest/GroupRestClient.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/rest/GroupRestClient.java b/client/console/src/main/java/org/apache/syncope/client/console/rest/GroupRestClient.java
index 36b2845..c4f78c9 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/rest/GroupRestClient.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/rest/GroupRestClient.java
@@ -18,9 +18,13 @@
  */
 package org.apache.syncope.client.console.rest;
 
+import static org.apache.syncope.client.console.rest.BaseRestClient.getService;
+
+import java.util.ArrayList;
 import java.util.List;
 import org.apache.syncope.common.lib.patch.GroupPatch;
 import org.apache.syncope.common.lib.to.GroupTO;
+import org.apache.syncope.common.lib.to.PagedResult;
 import org.apache.syncope.common.lib.types.BulkMembersActionType;
 import org.apache.syncope.common.rest.api.beans.AnyQuery;
 import org.apache.syncope.common.rest.api.service.AnyService;
@@ -48,13 +52,23 @@ public class GroupRestClient extends AbstractAnyRestClient<GroupTO, GroupPatch>
 
     @Override
     public List<GroupTO> search(
-            final String realm, final String fiql, final int page, final int size, final SortParam<String> sort,
+            final String realm,
+            final String fiql,
+            final int page,
+            final int size,
+            final SortParam<String> sort,
             final String type) {
 
-        return getService(GroupService.class).
-                search(new AnyQuery.Builder().realm(realm).fiql(fiql).page(page).size(size).
-                        orderBy(toOrderBy(sort)).details(false).build()).
-                getResult();
+        List<GroupTO> result = new ArrayList<>();
+        PagedResult<GroupTO> res;
+        do {
+            res = getService(GroupService.class).
+                    search(new AnyQuery.Builder().realm(realm).fiql(fiql).page(page).size(size).
+                    orderBy(toOrderBy(sort)).details(false).build());
+            result.addAll(res.getResult());
+        } while (page == -1 && size == -1 && res.getNext() != null);
+
+        return result;
     }
 
     public void bulkMembersAction(final String key, final BulkMembersActionType actionType) {

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/java/org/apache/syncope/client/console/tasks/TemplatesTogglePanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/tasks/TemplatesTogglePanel.java b/client/console/src/main/java/org/apache/syncope/client/console/tasks/TemplatesTogglePanel.java
index 32c171e..53edb6e 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/tasks/TemplatesTogglePanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/tasks/TemplatesTogglePanel.java
@@ -102,7 +102,7 @@ public abstract class TemplatesTogglePanel extends TogglePanel<Serializable> {
             protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
                 try {
                     final AjaxWizard.NewItemActionEvent<AnyTO> payload
-                            = new AjaxWizard.NewItemActionEvent<AnyTO>(null, target);
+                            = new AjaxWizard.NewItemActionEvent<>(null, target);
 
                     payload.setResourceModel(new StringResourceModel("inner.template.edit", container,
                             Model.of(Pair.of(typeModel.getObject(), targetObject))).setDefaultValue(

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectDetails.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectDetails.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectDetails.java
index 5d149e7..dc48586 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectDetails.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectDetails.java
@@ -37,7 +37,7 @@ public class AnyObjectDetails extends Details<AnyObjectTO> {
             final boolean includeStatusPanel,
             final PageReference pageRef) {
 
-        super(wrapper, statusModel, includeStatusPanel, pageRef);
+        super(wrapper, statusModel, templateMode, includeStatusPanel, pageRef);
 
         AnyObjectTO anyObjectTO = wrapper.getInnerObject();
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectTemplateWizardBuilder.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectTemplateWizardBuilder.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectTemplateWizardBuilder.java
index 6f60db3..da37ad5 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectTemplateWizardBuilder.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectTemplateWizardBuilder.java
@@ -22,6 +22,7 @@ import java.util.List;
 import org.apache.syncope.client.console.layout.AnyObjectFormLayoutInfo;
 import org.apache.syncope.client.console.wizards.AjaxWizard;
 import org.apache.syncope.common.lib.to.AnyObjectTO;
+import org.apache.syncope.common.lib.to.RealmTO;
 import org.apache.syncope.common.lib.to.TemplatableTO;
 import org.apache.wicket.PageReference;
 
@@ -43,7 +44,10 @@ public class AnyObjectTemplateWizardBuilder extends AnyObjectWizardBuilder
         } else {
             AnyObjectTO anyObjectTO = new AnyObjectTO();
             anyObjectTO.setType(anyType);
-            setItem(new AnyWrapper<>(new AnyObjectTO()));
+            if (templatable instanceof RealmTO) {
+                anyObjectTO.setRealm(RealmTO.class.cast(templatable).getFullPath());
+            }
+            setItem(new AnyWrapper<>(anyObjectTO));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyWizardBuilder.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyWizardBuilder.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyWizardBuilder.java
index 41fa6bb..793ebc7 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyWizardBuilder.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyWizardBuilder.java
@@ -108,7 +108,7 @@ public abstract class AnyWizardBuilder<A extends AnyTO> extends AjaxWizardBuilde
                 || formLayoutInfo instanceof AnyObjectFormLayoutInfo
                 && AnyObjectFormLayoutInfo.class.cast(formLayoutInfo).isGroups()) {
 
-            wizardModel.add(new Groups(modelObject.getInnerObject()));
+            wizardModel.add(new Groups(modelObject.getInnerObject(), mode == AjaxWizard.Mode.TEMPLATE));
         }
 
         // attributes panel steps
@@ -160,7 +160,11 @@ public abstract class AnyWizardBuilder<A extends AnyTO> extends AjaxWizardBuilde
 
         if (modelObject.getInnerObject().getKey() != null) {
             wizardModel.add(new Details<>(
-                    modelObject, new ListModel<>(Collections.<StatusBean>emptyList()), true, pageRef));
+                    modelObject,
+                    new ListModel<>(Collections.<StatusBean>emptyList()),
+                    mode == AjaxWizard.Mode.TEMPLATE,
+                    true,
+                    pageRef));
         }
         return this;
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Details.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Details.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Details.java
index a30d6bf..483539a 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Details.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Details.java
@@ -19,11 +19,14 @@
 package org.apache.syncope.client.console.wizards.any;
 
 import java.util.List;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.syncope.client.console.commons.status.StatusBean;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel;
 import org.apache.syncope.common.lib.to.AnyTO;
 import org.apache.wicket.PageReference;
 import org.apache.wicket.extensions.wizard.WizardStep;
 import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.PropertyModel;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -40,19 +43,27 @@ public class Details<T extends AnyTO> extends WizardStep {
     public Details(
             final AnyWrapper<T> wrapper,
             final IModel<List<StatusBean>> statusModel,
+            final boolean templateMode,
             final boolean includeStatusPanel,
             final PageReference pageRef) {
 
         this.pageRef = pageRef;
 
-        T anyTO = wrapper.getInnerObject();
+        final T inner = wrapper.getInnerObject();
 
-        statusPanel = new StatusPanel("status", anyTO, statusModel, pageRef);
+        final AjaxTextFieldPanel realm = new AjaxTextFieldPanel(
+                "destinationRealm", "destinationRealm", new PropertyModel<String>(inner, "realm"), false);
+        add(realm.setReadOnly(StringUtils.isNotEmpty(inner.getRealm())));
+        if (templateMode) {
+            realm.enableJexlHelp();
+        }
+        
+        statusPanel = new StatusPanel("status", inner, statusModel, pageRef);
 
         add(statusPanel.setEnabled(includeStatusPanel).
                 setVisible(includeStatusPanel).setRenderBodyOnly(true));
 
-        add(getGeneralStatusInformation("generalStatusInformation", anyTO).
+        add(getGeneralStatusInformation("generalStatusInformation", inner).
                 setEnabled(includeStatusPanel).setVisible(includeStatusPanel).setRenderBodyOnly(true));
     }
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupDetails.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupDetails.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupDetails.java
index e61e89c..9c19541 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupDetails.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupDetails.java
@@ -37,7 +37,7 @@ public class GroupDetails extends Details<GroupTO> {
             final boolean includeStatusPanel,
             final PageReference pageRef) {
 
-        super(wrapper, statusModel, includeStatusPanel, pageRef);
+        super(wrapper, statusModel, templateMode, includeStatusPanel, pageRef);
 
         GroupTO groupTO = GroupWrapper.class.cast(wrapper).getInnerObject();
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupTemplateWizardBuilder.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupTemplateWizardBuilder.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupTemplateWizardBuilder.java
index 3f07a38..cccc25f 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupTemplateWizardBuilder.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupTemplateWizardBuilder.java
@@ -22,6 +22,7 @@ import java.util.List;
 import org.apache.syncope.client.console.layout.GroupFormLayoutInfo;
 import org.apache.syncope.client.console.wizards.AjaxWizard;
 import org.apache.syncope.common.lib.to.GroupTO;
+import org.apache.syncope.common.lib.to.RealmTO;
 import org.apache.syncope.common.lib.to.TemplatableTO;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.wicket.PageReference;
@@ -40,7 +41,11 @@ public class GroupTemplateWizardBuilder extends GroupWizardBuilder implements Te
         if (templatable.getTemplates().containsKey(AnyTypeKind.GROUP.name())) {
             setItem(new GroupWrapper(GroupTO.class.cast(templatable.getTemplates().get(AnyTypeKind.GROUP.name()))));
         } else {
-            setItem(new GroupWrapper(new GroupTO()));
+            GroupTO groupTO = new GroupTO();
+            if (templatable instanceof RealmTO) {
+                groupTO.setRealm(RealmTO.class.cast(templatable).getFullPath());
+            }
+            setItem(new GroupWrapper(groupTO));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Groups.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Groups.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Groups.java
index 5131ce6..2e17763 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Groups.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Groups.java
@@ -48,7 +48,7 @@ public class Groups extends WizardStep {
 
     private final GroupRestClient groupRestClient = new GroupRestClient();
 
-    public <T extends AnyTO> Groups(final T anyTO) {
+    public <T extends AnyTO> Groups(final T anyTO, final boolean templateMode) {
         super();
         setOutputMarkupId(true);
 
@@ -57,31 +57,31 @@ public class Groups extends WizardStep {
         AjaxPalettePanel.Builder<MembershipTO> builder = new AjaxPalettePanel.Builder<MembershipTO>().
                 setRenderer(new IChoiceRenderer<MembershipTO>() {
 
-                    private static final long serialVersionUID = -3086661086073628855L;
+            private static final long serialVersionUID = -3086661086073628855L;
 
-                    @Override
-                    public Object getDisplayValue(final MembershipTO object) {
-                        return object.getGroupName();
-                    }
+            @Override
+            public Object getDisplayValue(final MembershipTO object) {
+                return object.getGroupName();
+            }
 
-                    @Override
-                    public String getIdValue(final MembershipTO object, final int index) {
-                        return object.getGroupName();
-                    }
+            @Override
+            public String getIdValue(final MembershipTO object, final int index) {
+                return object.getGroupName();
+            }
 
-                    @Override
-                    public MembershipTO getObject(
-                            final String id, final IModel<? extends List<? extends MembershipTO>> choices) {
+            @Override
+            public MembershipTO getObject(
+                    final String id, final IModel<? extends List<? extends MembershipTO>> choices) {
 
-                        return IterableUtils.find(choices.getObject(), new Predicate<MembershipTO>() {
+                return IterableUtils.find(choices.getObject(), new Predicate<MembershipTO>() {
 
-                            @Override
-                            public boolean evaluate(final MembershipTO object) {
-                                return id.equalsIgnoreCase(object.getGroupName());
-                            }
-                        });
+                    @Override
+                    public boolean evaluate(final MembershipTO object) {
+                        return id.equalsIgnoreCase(object.getGroupName());
                     }
                 });
+            }
+        });
 
         add(builder.setAllowOrder(true).withFilter().build("groups",
                 new ListModel<>(GroupableRelatableTO.class.cast(anyTO).getMemberships()),
@@ -93,12 +93,12 @@ public class Groups extends WizardStep {
             public List<MembershipTO> execute(final String filter) {
                 return CollectionUtils.collect(
                         groupRestClient.search(
-                                anyTO.getRealm(),
-                                SyncopeClient.getGroupSearchConditionBuilder().
-                                isAssignable().and().is("name").equalTo(filter).query(),
-                                -1, -1,
-                                new SortParam<>("name", true),
-                                null),
+                        anyTO.getRealm(),
+                        SyncopeClient.getGroupSearchConditionBuilder().
+                        isAssignable().and().is("name").equalTo(filter).query(),
+                        -1, -1,
+                        new SortParam<>("name", true),
+                        null),
                         new Transformer<GroupTO, MembershipTO>() {
 
                     @Override
@@ -112,27 +112,28 @@ public class Groups extends WizardStep {
         }).hideLabel().setOutputMarkupId(true));
 
         List<GroupTO> allGroups = groupRestClient.search(
-                anyTO.getRealm(), null, -1, -1, new SortParam<>("name", true), null);
+                templateMode ? "/" : anyTO.getRealm(), null, -1, -1, new SortParam<>("name", true), null);
+
         final Map<String, GroupTO> allGroupsByKey = new LinkedHashMap<>(allGroups.size());
         for (GroupTO group : allGroups) {
             allGroupsByKey.put(group.getKey(), group);
         }
         add(new AjaxPalettePanel.Builder<String>().setAllowOrder(true).build("dyngroups",
                 new ListModel<>(CollectionUtils.collect(GroupableRelatableTO.class.cast(anyTO).getDynGroups(),
-                        new Transformer<String, String>() {
+                new Transformer<String, String>() {
 
-                    @Override
-                    public String transform(final String input) {
-                        return allGroupsByKey.get(input).getName();
-                    }
-                }, new ArrayList<String>())),
+            @Override
+            public String transform(final String input) {
+                return allGroupsByKey.get(input).getName();
+            }
+        }, new ArrayList<String>())),
                 new ListModel<>(CollectionUtils.collect(allGroups, new Transformer<GroupTO, String>() {
 
-                    @Override
-                    public String transform(final GroupTO input) {
-                        return input.getName();
-                    }
-                }, new ArrayList<String>()))).
+            @Override
+            public String transform(final GroupTO input) {
+                return input.getName();
+            }
+        }, new ArrayList<String>()))).
                 hideLabel().setEnabled(false).setOutputMarkupId(true));
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserDetails.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserDetails.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserDetails.java
index ac02a6e..8dbfcff 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserDetails.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserDetails.java
@@ -51,8 +51,7 @@ public class UserDetails extends Details<UserTO> {
             final boolean includeStatusPanel,
             final boolean showPasswordManagement,
             final PageReference pageRef) {
-
-        super(wrapper, statusModel, includeStatusPanel, pageRef);
+        super(wrapper, statusModel, templateMode, includeStatusPanel, pageRef);
 
         final UserTO userTO = wrapper.getInnerObject();
         // ------------------------
@@ -85,8 +84,7 @@ public class UserDetails extends Details<UserTO> {
                 panel.setEnabled(model.getObject() >= 0);
                 return panel;
             }
-        }
-        ), model) {
+        }), model) {
 
             private static final long serialVersionUID = -2898628183677758699L;
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserTemplateWizardBuilder.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserTemplateWizardBuilder.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserTemplateWizardBuilder.java
index 4e99a5e..a795cd7 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserTemplateWizardBuilder.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserTemplateWizardBuilder.java
@@ -21,6 +21,7 @@ package org.apache.syncope.client.console.wizards.any;
 import java.util.List;
 import org.apache.syncope.client.console.layout.UserFormLayoutInfo;
 import org.apache.syncope.client.console.wizards.AjaxWizard;
+import org.apache.syncope.common.lib.to.RealmTO;
 import org.apache.syncope.common.lib.to.TemplatableTO;
 import org.apache.syncope.common.lib.to.UserTO;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
@@ -40,7 +41,11 @@ public class UserTemplateWizardBuilder extends UserWizardBuilder implements Temp
         if (templatable.getTemplates().containsKey(AnyTypeKind.USER.name())) {
             setItem(new UserWrapper(UserTO.class.cast(templatable.getTemplates().get(AnyTypeKind.USER.name()))));
         } else {
-            setItem(new UserWrapper(new UserTO()));
+            UserTO userTO = new UserTO();
+            if (templatable instanceof RealmTO) {
+                userTO.setRealm(RealmTO.class.cast(templatable).getFullPath());
+            }
+            setItem(new UserWrapper(userTO));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details.html b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details.html
index 829de18..b8ec7ca 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details.html
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details.html
@@ -21,6 +21,9 @@ under the License.
   <body>
     <wicket:panel>
       <div class="details">
+        <div class="form-group">
+          <span wicket:id="destinationRealm">[DESTINATION REALM]</span>
+        </div>
         <wicket:child/>
         <span wicket:id="status">[STATUS]</span>
       </div>

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details.properties b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details.properties
new file mode 100644
index 0000000..7366c21
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details.properties
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+username=Username
+password=Password
+confirmPassword=Password (confirm)
+password.change=Password management
+storePasswordInSyncope=Store password in Syncope
+destinationRealm=Destination realm

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details_it.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details_it.properties b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details_it.properties
new file mode 100644
index 0000000..b090895
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details_it.properties
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+username=Username
+password=Password
+confirmPassword=Password (conferma)
+password.change=Gestisci password
+storePasswordInSyncope=Salva password in Syncope
+destinationRealm=Realm di destinazione

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details_pt_BR.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details_pt_BR.properties b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details_pt_BR.properties
new file mode 100644
index 0000000..5a6f1a4
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details_pt_BR.properties
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+username=Nome do Usu\u00e1rio
+password=Senha
+confirmPassword=Senha (confirmar)
+password.change=Gest\u00e3o password
+storePasswordInSyncope=Salvar senha in Syncope
+destinationRealm=Destination realm

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details_ru.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details_ru.properties b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details_ru.properties
new file mode 100644
index 0000000..5e6998f
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Details_ru.properties
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+# username=\u00d0\u0098\u00d0\u00bc\u00d1\u008f \u00d0\u00bf\u00d0\u00be\u00d0\u00bb\u00d1\u008c\u00d0\u00b7\u00d0\u00be\u00d0\u00b2\u00d0\u00b0\u00d1\u0082\u00d0\u00b5\u00d0\u00bb\u00d1\u008f
+username=\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f
+# password=\u00d0\u009f\u00d0\u00b0\u00d1\u0080\u00d0\u00be\u00d0\u00bb\u00d1\u008c
+password=\u041f\u0430\u0440\u043e\u043b\u044c
+# confirmPassword=\u00d0\u009f\u00d0\u00b0\u00d1\u0080\u00d0\u00be\u00d0\u00bb\u00d1\u008c (\u00d0\u00bf\u00d0\u00be\u00d0\u00b4\u00d1\u0082\u00d0\u00b2\u00d0\u00b5\u00d1\u0080\u00d0\u00b6\u00d0\u00b4\u00d0\u00b5\u00d0\u00bd\u00d0\u00b8\u00d0\u00b5)
+confirmPassword=\u041f\u0430\u0440\u043e\u043b\u044c (\u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435)
+# password.change=\u00d0\u00a1\u00d0\u00bc\u00d0\u00b5\u00d0\u00bd\u00d0\u00b8\u00d1\u0082\u00d1\u008c \u00d0\u00bf\u00d0\u00b0\u00d1\u0080\u00d0\u00be\u00d0\u00bb\u00d1\u008c ...
+password.change=\u0421\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u044c ...
+storePasswordInSyncope=Store password in Syncope
+destinationRealm=Destination realm

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails.properties b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails.properties
deleted file mode 100644
index 6eebcae..0000000
--- a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-username=Username
-password=Password
-confirmPassword=Password (confirm)
-password.change=Password management
-storePasswordInSyncope=Store password in Syncope

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails_it.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails_it.properties b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails_it.properties
deleted file mode 100644
index 638a8c6..0000000
--- a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails_it.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-username=Username
-password=Password
-confirmPassword=Password (conferma)
-password.change=Gestisci password
-storePasswordInSyncope=Salva password in Syncope

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails_pt_BR.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails_pt_BR.properties b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails_pt_BR.properties
deleted file mode 100644
index 5b7dc9d..0000000
--- a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails_pt_BR.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-username=Nome do Usu\u00e1rio
-password=Senha
-confirmPassword=Senha (confirmar)
-password.change=Gest\u00e3o password
-storePasswordInSyncope=Salvar senha in Syncope

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails_ru.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails_ru.properties b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails_ru.properties
deleted file mode 100644
index 4fe286d..0000000
--- a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails_ru.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-# username=\u00d0\u0098\u00d0\u00bc\u00d1\u008f \u00d0\u00bf\u00d0\u00be\u00d0\u00bb\u00d1\u008c\u00d0\u00b7\u00d0\u00be\u00d0\u00b2\u00d0\u00b0\u00d1\u0082\u00d0\u00b5\u00d0\u00bb\u00d1\u008f
-username=\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f
-# password=\u00d0\u009f\u00d0\u00b0\u00d1\u0080\u00d0\u00be\u00d0\u00bb\u00d1\u008c
-password=\u041f\u0430\u0440\u043e\u043b\u044c
-# confirmPassword=\u00d0\u009f\u00d0\u00b0\u00d1\u0080\u00d0\u00be\u00d0\u00bb\u00d1\u008c (\u00d0\u00bf\u00d0\u00be\u00d0\u00b4\u00d1\u0082\u00d0\u00b2\u00d0\u00b5\u00d1\u0080\u00d0\u00b6\u00d0\u00b4\u00d0\u00b5\u00d0\u00bd\u00d0\u00b8\u00d0\u00b5)
-confirmPassword=\u041f\u0430\u0440\u043e\u043b\u044c (\u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435)
-# password.change=\u00d0\u00a1\u00d0\u00bc\u00d0\u00b5\u00d0\u00bd\u00d0\u00b8\u00d1\u0082\u00d1\u008c \u00d0\u00bf\u00d0\u00b0\u00d1\u0080\u00d0\u00be\u00d0\u00bb\u00d1\u008c ...
-password.change=\u0421\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u044c ...
-storePasswordInSyncope=Store password in Syncope

http://git-wip-us.apache.org/repos/asf/syncope/blob/46e642ea/fit/core-reference/src/test/java/org/apache/syncope/fit/console/RealmsITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/RealmsITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/RealmsITCase.java
index 6b75ee7..ec17ed3 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/RealmsITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/RealmsITCase.java
@@ -110,6 +110,12 @@ public class RealmsITCase extends AbstractConsoleITCase {
 
     @Test
     public void addUserTemplate() {
+        TESTER.executeAjaxEvent("body:content:realmChoicePanel:container:realms:btn", Constants.ON_CLICK);
+        TESTER.executeAjaxEvent("body:content:realmChoicePanel:container:realms:dropdown-menu:buttons:3:button",
+                Constants.ON_CLICK);
+        
+        TESTER.assertLabel("body:content:realmChoicePanel:container:realm", "/odd");
+        
         TESTER.clickLink(
                 "body:content:body:container:content:tabbedPanel:panel:actions:actions:panelTemplate:templateLink");
         TESTER.assertComponent("body:content:toggleTemplates", TogglePanel.class);
@@ -127,6 +133,8 @@ public class RealmsITCase extends AbstractConsoleITCase {
 
         TESTER.assertInfoMessages("Operation executed successfully");
         TESTER.cleanupFeedbackMessages();
+        
+        TESTER.assertLabel("body:content:realmChoicePanel:container:realm", "/odd");
 
         TESTER.clickLink(
                 "body:content:body:container:content:tabbedPanel:panel:actions:actions:panelTemplate:templateLink");
@@ -141,7 +149,7 @@ public class RealmsITCase extends AbstractConsoleITCase {
 
         TESTER.assertModelValue("body:content:templateModal:form:content:form:view:username:textField",
                 "'k' + firstname");
-
+        
         formTester = TESTER.newFormTester("body:content:templateModal:form:content:form");
         formTester.setValue("view:username:textField", "");
         formTester.submit("buttons:finish");