Fixed SYNCOPE-580, refactoring and added realm stack, SYNCOPE-158
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/47b9f64b Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/47b9f64b Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/47b9f64b Branch: refs/heads/SYNCOPE-156 Commit: 47b9f64bd1aeb9ec9260f809a83c042cbf09b9fd Parents: 7866cdb Author: massi <[email protected]> Authored: Tue Oct 27 18:07:06 2015 +0100 Committer: massi <[email protected]> Committed: Tue Oct 27 18:07:24 2015 +0100 ---------------------------------------------------------------------- .../org/apache/syncope/client/cli/Input.java | 6 + .../cli/commands/CommonsResultManager.java | 2 +- .../AbstractConfigurationCommand.java | 6 +- .../configuration/ConfigurationDelete.java | 2 +- .../configuration/ConfigurationExport.java | 2 +- .../configuration/ConfigurationGet.java | 2 +- .../configuration/ConfigurationRead.java | 2 +- .../ConfigurationSyncopeOperations.java | 50 +++++++ .../configuration/ConfigurationUpdate.java | 4 +- .../connector/AbstractConnectorCommand.java | 5 +- .../cli/commands/connector/ConnectorDelete.java | 4 +- .../cli/commands/connector/ConnectorList.java | 2 +- .../connector/ConnectorListBundles.java | 2 +- .../ConnectorListConfigurationProperties.java | 4 +- .../cli/commands/connector/ConnectorRead.java | 4 +- .../connector/ConnectorReadByResource.java | 2 +- .../connector/ConnectorSyncopeOperations.java | 50 +++++++ .../commands/domain/AbstractDomainCommand.java | 5 +- .../cli/commands/domain/DomainDelete.java | 2 +- .../client/cli/commands/domain/DomainList.java | 2 +- .../client/cli/commands/domain/DomainRead.java | 4 +- .../domain/DomainSyncopeOperations.java | 41 ++++++ .../cli/commands/install/InstallSetup.java | 3 +- .../commands/logger/AbstractLoggerCommand.java | 7 +- .../cli/commands/logger/LoggerCreate.java | 3 +- .../cli/commands/logger/LoggerDelete.java | 3 +- .../client/cli/commands/logger/LoggerList.java | 3 +- .../client/cli/commands/logger/LoggerRead.java | 3 +- .../logger/LoggerSyncopeOperations.java | 46 ++++++ .../cli/commands/logger/LoggerUpdate.java | 5 +- .../cli/commands/logger/LoggerUpdateAll.java | 5 +- .../AbstractNotificationCommand.java | 5 +- .../notification/NotificationDelete.java | 2 +- .../commands/notification/NotificationList.java | 2 +- .../commands/notification/NotificationRead.java | 2 +- .../NotificationSyncopeOperations.java | 41 ++++++ .../commands/policy/AbstractPolicyCommand.java | 7 +- .../cli/commands/policy/PolicyDelete.java | 2 +- .../client/cli/commands/policy/PolicyList.java | 2 +- .../client/cli/commands/policy/PolicyRead.java | 2 +- .../policy/PolicySyncopeOperations.java | 42 ++++++ .../commands/realm/AbstractRealmCommand.java | 27 ++++ .../client/cli/commands/realm/RealmCommand.java | 96 +++++++++++++ .../client/cli/commands/realm/RealmList.java | 36 +++++ .../cli/commands/realm/RealmResultManager.java | 39 +++++ .../commands/realm/RealmSyncopeOperations.java | 44 ++++++ .../commands/report/AbstractReportCommand.java | 5 +- .../cli/commands/report/ReportDelete.java | 4 +- .../commands/report/ReportDeleteExecution.java | 4 +- .../cli/commands/report/ReportExecute.java | 7 +- .../commands/report/ReportExportExecution.java | 10 +- .../client/cli/commands/report/ReportList.java | 2 +- .../cli/commands/report/ReportListJobs.java | 2 +- .../client/cli/commands/report/ReportRead.java | 4 +- .../commands/report/ReportReadExecution.java | 4 +- .../report/ReportSyncopeOperations.java | 65 +++++++++ .../resource/AbstractResourceCommand.java | 7 +- .../cli/commands/resource/ResourceDelete.java | 4 +- .../cli/commands/resource/ResourceList.java | 2 +- .../cli/commands/resource/ResourceRead.java | 4 +- .../resource/ResourceResultManager.java | 5 +- .../resource/ResourceSyncopeOperations.java | 51 +++++++ .../commands/schema/AbstractSchemaCommand.java | 7 +- .../cli/commands/schema/SchemaDelete.java | 2 +- .../client/cli/commands/schema/SchemaList.java | 2 +- .../cli/commands/schema/SchemaListAll.java | 2 +- .../cli/commands/schema/SchemaListDerived.java | 3 +- .../cli/commands/schema/SchemaListPlain.java | 3 +- .../cli/commands/schema/SchemaListVirtual.java | 3 +- .../client/cli/commands/schema/SchemaRead.java | 2 +- .../schema/SchemaSyncopeOperations.java | 54 +++++++ .../cli/commands/task/AbstractTaskCommand.java | 5 +- .../client/cli/commands/task/TaskDelete.java | 2 +- .../client/cli/commands/task/TaskExecute.java | 4 +- .../cli/commands/task/TaskExecutionDelete.java | 2 +- .../cli/commands/task/TaskExecutionRead.java | 2 +- .../client/cli/commands/task/TaskList.java | 2 +- .../client/cli/commands/task/TaskRead.java | 2 +- .../cli/commands/task/TaskRunningJobs.java | 3 +- .../cli/commands/task/TaskScheduledJobs.java | 3 +- .../commands/task/TaskSyncopeOperations.java | 66 +++++++++ .../cli/commands/user/AbstractUserCommand.java | 27 ++++ .../client/cli/commands/user/UserCommand.java | 144 +++++++++++++++++++ .../client/cli/commands/user/UserCount.java | 43 ++++++ .../client/cli/commands/user/UserDelete.java | 55 +++++++ .../client/cli/commands/user/UserGetKey.java | 45 ++++++ .../cli/commands/user/UserGetUsername.java | 45 ++++++ .../client/cli/commands/user/UserList.java | 48 +++++++ .../client/cli/commands/user/UserRead.java | 60 ++++++++ .../cli/commands/user/UserResultManager.java | 110 ++++++++++++++ .../commands/user/UserSearchByAttribute.java | 69 +++++++++ .../cli/commands/user/UserSearchByResource.java | 68 +++++++++ .../cli/commands/user/UserSearchByRole.java | 62 ++++++++ .../commands/user/UserSyncopeOperations.java | 78 ++++++++++ 94 files changed, 1697 insertions(+), 136 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/Input.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/Input.java b/client/cli/src/main/java/org/apache/syncope/client/cli/Input.java index 9314187..63d7952 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/Input.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/Input.java @@ -18,6 +18,8 @@ */ package org.apache.syncope.client.cli; +import java.util.Arrays; +import java.util.List; import org.apache.syncope.client.cli.commands.AbstractCommand; import org.apache.syncope.client.cli.util.CommandUtils; @@ -63,6 +65,10 @@ public class Input { public String[] getParameters() { return parameters; } + + public List<String> listParameters() { + return Arrays.asList(parameters); + } public String firstParameter() { return parameters[0]; http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/CommonsResultManager.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/CommonsResultManager.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/CommonsResultManager.java index 251297b..39c32e6 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/CommonsResultManager.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/CommonsResultManager.java @@ -24,7 +24,7 @@ import org.apache.syncope.common.lib.types.ConnConfProperty; public abstract class CommonsResultManager { - public void managerNumberFormatException(final String what, final String key) { + public void numberFormatException(final String what, final String key) { Messages.printIdNotNumberDeletedMessage(what, key); } http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/AbstractConfigurationCommand.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/AbstractConfigurationCommand.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/AbstractConfigurationCommand.java index 2942c07..87f0b00 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/AbstractConfigurationCommand.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/AbstractConfigurationCommand.java @@ -18,12 +18,10 @@ */ package org.apache.syncope.client.cli.commands.configuration; -import org.apache.syncope.client.cli.SyncopeServices; -import org.apache.syncope.common.rest.api.service.ConfigurationService; - public abstract class AbstractConfigurationCommand { - protected final ConfigurationService configurationService = SyncopeServices.get(ConfigurationService.class); + protected final ConfigurationSyncopeOperations configurationSyncopeOperations + = new ConfigurationSyncopeOperations(); protected final ConfigurationResultManager configurationResultManager = new ConfigurationResultManager(); http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationDelete.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationDelete.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationDelete.java index f308aa9..870cb27 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationDelete.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationDelete.java @@ -36,7 +36,7 @@ public class ConfigurationDelete extends AbstractConfigurationCommand { if (input.parameterNumber() >= 1) { for (final String parameter : input.getParameters()) { try { - configurationService.delete(parameter); + configurationSyncopeOperations.delete(parameter); configurationResultManager.deletedMessage("Configuration", parameter); } catch (final SyncopeClientException | WebServiceException ex) { if (ex.getMessage().startsWith("NotFound")) { http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationExport.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationExport.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationExport.java index 2e61c4f..d08677a 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationExport.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationExport.java @@ -45,7 +45,7 @@ public class ConfigurationExport extends AbstractConfigurationCommand { if (input.parameterNumber() == 1) { try { XMLUtils.createXMLFile( - (SequenceInputStream) configurationService.export().getEntity(), + (SequenceInputStream) configurationSyncopeOperations.export().getEntity(), input.firstParameter() + EXPORT_FILE_NAME); configurationResultManager.generic( input.firstParameter() + EXPORT_FILE_NAME + " successfully created"); http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationGet.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationGet.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationGet.java index 2aa3ff4..3cad82d 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationGet.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationGet.java @@ -27,7 +27,7 @@ public class ConfigurationGet extends AbstractConfigurationCommand { public void get() { try { - configurationResultManager.fromGet(new LinkedList<>(configurationService.list())); + configurationResultManager.fromGet(new LinkedList<>(configurationSyncopeOperations.list())); } catch (final Exception ex) { configurationResultManager.generic(ex.getMessage()); } http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationRead.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationRead.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationRead.java index c4294e7..5bccb3f 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationRead.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationRead.java @@ -40,7 +40,7 @@ public class ConfigurationRead extends AbstractConfigurationCommand { boolean failed = false; for (final String parameter : input.getParameters()) { try { - attrList.add(configurationService.get(parameter)); + attrList.add(configurationSyncopeOperations.get(parameter)); } catch (final SyncopeClientException | WebServiceException ex) { if (ex.getMessage().startsWith("NotFound")) { configurationResultManager.notFoundError("Configuration", parameter); http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationSyncopeOperations.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationSyncopeOperations.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationSyncopeOperations.java new file mode 100644 index 0000000..8efc97c --- /dev/null +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationSyncopeOperations.java @@ -0,0 +1,50 @@ +/* + * 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.configuration; + +import java.util.List; +import javax.ws.rs.core.Response; +import org.apache.syncope.client.cli.SyncopeServices; +import org.apache.syncope.common.lib.to.AttrTO; +import org.apache.syncope.common.rest.api.service.ConfigurationService; + +public class ConfigurationSyncopeOperations { + + private final ConfigurationService configurationService = SyncopeServices.get(ConfigurationService.class); + + public AttrTO get(final String schema) { + return configurationService.get(schema); + } + + public void set(final AttrTO attrTO) { + configurationService.set(attrTO); + } + + public List<AttrTO> list() { + return configurationService.list(); + } + + public Response export() { + return configurationService.export(); + } + + public void delete(final String schema) { + configurationService.delete(schema); + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationUpdate.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationUpdate.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationUpdate.java index 295ebd1..2f85ffa 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationUpdate.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/configuration/ConfigurationUpdate.java @@ -44,10 +44,10 @@ public class ConfigurationUpdate extends AbstractConfigurationCommand { for (final String parameter : input.getParameters()) { try { pairParameter = input.toPairParameter(parameter); - attrTO = configurationService.get(pairParameter.getKey()); + attrTO = configurationSyncopeOperations.get(pairParameter.getKey()); attrTO.getValues().clear(); attrTO.getValues().add(pairParameter.getValue()); - configurationService.set(attrTO); + configurationSyncopeOperations.set(attrTO); attrList.add(attrTO); } catch (final IllegalArgumentException ex) { configurationResultManager.generic(ex.getMessage(), UPDATE_HELP_MESSAGE); http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/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 index 0605c46..6286ed4 100644 --- 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 @@ -18,12 +18,9 @@ */ 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 ConnectorSyncopeOperations connectorSyncopeOperations = new ConnectorSyncopeOperations(); protected final ConnectorResultManager connectorResultManager = new ConnectorResultManager(); http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/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 index ab4c82e..6e26b9b 100644 --- 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 @@ -40,10 +40,10 @@ public class ConnectorDelete extends AbstractConnectorCommand { final List<ConnInstanceTO> connInstanceTOs = new ArrayList<>(); for (final String parameter : input.getParameters()) { try { - connectorService.delete(Long.valueOf(parameter)); + connectorSyncopeOperations.delete(parameter); connectorResultManager.deletedMessage("connector", parameter); } catch (final NumberFormatException ex) { - connectorResultManager.managerNumberFormatException("connector", parameter); + connectorResultManager.numberFormatException("connector", parameter); } catch (final SyncopeClientException | WebServiceException ex) { if (ex.getMessage().startsWith("NotFound")) { connectorResultManager.notFoundError("Connector", parameter); http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/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 index 7b6a3c6..f063228 100644 --- 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 @@ -24,7 +24,7 @@ public class ConnectorList extends AbstractConnectorCommand { public void list() { try { - connectorResultManager.toView(connectorService.list(null)); + connectorResultManager.toView(connectorSyncopeOperations.list()); } catch (final SyncopeClientException ex) { connectorResultManager.generic(ex.getMessage()); } http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/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 index 72a103d..d77cd83 100644 --- 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 @@ -24,7 +24,7 @@ public class ConnectorListBundles extends AbstractConnectorCommand { public void list() { try { - connectorResultManager.fromListBundles(connectorService.getBundles(null)); + connectorResultManager.fromListBundles(connectorSyncopeOperations.getBundles()); } catch (final SyncopeClientException ex) { connectorResultManager.generic(ex.getMessage()); } http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/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 index 3e454d7..91a0021 100644 --- 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 @@ -38,9 +38,9 @@ public class ConnectorListConfigurationProperties extends AbstractConnectorComma for (final String parameter : input.getParameters()) { try { connectorResultManager.fromConfigurationProperties( - connectorService.read(Long.valueOf(parameter), null).getConf()); + connectorSyncopeOperations.read(parameter).getConf()); } catch (final NumberFormatException ex) { - connectorResultManager.managerNumberFormatException("connector", parameter); + connectorResultManager.numberFormatException("connector", parameter); } catch (final SyncopeClientException | WebServiceException ex) { if (ex.getMessage().startsWith("NotFound")) { connectorResultManager.notFoundError("Connector", parameter); http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/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 index 46cbe84..e2dca1e 100644 --- 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 @@ -40,9 +40,9 @@ public class ConnectorRead extends AbstractConnectorCommand { final List<ConnInstanceTO> connInstanceTOs = new ArrayList<>(); for (final String parameter : input.getParameters()) { try { - connInstanceTOs.add(connectorService.read(Long.valueOf(parameter), READ_HELP_MESSAGE)); + connInstanceTOs.add(connectorSyncopeOperations.read(parameter)); } catch (final NumberFormatException ex) { - connectorResultManager.managerNumberFormatException("connector", parameter); + connectorResultManager.numberFormatException("connector", parameter); } catch (final SyncopeClientException | WebServiceException ex) { if (ex.getMessage().startsWith("NotFound")) { connectorResultManager.notFoundError("Connector", parameter); http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/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 index bd7797c..d062077 100644 --- 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 @@ -41,7 +41,7 @@ public class ConnectorReadByResource extends AbstractConnectorCommand { final List<ConnInstanceTO> connInstanceTOs = new ArrayList<>(); for (final String parameter : input.getParameters()) { try { - connInstanceTOs.add(connectorService.readByResource(parameter, READ_HELP_MESSAGE)); + connInstanceTOs.add(connectorSyncopeOperations.readByResource(parameter)); } catch (final SyncopeClientException | WebServiceException ex) { if (ex.getMessage().startsWith("NotFound")) { connectorResultManager.notFoundError("Resource", parameter); http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorSyncopeOperations.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorSyncopeOperations.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorSyncopeOperations.java new file mode 100644 index 0000000..b496063 --- /dev/null +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorSyncopeOperations.java @@ -0,0 +1,50 @@ +/* + * 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.List; +import org.apache.syncope.client.cli.SyncopeServices; +import org.apache.syncope.common.lib.to.ConnBundleTO; +import org.apache.syncope.common.lib.to.ConnInstanceTO; +import org.apache.syncope.common.rest.api.service.ConnectorService; + +public class ConnectorSyncopeOperations { + + protected final ConnectorService connectorService = SyncopeServices.get(ConnectorService.class); + + public ConnInstanceTO readByResource(final String resourceName) { + return connectorService.readByResource(resourceName, null); + } + + public ConnInstanceTO read(final String resourceId) { + return connectorService.read(Long.valueOf(resourceId), null); + } + + public List<ConnBundleTO> getBundles() { + return connectorService.getBundles(null); + } + + public List<ConnInstanceTO> list() { + return connectorService.list(null); + } + + public void delete(final String resourceId) { + connectorService.delete(Long.valueOf(resourceId)); + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/AbstractDomainCommand.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/AbstractDomainCommand.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/AbstractDomainCommand.java index b5bfca5..902f55c 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/AbstractDomainCommand.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/AbstractDomainCommand.java @@ -18,12 +18,9 @@ */ package org.apache.syncope.client.cli.commands.domain; -import org.apache.syncope.client.cli.SyncopeServices; -import org.apache.syncope.common.rest.api.service.DomainService; - public abstract class AbstractDomainCommand { - protected final DomainService domainService = SyncopeServices.get(DomainService.class); + protected final DomainSyncopeOperations domainSyncopeOperations = new DomainSyncopeOperations(); protected final DomainResultManager domainResultManager = new DomainResultManager(); http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainDelete.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainDelete.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainDelete.java index 1b0c235..f85d3c9 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainDelete.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainDelete.java @@ -35,7 +35,7 @@ public class DomainDelete extends AbstractDomainCommand { if (input.parameterNumber() >= 1) { for (final String parameter : input.getParameters()) { try { - domainService.delete(parameter); + domainSyncopeOperations.delete(parameter); domainResultManager.deletedMessage("Domain", parameter); } catch (final SyncopeClientException ex) { if (ex.getMessage().startsWith("NotFound")) { http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainList.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainList.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainList.java index 94329d2..6cf7b7d 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainList.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainList.java @@ -28,7 +28,7 @@ public class DomainList extends AbstractDomainCommand { public void list() { try { - for (final DomainTO domainTO : domainService.list()) { + for (final DomainTO domainTO : domainSyncopeOperations.list()) { domainResultManager.generic(domainTO.getKey()); } } catch (final SyncopeClientException ex) { http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainRead.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainRead.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainRead.java index a76711d..2eaa75a 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainRead.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainRead.java @@ -20,7 +20,6 @@ package org.apache.syncope.client.cli.commands.domain; import org.apache.syncope.client.cli.Input; import org.apache.syncope.common.lib.SyncopeClientException; -import org.apache.syncope.common.lib.to.DomainTO; public class DomainRead extends AbstractDomainCommand { @@ -36,8 +35,7 @@ public class DomainRead extends AbstractDomainCommand { if (input.parameterNumber() >= 1) { for (final String parameter : input.getParameters()) { try { - final DomainTO domainTO = domainService.read(parameter); - domainResultManager.generic(domainTO.getKey()); + domainResultManager.generic(domainSyncopeOperations.read(parameter).getKey()); } catch (final SyncopeClientException ex) { if (ex.getMessage().startsWith("NotFound")) { domainResultManager.notFoundError("Domain", parameter); http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainSyncopeOperations.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainSyncopeOperations.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainSyncopeOperations.java new file mode 100644 index 0000000..994c217 --- /dev/null +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/domain/DomainSyncopeOperations.java @@ -0,0 +1,41 @@ +/* + * 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.domain; + +import java.util.List; +import org.apache.syncope.client.cli.SyncopeServices; +import org.apache.syncope.common.lib.to.DomainTO; +import org.apache.syncope.common.rest.api.service.DomainService; + +public class DomainSyncopeOperations { + + private final DomainService domainService = SyncopeServices.get(DomainService.class); + + public DomainTO read(final String domainName) { + return domainService.read(domainName); + } + + public List<DomainTO> list() { + return domainService.list(); + } + + public void delete(final String domainName) { + domainService.delete(domainName); + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/install/InstallSetup.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/install/InstallSetup.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/install/InstallSetup.java index 10995b0..4d9a0ff 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/install/InstallSetup.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/install/InstallSetup.java @@ -48,8 +48,6 @@ public class InstallSetup { } public void setup() { - final Scanner scanIn = new Scanner(System.in); - System.out.println(""); System.out.println("###############################################"); System.out.println("# #"); @@ -67,6 +65,7 @@ public class InstallSetup { System.out.println("- File system permission checked"); System.out.println(""); + final Scanner scanIn = new Scanner(System.in); System.out.println("Syncope server schema [http/https]:"); String syncopeServerSchemaFromSystemIn = scanIn.nextLine(); boolean schemaFounded = false; http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/AbstractLoggerCommand.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/AbstractLoggerCommand.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/AbstractLoggerCommand.java index a8703a9..3e0978a 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/AbstractLoggerCommand.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/AbstractLoggerCommand.java @@ -18,13 +18,10 @@ */ package org.apache.syncope.client.cli.commands.logger; -import org.apache.syncope.client.cli.SyncopeServices; -import org.apache.syncope.common.rest.api.service.LoggerService; - public abstract class AbstractLoggerCommand { - protected final LoggerService loggerService = SyncopeServices.get(LoggerService.class); - + protected final LoggerSyncopeOperations loggerSyncopeOperations = new LoggerSyncopeOperations(); + protected final LoggerResultManager loggerResultManager = new LoggerResultManager(); } http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerCreate.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerCreate.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerCreate.java index 6a51e95..40b5e1b 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerCreate.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerCreate.java @@ -25,7 +25,6 @@ import org.apache.syncope.client.cli.util.CommandUtils; import org.apache.syncope.common.lib.SyncopeClientException; import org.apache.syncope.common.lib.to.LoggerTO; import org.apache.syncope.common.lib.types.LoggerLevel; -import org.apache.syncope.common.lib.types.LoggerType; public class LoggerCreate extends AbstractLoggerCommand { @@ -50,7 +49,7 @@ public class LoggerCreate extends AbstractLoggerCommand { pairParameter = input.toPairParameter(parameter); loggerTO.setKey(pairParameter.getKey()); loggerTO.setLevel(LoggerLevel.valueOf(pairParameter.getValue())); - loggerService.update(LoggerType.LOG, loggerTO); + loggerSyncopeOperations.update(loggerTO); loggerTOs.add(loggerTO); } catch (final WebServiceException | SyncopeClientException | IllegalArgumentException ex) { loggerResultManager.typeNotValidError( http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerDelete.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerDelete.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerDelete.java index 5815b71..8bdb3ab 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerDelete.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerDelete.java @@ -21,7 +21,6 @@ package org.apache.syncope.client.cli.commands.logger; 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.types.LoggerType; public class LoggerDelete extends AbstractLoggerCommand { @@ -37,7 +36,7 @@ public class LoggerDelete extends AbstractLoggerCommand { if (input.parameterNumber() >= 1) { for (final String parameter : input.getParameters()) { try { - loggerService.delete(LoggerType.LOG, parameter); + loggerSyncopeOperations.delete(parameter); loggerResultManager.deletedMessage("Logger", parameter); } catch (final WebServiceException | SyncopeClientException ex) { if (ex.getMessage().startsWith("NotFound")) { http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerList.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerList.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerList.java index d9d4f81..b64eef6 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerList.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerList.java @@ -20,7 +20,6 @@ package org.apache.syncope.client.cli.commands.logger; import java.util.LinkedList; import org.apache.syncope.common.lib.SyncopeClientException; -import org.apache.syncope.common.lib.types.LoggerType; public class LoggerList extends AbstractLoggerCommand { @@ -29,7 +28,7 @@ public class LoggerList extends AbstractLoggerCommand { public void list() { try { - loggerResultManager.fromList(new LinkedList<>(loggerService.list(LoggerType.LOG))); + loggerResultManager.fromList(new LinkedList<>(loggerSyncopeOperations.list())); } catch (final SyncopeClientException ex) { loggerResultManager.generic("Error: " + ex.getMessage()); } http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerRead.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerRead.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerRead.java index 6e2447d..1192252 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerRead.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerRead.java @@ -23,7 +23,6 @@ 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.LoggerTO; -import org.apache.syncope.common.lib.types.LoggerType; public class LoggerRead extends AbstractLoggerCommand { @@ -41,7 +40,7 @@ public class LoggerRead extends AbstractLoggerCommand { boolean failed = false; for (final String parameter : input.getParameters()) { try { - loggerTOs.add(loggerService.read(LoggerType.LOG, parameter)); + loggerTOs.add(loggerSyncopeOperations.read(parameter)); } catch (final SyncopeClientException | WebServiceException ex) { if (ex.getMessage().startsWith("NotFound")) { loggerResultManager.notFoundError("Logger", parameter); http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerSyncopeOperations.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerSyncopeOperations.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerSyncopeOperations.java new file mode 100644 index 0000000..14b7d18 --- /dev/null +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerSyncopeOperations.java @@ -0,0 +1,46 @@ +/* + * 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.logger; + +import java.util.List; +import org.apache.syncope.client.cli.SyncopeServices; +import org.apache.syncope.common.lib.to.LoggerTO; +import org.apache.syncope.common.lib.types.LoggerType; +import org.apache.syncope.common.rest.api.service.LoggerService; + +public class LoggerSyncopeOperations { + + private final LoggerService loggerService = SyncopeServices.get(LoggerService.class); + + public List<LoggerTO> list() { + return loggerService.list(LoggerType.LOG); + } + + public void update(final LoggerTO loggerTO) { + loggerService.update(LoggerType.LOG, loggerTO); + } + + public LoggerTO read(final String loggerName) { + return loggerService.read(LoggerType.LOG, loggerName); + } + + public void delete(final String loggerName) { + loggerService.delete(LoggerType.LOG, loggerName); + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerUpdate.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerUpdate.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerUpdate.java index 03de917..9a45916 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerUpdate.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerUpdate.java @@ -25,7 +25,6 @@ import org.apache.syncope.client.cli.util.CommandUtils; import org.apache.syncope.common.lib.SyncopeClientException; import org.apache.syncope.common.lib.to.LoggerTO; import org.apache.syncope.common.lib.types.LoggerLevel; -import org.apache.syncope.common.lib.types.LoggerType; public class LoggerUpdate extends AbstractLoggerCommand { @@ -47,9 +46,9 @@ public class LoggerUpdate extends AbstractLoggerCommand { for (final String parameter : input.getParameters()) { try { pairParameter = input.toPairParameter(parameter); - loggerTO = loggerService.read(LoggerType.LOG, pairParameter.getKey()); + loggerTO = loggerSyncopeOperations.read(pairParameter.getKey()); loggerTO.setLevel(LoggerLevel.valueOf(pairParameter.getValue())); - loggerService.update(LoggerType.LOG, loggerTO); + loggerSyncopeOperations.update(loggerTO); loggerTOs.add(loggerTO); } catch (final WebServiceException | SyncopeClientException | IllegalArgumentException ex) { if (ex.getMessage().startsWith("No enum constant org.apache.syncope.common.lib.types.")) { http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerUpdateAll.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerUpdateAll.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerUpdateAll.java index 55c2e60..83c8b9a 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerUpdateAll.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/logger/LoggerUpdateAll.java @@ -25,7 +25,6 @@ import org.apache.syncope.client.cli.util.CommandUtils; import org.apache.syncope.common.lib.SyncopeClientException; import org.apache.syncope.common.lib.to.LoggerTO; import org.apache.syncope.common.lib.types.LoggerLevel; -import org.apache.syncope.common.lib.types.LoggerType; public class LoggerUpdateAll extends AbstractLoggerCommand { @@ -41,10 +40,10 @@ public class LoggerUpdateAll extends AbstractLoggerCommand { if (input.parameterNumber() == 1) { final LinkedList<LoggerTO> loggerTOs = new LinkedList<>(); boolean failed = false; - for (final LoggerTO loggerTO : loggerService.list(LoggerType.LOG)) { + for (final LoggerTO loggerTO : loggerSyncopeOperations.list()) { try { loggerTO.setLevel(LoggerLevel.valueOf(input.firstParameter())); - loggerService.update(LoggerType.LOG, loggerTO); + loggerSyncopeOperations.update(loggerTO); loggerTOs.add(loggerTO); } catch (final WebServiceException | SyncopeClientException | IllegalArgumentException ex) { if (ex.getMessage().startsWith("No enum constant org.apache.syncope.common.lib.types.")) { http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/AbstractNotificationCommand.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/AbstractNotificationCommand.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/AbstractNotificationCommand.java index 2b862ed..a21f2cd 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/AbstractNotificationCommand.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/AbstractNotificationCommand.java @@ -18,12 +18,9 @@ */ package org.apache.syncope.client.cli.commands.notification; -import org.apache.syncope.client.cli.SyncopeServices; -import org.apache.syncope.common.rest.api.service.NotificationService; - public abstract class AbstractNotificationCommand { - protected final NotificationService notificationService = SyncopeServices.get(NotificationService.class); + protected final NotificationSyncopeOperations notificationSyncopeOperations = new NotificationSyncopeOperations(); protected final NotificationResultManager notificationResultManager = new NotificationResultManager(); http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationDelete.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationDelete.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationDelete.java index 2e0e5cd..3b11a5a 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationDelete.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationDelete.java @@ -37,7 +37,7 @@ public class NotificationDelete extends AbstractNotificationCommand { if (input.parameterNumber() >= 1) { for (final String parameter : input.getParameters()) { try { - notificationService.delete(Long.valueOf(parameter)); + notificationSyncopeOperations.delete(parameter); notificationResultManager.deletedMessage("Notification", parameter); } catch (final WebServiceException | SyncopeClientException ex) { if (ex.getMessage().startsWith("NotFound")) { http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationList.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationList.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationList.java index ff9561c..3df5d64 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationList.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationList.java @@ -25,7 +25,7 @@ public class NotificationList extends AbstractNotificationCommand { public void list() { try { - for (final NotificationTO notificationTO : notificationService.list()) { + for (final NotificationTO notificationTO : notificationSyncopeOperations.list()) { System.out.println(notificationTO); } } catch (final SyncopeClientException ex) { http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationRead.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationRead.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationRead.java index 386700c..bd82663 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationRead.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationRead.java @@ -36,7 +36,7 @@ public class NotificationRead extends AbstractNotificationCommand { if (input.parameterNumber() >= 1) { for (final String parameter : input.getParameters()) { try { - System.out.println(notificationService.read(Long.valueOf(parameter))); + System.out.println(notificationSyncopeOperations.read(parameter)); } catch (final NumberFormatException ex) { notificationResultManager.notBooleanDeletedError("notification", parameter); } catch (final WebServiceException | SyncopeClientException ex) { http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationSyncopeOperations.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationSyncopeOperations.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationSyncopeOperations.java new file mode 100644 index 0000000..cb11cb5 --- /dev/null +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/notification/NotificationSyncopeOperations.java @@ -0,0 +1,41 @@ +/* + * 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.notification; + +import java.util.List; +import org.apache.syncope.client.cli.SyncopeServices; +import org.apache.syncope.common.lib.to.NotificationTO; +import org.apache.syncope.common.rest.api.service.NotificationService; + +public class NotificationSyncopeOperations { + + private final NotificationService notificationService = SyncopeServices.get(NotificationService.class); + + public NotificationTO read(final String notificationId) { + return notificationService.read(Long.valueOf(notificationId)); + } + + public List<NotificationTO> list() { + return notificationService.list(); + } + + public void delete(final String notificationId) { + notificationService.delete(Long.valueOf(notificationId)); + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/AbstractPolicyCommand.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/AbstractPolicyCommand.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/AbstractPolicyCommand.java index 0bab4e5..0c8a55f 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/AbstractPolicyCommand.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/AbstractPolicyCommand.java @@ -18,13 +18,10 @@ */ package org.apache.syncope.client.cli.commands.policy; -import org.apache.syncope.client.cli.SyncopeServices; -import org.apache.syncope.common.rest.api.service.PolicyService; - public abstract class AbstractPolicyCommand { - protected final PolicyService policyService = SyncopeServices.get(PolicyService.class); - + protected final PolicySyncopeOperations policySyncopeOperations = new PolicySyncopeOperations(); + protected final PolicyResultManager policyResultManager = new PolicyResultManager(); } http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyDelete.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyDelete.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyDelete.java index 15ffa8d..8f9ede3 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyDelete.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyDelete.java @@ -36,7 +36,7 @@ public class PolicyDelete extends AbstractPolicyCommand { if (input.parameterNumber() >= 1) { for (final String parameter : input.getParameters()) { try { - policyService.delete(Long.valueOf(parameter)); + policySyncopeOperations.delete(parameter); policyResultManager.deletedMessage("Policy", parameter); } catch (final WebServiceException | SyncopeClientException ex) { System.out.println("Error:"); http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyList.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyList.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyList.java index c05acf7..4b672d6 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyList.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyList.java @@ -42,7 +42,7 @@ public class PolicyList extends AbstractPolicyCommand { try { final PolicyType policyType = PolicyType.valueOf(input.firstParameter()); final LinkedList<AbstractPolicyTO> policyTOs = new LinkedList<>(); - for (final AbstractPolicyTO policyTO : policyService.list(policyType)) { + for (final AbstractPolicyTO policyTO : policySyncopeOperations.list(policyType)) { policyTOs.add(policyTO); } policyResultManager.fromList(policyType, policyTOs); http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyRead.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyRead.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyRead.java index f20d41e..25c9306 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyRead.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyRead.java @@ -39,7 +39,7 @@ public class PolicyRead extends AbstractPolicyCommand { final LinkedList<AbstractPolicyTO> policyTOs = new LinkedList<>(); for (final String parameter : input.getParameters()) { try { - policyTOs.add(policyService.read(Long.valueOf(parameter))); + policyTOs.add(policySyncopeOperations.read(parameter)); policyResultManager.fromRead(policyTOs); } catch (final NumberFormatException ex) { policyResultManager.notBooleanDeletedError("policy", parameter); http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicySyncopeOperations.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicySyncopeOperations.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicySyncopeOperations.java new file mode 100644 index 0000000..7c478f8 --- /dev/null +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicySyncopeOperations.java @@ -0,0 +1,42 @@ +/* + * 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.policy; + +import java.util.List; +import org.apache.syncope.client.cli.SyncopeServices; +import org.apache.syncope.common.lib.policy.AbstractPolicyTO; +import org.apache.syncope.common.lib.types.PolicyType; +import org.apache.syncope.common.rest.api.service.PolicyService; + +public class PolicySyncopeOperations { + + private final PolicyService policyService = SyncopeServices.get(PolicyService.class); + + public <T extends AbstractPolicyTO> T read(final String policyId) { + return policyService.read(Long.valueOf(policyId)); + } + + public <T extends AbstractPolicyTO> List<T> list(final PolicyType policyType) { + return policyService.list(policyType); + } + + public void delete(final String policyId) { + policyService.delete(Long.valueOf(policyId)); + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/AbstractRealmCommand.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/AbstractRealmCommand.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/AbstractRealmCommand.java new file mode 100644 index 0000000..06cd1ba --- /dev/null +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/AbstractRealmCommand.java @@ -0,0 +1,27 @@ +/* + * 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.realm; + +public abstract class AbstractRealmCommand { + + protected final RealmSyncopeOperations realmSyncopeOperations = new RealmSyncopeOperations(); + + protected final RealmResultManager realmResultManager = new RealmResultManager(); + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/RealmCommand.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/RealmCommand.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/RealmCommand.java new file mode 100644 index 0000000..6a32562 --- /dev/null +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/RealmCommand.java @@ -0,0 +1,96 @@ +/* + * 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.realm; + +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 = "realm") +public class RealmCommand extends AbstractCommand { + + private static final String HELP_MESSAGE = "Usage: realm [options]\n" + + " Options:\n" + + " --help \n" + + " --list \n"; + + @Override + public void execute(final Input input) { + if (StringUtils.isBlank(input.getOption())) { + input.setOption(Options.HELP.getOptionName()); + } + switch (Options.fromName(input.getOption())) { + case LIST: + new RealmList().list(); + break; + case HELP: + System.out.println(HELP_MESSAGE); + break; + default: + new RealmResultManager().deletedMessage(input.getOption(), HELP_MESSAGE); + } + } + + @Override + public String getHelpMessage() { + return HELP_MESSAGE; + } + + private enum Options { + + HELP("--help"), + LIST("--list"); + + private final String optionName; + + Options(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 Options fromName(final String name) { + Options optionToReturn = HELP; + for (final Options option : Options.values()) { + if (option.equalsOptionName(name)) { + optionToReturn = option; + } + } + return optionToReturn; + } + + public static List<String> toList() { + final List<String> options = new ArrayList<>(); + for (final Options value : values()) { + options.add(value.getOptionName()); + } + return options; + } + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/RealmList.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/RealmList.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/RealmList.java new file mode 100644 index 0000000..5d4b902 --- /dev/null +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/RealmList.java @@ -0,0 +1,36 @@ +/* + * 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.realm; + +import org.apache.syncope.common.lib.SyncopeClientException; + +public class RealmList extends AbstractRealmCommand { + + public RealmList() { + } + + public void list() { + try { + realmResultManager.toView(realmSyncopeOperations.list()); + } catch (final SyncopeClientException ex) { + realmResultManager.generic("Error: " + ex.getMessage()); + } + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/RealmResultManager.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/RealmResultManager.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/RealmResultManager.java new file mode 100644 index 0000000..bbb46d9 --- /dev/null +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/RealmResultManager.java @@ -0,0 +1,39 @@ +/* + * 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.realm; + +import java.util.List; +import org.apache.syncope.client.cli.commands.CommonsResultManager; +import org.apache.syncope.common.lib.to.RealmTO; + +public class RealmResultManager extends CommonsResultManager { + + public void toView(final List<RealmTO> realmTOs) { + for (final RealmTO realmTO : realmTOs) { + System.out.println(" > REALM ID: " + realmTO.getKey()); + System.out.println(" name: " + realmTO.getName()); + System.out.println(" full path: " + realmTO.getFullPath()); + System.out.println(" actions: " + realmTO.getActionsClassNames()); + System.out.println(" templates: " + realmTO.getTemplates()); + System.out.println(" parent id: " + realmTO.getParent()); + System.out.println(" account policy id: " + realmTO.getAccountPolicy()); + System.out.println(" password policy id: " + realmTO.getPasswordPolicy()); + } + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/RealmSyncopeOperations.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/RealmSyncopeOperations.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/RealmSyncopeOperations.java new file mode 100644 index 0000000..e9d0b65 --- /dev/null +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/realm/RealmSyncopeOperations.java @@ -0,0 +1,44 @@ +/* + * 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.realm; + +import java.util.List; +import org.apache.syncope.client.cli.SyncopeServices; +import org.apache.syncope.common.lib.to.RealmTO; +import org.apache.syncope.common.rest.api.service.RealmService; + +public class RealmSyncopeOperations { + + private final RealmService realmService = SyncopeServices.get(RealmService.class); + + public List<RealmTO> list() { + return realmService.list(); + } + + public boolean exists(final String realm) { + boolean exists = false; + for (final RealmTO list : list()) { + if (list.getName().equals(realm)) { + exists = true; + } + } + return exists; + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/AbstractReportCommand.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/AbstractReportCommand.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/AbstractReportCommand.java index e4c2394..38a7b2f 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/AbstractReportCommand.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/AbstractReportCommand.java @@ -18,12 +18,9 @@ */ package org.apache.syncope.client.cli.commands.report; -import org.apache.syncope.client.cli.SyncopeServices; -import org.apache.syncope.common.rest.api.service.ReportService; - public abstract class AbstractReportCommand { - protected final ReportService reportService = SyncopeServices.get(ReportService.class); + protected final ReportSyncopeOperations reportSyncopeOperations = new ReportSyncopeOperations(); protected final ReportResultManager reportResultManager = new ReportResultManager(); http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportDelete.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportDelete.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportDelete.java index 012d04f..aa2c5f8 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportDelete.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportDelete.java @@ -36,7 +36,7 @@ public class ReportDelete extends AbstractReportCommand { if (input.parameterNumber() >= 1) { for (final String parameter : input.getParameters()) { try { - reportService.delete(Long.valueOf(parameter)); + reportSyncopeOperations.delete(parameter); reportResultManager.deletedMessage("Report", parameter); } catch (final WebServiceException | SyncopeClientException ex) { if (ex.getMessage().startsWith("NotFound")) { @@ -47,7 +47,7 @@ public class ReportDelete extends AbstractReportCommand { reportResultManager.generic(ex.getMessage()); } } catch (final NumberFormatException ex) { - reportResultManager.managerNumberFormatException("report", parameter); + reportResultManager.numberFormatException("report", parameter); } } } else { http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportDeleteExecution.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportDeleteExecution.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportDeleteExecution.java index 4ab53fa..86f31a2 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportDeleteExecution.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportDeleteExecution.java @@ -39,7 +39,7 @@ public class ReportDeleteExecution extends AbstractReportCommand { for (final String parameter : input.getParameters()) { try { - reportService.deleteExecution(Long.valueOf(parameter)); + reportSyncopeOperations.deleteExecution(parameter); reportResultManager.deletedMessage("Report execution", parameter); } catch (final WebServiceException | SyncopeClientException ex) { if (ex.getMessage().startsWith("NotFound")) { @@ -50,7 +50,7 @@ public class ReportDeleteExecution extends AbstractReportCommand { reportResultManager.generic(ex.getMessage()); } } catch (final NumberFormatException ex) { - reportResultManager.managerNumberFormatException("report", parameter); + reportResultManager.numberFormatException("report", parameter); } } } else { http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportExecute.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportExecute.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportExecute.java index 311544d..0641203 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportExecute.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportExecute.java @@ -39,10 +39,9 @@ public class ReportExecute extends AbstractReportCommand { if (input.parameterNumber() == 1) { try { - final Long reportIdToExecute = Long.valueOf(input.firstParameter()); - reportService.execute(reportIdToExecute); + reportSyncopeOperations.execute(input.firstParameter()); final List<ReportExecTO> executionList - = reportService.read(reportIdToExecute).getExecutions(); + = reportSyncopeOperations.read(input.firstParameter()).getExecutions(); final ReportExecTO lastExecution = executionList.get(executionList.size() - 1); reportResultManager.printReportExecution(Arrays.asList(lastExecution)); } catch (final WebServiceException | SyncopeClientException ex) { @@ -54,7 +53,7 @@ public class ReportExecute extends AbstractReportCommand { reportResultManager.generic(ex.getMessage()); } } catch (final NumberFormatException ex) { - reportResultManager.managerNumberFormatException("report", input.firstParameter()); + reportResultManager.numberFormatException("report", input.firstParameter()); } } else { reportResultManager.commandOptionError(EXECUTE_HELP_MESSAGE); http://git-wip-us.apache.org/repos/asf/syncope/blob/47b9f64b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportExportExecution.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportExportExecution.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportExportExecution.java index c55d339..ae79e57 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportExportExecution.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportExportExecution.java @@ -49,12 +49,11 @@ public class ReportExportExecution extends AbstractReportCommand { for (final String parameter : parameters) { try { final ReportExecExportFormat format = ReportExecExportFormat.valueOf(input.lastParameter()); - final Long exportId = Long.valueOf(parameter); - final SequenceInputStream report = (SequenceInputStream) reportService. - exportExecutionResult(exportId, format).getEntity(); + final SequenceInputStream report = (SequenceInputStream) reportSyncopeOperations. + exportExecutionResult(parameter, format).getEntity(); switch (format) { case XML: - final String xmlFinalName = "export_" + exportId + ".xml"; + final String xmlFinalName = "export_" + parameter + ".xml"; XMLUtils.createXMLFile(report, xmlFinalName); reportResultManager.generic(xmlFinalName + " successfully created"); break; @@ -75,14 +74,13 @@ public class ReportExportExecution extends AbstractReportCommand { break; } } catch (final WebServiceException | SyncopeClientException ex) { - ex.printStackTrace(); if (ex.getMessage().startsWith("NotFound")) { reportResultManager.notFoundError("Report", parameter); } else { reportResultManager.generic(ex.getMessage()); } } catch (final NumberFormatException ex) { - reportResultManager.managerNumberFormatException("report", parameter); + reportResultManager.numberFormatException("report", parameter); } catch (IOException | ParserConfigurationException | SAXException | TransformerException e) { reportResultManager.generic(" - Error creating " + "export_" + parameter + " " + e.getMessage()); } catch (final IllegalArgumentException ex) {
