Repository: syncope
Updated Branches:
  refs/heads/master 7a11bf3b9 -> 9a1474770


Fixed SYNCOPE-582


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

Branch: refs/heads/master
Commit: 9a1474770d0f77cd5655072e43280b2176cdc404
Parents: 7a11bf3
Author: massi <massimiliano.perr...@tirasa.net>
Authored: Fri Oct 23 15:56:32 2015 +0200
Committer: massi <massimiliano.perr...@tirasa.net>
Committed: Fri Oct 23 15:56:32 2015 +0200

----------------------------------------------------------------------
 .../syncope/client/cli/AvailableServices.java   |  31 -----
 .../connector/AbstractConnectorCommand.java     |  30 +++++
 .../commands/connector/ConnectorCommand.java    | 123 +++++++++++++++++++
 .../cli/commands/connector/ConnectorDelete.java |  62 ++++++++++
 .../cli/commands/connector/ConnectorList.java   |  32 +++++
 .../connector/ConnectorListBundles.java         |  32 +++++
 .../ConnectorListConfigurationProperties.java   |  58 +++++++++
 .../cli/commands/connector/ConnectorRead.java   |  61 +++++++++
 .../connector/ConnectorReadByResource.java      |  60 +++++++++
 .../connector/ConnectorResultManager.java       | 114 +++++++++++++++++
 .../commands/policy/PolicyResultManager.java    |   3 +
 .../client/cli/commands/report/ReportList.java  |   2 +-
 .../client/cli/commands/report/ReportRead.java  |   2 +-
 .../commands/report/ReportResultManager.java    |  17 +--
 14 files changed, 586 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/9a147477/client/cli/src/main/java/org/apache/syncope/client/cli/AvailableServices.java
