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 2013/10/30 17:08:08 UTC

svn commit: r1537151 - in /syncope/trunk: ./ console/src/main/java/org/apache/syncope/console/pages/panels/ console/src/main/java/org/apache/syncope/console/wicket/markup/html/tree/ console/src/main/resources/org/apache/syncope/console/pages/panels/ co...

Author: ilgrosso
Date: Wed Oct 30 16:08:07 2013
New Revision: 1537151

URL: http://svn.apache.org/r1537151
Log:
[SYNCOPE-432] Merge from 1_1_X

Removed:
    syncope/trunk/console/src/main/java/org/apache/syncope/console/wicket/markup/html/tree/TreeActionLinkPanel.java
    syncope/trunk/console/src/main/resources/org/apache/syncope/console/wicket/markup/html/tree/TreeActionLinkPanel.html
    syncope/trunk/console/src/main/resources/org/apache/syncope/console/wicket/markup/html/tree/TreeActionLinkPanel.properties
    syncope/trunk/console/src/main/resources/org/apache/syncope/console/wicket/markup/html/tree/TreeActionLinkPanel_it.properties
    syncope/trunk/console/src/main/resources/org/apache/syncope/console/wicket/markup/html/tree/TreeActionLinkPanel_pt_BR.properties
Modified:
    syncope/trunk/   (props changed)
    syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSummaryPanel.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleTabPanel.java
    syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/panels/RoleSummaryPanel.html
    syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/panels/RoleTabPanel.html
    syncope/trunk/console/src/main/webapp/img/actions/create.png
    syncope/trunk/console/src/test/java/org/apache/syncope/console/RoleTestITCase.java

Propchange: syncope/trunk/
------------------------------------------------------------------------------
  Merged /syncope/branches/1_1_X:r1536272-1537135

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSummaryPanel.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSummaryPanel.java?rev=1537151&r1=1537150&r2=1537151&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSummaryPanel.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSummaryPanel.java Wed Oct 30 16:08:07 2013
@@ -21,12 +21,18 @@ package org.apache.syncope.console.pages
 import java.io.Serializable;
 import org.apache.syncope.common.to.RoleTO;
 import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.console.commons.XMLRolesReader;
+import org.apache.syncope.console.pages.RoleModalPage;
 import org.apache.syncope.console.rest.RoleRestClient;
-import org.apache.syncope.console.wicket.markup.html.tree.TreeActionLinkPanel;
+import org.apache.syncope.console.wicket.markup.html.form.ActionLink;
+import org.apache.syncope.console.wicket.markup.html.form.ActionLinksPanel;
+import org.apache.wicket.Page;
 import org.apache.wicket.PageReference;
+import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
 import org.apache.wicket.markup.html.panel.Fragment;
 import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.Model;
 import org.apache.wicket.spring.injection.annot.SpringBean;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -41,16 +47,13 @@ public class RoleSummaryPanel extends Pa
     private static final Logger LOG = LoggerFactory.getLogger(RoleSummaryPanel.class);
 
     @SpringBean
+    private XMLRolesReader xmlRolesReader;
+
+    @SpringBean
     private RoleRestClient restClient;
 
     private RoleTO selectedNode;
 
