You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@syncope.apache.org by rohanjulka19 <gi...@git.apache.org> on 2018/08/14 08:10:52 UTC

[GitHub] syncope pull request #81: [Syncope 1220] Support Groovy implementations in t...

GitHub user rohanjulka19 opened a pull request:

    https://github.com/apache/syncope/pull/81

    [Syncope 1220] Support Groovy implementations in the Netbeans IDE plugin

    

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

    $ git pull https://github.com/rohanjulka19/syncope SYNCOPE-1220

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

    https://github.com/apache/syncope/pull/81.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 #81
    
----
commit 604da4dedce63a1bebbb0734939ecc160e3c713a
Author: rohanjulka19 <ro...@...>
Date:   2018-06-13T08:17:03Z

    Adding Implementation Class

commit 25881d7b46c95b81ad776ce1026b2f275f69c4e3
Author: rohanjulka19 <ro...@...>
Date:   2018-06-13T08:57:30Z

    [SYNCOPE-1220] Added Groovy Implementation Class

commit a05a1995ec7dec8dffa085a150ee6fa4315f3550
Author: rohanjulka19 <ro...@...>
Date:   2018-06-13T09:11:17Z

    [SYNCOPE-1220] Added functionality for listing Groovy Scripts

commit ee4f4a2347eef35b969332cbf4060a81b49b67c4
Author: rohanjulka19 <ro...@...>
Date:   2018-06-14T19:26:52Z

    [SYNCOPE-1220] Added Groovy Implementation Class

commit 3a74303af758aa233826f7236a9ef49c33cab87b
Author: rohanjulka19 <ro...@...>
Date:   2018-06-14T19:30:51Z

    [SYNCOPE-1220] Added functionality for creating and deleting

commit a071415caab0273c65aa13bcb6e5116141f89c11
Author: rohanjulka19 <ro...@...>
Date:   2018-07-02T12:01:15Z

    [SYNCOPE -1220] Function for  modifying the groovy Scripts

commit e5c9e42f76a83c601abacd65b0f6ca8b731e4ab3
Author: rohanjulka19 <ro...@...>
Date:   2018-07-02T12:03:11Z

    [SYNCOPE-1220] Added Default Groovy Scripts

commit 2996f28e90319bb31dea3054ddcef4249d9527b3
Author: rohanjulka19 <ro...@...>
Date:   2018-07-09T23:55:33Z

    [SYNCOPE - 1220]  Errors Fixed

commit d724e19d8af878a4ae4323f1d03e5100cc5faa74
Author: rohanjulka19 <ro...@...>
Date:   2018-07-10T02:31:31Z

    [SYNCOPE-1220] Fixed Errors

commit d671dd8523d1ab38c65b7c0ab9510491c6652f80
Author: rohanjulka19 <ro...@...>
Date:   2018-07-31T19:16:20Z

    Merge remote-tracking branch 'origin/master' into SYNCOPE-1220

commit 4c15741d82e2157c437502ebbfad36643f0b24f1
Author: rohanjulka19 <ro...@...>
Date:   2018-08-09T10:28:29Z

    [SYNCOPE-1220] Fixed Errors

commit 099cbfed8842d2518ae7bb39df2b7fc777e41441
Author: rohanjulka19 <ro...@...>
Date:   2018-08-09T10:44:13Z

    Merge branch 'master' into SYNCOPE-1220

commit 81947a5b9eb24c8a9326a07f799b13c2aee34568
Author: rohanjulka19 <ro...@...>
Date:   2018-08-13T20:59:39Z

    [SYNCOPE -1220] Fixed Checkstyle errors

commit 354a80545d116e94ab439e551095ebee29c9d819
Author: rohanjulka19 <ro...@...>
Date:   2018-08-14T08:04:55Z

    Merge branch 'master' into SYNCOPE-1220

----


---

