Repository: syncope Updated Branches: refs/heads/master 87140e648 -> 704682321
Fixed #SYNCOPE-583 Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/70468232 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/70468232 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/70468232 Branch: refs/heads/master Commit: 704682321e39ac000bd918566ad4e5d60517158d Parents: 87140e6 Author: massi <[email protected]> Authored: Mon Jan 26 17:28:59 2015 +0100 Committer: massi <[email protected]> Committed: Mon Jan 26 17:28:59 2015 +0100 ---------------------------------------------------------------------- .../java/org/apache/syncope/cli/SyncopeAdm.java | 11 ++- .../cli/commands/EntitlementCommand.java | 73 ++++++++++++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/70468232/cli/src/main/java/org/apache/syncope/cli/SyncopeAdm.java ---------------------------------------------------------------------- diff --git a/cli/src/main/java/org/apache/syncope/cli/SyncopeAdm.java b/cli/src/main/java/org/apache/syncope/cli/SyncopeAdm.java index da87d46..bcfa748 100644 --- a/cli/src/main/java/org/apache/syncope/cli/SyncopeAdm.java +++ b/cli/src/main/java/org/apache/syncope/cli/SyncopeAdm.java @@ -21,6 +21,7 @@ package org.apache.syncope.cli; import com.beust.jcommander.JCommander; import com.beust.jcommander.ParameterException; import org.apache.syncope.cli.commands.ConfigurationCommand; +import org.apache.syncope.cli.commands.EntitlementCommand; import org.apache.syncope.cli.commands.LoggerCommand; import org.apache.syncope.cli.commands.NotificationCommand; import org.apache.syncope.cli.commands.PolicyCommand; @@ -38,7 +39,8 @@ public class SyncopeAdm { + " config --help \n" + " notification --help \n" + " report --help \n" - + " policy --help \n"; + + " policy --help \n" + + " entitlement --help \n"; private static final JCommander jcommander = new JCommander(); @@ -51,6 +53,8 @@ public class SyncopeAdm { private static ReportCommand reportCommand; private static PolicyCommand policyCommand; + + private static EntitlementCommand entitlementCommand; public static void main(final String[] args) { LOG.debug("Starting with args \n"); @@ -92,6 +96,9 @@ public class SyncopeAdm { policyCommand = new PolicyCommand(); jcommander.addCommand(policyCommand); LOG.debug("Added PolicyCommand"); + entitlementCommand = new EntitlementCommand(); + jcommander.addCommand(entitlementCommand); + LOG.debug("Added EntitlementCommand"); } private static void executeCommand() { @@ -109,6 +116,8 @@ public class SyncopeAdm { reportCommand.execute(); } else if ("policy".equalsIgnoreCase(command)) { policyCommand.execute(); + } else if ("entitlement".equalsIgnoreCase(command)) { + entitlementCommand.execute(); } } } http://git-wip-us.apache.org/repos/asf/syncope/blob/70468232/cli/src/main/java/org/apache/syncope/cli/commands/EntitlementCommand.java ---------------------------------------------------------------------- diff --git a/cli/src/main/java/org/apache/syncope/cli/commands/EntitlementCommand.java b/cli/src/main/java/org/apache/syncope/cli/commands/EntitlementCommand.java new file mode 100644 index 0000000..c63dbcb --- /dev/null +++ b/cli/src/main/java/org/apache/syncope/cli/commands/EntitlementCommand.java @@ -0,0 +1,73 @@ +/* + * 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.cli.commands; + +import com.beust.jcommander.Parameter; +import com.beust.jcommander.Parameters; +import org.apache.syncope.cli.SyncopeServices; +import org.apache.syncope.common.services.EntitlementService; +import org.apache.syncope.common.wrap.EntitlementTO; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Parameters( + commandNames = "entitlement", + optionPrefixes = "-", + separators = "=", + commandDescription = "Apache Syncope entitlement service") +public class EntitlementCommand extends AbstractCommand { + + private static final Logger LOG = LoggerFactory.getLogger(EntitlementCommand.class); + + private static final Class SYNCOPE_ENTITLEMENT_CLASS = EntitlementService.class; + + private final String helpMessage = "Usage: entitlement [options]\n" + + " Options:\n" + + " -h, --help \n" + + " -l, --list \n" + + " -lo, --list-own \n"; + + @Parameter(names = {"-lo", "--list-own"}) + public boolean listOwn = false; + + @Override + public void execute() { + final EntitlementService entitlementService = (EntitlementService) SyncopeServices. + get(SYNCOPE_ENTITLEMENT_CLASS); + LOG.debug("Entitlement service successfully created"); + + if (help) { + LOG.debug("- entitlement help command"); + System.out.println(helpMessage); + } else if (list) { + System.out.println("All entitlement:"); + for (final EntitlementTO entitlementTO : entitlementService.getAllEntitlements()) { + System.out.println(" *** " + entitlementTO.getElement()); + } + } else if (listOwn) { + System.out.println("All own entitlement:"); + for (final EntitlementTO entitlementTO : entitlementService.getOwnEntitlements()) { + System.out.println(" *** " + entitlementTO.getElement()); + } + } else { + System.out.println(helpMessage); + } + } + +}