-    private final Fragment fragment;
-
-    private RoleTabPanel roleTabPanel;
-
-    private TreeActionLinkPanel actionLink;
-
     public static class Builder implements Serializable {
 
         private static final long serialVersionUID = 4164563358509351832L;
@@ -91,28 +94,54 @@ public class RoleSummaryPanel extends Pa
         super(builder.id);
 
         if (builder.selectedNodeId == null || builder.selectedNodeId == 0) {
-            this.selectedNode = null;
+            selectedNode = null;
         } else {
             try {
-                this.selectedNode = restClient.read(builder.selectedNodeId);
+                selectedNode = restClient.read(builder.selectedNodeId);
             } catch (SyncopeClientException e) {
                 LOG.error("Could not read {}", builder.selectedNodeId, e);
-                this.selectedNode = null;
+                selectedNode = null;
                 builder.selectedNodeId = null;
             }
         }
 
-        fragment = new Fragment("roleSummaryPanel", builder.selectedNodeId == null ? "fakerootFrag"
-                : (builder.selectedNodeId == 0 ? "rootPanel" : "roleViewPanel"), this);
+        Fragment fragment = new Fragment("roleSummaryPanel",
+                builder.selectedNodeId == null
+                ? "fakerootFrag"
+                : (builder.selectedNodeId == 0 ? "rootPanel" : "roleViewPanel"),
+                this);
 
         if (builder.selectedNodeId != null) {
             if (builder.selectedNodeId == 0) {
-                actionLink = new TreeActionLinkPanel("actionLink", builder.selectedNodeId,
-                        builder.window, builder.callerPageRef);
-                actionLink.setOutputMarkupId(true);
-                fragment.add(actionLink);
+                @SuppressWarnings("rawtypes")
+                final ActionLinksPanel links = new ActionLinksPanel("actionLinks", new Model(), builder.callerPageRef);
+                links.setOutputMarkupId(true);
+                fragment.add(links);
+
+                links.addWithRoles(new ActionLink() {
+
+                    private static final long serialVersionUID = -3722207913631435501L;
+
+                    @Override
+                    public void onClick(final AjaxRequestTarget target) {
+                        builder.window.setPageCreator(new ModalWindow.PageCreator() {
+
+                            private static final long serialVersionUID = -7834632442532690940L;
+
+                            @Override
+                            public Page createPage() {
+                                RoleTO roleTO = new RoleTO();
+                                RoleModalPage form = new RoleModalPage(builder.callerPageRef, builder.window, roleTO);
+                                return form;
+                            }
+                        });
+
+                        builder.window.show(target);
+                    }
+                }, ActionLink.ActionType.CREATE, xmlRolesReader.getAllAllowedRoles("Roles", "create"));
             } else {
-                roleTabPanel = new RoleTabPanel("nodeViewPanel", selectedNode, builder.window, builder.callerPageRef);
+                RoleTabPanel roleTabPanel =
+                        new RoleTabPanel("nodeViewPanel", selectedNode, builder.window, builder.callerPageRef);
                 roleTabPanel.setOutputMarkupId(true);
                 fragment.add(roleTabPanel);
             }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleTabPanel.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleTabPanel.java?rev=1537151&r1=1537150&r2=1537151&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleTabPanel.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleTabPanel.java Wed Oct 30 16:08:07 2013
@@ -21,10 +21,19 @@ package org.apache.syncope.console.pages
 import org.apache.syncope.common.search.MembershipCond;
 import org.apache.syncope.common.search.NodeCond;
 import org.apache.syncope.common.to.RoleTO;
+import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.console.commons.Constants;
+import org.apache.syncope.console.commons.XMLRolesReader;
+import org.apache.syncope.console.pages.ResultStatusModalPage;
 import org.apache.syncope.console.pages.RoleModalPage;
+import org.apache.syncope.console.pages.Roles;
+import org.apache.syncope.console.pages.StatusModalPage;
+import org.apache.syncope.console.rest.RoleRestClient;
 import org.apache.syncope.console.rest.UserRestClient;
 import org.apache.syncope.console.wicket.ajax.markup.html.ClearIndicatingAjaxButton;
-import org.apache.syncope.console.wicket.markup.html.tree.TreeActionLinkPanel;
+import org.apache.syncope.console.wicket.markup.html.form.ActionLink;
+import org.apache.syncope.console.wicket.markup.html.form.ActionLinksPanel;
+import org.apache.wicket.Page;
 import org.apache.wicket.PageReference;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
@@ -33,6 +42,7 @@ import org.apache.wicket.markup.html.bas
 import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.markup.html.panel.Panel;
 import org.apache.wicket.model.CompoundPropertyModel;
+import org.apache.wicket.model.Model;
 import org.apache.wicket.model.ResourceModel;
 import org.apache.wicket.spring.injection.annot.SpringBean;
 
@@ -41,25 +51,122 @@ public class RoleTabPanel extends Panel 
     private static final long serialVersionUID = 859236186975983959L;
 
     @SpringBean
-    private UserRestClient restClient;
+    private XMLRolesReader xmlRolesReader;
 
-    public RoleTabPanel(final String id, final RoleTO roleTO, final ModalWindow window,
+    @SpringBean
+    private RoleRestClient roleRestClient;
+
+    @SpringBean
+    private UserRestClient userRestClient;
+
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    public RoleTabPanel(final String id, final RoleTO selectedNode, final ModalWindow window,
             final PageReference pageRef) {
 
         super(id);
 
-        final Form form = new Form("roleForm");
+        this.add(new Label("displayName", selectedNode.getDisplayName()));
+
+        final ActionLinksPanel links = new ActionLinksPanel("actionLinks", new Model(), pageRef);
+        links.setOutputMarkupId(true);
+        this.add(links);
+        links.addWithRoles(new ActionLink() {
+
+            private static final long serialVersionUID = -3722207913631435501L;
+
+            @Override
+            public void onClick(final AjaxRequestTarget target) {
+                window.setPageCreator(new ModalWindow.PageCreator() {
+
+                    private static final long serialVersionUID = -7834632442532690940L;
+
+                    @Override
+                    public Page createPage() {
+                        RoleTO roleTO = new RoleTO();
+                        roleTO.setParent(selectedNode.getId());
+                        RoleModalPage form = new RoleModalPage(pageRef, window, roleTO);
+                        return form;
+                    }
+                });
+
+                window.show(target);
+            }
+        }, ActionLink.ActionType.CREATE, xmlRolesReader.getAllAllowedRoles("Roles", "create"));
+        links.addWithRoles(new ActionLink() {
+
+            private static final long serialVersionUID = -3722207913631435501L;
+
+            @Override
+            public void onClick(final AjaxRequestTarget target) {
+                window.setPageCreator(new ModalWindow.PageCreator() {
+
+                    private static final long serialVersionUID = -7834632442532690940L;
+
+                    @Override
+                    public Page createPage() {
+                        return new StatusModalPage<RoleTO>(pageRef, window, roleRestClient.read(selectedNode.getId()));
+                    }
+                });
+
+                window.show(target);
+            }
+        }, ActionLink.ActionType.MANAGE_RESOURCES, xmlRolesReader.getAllAllowedRoles("Roles", "update"));
+        links.addWithRoles(new ActionLink() {
+
+            private static final long serialVersionUID = -3722207913631435501L;
+
+            @Override
+            public void onClick(final AjaxRequestTarget target) {
+                window.setPageCreator(new ModalWindow.PageCreator() {
 
-        final TreeActionLinkPanel actionLink = new TreeActionLinkPanel("actionLink", roleTO.getId(), window, pageRef);
+                    private static final long serialVersionUID = -7834632442532690940L;
 
-        this.add(actionLink);
-        this.add(new Label("displayName", roleTO.getDisplayName()));
+                    @Override
+                    public Page createPage() {
+                        RoleTO roleTO = roleRestClient.read(selectedNode.getId());
+                        RoleModalPage form = new RoleModalPage(pageRef, window, roleTO);
+                        return form;
+                    }
+                });
 
-        form.setModel(new CompoundPropertyModel(roleTO));
+                window.show(target);
+            }
+        }, ActionLink.ActionType.EDIT, xmlRolesReader.getAllAllowedRoles("Roles", "update"));
+        links.addWithRoles(new ActionLink() {
+
+            private static final long serialVersionUID = -3722207913631435501L;
+
+            @Override
+            public void onClick(final AjaxRequestTarget target) {
+                try {
+                    final RoleTO roleTO = roleRestClient.delete(selectedNode.getId());
+
+                    ((Roles) pageRef.getPage()).setModalResult(true);
+
+                    window.setPageCreator(new ModalWindow.PageCreator() {
+
+                        private static final long serialVersionUID = -7834632442532690940L;
+
+                        @Override
+                        public Page createPage() {
+                            return new ResultStatusModalPage.Builder(window, roleTO).build();
+                        }
+                    });
+
+                    window.show(target);
+                } catch (SyncopeClientException e) {
+                    error(getString(Constants.OPERATION_ERROR) + ": " + e.getMessage());
+                    target.add(((Roles) pageRef.getPage()).getFeedbackPanel());
+                }
+            }
+        }, ActionLink.ActionType.DELETE, xmlRolesReader.getAllAllowedRoles("Roles", "delete"));
+
+        final Form form = new Form("roleForm");
+        form.setModel(new CompoundPropertyModel(selectedNode));
         form.setOutputMarkupId(true);
 
-        final RolePanel rolePanel = new RolePanel.Builder("rolePanel").form(form).roleTO(roleTO)
-                .roleModalPageMode(RoleModalPage.Mode.ADMIN).build();
+        final RolePanel rolePanel = new RolePanel.Builder("rolePanel").form(form).roleTO(selectedNode).
+                roleModalPageMode(RoleModalPage.Mode.ADMIN).build();
         rolePanel.setEnabled(false);
         form.add(rolePanel);
 
@@ -67,7 +174,7 @@ public class RoleTabPanel extends Panel 
 
         userListContainer.setOutputMarkupId(true);
         userListContainer.setEnabled(true);
-        userListContainer.add(new UserSearchResultPanel("userList", true, null, pageRef, restClient));
+        userListContainer.add(new UserSearchResultPanel("userList", true, null, pageRef, userRestClient));
         userListContainer.add(new ClearIndicatingAjaxButton("search", new ResourceModel("search"), pageRef) {
 
             private static final long serialVersionUID = -958724007591692537L;
@@ -75,10 +182,10 @@ public class RoleTabPanel extends Panel 
             @Override
             protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
                 final MembershipCond membershipCond = new MembershipCond();
-                membershipCond.setRoleName(roleTO.getName());
+                membershipCond.setRoleName(selectedNode.getName());
                 NodeCond cond = NodeCond.getLeafCond(membershipCond);
 
-                userListContainer.replace(new UserSearchResultPanel("userList", true, cond, pageRef, restClient));
+                userListContainer.replace(new UserSearchResultPanel("userList", true, cond, pageRef, userRestClient));
 
                 target.add(userListContainer);
             }

Modified: syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/panels/RoleSummaryPanel.html
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/panels/RoleSummaryPanel.html?rev=1537151&r1=1537150&r2=1537151&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/panels/RoleSummaryPanel.html (original)
+++ syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/panels/RoleSummaryPanel.html Wed Oct 30 16:08:07 2013
@@ -28,7 +28,7 @@ under the License.
     <wicket:fragment wicket:id="rootPanel">
       <div style="float:left; width:70%;">
         <p style="height:15px; margin-top: 0px;" class="ui-widget ui-corner-all ui-widget-header">
-          <span wicket:id="actionLink"/>
+          <span style="float:right;" wicket:id="actionLinks"/>
         </p>
       </div>
     </wicket:fragment>

Modified: syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/panels/RoleTabPanel.html
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/panels/RoleTabPanel.html?rev=1537151&r1=1537150&r2=1537151&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/panels/RoleTabPanel.html (original)
+++ syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/panels/RoleTabPanel.html Wed Oct 30 16:08:07 2013
@@ -22,7 +22,7 @@ under the License.
       <p style="height:15px; margin-top: 0px;" class="ui-widget ui-corner-all ui-widget-header">
         <wicket:message key="title"/>
         <span wicket:id="displayName"/>
-        <span wicket:id="actionLink"/>
+        <span style="float:right;" wicket:id="actionLinks"/>
       </p>
 
       <form wicket:id="roleForm">

Modified: syncope/trunk/console/src/main/webapp/img/actions/create.png
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/webapp/img/actions/create.png?rev=1537151&r1=1537150&r2=1537151&view=diff
==============================================================================
Binary files - no diff available.

Modified: syncope/trunk/console/src/test/java/org/apache/syncope/console/RoleTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/test/java/org/apache/syncope/console/RoleTestITCase.java?rev=1537151&r1=1537150&r2=1537151&view=diff
==============================================================================
--- syncope/trunk/console/src/test/java/org/apache/syncope/console/RoleTestITCase.java (original)
+++ syncope/trunk/console/src/test/java/org/apache/syncope/console/RoleTestITCase.java Wed Oct 30 16:08:07 2013
@@ -49,10 +49,9 @@ public class RoleTestITCase extends Abst
 
         selenium.click("//div/div/span/div/div/div/div/div[2]/div/div/span/a");
 
-        selenium.waitForCondition("selenium.isElementPresent("
-                + "\"//div/div/span[2]/span/span/div/p/span[2]/span/a\");", "30000");
+        selenium.waitForCondition("selenium.isElementPresent(\"css=img[title='Create']\");", "30000");
 
-        selenium.click("//div/div/span[2]/span/span/div/p/span[2]/span/a");
+        selenium.click("css=img[title='Create']");
 
         selenium.waitForCondition("selenium.isElementPresent(\"//iframe\");", "30000");
 
@@ -78,16 +77,15 @@ public class RoleTestITCase extends Abst
 
         selenium.click("//div/div/span/div/div/div/div/div[2]/div/div/span/a");
 
-        selenium.waitForCondition("selenium.isElementPresent("
-                + "\"//div/div/span[2]/span/span/div/p/span[2]/span/a[2]\");", "30000");
+        selenium.waitForCondition("selenium.isElementPresent(\"css=img[title='Edit']\");", "30000");
 
-        selenium.click("//div/div/span[2]/span/span/div/p/span[2]/span/a[2]");
+        selenium.click("css=img[title='Edit']");
 
         selenium.waitForCondition("selenium.isElementPresent(\"//iframe\");", "30000");
 
         selenium.selectFrame("relative=up");
 
-        selenium.waitForCondition("selenium.isElementPresent(" + "\"//div[2]/form/div[3]/div/ul/li[1]/a/span\");", "30000");
+        selenium.waitForCondition("selenium.isElementPresent(\"//div[2]/form/div[3]/div/ul/li[1]/a/span\");", "30000");
 
         selenium.click("//div[2]/form/div[3]/div/ul/li[2]/a/span");
         selenium.click("//div[2]/form/div[3]/div/ul/li[3]/a/span");
@@ -142,7 +140,7 @@ public class RoleTestITCase extends Abst
     }
 
     @Test
-    public void deleteUser() {
+    public void searchUsers() {
         selenium.click("css=img[alt=\"Roles\"]");
 
         selenium.waitForCondition("selenium.isElementPresent(\"//div[@id='navigationPane']\");", "30000");
@@ -152,15 +150,11 @@ public class RoleTestITCase extends Abst
         selenium.waitForCondition("selenium.isElementPresent("
                 + "\"//div/div/span[2]/span/span/div/form/div[2]/ul/li[8]/a\");", "30000");
 
-        selenium.click("//div/form/div[2]/ul/li[7]/a");
+        selenium.click("//div/div/span[2]/span/span/div/form/div[2]/ul/li[8]/a");
 
         selenium.click("//input[@name=\"userListContainer:search\"]");
 
         selenium.waitForCondition("selenium.isElementPresent(\"//span[14]/a\");", "30000");
-
-        selenium.click("//span[14]/a");
-
-        assertTrue(selenium.getConfirmation().matches("^Do you really want to delete the selected item[\\s\\S]$"));
     }
 
     @Test
@@ -172,10 +166,10 @@ public class RoleTestITCase extends Abst
         selenium.click(
                 "//div/div/span/div/div/div/div/div[2]/div[2]/div[2]/div/div[2]/div[3]/div/span[2]/a/span");
 
-        selenium.waitForCondition("selenium.isElementPresent(\"//div/p/span[2]/span/a[3]\");", "30000");
+        selenium.waitForCondition("selenium.isElementPresent(\"css=img[title='Delete']\");", "30000");
 
-        selenium.click("//div/div/span[2]/span/span/div/p/span[2]/span/a[3]");
+        selenium.click("css=img[title='Delete']");
 
         assertTrue(selenium.getConfirmation().matches("^Do you really want to delete the selected item[\\s\\S]$"));
     }
-}
\ No newline at end of file
+}