You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by ma...@apache.org on 2015/11/02 17:33:33 UTC
syncope git commit: added aby object command, SYNCOPE-158
Repository: syncope
Updated Branches:
refs/heads/master 26a4cd26c -> 2d036afe2
added aby object command, SYNCOPE-158
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/2d036afe
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/2d036afe
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/2d036afe
Branch: refs/heads/master
Commit: 2d036afe28f7024c76e0ed76d86c9b0805541b78
Parents: 26a4cd2
Author: massi <ma...@tirasa.net>
Authored: Mon Nov 2 17:32:13 2015 +0100
Committer: massi <ma...@tirasa.net>
Committed: Mon Nov 2 17:32:13 2015 +0100
----------------------------------------------------------------------
.../cli/commands/any/AbstractAnyCommand.java | 27 ++++
.../client/cli/commands/any/AnyCommand.java | 123 +++++++++++++++++++
.../client/cli/commands/any/AnyDelete.java | 59 +++++++++
.../client/cli/commands/any/AnyList.java | 50 ++++++++
.../client/cli/commands/any/AnyRead.java | 58 +++++++++
...yReadAttributeBySchemaTypeAndSchemaName.java | 61 +++++++++
.../any/AnyReadAttributesBySchemaType.java | 64 ++++++++++
.../cli/commands/any/AnyResultManager.java | 80 ++++++++++++
.../cli/commands/any/AnySyncopeOperations.java | 53 ++++++++
.../cli/commands/group/GroupResultManager.java | 2 +-
10 files changed, 576 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/2d036afe/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AbstractAnyCommand.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AbstractAnyCommand.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AbstractAnyCommand.java
new file mode 100644
index 0000000..dc62ba9
--- /dev/null
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AbstractAnyCommand.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.any;
+
+public abstract class AbstractAnyCommand {
+
+ protected final AnySyncopeOperations anySyncopeOperations = new AnySyncopeOperations();
+
+ protected final AnyResultManager anyResultManager = new AnyResultManager();
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/2d036afe/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyCommand.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyCommand.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyCommand.java
new file mode 100644
index 0000000..a8bed99
--- /dev/null
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyCommand.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.any;
+
+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 = "any")
+public class AnyCommand extends AbstractCommand {
+
+ private static final String HELP_MESSAGE = "\nUsage: any [options]\n"
+ + " Options:\n"
+ + " --help \n"
+ + " --details \n"
+ + " --list \n"
+ + " --read \n"
+ + " Syntax: --read {ANY-ID} {ANY-ID} [...]\n"
+ + " --read-attr-by-schema-type {ANY-ID} {SCHEMA-TYPE}\n"
+ + " Schema type: PLAIN / DERIVED / VIRTUAL\n"
+ + " --read-attr-by-schema {ANY-ID} {SCHEMA-TYPE} {SCHEMA-NAME}\n"
+ + " Schema type: PLAIN / DERIVED / VIRTUAL\n"
+ + " --delete \n"
+ + " Syntax: --delete {ANY-ID} {ANY-ID} [...]\n";
+
+ @Override
+ public void execute(final Input input) {
+ if (StringUtils.isBlank(input.getOption())) {
+ input.setOption(AnyOptions.HELP.getOptionName());
+ }
+ switch (AnyOptions.fromName(input.getOption())) {
+ case DETAILS:
+ break;
+ case LIST:
+ new AnyList(input).list();
+ break;
+ case READ:
+ new AnyRead(input).read();
+ break;
+ case READ_ATTRIBUTES_BY_SCHEMA:
+ new AnyReadAttributeBySchemaTypeAndSchemaName(input).read();
+ break;
+ case READ_ATTRIBUTES_BY_SCHEMA_TYPE:
+ new AnyReadAttributesBySchemaType(input).read();
+ break;
+ case DELETE:
+ new AnyDelete(input).delete();
+ break;
+ case HELP:
+ System.out.println(HELP_MESSAGE);
+ break;
+ default:
+ new AnyResultManager().defaultOptionMessage(input.getOption(), HELP_MESSAGE);
+ }
+ }
+
+ @Override
+ public String getHelpMessage() {
+ return HELP_MESSAGE;
+ }
+
+ private enum AnyOptions {
+
+ HELP("--help"),
+ DETAILS("--details"),
+ LIST("--list"),
+ READ("--read"),
+ READ_ATTRIBUTES_BY_SCHEMA("--read-attr-by-schema"),
+ READ_ATTRIBUTES_BY_SCHEMA_TYPE("--read-attr-by-schema-type"),
+ DELETE("--delete");
+
+ private final String optionName;
+
+ AnyOptions(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 AnyOptions fromName(final String name) {
+ AnyOptions optionToReturn = HELP;
+ for (final AnyOptions option : AnyOptions.values()) {
+ if (option.equalsOptionName(name)) {
+ optionToReturn = option;
+ }
+ }
+ return optionToReturn;
+ }
+
+ public static List<String> toList() {
+ final List<String> options = new ArrayList<>();
+ for (final AnyOptions value : values()) {
+ options.add(value.getOptionName());
+ }
+ return options;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/2d036afe/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyDelete.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyDelete.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyDelete.java
new file mode 100644
index 0000000..170cb57
--- /dev/null
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyDelete.java
@@ -0,0 +1,59 @@
+/*
+ * 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.any;
+
+import org.apache.syncope.client.cli.Input;
+import org.apache.syncope.common.lib.SyncopeClientException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AnyDelete extends AbstractAnyCommand {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AnyDelete.class);
+
+ private static final String DELETE_HELP_MESSAGE = "any --delete {ANY-ID} {ANY-ID} [...]";
+
+ private final Input input;
+
+ public AnyDelete(final Input input) {
+ this.input = input;
+ }
+
+ public void delete() {
+ if (input.parameterNumber() >= 1) {
+ for (final String parameter : input.getParameters()) {
+ try {
+ anySyncopeOperations.delete(parameter);
+ anyResultManager.deletedMessage("Any", parameter);
+ } catch (final SyncopeClientException ex) {
+ LOG.error("Error deleting group", ex);
+ if (ex.getMessage().startsWith("NotFound")) {
+ anyResultManager.notFoundError("any", parameter);
+ } else {
+ anyResultManager.genericError(ex.getMessage());
+ }
+ } catch (final NumberFormatException ex) {
+ anyResultManager.numberFormatException("any", parameter);
+ }
+ }
+ } else {
+ anyResultManager.commandOptionError(DELETE_HELP_MESSAGE);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/2d036afe/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyList.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyList.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyList.java
new file mode 100644
index 0000000..5b2ee56
--- /dev/null
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyList.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.any;
+
+import org.apache.syncope.client.cli.Input;
+import org.apache.syncope.common.lib.SyncopeClientException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AnyList extends AbstractAnyCommand {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AnyList.class);
+
+ private static final String LIST_HELP_MESSAGE = "any --list";
+
+ private final Input input;
+
+ public AnyList(final Input input) {
+ this.input = input;
+ }
+
+ public void list() {
+ if (input.parameterNumber() == 0) {
+ try {
+ anyResultManager.printAnys(anySyncopeOperations.list());
+ } catch (final SyncopeClientException ex) {
+ LOG.error("Error listing any object", ex);
+ anyResultManager.genericError(ex.getMessage());
+ }
+ } else {
+ anyResultManager.unnecessaryParameters(input.listParameters(), LIST_HELP_MESSAGE);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/2d036afe/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyRead.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyRead.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyRead.java
new file mode 100644
index 0000000..ca50b91
--- /dev/null
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyRead.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.any;
+
+import org.apache.syncope.client.cli.Input;
+import org.apache.syncope.common.lib.SyncopeClientException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AnyRead extends AbstractAnyCommand {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AnyRead.class);
+
+ private static final String READ_HELP_MESSAGE = "any --read {ANY-ID} {ANY-ID} [...]";
+
+ private final Input input;
+
+ public AnyRead(final Input input) {
+ this.input = input;
+ }
+
+ public void read() {
+ if (input.parameterNumber() >= 1) {
+ for (final String parameter : input.getParameters()) {
+ try {
+ anyResultManager.printGroup(anySyncopeOperations.read(parameter));
+ } catch (final SyncopeClientException ex) {
+ LOG.error("Error reading group", ex);
+ if (ex.getMessage().startsWith("NotFound")) {
+ anyResultManager.notFoundError("Any object", parameter);
+ } else {
+ anyResultManager.genericError(ex.getMessage());
+ }
+ } catch (final NumberFormatException ex) {
+ anyResultManager.numberFormatException("any object", parameter);
+ }
+ }
+ } else {
+ anyResultManager.commandOptionError(READ_HELP_MESSAGE);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/2d036afe/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyReadAttributeBySchemaTypeAndSchemaName.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyReadAttributeBySchemaTypeAndSchemaName.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyReadAttributeBySchemaTypeAndSchemaName.java
new file mode 100644
index 0000000..b1cd414
--- /dev/null
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyReadAttributeBySchemaTypeAndSchemaName.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.any;
+
+import org.apache.syncope.client.cli.Input;
+import org.apache.syncope.client.cli.util.CommandUtils;
+import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.types.SchemaType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AnyReadAttributeBySchemaTypeAndSchemaName extends AbstractAnyCommand {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AnyReadAttributeBySchemaTypeAndSchemaName.class);
+
+ private static final String READ_HELP_MESSAGE
+ = "any --read-attr-by-schema {ANY-ID} {SCHEMA-TYPE} {SCHEMA-NAME}\n"
+ + " Schema type: PLAIN / DERIVED / VIRTUAL";
+
+ private final Input input;
+
+ public AnyReadAttributeBySchemaTypeAndSchemaName(final Input input) {
+ this.input = input;
+ }
+
+ public void read() {
+ if (input.parameterNumber() == 3) {
+ try {
+ anyResultManager.printAttribute(anySyncopeOperations.readAttribute(
+ input.firstParameter(), input.secondParameter(), input.thirdParameter()));
+ } catch (final SyncopeClientException ex) {
+ LOG.error("Error reading any object", ex);
+ anyResultManager.genericError(ex.getMessage());
+ } catch (final NumberFormatException ex) {
+ anyResultManager.numberFormatException("any object", input.firstParameter());
+ } catch (final IllegalArgumentException ex) {
+ LOG.error("Error reading schema", ex);
+ anyResultManager.typeNotValidError(
+ "schema", input.secondParameter(), CommandUtils.fromEnumToArray(SchemaType.class));
+ }
+ } else {
+ anyResultManager.commandOptionError(READ_HELP_MESSAGE);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/2d036afe/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyReadAttributesBySchemaType.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyReadAttributesBySchemaType.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyReadAttributesBySchemaType.java
new file mode 100644
index 0000000..602c68f
--- /dev/null
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyReadAttributesBySchemaType.java
@@ -0,0 +1,64 @@
+/*
+ * 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.any;
+
+import org.apache.syncope.client.cli.Input;
+import org.apache.syncope.client.cli.util.CommandUtils;
+import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.types.SchemaType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AnyReadAttributesBySchemaType extends AbstractAnyCommand {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AnyReadAttributesBySchemaType.class);
+
+ private static final String READ_HELP_MESSAGE = "any --read-attr-by-schema-type {ANY-ID} {SCHEMA-TYPE}\n"
+ + " Schema type: PLAIN / DERIVED / VIRTUAL";
+
+ private final Input input;
+
+ public AnyReadAttributesBySchemaType(final Input input) {
+ this.input = input;
+ }
+
+ public void read() {
+ if (input.parameterNumber() == 2) {
+ try {
+ anyResultManager.printAttributes(anySyncopeOperations.readAttributes(
+ input.firstParameter(), input.secondParameter()));
+ } catch (final SyncopeClientException ex) {
+ LOG.error("Error reading any", ex);
+ if (ex.getMessage().startsWith("NotFound")) {
+ anyResultManager.notFoundError("Any", input.firstParameter());
+ } else {
+ anyResultManager.genericError(ex.getMessage());
+ }
+ } catch (final NumberFormatException ex) {
+ anyResultManager.numberFormatException("any", input.firstParameter());
+ } catch (final IllegalArgumentException ex) {
+ LOG.error("Error reading schema", ex);
+ anyResultManager.typeNotValidError(
+ "schema", input.secondParameter(), CommandUtils.fromEnumToArray(SchemaType.class));
+ }
+ } else {
+ anyResultManager.commandOptionError(READ_HELP_MESSAGE);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/2d036afe/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyResultManager.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyResultManager.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyResultManager.java
new file mode 100644
index 0000000..3b50406
--- /dev/null
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnyResultManager.java
@@ -0,0 +1,80 @@
+/*
+ * 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.any;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.syncope.client.cli.commands.CommonsResultManager;
+import org.apache.syncope.common.lib.to.AnyObjectTO;
+import org.apache.syncope.common.lib.to.AttrTO;
+
+public class AnyResultManager extends CommonsResultManager {
+
+ public void printAnys(final List<AnyObjectTO> anyObjectTOs) {
+ System.out.println("");
+ for (final AnyObjectTO anyObjectTO : anyObjectTOs) {
+ printGroup(anyObjectTO);
+ }
+ }
+
+ public void printGroup(final AnyObjectTO anyObjectTO) {
+ System.out.println(" > ANY ID: " + anyObjectTO.getKey());
+ System.out.println(" type: " + anyObjectTO.getType());
+ System.out.println(" realm: " + anyObjectTO.getRealm());
+ System.out.println(" status: " + anyObjectTO.getStatus());
+ System.out.println(" RESOURCES: ");
+ printResources(anyObjectTO.getResources());
+ System.out.println(" PLAIN ATTRIBUTES: ");
+ printAttributes(anyObjectTO.getPlainAttrs());
+ System.out.println(" DERIVED ATTRIBUTES: ");
+ printAttributes(anyObjectTO.getDerAttrs());
+ System.out.println(" VIRTUAL ATTRIBUTES: ");
+ printAttributes(anyObjectTO.getVirAttrs());
+ }
+
+ private void printResources(final Set<String> resources) {
+ for (final String resource : resources) {
+ System.out.println(" - " + resource);
+ }
+ }
+
+ public void printAttributes(final Set<AttrTO> attributes) {
+ for (final AttrTO attribute : attributes) {
+ printAttribute(attribute);
+ }
+ System.out.println("");
+ }
+
+ public void printAttribute(final AttrTO attribute) {
+ final StringBuilder attributeMessageBuilder = new StringBuilder();
+ attributeMessageBuilder.append(" - ")
+ .append(attribute.getSchema())
+ .append(": ")
+ .append(attribute.getValues());
+ if (attribute.isReadonly()) {
+ attributeMessageBuilder.append(" - is readonly");
+ }
+ System.out.println(attributeMessageBuilder.toString());
+ }
+
+ public void printDetails(final Map<String, String> details) {
+ printDetails("groups details", details);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/2d036afe/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnySyncopeOperations.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnySyncopeOperations.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnySyncopeOperations.java
new file mode 100644
index 0000000..5156952
--- /dev/null
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/any/AnySyncopeOperations.java
@@ -0,0 +1,53 @@
+/*
+ * 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.any;
+
+import java.util.List;
+import java.util.Set;
+import org.apache.syncope.client.cli.SyncopeServices;
+import org.apache.syncope.common.lib.to.AnyObjectTO;
+import org.apache.syncope.common.lib.to.AttrTO;
+import org.apache.syncope.common.lib.types.SchemaType;
+import org.apache.syncope.common.rest.api.beans.AnyListQuery;
+import org.apache.syncope.common.rest.api.service.AnyObjectService;
+
+public class AnySyncopeOperations {
+
+ private final AnyObjectService anyObjectService = SyncopeServices.get(AnyObjectService.class);
+
+ public List<AnyObjectTO> list() {
+ return anyObjectService.list(new AnyListQuery()).getResult();
+ }
+
+ public AnyObjectTO read(final String anyId) {
+ return anyObjectService.read(Long.valueOf(anyId));
+ }
+
+ public Set<AttrTO> readAttributes(final String anyId, final String schemaType) {
+ return anyObjectService.read(Long.valueOf(anyId), SchemaType.valueOf(schemaType));
+ }
+
+ public AttrTO readAttribute(final String anyId, final String schemaType, final String schema) {
+ return anyObjectService.read(Long.valueOf(anyId), SchemaType.valueOf(schemaType), schema);
+ }
+
+ public void delete(final String anyId) {
+ anyObjectService.delete(Long.valueOf(anyId));
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/2d036afe/client/cli/src/main/java/org/apache/syncope/client/cli/commands/group/GroupResultManager.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/group/GroupResultManager.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/group/GroupResultManager.java
index d8dda12..6a8cf69 100644
--- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/group/GroupResultManager.java
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/group/GroupResultManager.java
@@ -68,7 +68,7 @@ public class GroupResultManager extends CommonsResultManager {
public void printAttribute(final AttrTO attribute) {
final StringBuilder attributeMessageBuilder = new StringBuilder();
- attributeMessageBuilder.append(" ")
+ attributeMessageBuilder.append(" - ")
.append(attribute.getSchema())
.append(": ")
.append(attribute.getValues());