----------------------------------------------------------------------
diff --git 
a/client/cli/src/main/java/org/apache/syncope/client/cli/AvailableServices.java 
b/client/cli/src/main/java/org/apache/syncope/client/cli/AvailableServices.java
deleted file mode 100644
index 7d326a8..0000000
--- 
a/client/cli/src/main/java/org/apache/syncope/client/cli/AvailableServices.java
+++ /dev/null
@@ -1,31 +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.client.cli;
-
-public enum AvailableServices {
-
-    logger,
-    config,
-    notification,
-    report,
-    policy,
-    entitlement,
-    schema;
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/9a147477/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/AbstractConnectorCommand.java
----------------------------------------------------------------------
diff --git 
a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/AbstractConnectorCommand.java
 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/AbstractConnectorCommand.java
new file mode 100644
index 0000000..0605c46
--- /dev/null
+++ 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/AbstractConnectorCommand.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.cli.commands.connector;
+
+import org.apache.syncope.client.cli.SyncopeServices;
+import org.apache.syncope.common.rest.api.service.ConnectorService;
+
+public abstract class AbstractConnectorCommand {
+
+    protected final ConnectorService connectorService = 
SyncopeServices.get(ConnectorService.class);
+
+    protected final ConnectorResultManager connectorResultManager = new 
ConnectorResultManager();
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/9a147477/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorCommand.java
----------------------------------------------------------------------
diff --git 
a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorCommand.java
 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorCommand.java
new file mode 100644
index 0000000..83a03cb
--- /dev/null
+++ 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorCommand.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.cli.commands.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.client.cli.Command;
+import org.apache.syncope.client.cli.Input;
+import org.apache.syncope.client.cli.commands.AbstractCommand;
+
+@Command(name = "connector")
+public class ConnectorCommand extends AbstractCommand {
+
+    private static final String HELP_MESSAGE = "Usage: connector [options]\n"
+            + "  Options:\n"
+            + "    --help \n"
+            + "    --list \n"
+            + "    --list-bundles \n"
+            + "    --list-configuration-properties\n"
+            + "       Syntax: --list-configuration-properties {CONNECTOR-ID} 
{CONNECTOR-ID} [...]\n"
+            + "    --read \n"
+            + "       Syntax: --read {CONNECTOR-ID} {CONNECTOR-ID} [...]\n"
+            + "    --delete \n"
+            + "       Syntax: --delete {CONNECTOR-ID} {CONNECTOR-ID} [...]";
+
+    @Override
+    public void execute(final Input input) {
+        if (StringUtils.isBlank(input.getOption())) {
+            input.setOption(ConnectorOptions.HELP.getOptionName());
+        }
+
+        switch (ConnectorOptions.fromName(input.getOption())) {
+            case LIST:
+                new ConnectorList().list();
+                break;
+            case LIST_BUNDLES:
+                new ConnectorListBundles().list();
+                break;
+            case LIST_CONFIGURATION:
+                new ConnectorListConfigurationProperties(input).list();
+                break;
+            case READ:
+                new ConnectorRead(input).read();
+                break;
+            case READ_BY_RESOURCE:
+                new ConnectorReadByResource(input).read();
+                break;
+            case DELETE:
+                new ConnectorDelete(input).delete();
+                break;
+            case HELP:
+                System.out.println(HELP_MESSAGE);
+                break;
+            default:
+                new ConnectorResultManager().defaultError(input.getOption(), 
HELP_MESSAGE);
+        }
+    }
+
+    @Override
+    public String getHelpMessage() {
+        return HELP_MESSAGE;
+    }
+
+    private enum ConnectorOptions {
+
+        HELP("--help"),
+        LIST("--list"),
+        LIST_BUNDLES("--list-bundles"),
+        LIST_CONFIGURATION("--list-configuration-properties"),
+        READ("--read"),
+        READ_BY_RESOURCE("--read-by-resource"),
+        DELETE("--delete");
+
+        private final String optionName;
+
+        ConnectorOptions(final String optionName) {
+            this.optionName = optionName;
+        }
+
+        public String getOptionName() {
+            return optionName;
+        }
+
+        public boolean equalsOptionName(final String otherName) {
+            return (otherName == null) ? false : optionName.equals(otherName);
+        }
+
+        public static ConnectorOptions fromName(final String name) {
+            ConnectorOptions optionToReturn = HELP;
+            for (final ConnectorOptions option : ConnectorOptions.values()) {
+                if (option.equalsOptionName(name)) {
+                    optionToReturn = option;
+                }
+            }
+            return optionToReturn;
+        }
+
+        public static List<String> toList() {
+            final List<String> options = new ArrayList<>();
+            for (final ConnectorOptions value : values()) {
+                options.add(value.getOptionName());
+            }
+            return options;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/9a147477/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorDelete.java
----------------------------------------------------------------------
diff --git 
a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorDelete.java
 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorDelete.java
new file mode 100644
index 0000000..ab4c82e
--- /dev/null
+++ 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorDelete.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.cli.commands.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.ws.WebServiceException;
+import org.apache.syncope.client.cli.Input;
+import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.to.ConnInstanceTO;
+
+public class ConnectorDelete extends AbstractConnectorCommand {
+
+    private static final String DELETE_HELP_MESSAGE = "connector --delete 
{CONNECTOR-ID} {CONNECTOR-ID} [...]";
+
+    private final Input input;
+
+    public ConnectorDelete(final Input input) {
+        this.input = input;
+    }
+
+    public void delete() {
+        if (input.getParameters().length >= 1) {
+            final List<ConnInstanceTO> connInstanceTOs = new ArrayList<>();
+            for (final String parameter : input.getParameters()) {
+                try {
+                    connectorService.delete(Long.valueOf(parameter));
+                    connectorResultManager.deletedMessage("connector", 
parameter);
+                } catch (final NumberFormatException ex) {
+                    
connectorResultManager.managerNumberFormatException("connector", parameter);
+                } catch (final SyncopeClientException | WebServiceException 
ex) {
+                    if (ex.getMessage().startsWith("NotFound")) {
+                        connectorResultManager.notFoundError("Connector", 
parameter);
+                    } else {
+                        connectorResultManager.generic(ex.getMessage());
+                    }
+                    break;
+                }
+            }
+            connectorResultManager.toView(connInstanceTOs);
+        } else {
+            connectorResultManager.commandOptionError(DELETE_HELP_MESSAGE);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/9a147477/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorList.java
----------------------------------------------------------------------
diff --git 
a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorList.java
 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorList.java
new file mode 100644
index 0000000..7b6a3c6
--- /dev/null
+++ 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorList.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.cli.commands.connector;
+
+import org.apache.syncope.common.lib.SyncopeClientException;
+
+public class ConnectorList extends AbstractConnectorCommand {
+
+    public void list() {
+        try {
+            connectorResultManager.toView(connectorService.list(null));
+        } catch (final SyncopeClientException ex) {
+            connectorResultManager.generic(ex.getMessage());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/9a147477/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorListBundles.java
----------------------------------------------------------------------
diff --git 
a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorListBundles.java
 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorListBundles.java
new file mode 100644
index 0000000..72a103d
--- /dev/null
+++ 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorListBundles.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.cli.commands.connector;
+
+import org.apache.syncope.common.lib.SyncopeClientException;
+
+public class ConnectorListBundles extends AbstractConnectorCommand {
+
+    public void list() {
+        try {
+            
connectorResultManager.fromListBundles(connectorService.getBundles(null));
+        } catch (final SyncopeClientException ex) {
+            connectorResultManager.generic(ex.getMessage());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/9a147477/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorListConfigurationProperties.java
----------------------------------------------------------------------
diff --git 
a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorListConfigurationProperties.java
 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorListConfigurationProperties.java
new file mode 100644
index 0000000..6b80e8e
--- /dev/null
+++ 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorListConfigurationProperties.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.cli.commands.connector;
+
+import javax.xml.ws.WebServiceException;
+import org.apache.syncope.client.cli.Input;
+import org.apache.syncope.common.lib.SyncopeClientException;
+
+public class ConnectorListConfigurationProperties extends 
AbstractConnectorCommand {
+
+    private static final String LIST_CONFIGURATION_HELP_MESSAGE 
+            = "connector --list-configuration-properties {CONNECTOR-ID} 
{CONNECTOR-ID} [...]";
+
+    private final Input input;
+
+    public ConnectorListConfigurationProperties(final Input input) {
+        this.input = input;
+    }
+
+    public void list() {
+        if (input.getParameters().length >= 1) {
+            for (final String parameter : input.getParameters()) {
+                try {
+                    connectorResultManager.fromListConfigurationProperties(
+                            
connectorService.getConfigurationProperties(Long.valueOf(parameter)));
+                } catch (final NumberFormatException ex) {
+                    
connectorResultManager.managerNumberFormatException("connector", parameter);
+                } catch (final SyncopeClientException | WebServiceException 
ex) {
+                    if (ex.getMessage().startsWith("NotFound")) {
+                        connectorResultManager.notFoundError("Connector", 
parameter);
+                    } else {
+                        connectorResultManager.generic(ex.getMessage());
+                    }
+                    break;
+                }
+            }
+        } else {
+            
connectorResultManager.commandOptionError(LIST_CONFIGURATION_HELP_MESSAGE);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/9a147477/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorRead.java
----------------------------------------------------------------------
diff --git 
a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorRead.java
 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorRead.java
new file mode 100644
index 0000000..46cbe84
--- /dev/null
+++ 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorRead.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.cli.commands.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.ws.WebServiceException;
+import org.apache.syncope.client.cli.Input;
+import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.to.ConnInstanceTO;
+
+public class ConnectorRead extends AbstractConnectorCommand {
+
+    private static final String READ_HELP_MESSAGE = "connector --read 
{CONNECTOR-ID} {CONNECTOR-ID} [...]";
+
+    private final Input input;
+
+    public ConnectorRead(final Input input) {
+        this.input = input;
+    }
+
+    public void read() {
+        if (input.getParameters().length >= 1) {
+            final List<ConnInstanceTO> connInstanceTOs = new ArrayList<>();
+            for (final String parameter : input.getParameters()) {
+                try {
+                    
connInstanceTOs.add(connectorService.read(Long.valueOf(parameter), 
READ_HELP_MESSAGE));
+                } catch (final NumberFormatException ex) {
+                    
connectorResultManager.managerNumberFormatException("connector", parameter);
+                } catch (final SyncopeClientException | WebServiceException 
ex) {
+                    if (ex.getMessage().startsWith("NotFound")) {
+                        connectorResultManager.notFoundError("Connector", 
parameter);
+                    } else {
+                        connectorResultManager.generic(ex.getMessage());
+                    }
+                    break;
+                }
+            }
+            connectorResultManager.toView(connInstanceTOs);
+        } else {
+            connectorResultManager.commandOptionError(READ_HELP_MESSAGE);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/9a147477/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorReadByResource.java
----------------------------------------------------------------------
diff --git 
a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorReadByResource.java
 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorReadByResource.java
new file mode 100644
index 0000000..bd7797c
--- /dev/null
+++ 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorReadByResource.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.cli.commands.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.ws.WebServiceException;
+import org.apache.syncope.client.cli.Input;
+import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.to.ConnInstanceTO;
+
+public class ConnectorReadByResource extends AbstractConnectorCommand {
+
+    private static final String READ_HELP_MESSAGE
+            = "connector --read-by-resource {RESOURCE-NAME} {RESOURCE-NAME} 
[...]";
+
+    private final Input input;
+
+    public ConnectorReadByResource(final Input input) {
+        this.input = input;
+    }
+
+    public void read() {
+        if (input.getParameters().length >= 1) {
+            final List<ConnInstanceTO> connInstanceTOs = new ArrayList<>();
+            for (final String parameter : input.getParameters()) {
+                try {
+                    
connInstanceTOs.add(connectorService.readByResource(parameter, 
READ_HELP_MESSAGE));
+                } catch (final SyncopeClientException | WebServiceException 
ex) {
+                    if (ex.getMessage().startsWith("NotFound")) {
+                        connectorResultManager.notFoundError("Resource", 
parameter);
+                    } else {
+                        connectorResultManager.generic(ex.getMessage());
+                    }
+                    break;
+                }
+            }
+            connectorResultManager.toView(connInstanceTOs);
+        } else {
+            connectorResultManager.commandOptionError(READ_HELP_MESSAGE);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/9a147477/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorResultManager.java
----------------------------------------------------------------------
diff --git 
a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorResultManager.java
 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorResultManager.java
new file mode 100644
index 0000000..913c22e
--- /dev/null
+++ 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorResultManager.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.cli.commands.connector;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.syncope.client.cli.commands.CommonsResultManager;
+import org.apache.syncope.common.lib.to.ConnBundleTO;
+import org.apache.syncope.common.lib.to.ConnInstanceTO;
+import org.apache.syncope.common.lib.to.ConnPoolConfTO;
+import org.apache.syncope.common.lib.types.ConnConfPropSchema;
+import org.apache.syncope.common.lib.types.ConnConfProperty;
+import org.apache.syncope.common.lib.types.ConnectorCapability;
+
+public class ConnectorResultManager extends CommonsResultManager {
+
+    public void toView(final List<ConnInstanceTO> connInstanceTOs) {
+        for (final ConnInstanceTO connInstanceTO : connInstanceTOs) {
+            printConnector(connInstanceTO);
+        }
+    }
+
+    public void fromListBundles(final List<ConnBundleTO> connBundleTOs) {
+        for (final ConnBundleTO connBundleTO : connBundleTOs) {
+            System.out.println(" > BUNDLE NAME: " + 
connBundleTO.getBundleName());
+            System.out.println("    connector name: " + 
connBundleTO.getConnectorName());
+            System.out.println("    display name: " + 
connBundleTO.getDisplayName());
+            System.out.println("    location: " + connBundleTO.getLocation());
+            System.out.println("    version: " + connBundleTO.getVersion());
+            System.out.println("    PROPERTIES:");
+            printConfPropSchema(connBundleTO.getProperties());
+        }
+    }
+
+    public void fromListConfigurationProperties(final List<ConnConfProperty> 
connConfPropertys) {
+        printConfiguration(new HashSet<>(connConfPropertys));
+
+    }
+
+    private void printConnector(final ConnInstanceTO connInstanceTO) {
+        System.out.println(" > CONNECTOR ID: " + connInstanceTO.getKey());
+        System.out.println("    bundle name: " + 
connInstanceTO.getBundleName());
+        System.out.println("    connector name: " + 
connInstanceTO.getConnectorName());
+        System.out.println("    display name: " + 
connInstanceTO.getDisplayName());
+        System.out.println("    location: " + connInstanceTO.getLocation());
+        System.out.println("    version: " + connInstanceTO.getVersion());
+        System.out.println("    timeout: " + 
connInstanceTO.getConnRequestTimeout());
+        System.out.println("    CAPABILITIES:");
+        printCapabilities(connInstanceTO.getCapabilities());
+        System.out.println("    CONFIGURATION:");
+        printConfiguration(connInstanceTO.getConfiguration());
+        System.out.println("    POOL CONFIGURATION:");
+        printConfPool(connInstanceTO.getPoolConf());
+    }
+
+    private void printCapabilities(final Set<ConnectorCapability> 
capabilities) {
+        for (final ConnectorCapability capability : capabilities) {
+            System.out.println("       - " + capability.name());
+        }
+    }
+
+    private void printConfiguration(final Set<ConnConfProperty> 
configurationPropertys) {
+        for (final ConnConfProperty configuration : configurationPropertys) {
+            System.out.println("       name: " + 
configuration.getSchema().getName());
+            System.out.println("       values: " + configuration.getValues());
+            System.out.println("       type: " + 
configuration.getSchema().getType());
+            System.out.println("       display name: " + 
configuration.getSchema().getDisplayName());
+            System.out.println("       help message: " + 
configuration.getSchema().getHelpMessage());
+            System.out.println("       order: " + 
configuration.getSchema().getOrder());
+            System.out.println("       default values: " + 
configuration.getSchema().getDefaultValues());
+            System.out.println("       confidential: " + 
configuration.getSchema().isConfidential());
+            System.out.println("       required: " + 
configuration.getSchema().isRequired());
+            System.out.println("       overridable: " + 
configuration.isOverridable());
+            System.out.println("");
+        }
+    }
+
+    private void printConfPool(final ConnPoolConfTO connPoolConfTO) {
+        System.out.println("       min idle: " + connPoolConfTO.getMinIdle());
+        System.out.println("       min evictlable idle: " + 
connPoolConfTO.getMinEvictableIdleTimeMillis());
+        System.out.println("       max idle: " + connPoolConfTO.getMaxIdle());
+        System.out.println("       max objects: " + 
connPoolConfTO.getMaxObjects());
+        System.out.println("       max wait: " + connPoolConfTO.getMaxWait());
+    }
+
+    private void printConfPropSchema(final List<ConnConfPropSchema> 
connConfPropSchemas) {
+        for (final ConnConfPropSchema connConfPropSchema : 
connConfPropSchemas) {
+            System.out.println("       name: " + connConfPropSchema.getName());
+            System.out.println("       display name: " + 
connConfPropSchema.getDisplayName());
+            System.out.println("       help message: " + 
connConfPropSchema.getHelpMessage());
+            System.out.println("       type: " + connConfPropSchema.getType());
+            System.out.println("       order: " + 
connConfPropSchema.getOrder());
+            System.out.println("       default value: " + 
connConfPropSchema.getDefaultValues().toString());
+            System.out.println("");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/9a147477/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyResultManager.java
----------------------------------------------------------------------
diff --git 
a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyResultManager.java
 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyResultManager.java
index 7d140a3..86b5d13 100644
--- 
a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyResultManager.java
+++ 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyResultManager.java
@@ -90,6 +90,7 @@ public class PolicyResultManager extends CommonsResultManager 
{
         System.out.println("    propagation suspension : " + 
policyTO.isPropagateSuspension());
         System.out.println("    RULES : ");
         System.out.println("       > class : " + policyTO.getRuleConfs());
+        System.out.println("");
     }
 
     public void printPasswordPolicy(final PasswordPolicyTO policyTO) {
@@ -102,6 +103,7 @@ public class PolicyResultManager extends 
CommonsResultManager {
         System.out.println("    allow null password : " + 
policyTO.isAllowNullPassword());
         System.out.println("    RULES : ");
         System.out.println("       > class : " + ((PasswordPolicyTO) 
policyTO).getRuleConfs());
+        System.out.println("");
     }
 
     public void printSyncPolicy(final SyncPolicyTO policyTO) {
@@ -116,5 +118,6 @@ public class PolicyResultManager extends 
CommonsResultManager {
             System.out.println("    correlation rule : "
                     + 
policyTO.getSpecification().getCorrelationRules().toString());
         }
+        System.out.println("");
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/9a147477/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportList.java
----------------------------------------------------------------------
diff --git 
a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportList.java
 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportList.java
index d43f21f..1d3e5de 100644
--- 
a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportList.java
+++ 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportList.java
@@ -24,7 +24,7 @@ public class ReportList extends AbstractReportCommand {
 
     public void list() {
         try {
-            reportResultManager.fromList(reportService.list());
+            reportResultManager.fromValueToView(reportService.list());
         } catch (final SyncopeClientException ex) {
             reportResultManager.generic(ex.getMessage());
         }

http://git-wip-us.apache.org/repos/asf/syncope/blob/9a147477/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportRead.java
----------------------------------------------------------------------
diff --git 
a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportRead.java
 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportRead.java
index dd9760e..d1ab975 100644
--- 
a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportRead.java
+++ 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportRead.java
@@ -51,7 +51,7 @@ public class ReportRead extends AbstractReportCommand {
                     }
                 }
             }
-            reportResultManager.fromList(reportTOs);
+            reportResultManager.fromValueToView(reportTOs);
         } else {
             reportResultManager.commandOptionError(READ_HELP_MESSAGE);
         }

http://git-wip-us.apache.org/repos/asf/syncope/blob/9a147477/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportResultManager.java
----------------------------------------------------------------------
diff --git 
a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportResultManager.java
 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportResultManager.java
index cc1b41a..bafdffe 100644
--- 
a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportResultManager.java
+++ 
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportResultManager.java
@@ -27,7 +27,7 @@ import org.apache.syncope.common.lib.to.ReportTO;
 
 public class ReportResultManager extends CommonsResultManager {
 
-    public void fromList(final List<ReportTO> reportTOs) {
+    public void fromValueToView(final List<ReportTO> reportTOs) {
         for (final ReportTO reportTO : reportTOs) {
             printReport(reportTO);
         }
@@ -35,19 +35,20 @@ public class ReportResultManager extends 
CommonsResultManager {
 
     private void printReport(final ReportTO reportTO) {
         System.out.println(" > REPORT ID: " + reportTO.getKey());
-        System.out.println("    type: " + reportTO.getName());
-        System.out.println("    type: " + reportTO.getCronExpression());
-        System.out.println("    type: " + reportTO.getLatestExecStatus());
-        System.out.println("    type: " + reportTO.getLastExec());
-        System.out.println("    type: " + reportTO.getNextExec());
-        System.out.println("    type: " + reportTO.getStartDate());
-        System.out.println("    type: " + reportTO.getEndDate());
+        System.out.println("    name: " + reportTO.getName());
+        System.out.println("    cron expression: " + 
reportTO.getCronExpression());
+        System.out.println("    latest execution status: " + 
reportTO.getLatestExecStatus());
+        System.out.println("    last execution: " + reportTO.getLastExec());
+        System.out.println("    next execution: " + reportTO.getNextExec());
+        System.out.println("    start date: " + reportTO.getStartDate());
+        System.out.println("    end date: " + reportTO.getEndDate());
         System.out.println("    CONF:");
         for (final AbstractReportletConf reportletConf : 
reportTO.getReportletConfs()) {
             printReportletConf(reportletConf);
         }
         System.out.println("    EXECUTION:");
         printReportExecution(reportTO.getExecutions());
+        System.out.println("");
     }
 
     private void printReportletConf(final AbstractReportletConf reportletConf) 
{

Reply via email to