syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [1/2] syncope git commit: [SYNCOPE-1126] Explore resource for realms too
Date Tue, 27 Jun 2017 12:20:27 GMT
Repository: syncope
Updated Branches:
  refs/heads/2_0_X 047ef966f -> 6d9df32c0
  refs/heads/master ee802ac15 -> 636985db6


[SYNCOPE-1126] Explore resource for realms too


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

Branch: refs/heads/2_0_X
Commit: 6d9df32c070dd26b7d6af0c90632bfb064abb856
Parents: 047ef96
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Tue Jun 27 14:20:07 2017 +0200
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Tue Jun 27 14:20:07 2017 +0200

----------------------------------------------------------------------
 .../console/panels/ConnObjectListViewPanel.java |  7 ++-
 .../client/console/panels/ConnObjects.java      | 37 +++++++--------
 .../console/topology/TopologyTogglePanel.java   |  2 +-
 .../syncope/common/lib/SyncopeConstants.java    |  2 +
 .../syncope/core/logic/ResourceLogic.java       | 47 ++++++++++++++------
 .../jpa/validation/entity/AnyTypeValidator.java |  4 +-
 .../core/provisioning/api/Connector.java        |  6 +--
 .../provisioning/java/ConnectorFacadeProxy.java |  7 +--
 fit/core-reference/pom.xml                      |  3 ++
 9 files changed, 66 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/6d9df32c/client/console/src/main/java/org/apache/syncope/client/console/panels/ConnObjectListViewPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/ConnObjectListViewPanel.java
b/client/console/src/main/java/org/apache/syncope/client/console/panels/ConnObjectListViewPanel.java
index 60daaf7..1399c3e 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/ConnObjectListViewPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/ConnObjectListViewPanel.java
@@ -113,8 +113,7 @@ public abstract class ConnObjectListViewPanel extends Panel {
             public void onClick(final AjaxRequestTarget target) {
                 final List<ConnObjectTO> listOfItems = reloadItems(resource, anyType,
nextPageCookie);
                 target.add(arrows);
-                send(ConnObjectListViewPanel.this, Broadcast.DEPTH,
-                        new ListViewReload<ConnObjectTO>(listOfItems, target));
+                send(ConnObjectListViewPanel.this, Broadcast.DEPTH, new ListViewReload<>(listOfItems,
target));
             }
 
             @Override
@@ -131,11 +130,11 @@ public abstract class ConnObjectListViewPanel extends Panel {
             final String anyType,
             final String cookie) {
 
-        final Pair<String, List<ConnObjectTO>> items = new ResourceRestClient().listConnObjects(resource,
+        Pair<String, List<ConnObjectTO>> items = new ResourceRestClient().listConnObjects(resource,
                 anyType,
                 SIZE,
                 cookie,
-                new SortParam<String>(ConnIdSpecialName.UID, true));
+                new SortParam<>(ConnIdSpecialName.UID, true));
 
         nextPageCookie = items.getLeft();
         return items.getRight();

http://git-wip-us.apache.org/repos/asf/syncope/blob/6d9df32c/client/console/src/main/java/org/apache/syncope/client/console/panels/ConnObjects.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/ConnObjects.java
b/client/console/src/main/java/org/apache/syncope/client/console/panels/ConnObjects.java
index 17d5036..14a2b9c 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/ConnObjects.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/ConnObjects.java
@@ -26,8 +26,10 @@ import org.apache.syncope.client.console.commons.Constants;
 import org.apache.syncope.client.console.rest.ResourceRestClient;
 import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
 import org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel;
+import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.common.lib.to.ConnObjectTO;
 import org.apache.syncope.common.lib.to.ProvisionTO;
+import org.apache.syncope.common.lib.to.ResourceTO;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.wicket.PageReference;
 import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -44,21 +46,21 @@ public class ConnObjects extends Panel implements ModalPanel {
 
     private final MultilevelPanel connObjects;
 
-    public ConnObjects(final BaseModal<?> baseModal,
-            final String resource,
-            final PageReference pageReference) {
-
+    public ConnObjects(final String resource, final PageReference pageRef) {
         super(BaseModal.CONTENT_ID);
 
-        List<String> availableAnyTypes = CollectionUtils.
-                collect(new ResourceRestClient().read(resource).getProvisions(),
-                        new Transformer<ProvisionTO, String>() {
+        ResourceTO resourceTO = new ResourceRestClient().read(resource);
+        List<String> availableAnyTypes = CollectionUtils.collect(resourceTO.getProvisions(),
+                new Transformer<ProvisionTO, String>() {
 
-                    @Override
-                    public String transform(final ProvisionTO provision) {
-                        return provision.getAnyType();
-                    }
-                }, new ArrayList<String>());
+            @Override
+            public String transform(final ProvisionTO provision) {
+                return provision.getAnyType();
+            }
+        }, new ArrayList<String>());
+        if (resourceTO.getOrgUnit() != null) {
+            availableAnyTypes.add(SyncopeConstants.REALM_ANYTYPE);
+        }
 
         anyTypes = new AjaxDropDownChoicePanel<>("anyTypes", "anyTypes", new Model<String>());
         anyTypes.setChoices(availableAnyTypes);
@@ -87,7 +89,7 @@ public class ConnObjects extends Panel implements ModalPanel {
 
         };
         connObjects.setFirstLevel(new NextableConnObjectDirectoryPanel(
-                baseModal, connObjects, resource, anyTypes.getField().getModelObject(), pageReference));
+                connObjects, resource, anyTypes.getField().getModelObject(), pageRef));
         connObjects.setOutputMarkupId(true);
         add(connObjects);
 
@@ -98,7 +100,7 @@ public class ConnObjects extends Panel implements ModalPanel {
             @Override
             protected void onUpdate(final AjaxRequestTarget target) {
                 connObjects.setFirstLevel(new NextableConnObjectDirectoryPanel(
-                        baseModal, connObjects, resource, anyTypes.getField().getModelObject(),
pageReference));
+                        connObjects, resource, anyTypes.getField().getModelObject(), pageRef));
                 target.add(connObjects);
             }
         });
