You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by Ashadeepa <gi...@git.apache.org> on 2017/01/18 09:45:17 UTC

[GitHub] cloudstack pull request #1910: CLOUDSTACK-9748:VPN Users search functionalit...

GitHub user Ashadeepa opened a pull request:

    https://github.com/apache/cloudstack/pull/1910

    CLOUDSTACK-9748:VPN Users search functionality broken

    VPN Users search functionality broken 
    If you try to search VPN users with it\u2019s user name, you will not be able to search.
    
    Fixed the same.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/Ashadeepa/cloudstack CLOUDSTACK-9748

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cloudstack/pull/1910.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1910
    
----
commit 0752ff667db09eeb3276627baef009eb414abaf4
Author: root <ashadeepa debnath>
Date:   2017-01-17T18:09:17Z

    CLOUDSTACK-9748:VPN Users search functionality broken

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack issue #1910: CLOUDSTACK-9748:VPN Users search functionality broke...

Posted by ustcweizhou <gi...@git.apache.org>.
Github user ustcweizhou commented on the issue:

    https://github.com/apache/cloudstack/pull/1910
  
    @Ashadeepa your comments in previous comment is not what I expect.
    In my opinion, if username and keyword are both set, we should search by both condition, but only one.
    
    You might missed the line in your testing.
    ```
            sb.and("keyword", sb.entity().getUsername(), SearchCriteria.Op.LIKE);
    ```
    it works fine in my testing.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack issue #1910: CLOUDSTACK-9748:VPN Users search functionality broke...

Posted by SudharmaJain <gi...@git.apache.org>.
Github user SudharmaJain commented on the issue:

    https://github.com/apache/cloudstack/pull/1910
  
    Code changes looks good. LGTM


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request #1910: CLOUDSTACK-9748:VPN Users search functionalit...

Posted by Ashadeepa <gi...@git.apache.org>.
GitHub user Ashadeepa reopened a pull request:

    https://github.com/apache/cloudstack/pull/1910

    CLOUDSTACK-9748:VPN Users search functionality broken

    VPN Users search functionality broken 
    If you try to search VPN users with it\u2019s user name, you will not be able to search.
    
    Fixed the same.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/Ashadeepa/cloudstack CLOUDSTACK-9748

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cloudstack/pull/1910.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1910
    
----
commit 0752ff667db09eeb3276627baef009eb414abaf4
Author: root <ashadeepa debnath>
Date:   2017-01-17T18:09:17Z

    CLOUDSTACK-9748:VPN Users search functionality broken

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack issue #1910: CLOUDSTACK-9748:VPN Users search functionality broke...

Posted by Ashadeepa <gi...@git.apache.org>.
Github user Ashadeepa commented on the issue:

    https://github.com/apache/cloudstack/pull/1910
  
    @ustcweizhou : Thanks. I have made the changes.
    
    New PR : https://github.com/apache/cloudstack/pull/1957. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request #1910: CLOUDSTACK-9748:VPN Users search functionalit...

Posted by Ashadeepa <gi...@git.apache.org>.
Github user Ashadeepa closed the pull request at:

    https://github.com/apache/cloudstack/pull/1910


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request #1910: CLOUDSTACK-9748:VPN Users search functionalit...

Posted by syed <gi...@git.apache.org>.
Github user syed commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1910#discussion_r98365622
  
    --- Diff: server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java ---
    @@ -596,7 +597,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
     
     
             sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
    -        sb.and("username", sb.entity().getUsername(), SearchCriteria.Op.EQ);
    +        sb.and("username", sb.entity().getUsername(), SearchCriteria.Op.LIKE);
    --- End diff --
    
    Any reason for changing this to `LIKE` instead of `EQ` ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request #1910: CLOUDSTACK-9748:VPN Users search functionalit...

Posted by Ashadeepa <gi...@git.apache.org>.
Github user Ashadeepa commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1910#discussion_r98381118
  
    --- Diff: server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java ---
    @@ -613,6 +614,10 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
                 sc.setParameters("username", username);
             }
     
    +        if (keyword!= null) {
    +            sc.setParameters("username",  "%" + keyword + "%");
    +        }
    +
             Pair<List<VpnUserVO>, Integer> result = _vpnUsersDao.searchAndCount(sc, searchFilter);
    --- End diff --
    
    @syed : If both are set, we are giving preference to keyword as the search will happen using keyword query param. This is in according with other existing APIs. Keyword is the request parameter for : List by keyword functionality. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request #1910: CLOUDSTACK-9748:VPN Users search functionalit...

