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 2015/01/26 18:13:27 UTC

[1/9] syncope git commit: Merge branch '1_2_X' of https://git-wip-us.apache.org/repos/asf/syncope into 1_2_X

Repository: syncope
Updated Branches:
  refs/heads/1_2_X 4bdf7d781 -> 60a62434e
  refs/heads/2_0_X 8b11d0cb7 -> 820a99169
  refs/heads/master 704682321 -> 920f73adc


Merge branch '1_2_X' of https://git-wip-us.apache.org/repos/asf/syncope into 1_2_X


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

Branch: refs/heads/2_0_X
Commit: 4bdf7d781d106177d282254a06affe0916961f38
Parents: 4efca7c 3328bb6
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Fri Jan 23 17:42:49 2015 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Fri Jan 23 17:42:49 2015 +0100

----------------------------------------------------------------------
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------



[9/9] syncope git commit: [SYNCOPE-630] Merge from master

Posted by il...@apache.org.
[SYNCOPE-630] Merge from master


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

Branch: refs/heads/2_0_X
Commit: 820a9916913e58c33ed1816a5313585b701fef6d
Parents: 556fdb3
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Mon Jan 26 18:13:18 2015 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Mon Jan 26 18:13:18 2015 +0100

----------------------------------------------------------------------
 .../rest/api/service/ResourceService.java       |  11 --
 .../fit/server/reference/ConnectorITCase.java   |  19 +++-
 .../fit/server/reference/ResourceITCase.java    |  11 --
 .../syncope/server/logic/ResourceLogic.java     |  17 +--
 .../rest/cxf/QueryResourceInfoComparator.java   | 113 -------------------
 .../rest/cxf/service/ResourceServiceImpl.java   |   7 +-
 .../src/main/resources/restCXFContext.xml       |   3 -
 7 files changed, 18 insertions(+), 163 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/820a9916/syncope620/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ResourceService.java
----------------------------------------------------------------------
diff --git a/syncope620/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ResourceService.java b/syncope620/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ResourceService.java
index 313b0e9..b0580c3 100644
--- a/syncope620/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ResourceService.java
+++ b/syncope620/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ResourceService.java
@@ -23,7 +23,6 @@ import javax.validation.constraints.NotNull;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
-import javax.ws.rs.MatrixParam;
 import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