[GitHub] syncope pull request #81: [Syncope 1220] Support Groovy implementations in t...

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

    https://github.com/apache/syncope/pull/81#discussion_r210282427
  
    --- Diff: ide/netbeans/src/main/java/org/apache/syncope/ide/netbeans/service/ImplementationManagerService.java ---
    @@ -0,0 +1,57 @@
    +/*
    + * 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.ide.netbeans.service;
    +
    +import java.util.List;
    +import javax.ws.rs.core.Response;
    +import org.apache.syncope.client.lib.SyncopeClient;
    +import org.apache.syncope.client.lib.SyncopeClientFactoryBean;
    +import org.apache.syncope.common.lib.to.ImplementationTO;
    +import org.apache.syncope.common.lib.types.ImplementationType;
    +import org.apache.syncope.common.rest.api.service.ImplementationService;
    +
    +public class ImplementationManagerService {
    +
    +    private final ImplementationService service ;
    +
    +    public ImplementationManagerService(final String url, final String userName, final String password) {
    +        SyncopeClient syncopeClient = new SyncopeClientFactoryBean().setAddress(url).create(userName, password);
    +        service = syncopeClient.getService(ImplementationService.class);
    +    }
    + 
    +    public List<ImplementationTO> list(final ImplementationType type) {
    +        return service.list(type);
    +    } 
    +
    +    public ImplementationTO read(final ImplementationType type , final String key) {
    +        return service.read(type, key);
    +    }
    +
    +    public boolean create(final ImplementationTO implementationTO) {
    +        return Response.Status.CREATED.getStatusCode() == service.create(implementationTO).getStatus();
    --- End diff --
    
    Use `.equals()` instead of `==`.


---

[GitHub] syncope pull request #81: [Syncope 1220] Support Groovy implementations in t...

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

    https://github.com/apache/syncope/pull/81#discussion_r210284153
  
    --- Diff: ide/netbeans/src/main/java/org/apache/syncope/ide/netbeans/view/ResourceExplorerTopComponent.java ---
    @@ -312,6 +312,26 @@ private void addReportXslts() {
             treeModel.reload();
         }
     
    +    private void addGroovyScripts() {
    +        for (ImplementationType type : ImplementationType.values()) {
    +            String implType = type.toString();
    +            DefaultMutableTreeNode tempNode = new DefaultMutableTreeNode(implType.toString());
    +           if (implType.equals("JWT_SSO_PROVIDER") || implType.equals("AUDIT_APPENDER")) {
    +                continue ;
    +           }
    +            List<ImplementationTO> scripts = implementationManagerService.list(type);
    +            for (ImplementationTO script : scripts) {
    +                 if (script.getEngine() == ImplementationEngine.GROOVY) {
    --- End diff --
    
    Use `.equals()` instead.


---

[GitHub] syncope pull request #81: [Syncope 1220] Support Groovy implementations in t...

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

    https://github.com/apache/syncope/pull/81#discussion_r209894309
  
    --- Diff: ide/netbeans/src/main/java/org/apache/syncope/ide/netbeans/view/ResourceExplorerTopComponent.java ---
    @@ -410,7 +500,14 @@ public void actionPerformed(final ActionEvent e) {
                                     null, "Error while creating new element", "Error", JOptionPane.ERROR_MESSAGE);
                         }
                     }
    +            } catch (SyncopeClientException excp) {
    +                JOptionPane.showMessageDialog(null, excp.getMessage(), "Syncope Error", JOptionPane.ERROR_MESSAGE);
    +            } catch (IOException | NullPointerException ex) {
    --- End diff --
    
    Do not catch NullPointerException, avoid it in the code.


---

[GitHub] syncope pull request #81: [Syncope 1220] Support Groovy implementations in t...

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

    https://github.com/apache/syncope/pull/81#discussion_r210290890
  
    --- Diff: ide/netbeans/src/main/java/org/apache/syncope/ide/netbeans/view/ResourceExplorerTopComponent.java ---
    @@ -622,14 +751,32 @@ private void saveContent() {
                     reportTemplateManagerService.setFormat(key,
                             ReportTemplateFormat.FO,
                             IOUtils.toInputStream(content, encodingPattern));
    -            } else {
    +            } else if (format.equals("csv")) {
                     reportTemplateManagerService.setFormat(key,
                             ReportTemplateFormat.CSV,
                             IOUtils.toInputStream(content, encodingPattern));
    +            } else if (fileName.equals("Groovy")) {
    --- End diff --
    
    Invert equals


---

[GitHub] syncope pull request #81: [Syncope 1220] Support Groovy implementations in t...

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

    https://github.com/apache/syncope/pull/81#discussion_r210289517
  
    --- Diff: ide/netbeans/src/main/java/org/apache/syncope/ide/netbeans/view/ResourceExplorerTopComponent.java ---
    @@ -429,11 +526,16 @@ public void actionPerformed(final ActionEvent e) {
                     int result = JOptionPane.showConfirmDialog(null, "Are you sure to delete the item?");
                     if (result == JOptionPane.OK_OPTION) {
                         DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();
    -                    boolean deleted;
    +                    String nodeName = (String) node.getUserObject() ;
    +                    boolean deleted = false;
    +                try {
                         if (parent.getUserObject().equals(PluginConstants.MAIL_TEMPLATES)) {
    --- End diff --
    
    Invert equals.


---

[GitHub] syncope pull request #81: [Syncope 1220] Support Groovy implementations in t...

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

    https://github.com/apache/syncope/pull/81#discussion_r210291173
  
    --- Diff: ide/netbeans/src/main/java/org/apache/syncope/ide/netbeans/view/ResourceExplorerTopComponent.java ---
    @@ -622,14 +751,32 @@ private void saveContent() {
                     reportTemplateManagerService.setFormat(key,
                             ReportTemplateFormat.FO,
                             IOUtils.toInputStream(content, encodingPattern));
    -            } else {
    +            } else if (format.equals("csv")) {
                     reportTemplateManagerService.setFormat(key,
                             ReportTemplateFormat.CSV,
                             IOUtils.toInputStream(content, encodingPattern));
    +            } else if (fileName.equals("Groovy")) {
    +                    LOG.info("Setting groovy");
    --- End diff --
    
    Add a meaningful log message.


---

[GitHub] syncope pull request #81: [Syncope 1220] Support Groovy implementations in t...

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

    https://github.com/apache/syncope/pull/81#discussion_r210282822
  
    --- Diff: ide/netbeans/src/main/java/org/apache/syncope/ide/netbeans/service/ImplementationManagerService.java ---
    @@ -0,0 +1,57 @@
    +/*
    + * 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.ide.netbeans.service;
    +
    +import java.util.List;
    +import javax.ws.rs.core.Response;
    +import org.apache.syncope.client.lib.SyncopeClient;
    +import org.apache.syncope.client.lib.SyncopeClientFactoryBean;
    +import org.apache.syncope.common.lib.to.ImplementationTO;
    +import org.apache.syncope.common.lib.types.ImplementationType;
    +import org.apache.syncope.common.rest.api.service.ImplementationService;
    +
    +public class ImplementationManagerService {
    +
    +    private final ImplementationService service ;
    +
    +    public ImplementationManagerService(final String url, final String userName, final String password) {
    +        SyncopeClient syncopeClient = new SyncopeClientFactoryBean().setAddress(url).create(userName, password);
    +        service = syncopeClient.getService(ImplementationService.class);
    +    }
    + 
    +    public List<ImplementationTO> list(final ImplementationType type) {
    +        return service.list(type);
    +    } 
    +
    +    public ImplementationTO read(final ImplementationType type , final String key) {
    +        return service.read(type, key);
    +    }
    +
    +    public boolean create(final ImplementationTO implementationTO) {
    +        return Response.Status.CREATED.getStatusCode() == service.create(implementationTO).getStatus();
    +    }
    +
    +    public boolean delete(final ImplementationType type , final String key) {
    +        return Response.Status.NO_CONTENT.getStatusCode() == service.delete(type, key).getStatus();
    --- End diff --
    
    Same as above.


---

[GitHub] syncope pull request #81: [Syncope 1220] Support Groovy implementations in t...

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

    https://github.com/apache/syncope/pull/81#discussion_r210284819
  
    --- Diff: ide/netbeans/src/main/java/org/apache/syncope/ide/netbeans/view/ResourceExplorerTopComponent.java ---
    @@ -363,11 +383,17 @@ private void folderRightClickAction(final MouseEvent evt,
     
                 @Override
                 public void actionPerformed(final ActionEvent e) {
    -                String name = JOptionPane.showInputDialog("Enter Name");
    +            try {
    +                String name = "" ;
    +                while (name.equals("")) {
    --- End diff --
    
    Use `name.isEmpty()` instead


---

[GitHub] syncope pull request #81: [Syncope 1220] Support Groovy implementations in t...

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

    https://github.com/apache/syncope/pull/81


---

[GitHub] syncope pull request #81: [Syncope 1220] Support Groovy implementations in t...

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

    https://github.com/apache/syncope/pull/81#discussion_r210288384
  
    --- Diff: ide/netbeans/src/main/java/org/apache/syncope/ide/netbeans/view/ResourceExplorerTopComponent.java ---
    @@ -377,11 +403,79 @@ public void actionPerformed(final ActionEvent e) {
                             mailTemplateManagerService.setFormat(name,
                                     MailTemplateFormat.TEXT,
                                     IOUtils.toInputStream("//Enter Content here", encodingPattern));
    -                        try {
                                 openMailEditor(name);
    -                        } catch (IOException ex) {
    -                            Exceptions.printStackTrace(ex);
    -                        }
    +                    } else if ((parent.getUserObject().equals(PluginConstants.GROOVY_SCRIPTS))) {
    --- End diff --
    
    Invert equals.


---

[GitHub] syncope issue #81: [Syncope 1220] Support Groovy implementations in the Netb...

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

    https://github.com/apache/syncope/pull/81
  
    This PR is for SYNCOPE-1220 (auto-link to JIRA)


---

[GitHub] syncope pull request #81: [Syncope 1220] Support Groovy implementations in t...

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

    https://github.com/apache/syncope/pull/81#discussion_r210282709
  
    --- Diff: ide/netbeans/src/main/java/org/apache/syncope/ide/netbeans/service/ImplementationManagerService.java ---
    @@ -0,0 +1,57 @@
    +/*
    + * 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.ide.netbeans.service;
    +
    +import java.util.List;
    +import javax.ws.rs.core.Response;
    +import org.apache.syncope.client.lib.SyncopeClient;
    +import org.apache.syncope.client.lib.SyncopeClientFactoryBean;
    +import org.apache.syncope.common.lib.to.ImplementationTO;
    +import org.apache.syncope.common.lib.types.ImplementationType;
    +import org.apache.syncope.common.rest.api.service.ImplementationService;
    +
    +public class ImplementationManagerService {
    +
    +    private final ImplementationService service ;
    +
    +    public ImplementationManagerService(final String url, final String userName, final String password) {
    +        SyncopeClient syncopeClient = new SyncopeClientFactoryBean().setAddress(url).create(userName, password);
    +        service = syncopeClient.getService(ImplementationService.class);
    +    }
    + 
    +    public List<ImplementationTO> list(final ImplementationType type) {
    +        return service.list(type);
    +    } 
    +
    +    public ImplementationTO read(final ImplementationType type , final String key) {
    +        return service.read(type, key);
    +    }
    +
    +    public boolean create(final ImplementationTO implementationTO) {
    +        return Response.Status.CREATED.getStatusCode() == service.create(implementationTO).getStatus();
    +    }
    +
    +    public boolean delete(final ImplementationType type , final String key) {
    +        return Response.Status.NO_CONTENT.getStatusCode() == service.delete(type, key).getStatus();
    +    }
    +
    +    public boolean update(final ImplementationTO implementationTO) {
    +       return Response.Status.NO_CONTENT.getStatusCode() == service.update(implementationTO).getStatus();
    --- End diff --
    
    Same as above.


---

[GitHub] syncope pull request #81: [Syncope 1220] Support Groovy implementations in t...

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

    https://github.com/apache/syncope/pull/81#discussion_r210289727
  
    --- Diff: ide/netbeans/src/main/java/org/apache/syncope/ide/netbeans/view/ResourceExplorerTopComponent.java ---
    @@ -429,11 +526,16 @@ public void actionPerformed(final ActionEvent e) {
                     int result = JOptionPane.showConfirmDialog(null, "Are you sure to delete the item?");
                     if (result == JOptionPane.OK_OPTION) {
                         DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();
    -                    boolean deleted;
    +                    String nodeName = (String) node.getUserObject() ;
    +                    boolean deleted = false;
    +                try {
                         if (parent.getUserObject().equals(PluginConstants.MAIL_TEMPLATES)) {
    -                        deleted = mailTemplateManagerService.delete((String) node.getUserObject());
    +                        deleted = mailTemplateManagerService.delete(nodeName);
    +                    } else if (parent.getUserObject().equals(PluginConstants.REPORT_XSLTS)) {
    --- End diff --
    
    Invert equals


---