syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [19/20] syncope git commit: [SYNCOPE-862] Now managing any object's name via admin console
Date Wed, 08 Jun 2016 15:58:55 GMT
[SYNCOPE-862] Now managing any object's name via admin console


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

Branch: refs/heads/SYNCOPE-862
Commit: 3aee277bb0ae9d3a2617e1e22db6f8233d5a6771
Parents: 50868ae
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Wed Jun 1 12:57:33 2016 +0200
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Wed Jun 8 17:37:40 2016 +0200

----------------------------------------------------------------------
 .../console/wizards/any/AnyObjectDetails.java   | 53 ++++++++++++++++++++
 .../wizards/any/AnyObjectWizardBuilder.java     | 22 +++++++-
 .../console/wizards/any/AnyWizardBuilder.java   |  3 --
 .../console/wizards/any/GroupDetails.java       |  4 +-
 .../console/wizards/any/AnyObjectDetails.html   | 25 +++++++++
 .../syncope/fit/core/MembershipITCase.java      | 44 ++++++++++++++++
 6 files changed, 144 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/3aee277b/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
new file mode 100644
index 0000000..5d149e7
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectDetails.java
@@ -0,0 +1,53 @@
+/*
+ * 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.wizards.any;
+
+import java.util.List;
+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.AnyObjectTO;
+import org.apache.wicket.PageReference;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.PropertyModel;
+
+public class AnyObjectDetails extends Details<AnyObjectTO> {
+
+    private static final long serialVersionUID = 855618618337931784L;
+
+    public AnyObjectDetails(
+            final AnyWrapper<AnyObjectTO> wrapper,
+            final IModel<List<StatusBean>> statusModel,
+            final boolean templateMode,
+            final boolean includeStatusPanel,
+            final PageReference pageRef) {
+
+        super(wrapper, statusModel, includeStatusPanel, pageRef);
+
+        AnyObjectTO anyObjectTO = wrapper.getInnerObject();
+
+        AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", "name",
+                new PropertyModel<String>(anyObjectTO, "name"), false);
+        if (templateMode) {
+            name.enableJexlHelp();
+        } else {
+            name.addRequiredLabel();
+        }
+        this.add(name);
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/3aee277b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectWizardBuilder.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectWizardBuilder.java
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectWizardBuilder.java
index f92bb31..5952017 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectWizardBuilder.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectWizardBuilder.java
@@ -19,20 +19,27 @@
 package org.apache.syncope.client.console.wizards.any;
 
 import java.io.Serializable;
-
+import java.util.Collections;
 import java.util.List;
+import org.apache.syncope.client.console.commons.status.StatusBean;
 import org.apache.syncope.client.console.layout.AnyObjectForm;
 import org.apache.syncope.client.console.layout.AnyObjectFormLayoutInfo;
+import org.apache.syncope.client.console.rest.AnyObjectRestClient;
+import org.apache.syncope.client.console.wizards.AjaxWizard;
 import org.apache.syncope.common.lib.AnyOperations;
 import org.apache.syncope.common.lib.patch.AnyObjectPatch;
 import org.apache.syncope.common.lib.to.AnyObjectTO;
 import org.apache.syncope.common.lib.to.ProvisioningResult;
 import org.apache.wicket.PageReference;
+import org.apache.wicket.extensions.wizard.WizardModel;
+import org.apache.wicket.model.util.ListModel;
 
 public class AnyObjectWizardBuilder extends AnyWizardBuilder<AnyObjectTO> implements
AnyObjectForm {
 
     private static final long serialVersionUID = -2480279868319546243L;
 
+    private final AnyObjectRestClient anyObjectRestClient = new AnyObjectRestClient();
+
     public AnyObjectWizardBuilder(
             final AnyObjectTO anyObjectTO,
             final List<String> anyTypeClasses,
@@ -48,7 +55,7 @@ public class AnyObjectWizardBuilder extends AnyWizardBuilder<AnyObjectTO>
implem
 
         ProvisioningResult<AnyObjectTO> actual;
         if (inner.getKey() == null) {
-            actual = anyObjectRestClient.create(AnyObjectTO.class.cast(inner));
+            actual = anyObjectRestClient.create(inner);
         } else {
             AnyObjectPatch patch = AnyOperations.diff(inner, getOriginalItem().getInnerObject(),
false);
 
@@ -63,4 +70,15 @@ public class AnyObjectWizardBuilder extends AnyWizardBuilder<AnyObjectTO>
implem
 
         return actual;
     }
+
+    @Override
+    protected AnyObjectWizardBuilder addOptionalDetailsPanel(
+            final AnyWrapper<AnyObjectTO> modelObject, final WizardModel wizardModel)
{
+        wizardModel.add(new AnyObjectDetails(
+                modelObject,
+                new ListModel<>(Collections.<StatusBean>emptyList()),
+                mode == AjaxWizard.Mode.TEMPLATE,
+                modelObject.getInnerObject().getKey() != null, pageRef));
+        return this;
+    }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/3aee277b/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 a63a757..41fa6bb 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
@@ -26,7 +26,6 @@ import org.apache.syncope.client.console.layout.AnyForm;
 import org.apache.syncope.client.console.layout.AnyObjectFormLayoutInfo;
 import org.apache.syncope.client.console.layout.GroupFormLayoutInfo;
 import org.apache.syncope.client.console.layout.UserFormLayoutInfo;
-import org.apache.syncope.client.console.rest.AnyObjectRestClient;
 import org.apache.syncope.client.console.wizards.AjaxWizard;
 import org.apache.syncope.client.console.wizards.AjaxWizardBuilder;
 import org.apache.syncope.common.lib.to.AnyTO;
@@ -40,8 +39,6 @@ public abstract class AnyWizardBuilder<A extends AnyTO> extends AjaxWizardBuilde
 
     private static final long serialVersionUID = -2480279868319546243L;
 
-    protected final AnyObjectRestClient anyObjectRestClient = new AnyObjectRestClient();
-
     protected final List<String> anyTypeClasses;
 
     protected AbstractAnyFormLayout<A, ? extends AnyForm<A>> formLayoutInfo;

http://git-wip-us.apache.org/repos/asf/syncope/blob/3aee277b/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 7b4f4ce..e61e89c 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
@@ -39,9 +39,9 @@ public class GroupDetails extends Details<GroupTO> {
 
         super(wrapper, statusModel, includeStatusPanel, pageRef);
 
-        final GroupTO groupTO = GroupWrapper.class.cast(wrapper).getInnerObject();
+        GroupTO groupTO = GroupWrapper.class.cast(wrapper).getInnerObject();
 
-        final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", "name",
+        AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", "name",
                 new PropertyModel<String>(groupTO, "name"), false);
         if (templateMode) {
             name.enableJexlHelp();

http://git-wip-us.apache.org/repos/asf/syncope/blob/3aee277b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/AnyObjectDetails.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/AnyObjectDetails.html
b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/AnyObjectDetails.html
new file mode 100644
index 0000000..4d821fe
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/AnyObjectDetails.html
@@ -0,0 +1,25 @@
+<!--
+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.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+  <wicket:extend>
+    <div class="form-group">
+      <span wicket:id="name"/>
+    </div>
+  </wicket:extend>
+</html>

http://git-wip-us.apache.org/repos/asf/syncope/blob/3aee277b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MembershipITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MembershipITCase.java
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MembershipITCase.java
index 09a560c..38b3631 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MembershipITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MembershipITCase.java
@@ -31,8 +31,11 @@ import org.apache.syncope.common.lib.patch.AttrPatch;
 import org.apache.syncope.common.lib.patch.MembershipPatch;
 import org.apache.syncope.common.lib.patch.UserPatch;
 import org.apache.syncope.common.lib.to.AttrTO;
+import org.apache.syncope.common.lib.to.GroupTO;
 import org.apache.syncope.common.lib.to.MembershipTO;
+import org.apache.syncope.common.lib.to.TypeExtensionTO;
 import org.apache.syncope.common.lib.to.UserTO;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.ClientExceptionType;
 import org.apache.syncope.common.lib.types.PatchOperation;
 import org.apache.syncope.fit.AbstractITCase;
@@ -159,4 +162,45 @@ public class MembershipITCase extends AbstractITCase {
 
         userService.delete(user.getKey());
     }
+
+    @Test
+    public void onGroupDelete() {
+        // pre: create group with type extension
+        TypeExtensionTO typeExtension = new TypeExtensionTO();
+        typeExtension.setAnyType(AnyTypeKind.USER.name());
+        typeExtension.getAuxClasses().add("csv");
+        typeExtension.getAuxClasses().add("other");
+
+        GroupTO groupTO = GroupITCase.getBasicSampleTO("typeExt");
+        groupTO.getTypeExtensions().add(typeExtension);
+        groupTO = createGroup(groupTO).getAny();
+        assertNotNull(groupTO);
+
+        // pre: create user with membership to such group
+        UserTO user = UserITCase.getUniqueSampleTO("typeExt@apache.org");
+
+        MembershipTO membership = new MembershipTO.Builder().group(groupTO.getKey()).build();
+        membership.getPlainAttrs().add(new AttrTO.Builder().schema("aLong").value("1454").build());
+        user.getMemberships().add(membership);
+
+        user = createUser(user).getAny();
+
+        // verify that 'aLong' is correctly populated for user's membership
+        assertEquals(1, user.getMemberships().size());
+        membership = user.getMembershipMap().get(groupTO.getKey());
+        assertNotNull(membership);
+        assertEquals(1, membership.getPlainAttrMap().get("aLong").getValues().size());
+        assertEquals("1454", membership.getPlainAttrMap().get("aLong").getValues().get(0));
+
+        // verify that derived attrbutes from 'csv' and 'other' are also populated for user's
membership
+        assertFalse(membership.getDerAttrMap().get("csvuserid").getValues().isEmpty());
+        assertFalse(membership.getDerAttrMap().get("noschema").getValues().isEmpty());
+
+        // now remove the group -> all related memberships should have been removed as
well
+        groupService.delete(groupTO.getKey());
+
+        // re-read user and verify that no memberships are available any more
+        user = userService.read(user.getKey());
+        assertTrue(user.getMemberships().isEmpty());
+    }
 }


Mime
View raw message