@@ -83,16 +82,6 @@ public interface ResourceService extends JAXRSService {
     List<ResourceTO> list();
 
     /**
-     * Returns a list of resources using matching connector instance id.
-     *
-     * @param connInstanceId Connector id to filter for resources
-     * @return resources using matching connector instance id
-     */
-    @GET
-    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
-    List<ResourceTO> list(@NotNull @MatrixParam("connectorId") Long connInstanceId);
-
-    /**
      * Creates a new resource.
      *
      * @param resourceTO Resource to be created

http://git-wip-us.apache.org/repos/asf/syncope/blob/820a9916/syncope620/fit/reference/src/test/java/org/apache/syncope/fit/server/reference/ConnectorITCase.java
----------------------------------------------------------------------
diff --git a/syncope620/fit/reference/src/test/java/org/apache/syncope/fit/server/reference/ConnectorITCase.java b/syncope620/fit/reference/src/test/java/org/apache/syncope/fit/server/reference/ConnectorITCase.java
index e7d12d9..f426526 100644
--- a/syncope620/fit/reference/src/test/java/org/apache/syncope/fit/server/reference/ConnectorITCase.java
+++ b/syncope620/fit/reference/src/test/java/org/apache/syncope/fit/server/reference/ConnectorITCase.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
 import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -265,6 +266,18 @@ public class ConnectorITCase extends AbstractITCase {
         assertEquals(Integer.valueOf(20), actual.getConnRequestTimeout());
     }
 
+    private List<ResourceTO> filter(final List<ResourceTO> input, final Long connectorKey) {
+        List<ResourceTO> result = new ArrayList<>();
+
+        for (ResourceTO resource : input) {
+            if (connectorKey.equals(resource.getConnectorId())) {
+                result.add(resource);
+            }
+        }
+
+        return result;
+    }
+
     @Test
     public void issueSYNCOPE10() {
         // ----------------------------------
@@ -276,8 +289,7 @@ public class ConnectorITCase extends AbstractITCase {
         assertNotNull(connInstanceTO);
 
         // check for resource
-        List<ResourceTO> resources = resourceService.list(Long.valueOf(103));
-
+        List<ResourceTO> resources = filter(resourceService.list(), 103L);
         assertEquals(4, resources.size());
 
         // Retrieve a resource TO template.
@@ -317,8 +329,7 @@ public class ConnectorITCase extends AbstractITCase {
 
         assertNotNull(resourceTO);
 
-        resources = resourceService.list(connId);
-
+        resources = filter(resourceService.list(), connId);
         assertEquals(1, resources.size());
         // ----------------------------------
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/820a9916/syncope620/fit/reference/src/test/java/org/apache/syncope/fit/server/reference/ResourceITCase.java
----------------------------------------------------------------------
diff --git a/syncope620/fit/reference/src/test/java/org/apache/syncope/fit/server/reference/ResourceITCase.java b/syncope620/fit/reference/src/test/java/org/apache/syncope/fit/server/reference/ResourceITCase.java
index 69f26e3..4b701c4 100644
--- a/syncope620/fit/reference/src/test/java/org/apache/syncope/fit/server/reference/ResourceITCase.java
+++ b/syncope620/fit/reference/src/test/java/org/apache/syncope/fit/server/reference/ResourceITCase.java
@@ -403,17 +403,6 @@ public class ResourceITCase extends AbstractITCase {
     }
 
     @Test
-    public void listByType() {
-        List<ResourceTO> actuals = resourceService.list(105L);
-        assertNotNull(actuals);
-
-        for (ResourceTO resourceTO : actuals) {
-            assertNotNull(resourceTO);
-            assertEquals(105L, resourceTO.getConnectorId().longValue());
-        }
-    }
-
-    @Test
     public void read() {
         ResourceTO actual = resourceService.read(RESOURCE_NAME_TESTDB);
         assertNotNull(actual);

http://git-wip-us.apache.org/repos/asf/syncope/blob/820a9916/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/ResourceLogic.java
----------------------------------------------------------------------
diff --git a/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/ResourceLogic.java b/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/ResourceLogic.java
index 07d2795..18c1f58 100644
--- a/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/ResourceLogic.java
+++ b/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/ResourceLogic.java
@@ -31,7 +31,6 @@ import org.apache.syncope.common.lib.to.ResourceTO;
 import org.apache.syncope.common.lib.types.ClientExceptionType;
 import org.apache.syncope.common.lib.types.MappingPurpose;
 import org.apache.syncope.common.lib.types.SubjectType;
-import org.apache.syncope.server.persistence.api.dao.ConnInstanceDAO;
 import org.apache.syncope.server.persistence.api.dao.DuplicateException;
 import org.apache.syncope.server.persistence.api.dao.ExternalResourceDAO;
 import org.apache.syncope.server.persistence.api.dao.NotFoundException;
@@ -66,9 +65,6 @@ public class ResourceLogic extends AbstractTransactionalLogic<ResourceTO> {
     private ExternalResourceDAO resourceDAO;
 
     @Autowired
-    private ConnInstanceDAO connInstanceDAO;
-
-    @Autowired
     private UserDAO userDAO;
 
     @Autowired
@@ -160,17 +156,8 @@ public class ResourceLogic extends AbstractTransactionalLogic<ResourceTO> {
 
     @PreAuthorize("isAuthenticated()")
     @Transactional(readOnly = true)
-    public List<ResourceTO> list(final Long connInstanceId) {
-        List<? extends ExternalResource> resources;
-
-        if (connInstanceId == null) {
-            resources = resourceDAO.findAll();
-        } else {
-            ConnInstance connInstance = connInstanceDAO.find(connInstanceId);
-            resources = connInstance.getResources();
-        }
-
-        return binder.getResourceTOs(resources);
+    public List<ResourceTO> list() {
+        return binder.getResourceTOs(resourceDAO.findAll());
     }
 
     @PreAuthorize("hasRole('RESOURCE_GETCONNECTOROBJECT')")

http://git-wip-us.apache.org/repos/asf/syncope/blob/820a9916/syncope620/server/rest-cxf/src/main/java/org/apache/syncope/server/rest/cxf/QueryResourceInfoComparator.java
----------------------------------------------------------------------
diff --git a/syncope620/server/rest-cxf/src/main/java/org/apache/syncope/server/rest/cxf/QueryResourceInfoComparator.java b/syncope620/server/rest-cxf/src/main/java/org/apache/syncope/server/rest/cxf/QueryResourceInfoComparator.java
deleted file mode 100644
index 7c879c8..0000000
--- a/syncope620/server/rest-cxf/src/main/java/org/apache/syncope/server/rest/cxf/QueryResourceInfoComparator.java
+++ /dev/null
@@ -1,113 +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.
- */
-package org.apache.syncope.server.rest.cxf;
-
-import java.util.List;
-import java.util.Map;
-import org.apache.cxf.jaxrs.ext.ResourceComparator;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.jaxrs.model.OperationResourceInfo;
-import org.apache.cxf.jaxrs.model.OperationResourceInfoComparator;
-import org.apache.cxf.jaxrs.model.Parameter;
-import org.apache.cxf.jaxrs.utils.JAXRSUtils;
-import org.apache.cxf.message.Message;
-
-public class QueryResourceInfoComparator extends OperationResourceInfoComparator implements ResourceComparator {
-
-    public QueryResourceInfoComparator() {
-        super(null, null);
-    }
-
-    @Override
-    public int compare(final ClassResourceInfo cri1, final ClassResourceInfo cri2, final Message message) {
-        // Leave Class selection to CXF
-        return 0;
-    }
-
-    @Override
-    public int compare(final OperationResourceInfo oper1, final OperationResourceInfo oper2, final Message message) {
-        // Check if CXF can make a decision
-        int cxfResult = super.compare(oper1, oper2);
-        if (cxfResult != 0) {
-            return cxfResult;
-        }
-
-        int op1Counter = getMatchingRate(oper1, message);
-        int op2Counter = getMatchingRate(oper2, message);
-
-        return op1Counter == op2Counter
-                ? 0
-                : op1Counter < op2Counter
-                        ? 1
-                        : -1;
-    }
-
-    /**
-     * This method calculates a number indicating a good or bad match between values provided within the request and
-     * expected method parameters. A higher number means a better match.
-     *
-     * @param operation The operation to be rated, based on contained parameterInfo values.
-     * @param message A message containing query and header values from user request
-     * @return A positive or negative number, indicating a good match between query and method
-     */
-    protected int getMatchingRate(final OperationResourceInfo operation, final Message message) {
-        List<Parameter> params = operation.getParameters();
-        if (params == null || params.isEmpty()) {
-            return 0;
-        }
-
-        // Get Request QueryParams
-        String query = (String) message.get(Message.QUERY_STRING);
-        String path = (String) message.get(Message.REQUEST_URI);
-        Map<String, List<String>> qParams = JAXRSUtils.getStructuredParams(query, "&", true, false);
-        Map<String, List<String>> mParams = JAXRSUtils.getMatrixParams(path, true);
-        // Get Request Headers
-        Map<?, ?> qHeader = (java.util.Map<?, ?>) message.get(Message.PROTOCOL_HEADERS);
-
-        int rate = 0;
-        for (Parameter p : params) {
-            switch (p.getType()) {
-                case QUERY:
-                    if (qParams.containsKey(p.getName())) {
-                        rate += 2;
-                    } else if (p.getDefaultValue() == null) {
-                        rate -= 1;
-                    }
-                    break;
-                case MATRIX:
-                    if (mParams.containsKey(p.getName())) {
-                        rate += 2;
-                    } else if (p.getDefaultValue() == null) {
-                        rate -= 1;
-                    }
-                    break;
-                case HEADER:
-                    if (qHeader.containsKey(p.getName())) {
-                        rate += 2;
-                    } else if (p.getDefaultValue() == null) {
-                        rate -= 1;
-                    }
-                    break;
-                default:
-                    break;
-            }
-        }
-        return rate;
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/820a9916/syncope620/server/rest-cxf/src/main/java/org/apache/syncope/server/rest/cxf/service/ResourceServiceImpl.java
----------------------------------------------------------------------
diff --git a/syncope620/server/rest-cxf/src/main/java/org/apache/syncope/server/rest/cxf/service/ResourceServiceImpl.java b/syncope620/server/rest-cxf/src/main/java/org/apache/syncope/server/rest/cxf/service/ResourceServiceImpl.java
index cc28c50..b8bdd0a 100644
--- a/syncope620/server/rest-cxf/src/main/java/org/apache/syncope/server/rest/cxf/service/ResourceServiceImpl.java
+++ b/syncope620/server/rest-cxf/src/main/java/org/apache/syncope/server/rest/cxf/service/ResourceServiceImpl.java
@@ -79,12 +79,7 @@ public class ResourceServiceImpl extends AbstractServiceImpl implements Resource
 
     @Override
     public List<ResourceTO> list() {
-        return logic.list(null);
-    }
-
-    @Override
-    public List<ResourceTO> list(final Long connInstanceId) {
-        return logic.list(connInstanceId);
+        return logic.list();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/820a9916/syncope620/server/rest-cxf/src/main/resources/restCXFContext.xml
----------------------------------------------------------------------
diff --git a/syncope620/server/rest-cxf/src/main/resources/restCXFContext.xml b/syncope620/server/rest-cxf/src/main/resources/restCXFContext.xml
index ddb3e5c..f98fcef 100644
--- a/syncope620/server/rest-cxf/src/main/resources/restCXFContext.xml
+++ b/syncope620/server/rest-cxf/src/main/resources/restCXFContext.xml
@@ -93,9 +93,6 @@ under the License.
   <jaxrs:server id="restContainer" address="/" 
                 basePackages="org.apache.syncope.common.rest.api.service, org.apache.syncope.server.rest.cxf.service" 
                 staticSubresourceResolution="true">
-    <jaxrs:resourceComparator>
-      <bean class="org.apache.syncope.server.rest.cxf.QueryResourceInfoComparator"/>
-    </jaxrs:resourceComparator>
     <jaxrs:properties> 
       <entry key="search.lax.property.match" value="true"/> 
     </jaxrs:properties> 


[5/9] syncope git commit: [SYNCOPE-630] Removing unused ResourceService#list(Long) and QueryResourceInfoComparator

Posted by il...@apache.org.
[SYNCOPE-630] Removing unused ResourceService#list(Long) and QueryResourceInfoComparator


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

Branch: refs/heads/master
Commit: 60a62434e16a3a811d8f549e2d4351633667e90c
Parents: 4bdf7d7
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Mon Jan 26 17:51:45 2015 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Mon Jan 26 17:51:45 2015 +0100

----------------------------------------------------------------------
 .../common/services/ResourceService.java        |  11 --
 .../rest/controller/ResourceController.java     |  17 +--
 .../rest/utils/QueryResourceInfoComparator.java | 114 -------------------
 .../core/services/ResourceServiceImpl.java      |   7 +-
 core/src/main/resources/restContext.xml         |   3 -
 .../syncope/core/rest/ConnectorTestITCase.java  |  25 ++--
 .../syncope/core/rest/ResourceTestITCase.java   |  13 +--
 7 files changed, 22 insertions(+), 168 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/syncope/common/services/ResourceService.java b/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
index f4d19f6..dae4622 100644
--- a/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
+++ b/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
@@ -23,7 +23,6 @@ import javax.validation.constraints.NotNull;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
-import javax.ws.rs.MatrixParam;
 import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
@@ -94,16 +93,6 @@ public interface ResourceService extends JAXRSService {
     List<ResourceTO> list();
 
     /**
-     * Returns a list of resources using matching connector instance id.
-     *
-     * @param connInstanceId Connector id to filter for resources
-     * @return resources using matching connector instance id
-     */
-    @GET
-    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
-    List<ResourceTO> list(@NotNull @MatrixParam("connectorId") Long connInstanceId);
-
-    /**
      * Creates a new resource.
      *
      * @param resourceTO Resource to be created

http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java b/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
index b61afcc..d3dc9d7 100644
--- a/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
+++ b/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
@@ -38,7 +38,6 @@ import org.apache.syncope.core.persistence.beans.AbstractMappingItem;
 import org.apache.syncope.core.persistence.beans.AbstractSubject;
 import org.apache.syncope.core.persistence.beans.ConnInstance;
 import org.apache.syncope.core.persistence.beans.ExternalResource;
-import org.apache.syncope.core.persistence.dao.ConnInstanceDAO;
 import org.apache.syncope.core.persistence.dao.NotFoundException;
 import org.apache.syncope.core.persistence.dao.ResourceDAO;
 import org.apache.syncope.core.persistence.dao.RoleDAO;
@@ -66,9 +65,6 @@ public class ResourceController extends AbstractTransactionalController<Resource
     private ResourceDAO resourceDAO;
 
     @Autowired
-    private ConnInstanceDAO connInstanceDAO;
-
-    @Autowired
     private UserDAO userDAO;
 
     @Autowired
@@ -171,17 +167,8 @@ public class ResourceController extends AbstractTransactionalController<Resource
 
     @PreAuthorize("isAuthenticated()")
     @Transactional(readOnly = true)
-    public List<ResourceTO> list(final Long connInstanceId) {
-        List<ExternalResource> resources;
-
-        if (connInstanceId == null) {
-            resources = resourceDAO.findAll();
-        } else {
-            ConnInstance connInstance = connInstanceDAO.find(connInstanceId);
-            resources = connInstance.getResources();
-        }
-
-        return binder.getResourceTOs(resources);
+    public List<ResourceTO> list() {
+        return binder.getResourceTOs(resourceDAO.findAll());
     }
 
     @PreAuthorize("hasRole('RESOURCE_GETCONNECTOROBJECT')")

http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/core/src/main/java/org/apache/syncope/core/rest/utils/QueryResourceInfoComparator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/rest/utils/QueryResourceInfoComparator.java b/core/src/main/java/org/apache/syncope/core/rest/utils/QueryResourceInfoComparator.java
deleted file mode 100644
index bcc015d..0000000
--- a/core/src/main/java/org/apache/syncope/core/rest/utils/QueryResourceInfoComparator.java
+++ /dev/null
@@ -1,114 +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.
- */
-package org.apache.syncope.core.rest.utils;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cxf.jaxrs.ext.ResourceComparator;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.jaxrs.model.OperationResourceInfo;
-import org.apache.cxf.jaxrs.model.OperationResourceInfoComparator;
-import org.apache.cxf.jaxrs.model.Parameter;
-import org.apache.cxf.jaxrs.utils.JAXRSUtils;
-import org.apache.cxf.message.Message;
-
-public class QueryResourceInfoComparator extends OperationResourceInfoComparator implements ResourceComparator {
-
-    public QueryResourceInfoComparator() {
-        super(null, null);
-    }
-
-    @Override
-    public int compare(final ClassResourceInfo cri1, final ClassResourceInfo cri2, final Message message) {
-        // Leave Class selection to CXF
-        return 0;
-    }
-
-    @Override
-    public int compare(final OperationResourceInfo oper1, final OperationResourceInfo oper2, final Message message) {
-        // Check if CXF can make a decision
-        int cxfResult = super.compare(oper1, oper2);
-        if (cxfResult != 0) {
-            return cxfResult;
-        }
-
-        int op1Counter = getMatchingRate(oper1, message);
-        int op2Counter = getMatchingRate(oper2, message);
-
-        return op1Counter == op2Counter
-                ? 0
-                : op1Counter < op2Counter
-                ? 1
-                : -1;
-    }
-
-    /**
-     * This method calculates a number indicating a good or bad match between values provided within the request and
-     * expected method parameters. A higher number means a better match.
-     *
-     * @param operation The operation to be rated, based on contained parameterInfo values.
-     * @param message A message containing query and header values from user request
-     * @return A positive or negative number, indicating a good match between query and method
-     */
-    protected int getMatchingRate(final OperationResourceInfo operation, final Message message) {
-        List<Parameter> params = operation.getParameters();
-        if (params == null || params.isEmpty()) {
-            return 0;
-        }
-
-        // Get Request QueryParams
-        String query = (String) message.get(Message.QUERY_STRING);
-        String path = (String) message.get(Message.REQUEST_URI);
-        Map<String, List<String>> qParams = JAXRSUtils.getStructuredParams(query, "&", true, false);
-        Map<String, List<String>> mParams = JAXRSUtils.getMatrixParams(path, true);
-        // Get Request Headers
-        Map<?, ?> qHeader = (java.util.Map<?, ?>) message.get(Message.PROTOCOL_HEADERS);
-
-        int rate = 0;
-        for (Parameter p : params) {
-            switch (p.getType()) {
-                case QUERY:
-                    if (qParams.containsKey(p.getName())) {
-                        rate += 2;
-                    } else if (p.getDefaultValue() == null) {
-                        rate -= 1;
-                    }
-                    break;
-                case MATRIX:
-                    if (mParams.containsKey(p.getName())) {
-                        rate += 2;
-                    } else if (p.getDefaultValue() == null) {
-                        rate -= 1;
-                    }
-                    break;
-                case HEADER:
-                    if (qHeader.containsKey(p.getName())) {
-                        rate += 2;
-                    } else if (p.getDefaultValue() == null) {
-                        rate -= 1;
-                    }
-                    break;
-                default:
-                    break;
-            }
-        }
-        return rate;
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java b/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
index 674a674..dda5561 100644
--- a/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
+++ b/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
@@ -86,12 +86,7 @@ public class ResourceServiceImpl extends AbstractServiceImpl implements Resource
 
     @Override
     public List<ResourceTO> list() {
-        return controller.list(null);
-    }
-
-    @Override
-    public List<ResourceTO> list(final Long connInstanceId) {
-        return controller.list(connInstanceId);
+        return controller.list();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/core/src/main/resources/restContext.xml
----------------------------------------------------------------------
diff --git a/core/src/main/resources/restContext.xml b/core/src/main/resources/restContext.xml
index 1b71e31..7b6fe30 100644
--- a/core/src/main/resources/restContext.xml
+++ b/core/src/main/resources/restContext.xml
@@ -100,9 +100,6 @@ under the License.
   <jaxrs:server id="restContainer" address="/" 
                 basePackages="org.apache.syncope.common.services, org.apache.syncope.core.services" 
                 staticSubresourceResolution="true">
-    <jaxrs:resourceComparator>
-      <bean id="queryResourceInfoComparator" class="org.apache.syncope.core.rest.utils.QueryResourceInfoComparator"/>
-    </jaxrs:resourceComparator>
     <jaxrs:properties> 
       <entry key="search.lax.property.match" value="true"/> 
     </jaxrs:properties> 

http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/core/src/test/java/org/apache/syncope/core/rest/ConnectorTestITCase.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/syncope/core/rest/ConnectorTestITCase.java b/core/src/test/java/org/apache/syncope/core/rest/ConnectorTestITCase.java
index d1063f5..fc4e830 100644
--- a/core/src/test/java/org/apache/syncope/core/rest/ConnectorTestITCase.java
+++ b/core/src/test/java/org/apache/syncope/core/rest/ConnectorTestITCase.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
 import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -265,6 +266,18 @@ public class ConnectorTestITCase extends AbstractTest {
         assertEquals(Integer.valueOf(20), actual.getConnRequestTimeout());
     }
 
+    private List<ResourceTO> filter(final List<ResourceTO> input, final Long connectorId) {
+        List<ResourceTO> result = new ArrayList<ResourceTO>();
+
+        for (ResourceTO resource : input) {
+            if (connectorId.equals(resource.getConnectorId())) {
+                result.add(resource);
+            }
+        }
+
+        return result;
+    }
+
     @Test
     public void issueSYNCOPE10() {
         // ----------------------------------
@@ -276,8 +289,7 @@ public class ConnectorTestITCase extends AbstractTest {
         assertNotNull(connInstanceTO);
 
         // check for resource
-        List<ResourceTO> resources = resourceService.list(Long.valueOf(103));
-
+        List<ResourceTO> resources = filter(resourceService.list(), 103L);
         assertEquals(4, resources.size());
 
         // Retrieve a resource TO template.
@@ -317,8 +329,7 @@ public class ConnectorTestITCase extends AbstractTest {
 
         assertNotNull(resourceTO);
 
-        resources = resourceService.list(connId);
-
+        resources = filter(resourceService.list(), connId);
         assertEquals(1, resources.size());
         // ----------------------------------
 
@@ -709,13 +720,13 @@ public class ConnectorTestITCase extends AbstractTest {
 
     @Test
     public void issueSYNCOPE605() {
-        
+
         ConnInstanceTO connectorInstanceTO = connectorService.read(103L);
         assertTrue(connectorInstanceTO.getCapabilities().isEmpty());
-        
+
         connectorInstanceTO.getCapabilities().add(ConnectorCapability.SEARCH);
         connectorService.update(connectorInstanceTO.getId(), connectorInstanceTO);
-        
+
         ConnInstanceTO updatedCapabilities = connectorService.read(connectorInstanceTO.getId());
         assertNotNull(updatedCapabilities.getCapabilities());
         assertTrue(updatedCapabilities.getCapabilities().size() == 1);

http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java b/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
index 77f4c66..de4435b 100644
--- a/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
+++ b/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
@@ -406,17 +406,6 @@ public class ResourceTestITCase extends AbstractTest {
     }
 
     @Test
-    public void listByType() {
-        List<ResourceTO> actuals = resourceService.list(105L);
-        assertNotNull(actuals);
-
-        for (ResourceTO resourceTO : actuals) {
-            assertNotNull(resourceTO);
-            assertEquals(105L, resourceTO.getConnectorId().longValue());
-        }
-    }
-
-    @Test
     public void read() {
         ResourceTO actual = resourceService.read(RESOURCE_NAME_TESTDB);
         assertNotNull(actual);
@@ -507,7 +496,7 @@ public class ResourceTestITCase extends AbstractTest {
         item.setExtAttrName("cn");
         item.setPurpose(MappingPurpose.BOTH);
         mapping.setAccountIdItem(item);
-            
+
         item = new MappingItemTO();
         item.setIntMappingType(IntMappingType.RoleOwnerSchema);
         item.setExtAttrName("owner");


[4/9] syncope git commit: [SYNCOPE-630] Removing unused ResourceService#list(Long) and QueryResourceInfoComparator

Posted by il...@apache.org.
[SYNCOPE-630] Removing unused ResourceService#list(Long) and QueryResourceInfoComparator


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

Branch: refs/heads/2_0_X
Commit: 60a62434e16a3a811d8f549e2d4351633667e90c
Parents: 4bdf7d7
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Mon Jan 26 17:51:45 2015 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Mon Jan 26 17:51:45 2015 +0100

----------------------------------------------------------------------
 .../common/services/ResourceService.java        |  11 --
 .../rest/controller/ResourceController.java     |  17 +--
 .../rest/utils/QueryResourceInfoComparator.java | 114 -------------------
 .../core/services/ResourceServiceImpl.java      |   7 +-
 core/src/main/resources/restContext.xml         |   3 -
 .../syncope/core/rest/ConnectorTestITCase.java  |  25 ++--
 .../syncope/core/rest/ResourceTestITCase.java   |  13 +--
 7 files changed, 22 insertions(+), 168 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/syncope/common/services/ResourceService.java b/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
index f4d19f6..dae4622 100644
--- a/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
+++ b/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
@@ -23,7 +23,6 @@ import javax.validation.constraints.NotNull;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
-import javax.ws.rs.MatrixParam;
 import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
@@ -94,16 +93,6 @@ public interface ResourceService extends JAXRSService {
     List<ResourceTO> list();
 
     /**
-     * Returns a list of resources using matching connector instance id.
-     *
-     * @param connInstanceId Connector id to filter for resources
-     * @return resources using matching connector instance id
-     */
-    @GET
-    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
-    List<ResourceTO> list(@NotNull @MatrixParam("connectorId") Long connInstanceId);
-
-    /**
      * Creates a new resource.
      *
      * @param resourceTO Resource to be created

http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java b/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
index b61afcc..d3dc9d7 100644
--- a/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
+++ b/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
@@ -38,7 +38,6 @@ import org.apache.syncope.core.persistence.beans.AbstractMappingItem;
 import org.apache.syncope.core.persistence.beans.AbstractSubject;
 import org.apache.syncope.core.persistence.beans.ConnInstance;
 import org.apache.syncope.core.persistence.beans.ExternalResource;
-import org.apache.syncope.core.persistence.dao.ConnInstanceDAO;
 import org.apache.syncope.core.persistence.dao.NotFoundException;
 import org.apache.syncope.core.persistence.dao.ResourceDAO;
 import org.apache.syncope.core.persistence.dao.RoleDAO;
@@ -66,9 +65,6 @@ public class ResourceController extends AbstractTransactionalController<Resource
     private ResourceDAO resourceDAO;
 
     @Autowired
-    private ConnInstanceDAO connInstanceDAO;
-
-    @Autowired
     private UserDAO userDAO;
 
     @Autowired
@@ -171,17 +167,8 @@ public class ResourceController extends AbstractTransactionalController<Resource
 
     @PreAuthorize("isAuthenticated()")
     @Transactional(readOnly = true)
-    public List<ResourceTO> list(final Long connInstanceId) {
-        List<ExternalResource> resources;
-
-        if (connInstanceId == null) {
-            resources = resourceDAO.findAll();
-        } else {
-            ConnInstance connInstance = connInstanceDAO.find(connInstanceId);
-            resources = connInstance.getResources();
-        }
-
-        return binder.getResourceTOs(resources);
+    public List<ResourceTO> list() {
+        return binder.getResourceTOs(resourceDAO.findAll());
     }
 
     @PreAuthorize("hasRole('RESOURCE_GETCONNECTOROBJECT')")

http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/core/src/main/java/org/apache/syncope/core/rest/utils/QueryResourceInfoComparator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/rest/utils/QueryResourceInfoComparator.java b/core/src/main/java/org/apache/syncope/core/rest/utils/QueryResourceInfoComparator.java
deleted file mode 100644
index bcc015d..0000000
--- a/core/src/main/java/org/apache/syncope/core/rest/utils/QueryResourceInfoComparator.java
+++ /dev/null
@@ -1,114 +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.
- */
-package org.apache.syncope.core.rest.utils;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cxf.jaxrs.ext.ResourceComparator;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.jaxrs.model.OperationResourceInfo;
-import org.apache.cxf.jaxrs.model.OperationResourceInfoComparator;
-import org.apache.cxf.jaxrs.model.Parameter;
-import org.apache.cxf.jaxrs.utils.JAXRSUtils;
-import org.apache.cxf.message.Message;
-
-public class QueryResourceInfoComparator extends OperationResourceInfoComparator implements ResourceComparator {
-
-    public QueryResourceInfoComparator() {
-        super(null, null);
-    }
-
-    @Override
-    public int compare(final ClassResourceInfo cri1, final ClassResourceInfo cri2, final Message message) {
-        // Leave Class selection to CXF
-        return 0;
-    }
-
-    @Override
-    public int compare(final OperationResourceInfo oper1, final OperationResourceInfo oper2, final Message message) {
-        // Check if CXF can make a decision
-        int cxfResult = super.compare(oper1, oper2);
-        if (cxfResult != 0) {
-            return cxfResult;
-        }
-
-        int op1Counter = getMatchingRate(oper1, message);
-        int op2Counter = getMatchingRate(oper2, message);
-
-        return op1Counter == op2Counter
-                ? 0
-                : op1Counter < op2Counter
-                ? 1
-                : -1;
-    }
-
-    /**
-     * This method calculates a number indicating a good or bad match between values provided within the request and
-     * expected method parameters. A higher number means a better match.
-     *
-     * @param operation The operation to be rated, based on contained parameterInfo values.
-     * @param message A message containing query and header values from user request
-     * @return A positive or negative number, indicating a good match between query and method
-     */
-    protected int getMatchingRate(final OperationResourceInfo operation, final Message message) {
-        List<Parameter> params = operation.getParameters();
-        if (params == null || params.isEmpty()) {
-            return 0;
-        }
-
-        // Get Request QueryParams
-        String query = (String) message.get(Message.QUERY_STRING);
-        String path = (String) message.get(Message.REQUEST_URI);
-        Map<String, List<String>> qParams = JAXRSUtils.getStructuredParams(query, "&", true, false);
-        Map<String, List<String>> mParams = JAXRSUtils.getMatrixParams(path, true);
-        // Get Request Headers
-        Map<?, ?> qHeader = (java.util.Map<?, ?>) message.get(Message.PROTOCOL_HEADERS);
-
-        int rate = 0;
-        for (Parameter p : params) {
-            switch (p.getType()) {
-                case QUERY:
-                    if (qParams.containsKey(p.getName())) {
-                        rate += 2;
-                    } else if (p.getDefaultValue() == null) {
-                        rate -= 1;
-                    }
-                    break;
-                case MATRIX:
-                    if (mParams.containsKey(p.getName())) {
-                        rate += 2;
-                    } else if (p.getDefaultValue() == null) {
-                        rate -= 1;
-                    }
-                    break;
-                case HEADER:
-                    if (qHeader.containsKey(p.getName())) {
-                        rate += 2;
-                    } else if (p.getDefaultValue() == null) {
-                        rate -= 1;
-                    }
-                    break;
-                default:
-                    break;
-            }
-        }
-        return rate;
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java b/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
index 674a674..dda5561 100644
--- a/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
+++ b/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
@@ -86,12 +86,7 @@ public class ResourceServiceImpl extends AbstractServiceImpl implements Resource
 
     @Override
     public List<ResourceTO> list() {
-        return controller.list(null);
-    }
-
-    @Override
-    public List<ResourceTO> list(final Long connInstanceId) {
-        return controller.list(connInstanceId);
+        return controller.list();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/core/src/main/resources/restContext.xml
----------------------------------------------------------------------
diff --git a/core/src/main/resources/restContext.xml b/core/src/main/resources/restContext.xml
index 1b71e31..7b6fe30 100644
--- a/core/src/main/resources/restContext.xml
+++ b/core/src/main/resources/restContext.xml
@@ -100,9 +100,6 @@ under the License.
   <jaxrs:server id="restContainer" address="/" 
                 basePackages="org.apache.syncope.common.services, org.apache.syncope.core.services" 
                 staticSubresourceResolution="true">
-    <jaxrs:resourceComparator>
-      <bean id="queryResourceInfoComparator" class="org.apache.syncope.core.rest.utils.QueryResourceInfoComparator"/>
-    </jaxrs:resourceComparator>
     <jaxrs:properties> 
       <entry key="search.lax.property.match" value="true"/> 
     </jaxrs:properties> 

http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/core/src/test/java/org/apache/syncope/core/rest/ConnectorTestITCase.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/syncope/core/rest/ConnectorTestITCase.java b/core/src/test/java/org/apache/syncope/core/rest/ConnectorTestITCase.java
index d1063f5..fc4e830 100644
--- a/core/src/test/java/org/apache/syncope/core/rest/ConnectorTestITCase.java
+++ b/core/src/test/java/org/apache/syncope/core/rest/ConnectorTestITCase.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
 import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -265,6 +266,18 @@ public class ConnectorTestITCase extends AbstractTest {
         assertEquals(Integer.valueOf(20), actual.getConnRequestTimeout());
     }
 
+    private List<ResourceTO> filter(final List<ResourceTO> input, final Long connectorId) {
+        List<ResourceTO> result = new ArrayList<ResourceTO>();
+
+        for (ResourceTO resource : input) {
+            if (connectorId.equals(resource.getConnectorId())) {
+                result.add(resource);
+            }
+        }
+
+        return result;
+    }
+
     @Test
     public void issueSYNCOPE10() {
         // ----------------------------------
@@ -276,8 +289,7 @@ public class ConnectorTestITCase extends AbstractTest {
         assertNotNull(connInstanceTO);
 
         // check for resource
-        List<ResourceTO> resources = resourceService.list(Long.valueOf(103));
-
+        List<ResourceTO> resources = filter(resourceService.list(), 103L);
         assertEquals(4, resources.size());
 
         // Retrieve a resource TO template.
@@ -317,8 +329,7 @@ public class ConnectorTestITCase extends AbstractTest {
 
         assertNotNull(resourceTO);
 
-        resources = resourceService.list(connId);
-
+        resources = filter(resourceService.list(), connId);
         assertEquals(1, resources.size());
         // ----------------------------------
 
@@ -709,13 +720,13 @@ public class ConnectorTestITCase extends AbstractTest {
 
     @Test
     public void issueSYNCOPE605() {
-        
+
         ConnInstanceTO connectorInstanceTO = connectorService.read(103L);
         assertTrue(connectorInstanceTO.getCapabilities().isEmpty());
-        
+
         connectorInstanceTO.getCapabilities().add(ConnectorCapability.SEARCH);
         connectorService.update(connectorInstanceTO.getId(), connectorInstanceTO);
-        
+
         ConnInstanceTO updatedCapabilities = connectorService.read(connectorInstanceTO.getId());
         assertNotNull(updatedCapabilities.getCapabilities());
         assertTrue(updatedCapabilities.getCapabilities().size() == 1);

http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java b/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
index 77f4c66..de4435b 100644
--- a/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
+++ b/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
@@ -406,17 +406,6 @@ public class ResourceTestITCase extends AbstractTest {
     }
 
     @Test
-    public void listByType() {
-        List<ResourceTO> actuals = resourceService.list(105L);
-        assertNotNull(actuals);
-
-        for (ResourceTO resourceTO : actuals) {
-            assertNotNull(resourceTO);
-            assertEquals(105L, resourceTO.getConnectorId().longValue());
-        }
-    }
-
-    @Test
     public void read() {
         ResourceTO actual = resourceService.read(RESOURCE_NAME_TESTDB);
         assertNotNull(actual);
@@ -507,7 +496,7 @@ public class ResourceTestITCase extends AbstractTest {
         item.setExtAttrName("cn");
         item.setPurpose(MappingPurpose.BOTH);
         mapping.setAccountIdItem(item);
-            
+
         item = new MappingItemTO();
         item.setIntMappingType(IntMappingType.RoleOwnerSchema);
         item.setExtAttrName("owner");


[7/9] syncope git commit: [SYNCOPE-630] Merge from 1_2_X

Posted by il...@apache.org.
[SYNCOPE-630] Merge from 1_2_X


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

Branch: refs/heads/2_0_X
Commit: 920f73adc9627109a467ca3c59642ce7d45ce417
Parents: 7046823 60a6243
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Mon Jan 26 17:59:12 2015 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Mon Jan 26 17:59:12 2015 +0100

----------------------------------------------------------------------
 .../common/services/ResourceService.java        |  11 --
 .../rest/controller/ResourceController.java     |  17 +--
 .../rest/utils/QueryResourceInfoComparator.java | 114 -------------------
 .../core/services/ResourceServiceImpl.java      |   7 +-
 core/src/main/resources/restContext.xml         |   3 -
 .../syncope/core/rest/ConnectorTestITCase.java  |  19 +++-
 .../syncope/core/rest/ResourceTestITCase.java   |  11 --
 7 files changed, 18 insertions(+), 164 deletions(-)
----------------------------------------------------------------------



[2/9] syncope git commit: Merge branch '1_2_X' of https://git-wip-us.apache.org/repos/asf/syncope into 1_2_X

Posted by il...@apache.org.
Merge branch '1_2_X' of https://git-wip-us.apache.org/repos/asf/syncope into 1_2_X


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

Branch: refs/heads/master
Commit: 4bdf7d781d106177d282254a06affe0916961f38
Parents: 4efca7c 3328bb6
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Fri Jan 23 17:42:49 2015 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Fri Jan 23 17:42:49 2015 +0100

----------------------------------------------------------------------
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------



[8/9] syncope git commit: Merge branch 'master' into 2_0_X

Posted by il...@apache.org.
Merge branch 'master' into 2_0_X


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

Branch: refs/heads/2_0_X
Commit: 556fdb332f7cee0808dbb9ff161446965e65db4c
Parents: 8b11d0c 920f73a
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Mon Jan 26 17:59:23 2015 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Mon Jan 26 17:59:23 2015 +0100

----------------------------------------------------------------------
 .../common/services/ResourceService.java        |  11 --
 .../rest/controller/ResourceController.java     |  17 +--
 .../rest/utils/QueryResourceInfoComparator.java | 114 -------------------
 .../core/services/ResourceServiceImpl.java      |   7 +-
 core/src/main/resources/restContext.xml         |   3 -
 .../syncope/core/rest/ConnectorTestITCase.java  |  19 +++-
 .../syncope/core/rest/ResourceTestITCase.java   |  11 --
 7 files changed, 18 insertions(+), 164 deletions(-)
----------------------------------------------------------------------



[6/9] syncope git commit: [SYNCOPE-630] Merge from 1_2_X

Posted by il...@apache.org.
[SYNCOPE-630] Merge from 1_2_X


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

Branch: refs/heads/master
Commit: 920f73adc9627109a467ca3c59642ce7d45ce417
Parents: 7046823 60a6243
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Mon Jan 26 17:59:12 2015 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Mon Jan 26 17:59:12 2015 +0100

----------------------------------------------------------------------
 .../common/services/ResourceService.java        |  11 --
 .../rest/controller/ResourceController.java     |  17 +--
 .../rest/utils/QueryResourceInfoComparator.java | 114 -------------------
 .../core/services/ResourceServiceImpl.java      |   7 +-
 core/src/main/resources/restContext.xml         |   3 -
 .../syncope/core/rest/ConnectorTestITCase.java  |  19 +++-
 .../syncope/core/rest/ResourceTestITCase.java   |  11 --
 7 files changed, 18 insertions(+), 164 deletions(-)
----------------------------------------------------------------------



[3/9] syncope git commit: [SYNCOPE-630] Removing unused ResourceService#list(Long) and QueryResourceInfoComparator

Posted by il...@apache.org.
[SYNCOPE-630] Removing unused ResourceService#list(Long) and QueryResourceInfoComparator


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

Branch: refs/heads/1_2_X
Commit: 60a62434e16a3a811d8f549e2d4351633667e90c
Parents: 4bdf7d7
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Mon Jan 26 17:51:45 2015 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Mon Jan 26 17:51:45 2015 +0100

----------------------------------------------------------------------
 .../common/services/ResourceService.java        |  11 --
 .../rest/controller/ResourceController.java     |  17 +--
 .../rest/utils/QueryResourceInfoComparator.java | 114 -------------------
 .../core/services/ResourceServiceImpl.java      |   7 +-
 core/src/main/resources/restContext.xml         |   3 -
 .../syncope/core/rest/ConnectorTestITCase.java  |  25 ++--
 .../syncope/core/rest/ResourceTestITCase.java   |  13 +--
 7 files changed, 22 insertions(+), 168 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/syncope/common/services/ResourceService.java b/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
index f4d19f6..dae4622 100644
--- a/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
+++ b/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
@@ -23,7 +23,6 @@ import javax.validation.constraints.NotNull;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
-import javax.ws.rs.MatrixParam;
 import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
@@ -94,16 +93,6 @@ public interface ResourceService extends JAXRSService {
     List<ResourceTO> list();
 
     /**
-     * Returns a list of resources using matching connector instance id.
-     *
-     * @param connInstanceId Connector id to filter for resources
-     * @return resources using matching connector instance id
-     */
-    @GET
-    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
-    List<ResourceTO> list(@NotNull @MatrixParam("connectorId") Long connInstanceId);
-
-    /**
      * Creates a new resource.
      *
      * @param resourceTO Resource to be created

http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java b/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
index b61afcc..d3dc9d7 100644
--- a/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
+++ b/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
@@ -38,7 +38,6 @@ import org.apache.syncope.core.persistence.beans.AbstractMappingItem;
 import org.apache.syncope.core.persistence.beans.AbstractSubject;
 import org.apache.syncope.core.persistence.beans.ConnInstance;
 import org.apache.syncope.core.persistence.beans.ExternalResource;
-import org.apache.syncope.core.persistence.dao.ConnInstanceDAO;
 import org.apache.syncope.core.persistence.dao.NotFoundException;
 import org.apache.syncope.core.persistence.dao.ResourceDAO;
 import org.apache.syncope.core.persistence.dao.RoleDAO;
@@ -66,9 +65,6 @@ public class ResourceController extends AbstractTransactionalController<Resource
     private ResourceDAO resourceDAO;
 
     @Autowired
-    private ConnInstanceDAO connInstanceDAO;
-
-    @Autowired
     private UserDAO userDAO;
 
     @Autowired
@@ -171,17 +167,8 @@ public class ResourceController extends AbstractTransactionalController<Resource
 
     @PreAuthorize("isAuthenticated()")
     @Transactional(readOnly = true)
-    public List<ResourceTO> list(final Long connInstanceId) {
-        List<ExternalResource> resources;
-
-        if (connInstanceId == null) {
-            resources = resourceDAO.findAll();
-        } else {
-            ConnInstance connInstance = connInstanceDAO.find(connInstanceId);
-            resources = connInstance.getResources();
-        }
-
-        return binder.getResourceTOs(resources);
+    public List<ResourceTO> list() {
+        return binder.getResourceTOs(resourceDAO.findAll());
     }
 
     @PreAuthorize("hasRole('RESOURCE_GETCONNECTOROBJECT')")

http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/core/src/main/java/org/apache/syncope/core/rest/utils/QueryResourceInfoComparator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/rest/utils/QueryResourceInfoComparator.java b/core/src/main/java/org/apache/syncope/core/rest/utils/QueryResourceInfoComparator.java
deleted file mode 100644
index bcc015d..0000000
--- a/core/src/main/java/org/apache/syncope/core/rest/utils/QueryResourceInfoComparator.java
+++ /dev/null
@@ -1,114 +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.
- */
-package org.apache.syncope.core.rest.utils;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cxf.jaxrs.ext.ResourceComparator;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.jaxrs.model.OperationResourceInfo;
-import org.apache.cxf.jaxrs.model.OperationResourceInfoComparator;
-import org.apache.cxf.jaxrs.model.Parameter;
-import org.apache.cxf.jaxrs.utils.JAXRSUtils;
-import org.apache.cxf.message.Message;
-
-public class QueryResourceInfoComparator extends OperationResourceInfoComparator implements ResourceComparator {
-
-    public QueryResourceInfoComparator() {
-        super(null, null);
-    }
-
-    @Override
-    public int compare(final ClassResourceInfo cri1, final ClassResourceInfo cri2, final Message message) {
-        // Leave Class selection to CXF
-        return 0;
-    }
-
-    @Override
-    public int compare(final OperationResourceInfo oper1, final OperationResourceInfo oper2, final Message message) {
-        // Check if CXF can make a decision
-        int cxfResult = super.compare(oper1, oper2);
-        if (cxfResult != 0) {
-            return cxfResult;
-        }
-
-        int op1Counter = getMatchingRate(oper1, message);
-        int op2Counter = getMatchingRate(oper2, message);
-
-        return op1Counter == op2Counter
-                ? 0
-                : op1Counter < op2Counter
-                ? 1
-                : -1;
-    }
-
-    /**
-     * This method calculates a number indicating a good or bad match between values provided within the request and
-     * expected method parameters. A higher number means a better match.
-     *
-     * @param operation The operation to be rated, based on contained parameterInfo values.
-     * @param message A message containing query and header values from user request
-     * @return A positive or negative number, indicating a good match between query and method
-     */
-    protected int getMatchingRate(final OperationResourceInfo operation, final Message message) {
-        List<Parameter> params = operation.getParameters();
-        if (params == null || params.isEmpty()) {
-            return 0;
-        }
-
-        // Get Request QueryParams
-        String query = (String) message.get(Message.QUERY_STRING);
-        String path = (String) message.get(Message.REQUEST_URI);
-        Map<String, List<String>> qParams = JAXRSUtils.getStructuredParams(query, "&", true, false);
-        Map<String, List<String>> mParams = JAXRSUtils.getMatrixParams(path, true);
-        // Get Request Headers
-        Map<?, ?> qHeader = (java.util.Map<?, ?>) message.get(Message.PROTOCOL_HEADERS);
-
-        int rate = 0;
-        for (Parameter p : params) {
-            switch (p.getType()) {
-                case QUERY:
-                    if (qParams.containsKey(p.getName())) {
-                        rate += 2;
-                    } else if (p.getDefaultValue() == null) {
-                        rate -= 1;
-                    }
-                    break;
-                case MATRIX:
-                    if (mParams.containsKey(p.getName())) {
-                        rate += 2;
-                    } else if (p.getDefaultValue() == null) {
-                        rate -= 1;
-                    }
-                    break;
-                case HEADER:
-                    if (qHeader.containsKey(p.getName())) {
-                        rate += 2;
-                    } else if (p.getDefaultValue() == null) {
-                        rate -= 1;
-                    }
-                    break;
-                default:
-                    break;
-            }
-        }
-        return rate;
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java b/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
index 674a674..dda5561 100644
--- a/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
+++ b/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
@@ -86,12 +86,7 @@ public class ResourceServiceImpl extends AbstractServiceImpl implements Resource
 
     @Override
     public List<ResourceTO> list() {
-        return controller.list(null);
-    }
-
-    @Override
-    public List<ResourceTO> list(final Long connInstanceId) {
-        return controller.list(connInstanceId);
+        return controller.list();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/core/src/main/resources/restContext.xml
----------------------------------------------------------------------
diff --git a/core/src/main/resources/restContext.xml b/core/src/main/resources/restContext.xml
index 1b71e31..7b6fe30 100644
--- a/core/src/main/resources/restContext.xml
+++ b/core/src/main/resources/restContext.xml
@@ -100,9 +100,6 @@ under the License.
   <jaxrs:server id="restContainer" address="/" 
                 basePackages="org.apache.syncope.common.services, org.apache.syncope.core.services" 
                 staticSubresourceResolution="true">
-    <jaxrs:resourceComparator>
-      <bean id="queryResourceInfoComparator" class="org.apache.syncope.core.rest.utils.QueryResourceInfoComparator"/>
-    </jaxrs:resourceComparator>
     <jaxrs:properties> 
       <entry key="search.lax.property.match" value="true"/> 
     </jaxrs:properties> 

http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/core/src/test/java/org/apache/syncope/core/rest/ConnectorTestITCase.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/syncope/core/rest/ConnectorTestITCase.java b/core/src/test/java/org/apache/syncope/core/rest/ConnectorTestITCase.java
index d1063f5..fc4e830 100644
--- a/core/src/test/java/org/apache/syncope/core/rest/ConnectorTestITCase.java
+++ b/core/src/test/java/org/apache/syncope/core/rest/ConnectorTestITCase.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
 import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -265,6 +266,18 @@ public class ConnectorTestITCase extends AbstractTest {
         assertEquals(Integer.valueOf(20), actual.getConnRequestTimeout());
     }
 
+    private List<ResourceTO> filter(final List<ResourceTO> input, final Long connectorId) {
+        List<ResourceTO> result = new ArrayList<ResourceTO>();
+
+        for (ResourceTO resource : input) {
+            if (connectorId.equals(resource.getConnectorId())) {
+                result.add(resource);
+            }
+        }
+
+        return result;
+    }
+
     @Test
     public void issueSYNCOPE10() {
         // ----------------------------------
@@ -276,8 +289,7 @@ public class ConnectorTestITCase extends AbstractTest {
         assertNotNull(connInstanceTO);
 
         // check for resource
-        List<ResourceTO> resources = resourceService.list(Long.valueOf(103));
-
+        List<ResourceTO> resources = filter(resourceService.list(), 103L);
         assertEquals(4, resources.size());
 
         // Retrieve a resource TO template.
@@ -317,8 +329,7 @@ public class ConnectorTestITCase extends AbstractTest {
 
         assertNotNull(resourceTO);
 
-        resources = resourceService.list(connId);
-
+        resources = filter(resourceService.list(), connId);
         assertEquals(1, resources.size());
         // ----------------------------------
 
@@ -709,13 +720,13 @@ public class ConnectorTestITCase extends AbstractTest {
 
     @Test
     public void issueSYNCOPE605() {
-        
+
         ConnInstanceTO connectorInstanceTO = connectorService.read(103L);
         assertTrue(connectorInstanceTO.getCapabilities().isEmpty());
-        
+
         connectorInstanceTO.getCapabilities().add(ConnectorCapability.SEARCH);
         connectorService.update(connectorInstanceTO.getId(), connectorInstanceTO);
-        
+
         ConnInstanceTO updatedCapabilities = connectorService.read(connectorInstanceTO.getId());
         assertNotNull(updatedCapabilities.getCapabilities());
         assertTrue(updatedCapabilities.getCapabilities().size() == 1);

http://git-wip-us.apache.org/repos/asf/syncope/blob/60a62434/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java b/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
index 77f4c66..de4435b 100644
--- a/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
+++ b/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
@@ -406,17 +406,6 @@ public class ResourceTestITCase extends AbstractTest {
     }
 
     @Test
-    public void listByType() {
-        List<ResourceTO> actuals = resourceService.list(105L);
-        assertNotNull(actuals);
-
-        for (ResourceTO resourceTO : actuals) {
-            assertNotNull(resourceTO);
-            assertEquals(105L, resourceTO.getConnectorId().longValue());
-        }
-    }
-
-    @Test
     public void read() {
         ResourceTO actual = resourceService.read(RESOURCE_NAME_TESTDB);
         assertNotNull(actual);
@@ -507,7 +496,7 @@ public class ResourceTestITCase extends AbstractTest {
         item.setExtAttrName("cn");
         item.setPurpose(MappingPurpose.BOTH);
         mapping.setAccountIdItem(item);
-            
+
         item = new MappingItemTO();
         item.setIntMappingType(IntMappingType.RoleOwnerSchema);
         item.setExtAttrName("owner");