Posted by ustcweizhou <gi...@git.apache.org>.
Github user ustcweizhou commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1910#discussion_r98412264
  
    --- Diff: server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java ---
    @@ -596,7 +597,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
     
     
             sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
    -        sb.and("username", sb.entity().getUsername(), SearchCriteria.Op.EQ);
    +        sb.and("username", sb.entity().getUsername(), SearchCriteria.Op.LIKE);
    --- End diff --
    
    I vote EQ instead LIKE here.
    you may add new rules here in the next part, for example.
    
    +        if (keyword != null) {
    +            final SearchCriteria<VpnUserVO> ssc = _vpnUsersDao.createSearchCriteria();
    +            ssc.addOr("username", SearchCriteria.Op.LIKE, "%" + keyword + "%");
    +            ssc.addOr("state", SearchCriteria.Op.EQ, "%" + keyword + "%");
    +            sc.addAnd("username", SearchCriteria.Op.SC, ssc);
    +        }
    



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack issue #1910: CLOUDSTACK-9748:VPN Users search functionality broke...

Posted by ustcweizhou <gi...@git.apache.org>.
Github user ustcweizhou commented on the issue:

    https://github.com/apache/cloudstack/pull/1910
  
    @Ashadeepa I just tested it. It seems it is not working as I expected if username and keyword are both set.
    I suggest to use the following
    ```
            sb.and("username", sb.entity().getUsername(), SearchCriteria.Op.EQ);
            sb.and("keyword", sb.entity().getUsername(), SearchCriteria.Op.LIKE);
    ...
            if (keyword!= null) {
                 sc.setParameters("keyword",  "%" + keyword + "%");
             }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request #1910: CLOUDSTACK-9748:VPN Users search functionalit...

Posted by syed <gi...@git.apache.org>.
Github user syed commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1910#discussion_r98365603
  
    --- Diff: server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java ---
    @@ -613,6 +614,10 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
                 sc.setParameters("username", username);
             }
     
    +        if (keyword!= null) {
    +            sc.setParameters("username",  "%" + keyword + "%");
    +        }
    +
             Pair<List<VpnUserVO>, Integer> result = _vpnUsersDao.searchAndCount(sc, searchFilter);
    --- End diff --
    
    What if both username and keyword are set? Shouldn't we prefer the username? Also what is `keyword` anyways?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request #1910: CLOUDSTACK-9748:VPN Users search functionalit...

Posted by Ashadeepa <gi...@git.apache.org>.
Github user Ashadeepa commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1910#discussion_r98381232
  
    --- Diff: server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java ---
    @@ -596,7 +597,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
     
     
             sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
    -        sb.and("username", sb.entity().getUsername(), SearchCriteria.Op.EQ);
    +        sb.and("username", sb.entity().getUsername(), SearchCriteria.Op.LIKE);
    --- End diff --
    
    @syed Used LIKE instead of EQ as username will be used in a WHERE clause to search for a specified pattern in a column using the keyword.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request #1910: CLOUDSTACK-9748:VPN Users search functionalit...

Posted by Ashadeepa <gi...@git.apache.org>.
Github user Ashadeepa closed the pull request at:

    https://github.com/apache/cloudstack/pull/1910


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack issue #1910: CLOUDSTACK-9748:VPN Users search functionality broke...

Posted by Ashadeepa <gi...@git.apache.org>.
Github user Ashadeepa commented on the issue:

    https://github.com/apache/cloudstack/pull/1910
  
    ![test_input_ss](https://cloud.githubusercontent.com/assets/24891090/23020031/12ead576-f46b-11e6-80f6-689e34f18998.PNG)
    ![test_output_ss](https://cloud.githubusercontent.com/assets/24891090/23020032/12ed37f8-f46b-11e6-8e32-1e331d4ace06.PNG)
    [TestResults_CLOUDSTACK-9748.txt](https://github.com/apache/cloudstack/files/779944/TestResults_CLOUDSTACK-9748.txt)



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request #1910: CLOUDSTACK-9748:VPN Users search functionalit...

Posted by Ashadeepa <gi...@git.apache.org>.
Github user Ashadeepa commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1910#discussion_r98422211
  
    --- Diff: server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java ---
    @@ -596,7 +597,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
     
     
             sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
    -        sb.and("username", sb.entity().getUsername(), SearchCriteria.Op.EQ);
    +        sb.and("username", sb.entity().getUsername(), SearchCriteria.Op.LIKE);
    --- End diff --
    
    @ustcweizhou : Thanks but unfortunately, addOr & addAnd methods are now deprecated, so I avoided using the same.
    
    Also, LIKE with work only when keyword is set. When only username is set,      `sc.setParameters("username", username); `
    will get executed with the exact match i.e. same as how EQ will work!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack issue #1910: CLOUDSTACK-9748:VPN Users search functionality broke...

Posted by Ashadeepa <gi...@git.apache.org>.
Github user Ashadeepa commented on the issue:

    https://github.com/apache/cloudstack/pull/1910
  
    @ustcweizhou : Hi, I had tested the same and added my test results in the file TestResults_CLOUDSTACK-9748.txt. 
    
    As per my previous comment, when both username & keyword are set, users with username like 'keyword' will be the expected result. 
    
    Also, your suggested won't work as "keyword" in absent in the VPNUserVO class as there is no such column named as keyword. I tried it, got an exception.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---