@@ -108,20 +110,13 @@ public class ConnObjects extends Panel implements ModalPanel {
 
         private static final long serialVersionUID = 956427874406567048L;
 
-        private final BaseModal<?> baseModal;
-
-        private final PageReference pageRef;
-
         NextableConnObjectDirectoryPanel(
-                final BaseModal<?> baseModal,
                 final MultilevelPanel multiLevelPanelRef,
                 final String resource,
                 final String anyType,
                 final PageReference pageRef) {
 
             super(MultilevelPanel.FIRST_LEVEL_ID, resource, anyType, pageRef);
-            this.baseModal = baseModal;
-            this.pageRef = pageRef;
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/6d9df32c/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java
b/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java
index 0851437..cf75204 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java
@@ -443,7 +443,7 @@ public class TopologyTogglePanel extends TogglePanel<Serializable>
{
 
             @Override
             public void onClick(final AjaxRequestTarget target) {
-                target.add(propTaskModal.setContent(new ConnObjects(propTaskModal, node.getKey(),
pageRef)));
+                target.add(propTaskModal.setContent(new ConnObjects(node.getKey(), pageRef)));
                 propTaskModal.header(new StringResourceModel("resource.explore.list", Model.of(node)));
                 propTaskModal.show(true);
             }

http://git-wip-us.apache.org/repos/asf/syncope/blob/6d9df32c/common/lib/src/main/java/org/apache/syncope/common/lib/SyncopeConstants.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/SyncopeConstants.java
b/common/lib/src/main/java/org/apache/syncope/common/lib/SyncopeConstants.java
index 9b804bc..9ce9b06 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/SyncopeConstants.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/SyncopeConstants.java
@@ -32,6 +32,8 @@ public final class SyncopeConstants {
 
     public static final String ROOT_REALM = "/";
 
+    public static final String REALM_ANYTYPE = "REALM";
+
     public static final Set<String> FULL_ADMIN_REALMS = Collections.singleton("/");
 
     public static final String UNAUTHENTICATED = "unauthenticated";

http://git-wip-us.apache.org/repos/asf/syncope/blob/6d9df32c/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
index 4520775..b07a92b 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
@@ -34,6 +34,7 @@ import org.apache.commons.lang3.tuple.ImmutableTriple;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.commons.lang3.tuple.Triple;
 import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.common.lib.to.ConnObjectTO;
 import org.apache.syncope.common.lib.to.ResourceTO;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
@@ -66,6 +67,8 @@ import org.identityconnectors.framework.common.objects.Attribute;
 import org.identityconnectors.framework.common.objects.AttributeUtil;
 import org.identityconnectors.framework.common.objects.ConnectorObject;
 import org.identityconnectors.framework.common.objects.Name;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.OperationOptions;
 import org.identityconnectors.framework.common.objects.SearchResult;
 import org.identityconnectors.framework.common.objects.Uid;
 import org.identityconnectors.framework.spi.SearchResultsHandler;
@@ -269,8 +272,8 @@ public class ResourceLogic extends AbstractTransactionalLogic<ResourceTO>
{
         Any<?> any = init.getMiddle().getKind() == AnyTypeKind.USER
                 ? userDAO.find(anyKey)
                 : init.getMiddle().getKind() == AnyTypeKind.ANY_OBJECT
-                        ? anyObjectDAO.find(anyKey)
-                        : groupDAO.find(anyKey);
+                ? anyObjectDAO.find(anyKey)
+                : groupDAO.find(anyKey);
         if (any == null) {
             throw new NotFoundException(init.getMiddle() + " " + anyKey);
         }
@@ -320,22 +323,40 @@ public class ResourceLogic extends AbstractTransactionalLogic<ResourceTO>
{
     public Pair<SearchResult, List<ConnObjectTO>> listConnObjects(final String
key, final String anyTypeKey,
             final int size, final String pagedResultsCookie, final List<OrderByClause>
orderBy) {
 
-        Triple<ExternalResource, AnyType, Provision> init = connObjectInit(key, anyTypeKey);
-
-        Connector connector = connFactory.getConnector(init.getLeft());
+        ExternalResource resource;
+        ObjectClass objectClass;
+        OperationOptions options;
+        if (SyncopeConstants.REALM_ANYTYPE.equals(anyTypeKey)) {
+            resource = resourceDAO.find(key);
+            if (resource == null) {
+                throw new NotFoundException("Resource '" + key + "'");
+            }
+            if (resource.getOrgUnit() == null) {
+                throw new NotFoundException("Realm provisioning for resource '" + key + "'");
+            }
 
-        Set<MappingItem> linkinMappingItems = new HashSet<>();
-        for (VirSchema virSchema : virSchemaDAO.findByProvision(init.getRight())) {
-            linkinMappingItems.add(virSchema.asLinkingMappingItem());
+            objectClass = resource.getOrgUnit().getObjectClass();
+            options = MappingUtils.buildOperationOptions(resource.getOrgUnit());
+        } else {
+            Triple<ExternalResource, AnyType, Provision> init = connObjectInit(key,
anyTypeKey);
+            resource = init.getLeft();
+            objectClass = init.getRight().getObjectClass();
+            init.getRight().getMapping().getItems();
+
+            Set<MappingItem> linkinMappingItems = new HashSet<>();
+            for (VirSchema virSchema : virSchemaDAO.findByProvision(init.getRight())) {
+                linkinMappingItems.add(virSchema.asLinkingMappingItem());
+            }
+            Iterator<MappingItem> mapItems = IteratorUtils.chainedIterator(
+                    init.getRight().getMapping().getItems().iterator(),
+                    linkinMappingItems.iterator());
+            options = MappingUtils.buildOperationOptions(mapItems);
         }
-        Iterator<MappingItem> mapItems = IteratorUtils.chainedIterator(
-                init.getRight().getMapping().getItems().iterator(),
-                linkinMappingItems.iterator());
 
         final SearchResult[] searchResult = new SearchResult[1];
         final List<ConnObjectTO> connObjects = new ArrayList<>();
 
-        connector.search(init.getRight().getObjectClass(), null, new SearchResultsHandler()
{
+        connFactory.getConnector(resource).search(objectClass, null, new SearchResultsHandler()
{
 
             private int count;
 
@@ -351,7 +372,7 @@ public class ResourceLogic extends AbstractTransactionalLogic<ResourceTO>
{
                 count++;
                 return count < size;
             }
-        }, size, pagedResultsCookie, orderBy, mapItems);
+        }, size, pagedResultsCookie, orderBy, options);
 
         return ImmutablePair.of(searchResult[0], connObjects);
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/6d9df32c/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/AnyTypeValidator.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/AnyTypeValidator.java
b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/AnyTypeValidator.java
index 5619295..639061a 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/AnyTypeValidator.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/AnyTypeValidator.java
@@ -19,6 +19,7 @@
 package org.apache.syncope.core.persistence.jpa.validation.entity;
 
 import javax.validation.ConstraintValidatorContext;
+import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.EntityViolationType;
 import org.apache.syncope.core.persistence.api.entity.AnyType;
@@ -42,7 +43,8 @@ public class AnyTypeValidator extends AbstractValidator<AnyTypeCheck,
AnyType> {
             case ANY_OBJECT:
             default:
                 isValid = !AnyTypeKind.USER.name().equalsIgnoreCase(object.getKey())
-                        && !AnyTypeKind.GROUP.name().equalsIgnoreCase(object.getKey());
+                        && !AnyTypeKind.GROUP.name().equalsIgnoreCase(object.getKey())
+                        && !SyncopeConstants.REALM_ANYTYPE.equalsIgnoreCase(object.getKey());
         }
 
         if (!isValid) {

http://git-wip-us.apache.org/repos/asf/syncope/blob/6d9df32c/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/Connector.java
----------------------------------------------------------------------
diff --git a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/Connector.java
b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/Connector.java
index c54cf71..694ab30 100644
--- a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/Connector.java
+++ b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/Connector.java
@@ -18,12 +18,10 @@
  */
 package org.apache.syncope.core.provisioning.api;
 
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
 import org.apache.syncope.core.persistence.api.entity.ConnInstance;
-import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
 import org.identityconnectors.framework.common.objects.Attribute;
 import org.identityconnectors.framework.common.objects.ConnectorObject;
 import org.identityconnectors.framework.common.objects.ObjectClass;
@@ -173,7 +171,7 @@ public interface Connector {
      * query results
      * @param orderBy the sort keys which should be used for ordering the {@link ConnectorObject}
returned by
      * search request
-     * @param mapItems mapping items
+     * @param options ConnId's OperationOptions
      */
     void search(
             ObjectClass objectClass,
@@ -182,7 +180,7 @@ public interface Connector {
             int pageSize,
             String pagedResultsCookie,
             List<OrderByClause> orderBy,
-            Iterator<? extends MappingItem> mapItems);
+            OperationOptions options);
 
     /**
      * Builds metadata description of ConnId {@link ObjectClass}.

http://git-wip-us.apache.org/repos/asf/syncope/blob/6d9df32c/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java
index c763447..8184c5d 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java
@@ -21,7 +21,6 @@ package org.apache.syncope.core.provisioning.java;
 import java.io.File;
 import java.net.URI;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.Future;
@@ -36,9 +35,7 @@ import org.apache.syncope.core.provisioning.api.utils.ConnPoolConfUtils;
 import org.apache.syncope.core.provisioning.api.Connector;
 import org.apache.syncope.core.provisioning.api.TimeoutException;
 import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
-import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
 import org.apache.syncope.core.provisioning.api.pushpull.ReconciliationFilterBuilder;
-import org.apache.syncope.core.provisioning.java.utils.MappingUtils;
 import org.apache.syncope.core.spring.ApplicationContextProvider;
 import org.identityconnectors.common.security.GuardedByteArray;
 import org.identityconnectors.common.security.GuardedString;
@@ -469,7 +466,7 @@ public class ConnectorFacadeProxy implements Connector {
             final int pageSize,
             final String pagedResultsCookie,
             final List<OrderByClause> orderBy,
-            final Iterator<? extends MappingItem> mapItems) {
+            final OperationOptions options) {
 
         OperationOptionsBuilder builder = new OperationOptionsBuilder().setPageSize(pageSize);
         if (pagedResultsCookie != null) {
@@ -483,7 +480,7 @@ public class ConnectorFacadeProxy implements Connector {
             }
         }, new ArrayList<SortKey>(orderBy.size())));
 
-        builder.setAttributesToGet(MappingUtils.buildOperationOptions(mapItems).getAttributesToGet());
+        builder.setAttributesToGet(options.getAttributesToGet());
 
         search(objectClass, filter, handler, builder.build());
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/6d9df32c/fit/core-reference/pom.xml
----------------------------------------------------------------------
diff --git a/fit/core-reference/pom.xml b/fit/core-reference/pom.xml
index f9a0f71..b23636e 100644
--- a/fit/core-reference/pom.xml
+++ b/fit/core-reference/pom.xml
@@ -401,6 +401,9 @@ under the License.
               <includes>
                 <include>**/*ITCase.java</include>
               </includes>
+              <excludes>
+                <exclude>**/*Test.java</exclude>
+              </excludes>
             </configuration>
             <executions>
               <execution>


Mime
View raw message