Return-Path: X-Original-To: apmail-syncope-commits-archive@www.apache.org Delivered-To: apmail-syncope-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3D47810D85 for ; Fri, 13 Feb 2015 11:44:07 +0000 (UTC) Received: (qmail 19064 invoked by uid 500); 13 Feb 2015 11:44:07 -0000 Delivered-To: apmail-syncope-commits-archive@syncope.apache.org Received: (qmail 19000 invoked by uid 500); 13 Feb 2015 11:44:07 -0000 Mailing-List: contact commits-help@syncope.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@syncope.apache.org Delivered-To: mailing list commits@syncope.apache.org Received: (qmail 18258 invoked by uid 99); 13 Feb 2015 11:44:06 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Feb 2015 11:44:06 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CE27EE0989; Fri, 13 Feb 2015 11:44:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ilgrosso@apache.org To: commits@syncope.apache.org Date: Fri, 13 Feb 2015 11:44:20 -0000 Message-Id: <73ed185434e9424386d30f9c13adc989@git.apache.org> In-Reply-To: <580024b1fe814ca4b128ea791e676809@git.apache.org> References: <580024b1fe814ca4b128ea791e676809@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [16/51] [partial] syncope git commit: [SYNCOPE-620] Re-organization completed http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/report/UserReportletConf.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/report/UserReportletConf.java b/common/lib/src/main/java/org/apache/syncope/common/lib/report/UserReportletConf.java new file mode 100644 index 0000000..78735eb --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/report/UserReportletConf.java @@ -0,0 +1,114 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.syncope.common.lib.report; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import org.apache.syncope.common.lib.annotation.FormAttributeField; +import org.apache.syncope.common.lib.types.IntMappingType; + +@XmlRootElement(name = "userReportletConf") +@XmlType +public class UserReportletConf extends AbstractReportletConf { + + @XmlEnum + @XmlType(name = "userReportletConfFeature") + public enum Feature { + + key, + username, + workflowId, + status, + creationDate, + lastLoginDate, + changePwdDate, + passwordHistorySize, + failedLoginCount, + memberships, + resources + + } + + private static final long serialVersionUID = 6602717600064602764L; + + @FormAttributeField(userSearch = true) + private String matchingCond; + + @FormAttributeField(schema = IntMappingType.UserPlainSchema) + private final List plainAttrs = new ArrayList<>(); + + @FormAttributeField(schema = IntMappingType.UserDerivedSchema) + private final List derAttrs = new ArrayList<>(); + + @FormAttributeField(schema = IntMappingType.UserVirtualSchema) + private final List virAttrs = new ArrayList<>(); + + private final List features = new ArrayList<>(); + + public UserReportletConf() { + super(); + } + + public UserReportletConf(final String name) { + super(name); + } + + @XmlElementWrapper(name = "plainAttributes") + @XmlElement(name = "plainAttribute") + @JsonProperty("plainAttributes") + public List getPlainAttrs() { + return plainAttrs; + } + + @XmlElementWrapper(name = "derivedAttributes") + @XmlElement(name = "attribute") + @JsonProperty("derivedAttributes") + public List getDerAttrs() { + return derAttrs; + } + + @XmlElementWrapper(name = "virtualAttributes") + @XmlElement(name = "attribute") + @JsonProperty("virtualAttributes") + public List getVirAttrs() { + return virAttrs; + } + + @XmlElementWrapper(name = "features") + @XmlElement(name = "feature") + @JsonProperty("features") + public List getFeatures() { + return features; + } + + public String getMatchingCond() { + return matchingCond; + } + + public void setMatchingCond(final String matchingCond) { + this.matchingCond = matchingCond; + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/report/package-info.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/report/package-info.java b/common/lib/src/main/java/org/apache/syncope/common/lib/report/package-info.java new file mode 100644 index 0000000..bc452c1 --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/report/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ +@XmlSchema(namespace = SyncopeConstants.NAMESPACE) +package org.apache.syncope.common.lib.report; + +import javax.xml.bind.annotation.XmlSchema; +import org.apache.syncope.common.lib.SyncopeConstants; http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/search/OrderByClauseBuilder.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/search/OrderByClauseBuilder.java b/common/lib/src/main/java/org/apache/syncope/common/lib/search/OrderByClauseBuilder.java new file mode 100644 index 0000000..41d152c --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/search/OrderByClauseBuilder.java @@ -0,0 +1,45 @@ +/* + * 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.common.lib.search; + +import org.apache.commons.lang3.StringUtils; + +/** + * Simple builder for generating orderby values. + */ +public class OrderByClauseBuilder { + + private final StringBuilder builder = new StringBuilder(); + + public OrderByClauseBuilder asc(final String key) { + builder.append(key).append(" ASC,"); + return this; + } + + public OrderByClauseBuilder desc(final String key) { + builder.append(key).append(" DESC,"); + return this; + } + + public String build() { + return builder.length() == 0 + ? StringUtils.EMPTY + : builder.deleteCharAt(builder.length() - 1).toString(); + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/search/RoleFiqlSearchConditionBuilder.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/search/RoleFiqlSearchConditionBuilder.java b/common/lib/src/main/java/org/apache/syncope/common/lib/search/RoleFiqlSearchConditionBuilder.java new file mode 100644 index 0000000..b6cbb6d --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/search/RoleFiqlSearchConditionBuilder.java @@ -0,0 +1,90 @@ +/* + * 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.common.lib.search; + +import java.util.Map; +import org.apache.cxf.jaxrs.ext.search.client.CompleteCondition; +import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser; + +/** + * Extends SyncopeFiqlSearchConditionBuilder by providing some additional facilities for searching + * roles in Syncope. + */ +public class RoleFiqlSearchConditionBuilder extends SyncopeFiqlSearchConditionBuilder { + + public RoleFiqlSearchConditionBuilder() { + super(); + } + + public RoleFiqlSearchConditionBuilder(final Map properties) { + super(properties); + } + + @Override + protected Builder newBuilderInstance() { + return new Builder(properties); + } + + @Override + public RoleProperty is(final String property) { + return newBuilderInstance().is(property); + } + + public CompleteCondition hasEntitlements(final String entitlement, final String... moreEntitlements) { + return newBuilderInstance().is(SpecialAttr.ENTITLEMENTS.toString()). + hasEntitlements(entitlement, moreEntitlements); + } + + public CompleteCondition hasNotEntitlements(final String entitlement, final String... moreEntitlements) { + return newBuilderInstance().is(SpecialAttr.ENTITLEMENTS.toString()). + hasNotEntitlements(entitlement, moreEntitlements); + } + + protected static class Builder extends SyncopeFiqlSearchConditionBuilder.Builder + implements RoleProperty, CompleteCondition { + + public Builder(final Map properties) { + super(properties); + } + + public Builder(final Builder parent) { + super(parent); + } + + @Override + public RoleProperty is(final String property) { + Builder b = new Builder(this); + b.result = property; + return b; + } + + @Override + public CompleteCondition hasEntitlements(final String entitlement, final String... moreEntitlements) { + this.result = SpecialAttr.ENTITLEMENTS.toString(); + return condition(FiqlParser.EQ, entitlement, (Object[]) moreEntitlements); + } + + @Override + public CompleteCondition hasNotEntitlements(final String entitlement, final String... moreEntitlements) { + this.result = SpecialAttr.ENTITLEMENTS.toString(); + return condition(FiqlParser.NEQ, entitlement, (Object[]) moreEntitlements); + } + + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/search/RoleProperty.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/search/RoleProperty.java b/common/lib/src/main/java/org/apache/syncope/common/lib/search/RoleProperty.java new file mode 100644 index 0000000..433ed11 --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/search/RoleProperty.java @@ -0,0 +1,29 @@ +/* + * 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.common.lib.search; + +import org.apache.cxf.jaxrs.ext.search.client.CompleteCondition; + +public interface RoleProperty extends SyncopeProperty { + + CompleteCondition hasEntitlements(String entitlement, String... moreEntitlements); + + CompleteCondition hasNotEntitlements(String entitlement, String... moreEntitlements); + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/search/SearchableFields.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/search/SearchableFields.java b/common/lib/src/main/java/org/apache/syncope/common/lib/search/SearchableFields.java new file mode 100644 index 0000000..4945cca --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/search/SearchableFields.java @@ -0,0 +1,69 @@ +/* + * 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.common.lib.search; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.syncope.common.lib.to.AbstractAttributableTO; +import org.apache.syncope.common.lib.to.RoleTO; +import org.apache.syncope.common.lib.to.UserTO; +import org.apache.syncope.common.lib.types.SubjectType; + +public class SearchableFields { + + protected static final String[] ATTRIBUTES_NOTINCLUDED = { + "serialVersionUID", "password" + }; + + public static final List get(final SubjectType subjectType) { + return get(subjectType == SubjectType.USER + ? UserTO.class + : RoleTO.class); + } + + public static final List get(final Class attributableRef) { + final List fieldNames = new ArrayList<>(); + + // loop on class and all superclasses searching for field + Class clazz = attributableRef; + while (clazz != null && clazz != Object.class) { + for (Field field : clazz.getDeclaredFields()) { + if (!ArrayUtils.contains(ATTRIBUTES_NOTINCLUDED, field.getName()) + && !Collection.class.isAssignableFrom(field.getType()) + && !Map.class.isAssignableFrom(field.getType())) { + + fieldNames.add(field.getName()); + } + } + clazz = clazz.getSuperclass(); + } + + Collections.reverse(fieldNames); + return fieldNames; + } + + private SearchableFields() { + // empty constructor for static utility class + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/search/SpecialAttr.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/search/SpecialAttr.java b/common/lib/src/main/java/org/apache/syncope/common/lib/search/SpecialAttr.java new file mode 100644 index 0000000..b4c2f21 --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/search/SpecialAttr.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.common.lib.search; + +public enum SpecialAttr { + + NULL("$null"), + RESOURCES("$resources"), + ROLES("$roles"), + ENTITLEMENTS("$entitlements"); + + private final String literal; + + SpecialAttr(final String literal) { + this.literal = literal; + } + + public static SpecialAttr fromString(final String value) { + SpecialAttr result = null; + for (SpecialAttr specialAttr : values()) { + if (specialAttr.literal.equals(value)) { + result = specialAttr; + } + } + + return result; + } + + @Override + public String toString() { + return literal; + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/search/SyncopeFiqlSearchConditionBuilder.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/search/SyncopeFiqlSearchConditionBuilder.java b/common/lib/src/main/java/org/apache/syncope/common/lib/search/SyncopeFiqlSearchConditionBuilder.java new file mode 100644 index 0000000..6c710a2 --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/search/SyncopeFiqlSearchConditionBuilder.java @@ -0,0 +1,110 @@ +/* + * 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.common.lib.search; + +import java.util.HashMap; +import java.util.Map; +import org.apache.cxf.jaxrs.ext.search.SearchUtils; +import org.apache.cxf.jaxrs.ext.search.client.CompleteCondition; +import org.apache.cxf.jaxrs.ext.search.client.FiqlSearchConditionBuilder; +import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser; + +public abstract class SyncopeFiqlSearchConditionBuilder extends FiqlSearchConditionBuilder { + + public static final Map CONTEXTUAL_PROPERTIES; + + static { + CONTEXTUAL_PROPERTIES = new HashMap(); + CONTEXTUAL_PROPERTIES.put(SearchUtils.LAX_PROPERTY_MATCH, "true"); + } + + protected SyncopeFiqlSearchConditionBuilder() { + super(); + } + + protected SyncopeFiqlSearchConditionBuilder(final Map properties) { + super(properties); + } + + @Override + protected Builder newBuilderInstance() { + return new Builder(properties); + } + + public SyncopeProperty is(final String property) { + return newBuilderInstance().is(property); + } + + public CompleteCondition isNull(final String property) { + return newBuilderInstance().is(property).nullValue(); + } + + public CompleteCondition isNotNull(final String property) { + return newBuilderInstance().is(property).notNullValue(); + } + + public CompleteCondition hasResources(final String resource, final String... moreResources) { + return newBuilderInstance().is(SpecialAttr.RESOURCES.toString()).hasResources(resource, moreResources); + } + + public CompleteCondition hasNotResources(final String resource, final String... moreResources) { + return newBuilderInstance().is(SpecialAttr.RESOURCES.toString()).hasNotResources(resource, moreResources); + } + + protected static class Builder extends FiqlSearchConditionBuilder.Builder + implements SyncopeProperty, CompleteCondition { + + protected Builder(final Map properties) { + super(properties); + } + + protected Builder(final Builder parent) { + super(parent); + } + + @Override + public SyncopeProperty is(final String property) { + Builder b = new Builder(this); + b.result = property; + return b; + } + + @Override + public CompleteCondition nullValue() { + return condition(FiqlParser.EQ, SpecialAttr.NULL); + } + + @Override + public CompleteCondition notNullValue() { + return condition(FiqlParser.NEQ, SpecialAttr.NULL); + } + + @Override + public CompleteCondition hasResources(final String resource, final String... moreResources) { + this.result = SpecialAttr.RESOURCES.toString(); + return condition(FiqlParser.EQ, resource, (Object[]) moreResources); + } + + @Override + public CompleteCondition hasNotResources(final String resource, final String... moreResources) { + this.result = SpecialAttr.RESOURCES.toString(); + return condition(FiqlParser.NEQ, resource, (Object[]) moreResources); + } + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/search/SyncopeProperty.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/search/SyncopeProperty.java b/common/lib/src/main/java/org/apache/syncope/common/lib/search/SyncopeProperty.java new file mode 100644 index 0000000..0f833f8 --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/search/SyncopeProperty.java @@ -0,0 +1,37 @@ +/* + * 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.common.lib.search; + +import org.apache.cxf.jaxrs.ext.search.client.CompleteCondition; +import org.apache.cxf.jaxrs.ext.search.client.Property; + +/** + * Extension of fluent interface, for {@link SyncopeFiqlSearchConditionBuilder}. + */ +public abstract interface SyncopeProperty extends Property { + + CompleteCondition nullValue(); + + CompleteCondition notNullValue(); + + CompleteCondition hasResources(String resource, String... moreResources); + + CompleteCondition hasNotResources(String resource, String... moreResources); + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/search/UserFiqlSearchConditionBuilder.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/search/UserFiqlSearchConditionBuilder.java b/common/lib/src/main/java/org/apache/syncope/common/lib/search/UserFiqlSearchConditionBuilder.java new file mode 100644 index 0000000..ef16e3d --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/search/UserFiqlSearchConditionBuilder.java @@ -0,0 +1,95 @@ +/* + * 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.common.lib.search; + +import java.util.Map; +import org.apache.cxf.jaxrs.ext.search.client.CompleteCondition; +import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser; + +/** + * Extends SyncopeFiqlSearchConditionBuilder by providing some additional facilities for searching + * users in Syncope. + */ +public class UserFiqlSearchConditionBuilder extends SyncopeFiqlSearchConditionBuilder { + + public UserFiqlSearchConditionBuilder() { + super(); + } + + public UserFiqlSearchConditionBuilder(final Map properties) { + super(properties); + } + + @Override + protected Builder newBuilderInstance() { + return new Builder(properties); + } + + @Override + public UserProperty is(final String property) { + return newBuilderInstance().is(property); + } + + public CompleteCondition hasRoles(final Long role, final Long... moreRoles) { + return newBuilderInstance().is(SpecialAttr.ROLES.toString()).hasRoles(role, moreRoles); + } + + public CompleteCondition hasNotRoles(final Long role, final Long... moreRoles) { + return newBuilderInstance().is(SpecialAttr.ROLES.toString()).hasNotRoles(role, moreRoles); + } + + public CompleteCondition hasResources(final String resource, final String... moreResources) { + return newBuilderInstance().is(SpecialAttr.RESOURCES.toString()).hasResources(resource, moreResources); + } + + public CompleteCondition hasNotResources(final String resource, final String... moreResources) { + return newBuilderInstance().is(SpecialAttr.RESOURCES.toString()).hasNotResources(resource, moreResources); + } + + protected static class Builder extends SyncopeFiqlSearchConditionBuilder.Builder + implements UserProperty, CompleteCondition { + + public Builder(final Map properties) { + super(properties); + } + + public Builder(final Builder parent) { + super(parent); + } + + @Override + public UserProperty is(final String property) { + Builder b = new Builder(this); + b.result = property; + return b; + } + + @Override + public CompleteCondition hasRoles(final Long role, final Long... moreRoles) { + this.result = SpecialAttr.ROLES.toString(); + return condition(FiqlParser.EQ, role, (Object[]) moreRoles); + } + + @Override + public CompleteCondition hasNotRoles(final Long role, final Long... moreRoles) { + this.result = SpecialAttr.ROLES.toString(); + return condition(FiqlParser.NEQ, role, (Object[]) moreRoles); + } + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/search/UserProperty.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/search/UserProperty.java b/common/lib/src/main/java/org/apache/syncope/common/lib/search/UserProperty.java new file mode 100644 index 0000000..886f27f --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/search/UserProperty.java @@ -0,0 +1,29 @@ +/* + * 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.common.lib.search; + +import org.apache.cxf.jaxrs.ext.search.client.CompleteCondition; + +public interface UserProperty extends SyncopeProperty { + + CompleteCondition hasRoles(Long role, Long... moreRoles); + + CompleteCondition hasNotRoles(Long role, Long... moreRoles); + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/search/package-info.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/search/package-info.java b/common/lib/src/main/java/org/apache/syncope/common/lib/search/package-info.java new file mode 100644 index 0000000..ff6b5e7 --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/search/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ +@XmlSchema(namespace = SyncopeConstants.NAMESPACE) +package org.apache.syncope.common.lib.search; + +import javax.xml.bind.annotation.XmlSchema; +import org.apache.syncope.common.lib.SyncopeConstants; http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractAnnotatedBean.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractAnnotatedBean.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractAnnotatedBean.java new file mode 100644 index 0000000..c0f7155 --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractAnnotatedBean.java @@ -0,0 +1,108 @@ +/* + * 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.common.lib.to; + +import org.apache.syncope.common.lib.AbstractBaseBean; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.Date; +import javax.xml.bind.annotation.XmlType; +import org.apache.commons.lang3.StringUtils; + +/** + * Abstract wrapper for common system information. + */ +@XmlType +public class AbstractAnnotatedBean extends AbstractBaseBean { + + private static final long serialVersionUID = -930797879027642457L; + + /** + * Username of the user that has created this profile. + *

+ * Cannot be used a reference to an existing user for two main reasons: the creator can be the user admin; + * the creator could have been removed. + */ + private String creator; + + /** + * Creation date. + */ + private Date creationDate; + + /** + * Username of the user that has performed the last modification to this profile. + *

+ * This field cannot be null: at creation time it have to be initialized with the creator username. + *

+ * The modifier can be the user itself whether the last performed change has been a self-modification. + *

+ * Cannot be used a reference to an existing user for two main reasons: the modifier can be the user admin; + * the modifier could have been removed. + */ + private String lastModifier; + + /** + * Last change date. + *

+ * This field cannot be null: at creation time it has to be initialized with creationDate field value. + */ + private Date lastChangeDate; + + public String getCreator() { + return creator; + } + + public void setCreator(final String creator) { + this.creator = creator; + } + + public Date getCreationDate() { + return creationDate; + } + + public void setCreationDate(final Date creationDate) { + this.creationDate = creationDate; + } + + public String getLastModifier() { + return lastModifier; + } + + public void setLastModifier(final String lastModifier) { + this.lastModifier = lastModifier; + } + + public Date getLastChangeDate() { + return lastChangeDate; + } + + public void setLastChangeDate(final Date lastChangeDate) { + this.lastChangeDate = lastChangeDate; + } + + @JsonIgnore + public String getETagValue() { + Date etagDate = getLastChangeDate() == null + ? getCreationDate() : getLastChangeDate(); + return etagDate == null + ? StringUtils.EMPTY + : String.valueOf(etagDate.getTime()); + + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractAttributableTO.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractAttributableTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractAttributableTO.java new file mode 100644 index 0000000..0794b09 --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractAttributableTO.java @@ -0,0 +1,86 @@ +/* + * 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.common.lib.to; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlType; + +@XmlType +public abstract class AbstractAttributableTO extends ConnObjectTO { + + private static final long serialVersionUID = 4083884098736820255L; + + private long key; + + private final List derAttrs = new ArrayList<>(); + + private final List virAttrs = new ArrayList<>(); + + public long getKey() { + return key; + } + + public void setKey(final long id) { + this.key = id; + } + + @JsonIgnore + public Map getDerAttrMap() { + Map result = new HashMap<>(derAttrs.size()); + for (AttrTO attributeTO : derAttrs) { + result.put(attributeTO.getSchema(), attributeTO); + } + result = Collections.unmodifiableMap(result); + + return result; + } + + @JsonIgnore + public Map getVirAttrMap() { + Map result = new HashMap<>(virAttrs.size()); + for (AttrTO attributeTO : virAttrs) { + result.put(attributeTO.getSchema(), attributeTO); + } + result = Collections.unmodifiableMap(result); + + return result; + } + + @XmlElementWrapper(name = "derivedAttributes") + @XmlElement(name = "attribute") + @JsonProperty("derivedAttributes") + public List getDerAttrs() { + return derAttrs; + } + + @XmlElementWrapper(name = "virtualAttributes") + @XmlElement(name = "attribute") + @JsonProperty("virtualAttributes") + public List getVirAttrs() { + return virAttrs; + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractExecTO.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractExecTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractExecTO.java new file mode 100644 index 0000000..71b735f --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractExecTO.java @@ -0,0 +1,87 @@ +/* + * 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.common.lib.to; + +import java.util.Date; +import javax.xml.bind.annotation.XmlType; +import org.apache.syncope.common.lib.AbstractBaseBean; + +@XmlType +public class AbstractExecTO extends AbstractBaseBean { + + private static final long serialVersionUID = -4621191979198357081L; + + protected long key; + + protected String status; + + protected String message; + + protected Date startDate; + + protected Date endDate; + + public long getKey() { + return key; + } + + public void setKey(long key) { + this.key = key; + } + + public String getMessage() { + return message; + } + + public void setMessage(final String message) { + this.message = message; + } + + public String getStatus() { + return status; + } + + public void setStatus(final String status) { + this.status = status; + } + + public Date getStartDate() { + return startDate == null + ? null + : new Date(startDate.getTime()); + } + + public void setStartDate(final Date startDate) { + if (startDate != null) { + this.startDate = new Date(startDate.getTime()); + } + } + + public Date getEndDate() { + return endDate == null + ? null + : new Date(endDate.getTime()); + } + + public void setEndDate(final Date endDate) { + if (endDate != null) { + this.endDate = new Date(endDate.getTime()); + } + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractPolicyTO.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractPolicyTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractPolicyTO.java new file mode 100644 index 0000000..3851f4e --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractPolicyTO.java @@ -0,0 +1,89 @@ +/* + * 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.common.lib.to; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlType; +import org.apache.syncope.common.lib.AbstractBaseBean; +import org.apache.syncope.common.lib.types.PolicyType; + +@XmlRootElement(name = "abstractPolicy") +@XmlType +@XmlSeeAlso({ AccountPolicyTO.class, PasswordPolicyTO.class, SyncPolicyTO.class }) +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class") +public abstract class AbstractPolicyTO extends AbstractBaseBean { + + private static final long serialVersionUID = -2903888572649721035L; + + private long key; + + private String description; + + private PolicyType type; + + private final List usedByResources = new ArrayList<>(); + + private final List usedByRoles = new ArrayList<>(); + + public long getKey() { + return key; + } + + public void setKey(long key) { + this.key = key; + } + + public String getDescription() { + return description; + } + + public void setDescription(final String description) { + this.description = description; + } + + public PolicyType getType() { + return type; + } + + public void setType(final PolicyType type) { + this.type = type; + } + + @XmlElementWrapper(name = "usedByResources") + @XmlElement(name = "resource") + @JsonProperty("usedByResources") + public List getUsedByResources() { + return usedByResources; + } + + @XmlElementWrapper(name = "usedByRoles") + @XmlElement(name = "role") + @JsonProperty("usedByRoles") + public List getUsedByRoles() { + return usedByRoles; + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractProvisioningTaskTO.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractProvisioningTaskTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractProvisioningTaskTO.java new file mode 100644 index 0000000..fe92877 --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractProvisioningTaskTO.java @@ -0,0 +1,117 @@ +/* + * 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.common.lib.to; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlType; +import org.apache.syncope.common.lib.types.MatchingRule; +import org.apache.syncope.common.lib.types.UnmatchingRule; + +@XmlRootElement(name = "abstractProvisioningTask") +@XmlType +@XmlSeeAlso({ PushTaskTO.class, SyncTaskTO.class }) +public class AbstractProvisioningTaskTO extends SchedTaskTO { + + private static final long serialVersionUID = -2143537546915809016L; + + private String resource; + + private boolean performCreate; + + private boolean performUpdate; + + private boolean performDelete; + + private boolean syncStatus; + + private UnmatchingRule unmatchingRule; + + private MatchingRule matchingRule; + + private List actionsClassNames = new ArrayList<>(); + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + } + + public boolean isPerformCreate() { + return performCreate; + } + + public void setPerformCreate(boolean performCreate) { + this.performCreate = performCreate; + } + + public boolean isPerformUpdate() { + return performUpdate; + } + + public void setPerformUpdate(boolean performUpdate) { + this.performUpdate = performUpdate; + } + + public boolean isPerformDelete() { + return performDelete; + } + + public void setPerformDelete(boolean performDelete) { + this.performDelete = performDelete; + } + + public boolean isSyncStatus() { + return syncStatus; + } + + public void setSyncStatus(boolean syncStatus) { + this.syncStatus = syncStatus; + } + + @XmlElementWrapper(name = "actionsClassNames") + @XmlElement(name = "actionsClassName") + @JsonProperty("actionsClassNames") + public List getActionsClassNames() { + return actionsClassNames; + } + + public UnmatchingRule getUnmatchingRule() { + return unmatchingRule; + } + + public void setUnmatchingRule(final UnmatchingRule unmatchigRule) { + this.unmatchingRule = unmatchigRule; + } + + public MatchingRule getMatchingRule() { + return matchingRule; + } + + public void setMatchingRule(final MatchingRule matchigRule) { + this.matchingRule = matchigRule; + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractSchemaTO.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractSchemaTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractSchemaTO.java new file mode 100644 index 0000000..b3a37a8 --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractSchemaTO.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.common.lib.to; + +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlType; +import org.apache.syncope.common.lib.AbstractBaseBean; + +@XmlRootElement(name = "abstractSchema") +@XmlType +@XmlSeeAlso({ PlainSchemaTO.class, DerSchemaTO.class, VirSchemaTO.class }) +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class") +public abstract class AbstractSchemaTO extends AbstractBaseBean { + + private static final long serialVersionUID = 4088388951694301759L; + + private String key; + + public String getKey() { + return key; + } + + public void setKey(final String key) { + this.key = key; + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractSubjectTO.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractSubjectTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractSubjectTO.java new file mode 100644 index 0000000..a2e1b3a --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractSubjectTO.java @@ -0,0 +1,68 @@ +/* + * 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.common.lib.to; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlType; + +@XmlType +public abstract class AbstractSubjectTO extends AbstractAttributableTO { + + private static final long serialVersionUID = 114668706977919206L; + + private final Set resources = new HashSet<>(); + + private final List propagationStatusTOs = new ArrayList<>(); + + @XmlElementWrapper(name = "resources") + @XmlElement(name = "resource") + @JsonProperty("resources") + public Set getResources() { + return resources; + } + + public boolean removePropagationTO(final String resource) { + if (resource != null && getPropagationStatusTOs().isEmpty()) { + final List toBeRemoved = new ArrayList<>(); + + for (PropagationStatus propagationTO : getPropagationStatusTOs()) { + if (resource.equals(propagationTO.getResource())) { + toBeRemoved.add(propagationTO); + } + } + + return propagationStatusTOs.removeAll(toBeRemoved); + } + return false; + } + + @XmlElementWrapper(name = "propagationStatuses") + @XmlElement(name = "propagationStatus") + @JsonProperty("propagationStatuses") + public List getPropagationStatusTOs() { + return propagationStatusTOs; + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractTaskTO.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractTaskTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractTaskTO.java new file mode 100644 index 0000000..eb61493 --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractTaskTO.java @@ -0,0 +1,98 @@ +/* + * 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.common.lib.to; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlType; +import org.apache.syncope.common.lib.AbstractBaseBean; + +@XmlRootElement(name = "abstractTask") +@XmlType +@XmlSeeAlso({ PropagationTaskTO.class, SchedTaskTO.class, NotificationTaskTO.class }) +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class") +public abstract class AbstractTaskTO extends AbstractBaseBean { + + private static final long serialVersionUID = 386450127003321197L; + + private long key; + + private String latestExecStatus; + + private final List executions = new ArrayList<>(); + + private Date startDate; + + private Date endDate; + + public long getKey() { + return key; + } + + public void setKey(final long key) { + this.key = key; + } + + public String getLatestExecStatus() { + return latestExecStatus; + } + + public void setLatestExecStatus(final String latestExecStatus) { + this.latestExecStatus = latestExecStatus; + } + + @XmlElementWrapper(name = "executions") + @XmlElement(name = "execution") + @JsonProperty("executions") + public List getExecutions() { + return executions; + } + + public Date getStartDate() { + return startDate == null + ? null + : new Date(startDate.getTime()); + } + + public void setStartDate(final Date startDate) { + if (startDate != null) { + this.startDate = new Date(startDate.getTime()); + } + } + + public Date getEndDate() { + return endDate == null + ? null + : new Date(endDate.getTime()); + } + + public void setEndDate(final Date endDate) { + if (endDate != null) { + this.endDate = new Date(endDate.getTime()); + } + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/to/AccountPolicyTO.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AccountPolicyTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AccountPolicyTO.java new file mode 100644 index 0000000..a58b24f --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AccountPolicyTO.java @@ -0,0 +1,68 @@ +/* + * 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.common.lib.to; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import org.apache.syncope.common.lib.types.AccountPolicySpec; +import org.apache.syncope.common.lib.types.PolicyType; + +@XmlRootElement(name = "accountPolicy") +@XmlType +public class AccountPolicyTO extends AbstractPolicyTO { + + private static final long serialVersionUID = -1557150042828800134L; + + private AccountPolicySpec specification; + + private final List resources = new ArrayList(); + + public AccountPolicyTO() { + this(false); + } + + public AccountPolicyTO(final boolean global) { + super(); + + PolicyType type = global + ? PolicyType.GLOBAL_ACCOUNT + : PolicyType.ACCOUNT; + setType(type); + } + + public void setSpecification(final AccountPolicySpec specification) { + this.specification = specification; + } + + public AccountPolicySpec getSpecification() { + return specification; + } + + @XmlElementWrapper(name = "resources") + @XmlElement(name = "resource") + @JsonProperty("resources") + public List getResources() { + return resources; + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java new file mode 100644 index 0000000..829f309 --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java @@ -0,0 +1,92 @@ +/* + * 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.common.lib.to; + +import org.apache.syncope.common.lib.AbstractBaseBean; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +@XmlRootElement(name = "attribute") +@XmlType +public class AttrTO extends AbstractBaseBean { + + private static final long serialVersionUID = 4941691338796323623L; + + /** + * Name of the schema that this attribute is referring to. + */ + private String schema; + + /** + * Set of (string) values of this attribute. + */ + private final List values; + + /** + * Whether this attribute is read-only or not. + */ + private boolean readonly; + + /** + * Default constructor. + */ + public AttrTO() { + super(); + values = new ArrayList(); + readonly = false; + } + + /** + * @return the name of the schema that this attribute is referring to + */ + public String getSchema() { + return schema; + } + + /** + * @param schema name to be set + */ + public void setSchema(final String schema) { + this.schema = schema; + + } + + /** + * @return attribute values as strings + */ + @XmlElementWrapper(name = "values") + @XmlElement(name = "value") + @JsonProperty("values") + public List getValues() { + return values; + } + + public boolean isReadonly() { + return readonly; + } + + public void setReadonly(final boolean readonly) { + this.readonly = readonly; + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/to/BulkAction.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/BulkAction.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/BulkAction.java new file mode 100644 index 0000000..a514dcb --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/BulkAction.java @@ -0,0 +1,70 @@ +/* + * 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.common.lib.to; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import org.apache.syncope.common.lib.AbstractBaseBean; + +@XmlRootElement(name = "bulkAction") +@XmlType +public class BulkAction extends AbstractBaseBean { + + private static final long serialVersionUID = 1395353278878758961L; + + @XmlEnum + @XmlType(name = "bulkActionType") + public enum Type { + + DELETE, + REACTIVATE, + SUSPEND, + DRYRUN, + EXECUTE + + } + + private Type operation; + + /** + * Serialized identifiers. + */ + private final List targets = new ArrayList<>(); + + public Type getOperation() { + return operation; + } + + public void setOperation(final Type operation) { + this.operation = operation; + } + + @XmlElementWrapper(name = "targets") + @XmlElement(name = "target") + @JsonProperty("targets") + public List getTargets() { + return targets; + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/to/BulkActionResult.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/BulkActionResult.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/BulkActionResult.java new file mode 100644 index 0000000..dfe52de --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/BulkActionResult.java @@ -0,0 +1,134 @@ +/* + * 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.common.lib.to; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import org.apache.syncope.common.lib.AbstractBaseBean; + +@XmlRootElement(name = "bulkActionResult") +@XmlType +public class BulkActionResult extends AbstractBaseBean { + + private static final long serialVersionUID = 2868894178821778133L; + + @XmlEnum + @XmlType(name = "bulkActionStatus") + public enum Status { + + // general bulk action result statuses + SUCCESS, + FAILURE, + // specific propagation task execution statuses + CREATED, + SUBMITTED, + UNSUBMITTED; + + } + + private final List results = new ArrayList(); + + @XmlElementWrapper(name = "result") + @XmlElement(name = "item") + @JsonProperty("result") + public List getResult() { + return results; + } + + @JsonIgnore + public void add(final Object id, final Status status) { + if (id != null) { + results.add(new Result(id.toString(), status)); + } + } + + @JsonIgnore + public void add(final Object id, final String status) { + if (id != null) { + results.add(new Result(id.toString(), Status.valueOf(status.toUpperCase()))); + } + } + + @JsonIgnore + public Map getResultMap() { + final Map res = new HashMap(); + + for (Result result : results) { + res.put(result.getKey(), result.getValue()); + } + + return res; + } + + @JsonIgnore + public List getResultByStatus(final Status status) { + final List res = new ArrayList(); + + for (Result result : results) { + if (result.getValue() == status) { + res.add(result.getKey()); + } + } + + return res; + } + + public static class Result extends AbstractBaseBean { + + private static final long serialVersionUID = -1149681964161193232L; + + private String key; + + private Status value; + + public Result() { + super(); + } + + public Result(final String key, final Status value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public Status getValue() { + return value; + } + + public void setKey(final String key) { + this.key = key; + } + + public void setValue(final Status value) { + this.value = value; + } + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConfTO.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConfTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConfTO.java new file mode 100644 index 0000000..4856a48 --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConfTO.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.syncope.common.lib.to; + +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +@XmlRootElement(name = "conf") +@XmlType +public class ConfTO extends AbstractAttributableTO { + + private static final long serialVersionUID = -3825039700228595590L; + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnBundleTO.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnBundleTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnBundleTO.java new file mode 100644 index 0000000..87583a4 --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnBundleTO.java @@ -0,0 +1,95 @@ +/* + * 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.common.lib.to; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import org.apache.syncope.common.lib.AbstractBaseBean; +import org.apache.syncope.common.lib.types.ConnConfPropSchema; + +@XmlRootElement(name = "connectorBundle") +@XmlType +public class ConnBundleTO extends AbstractBaseBean { + + private static final long serialVersionUID = 7215115961910138005L; + + private String displayName; + + private String location; + + private String bundleName; + + private String connectorName; + + private String version; + + private List properties = new ArrayList<>(); + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(final String displayName) { + this.displayName = displayName; + } + + public String getLocation() { + return location; + } + + public void setLocation(final String location) { + this.location = location; + } + + public String getBundleName() { + return bundleName; + } + + public void setBundleName(final String bundleName) { + this.bundleName = bundleName; + } + + public String getConnectorName() { + return connectorName; + } + + public void setConnectorName(final String connectorName) { + this.connectorName = connectorName; + } + + @XmlElementWrapper(name = "properties") + @XmlElement(name = "connConfPropSchema") + @JsonProperty("properties") + public List getProperties() { + return properties; + } + + public String getVersion() { + return version; + } + + public void setVersion(final String version) { + this.version = version; + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnIdObjectClassTO.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnIdObjectClassTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnIdObjectClassTO.java new file mode 100644 index 0000000..fd4d0b7 --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnIdObjectClassTO.java @@ -0,0 +1,72 @@ +/* + * 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.common.lib.to; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import org.apache.syncope.common.lib.AbstractBaseBean; + +/** + * Mimic ConnId's ObjectClass information. + */ +@XmlRootElement(name = "connIdObjectClass") +@XmlType +public class ConnIdObjectClassTO extends AbstractBaseBean { + + private static final long serialVersionUID = 5802458031138859994L; + + @XmlEnum + public enum DefaultType { + + ACCOUNT("__ACCOUNT__"), + GROUP("__GROUP__"); + + private String specialName; + + private DefaultType(final String specialName) { + this.specialName = specialName; + } + + public String getSpecialName() { + return specialName; + } + } + + public static ConnIdObjectClassTO ACCOUNT = new ConnIdObjectClassTO(DefaultType.ACCOUNT.getSpecialName()); + + public static ConnIdObjectClassTO GROUP = new ConnIdObjectClassTO(DefaultType.GROUP.getSpecialName()); + + private String type; + + public ConnIdObjectClassTO() { + } + + public ConnIdObjectClassTO(final String type) { + this.type = type; + } + + public String getType() { + return type; + } + + public void setType(final String type) { + this.type = type; + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnInstanceTO.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnInstanceTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnInstanceTO.java new file mode 100644 index 0000000..5c25783 --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnInstanceTO.java @@ -0,0 +1,177 @@ +/* + * 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.common.lib.to; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Collections; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import org.apache.syncope.common.lib.AbstractBaseBean; +import org.apache.syncope.common.lib.types.ConnConfProperty; +import org.apache.syncope.common.lib.types.ConnectorCapability; + +@XmlRootElement(name = "connInstance") +@XmlType +public class ConnInstanceTO extends AbstractBaseBean { + + private static final long serialVersionUID = 2707778645445168671L; + + private long key; + + private String location; + + private String connectorName; + + private String bundleName; + + private String version; + + private final Set configuration; + + private final Set capabilities; + + private String displayName; + + private Integer connRequestTimeout; + + private ConnPoolConfTO poolConf; + + public ConnInstanceTO() { + super(); + + configuration = new HashSet<>(); + capabilities = EnumSet.noneOf(ConnectorCapability.class); + } + + public long getKey() { + return key; + } + + public void setKey(final long key) { + this.key = key; + } + + public String getLocation() { + return location; + } + + public void setLocation(final String location) { + this.location = location; + } + + public String getConnectorName() { + return connectorName; + } + + public void setConnectorName(final String connectorname) { + this.connectorName = connectorname; + } + + public String getBundleName() { + return bundleName; + } + + public void setBundleName(final String bundlename) { + this.bundleName = bundlename; + } + + public String getVersion() { + return version; + } + + public void setVersion(final String version) { + this.version = version; + } + + @XmlElementWrapper(name = "configuration") + @XmlElement(name = "property") + @JsonProperty("configuration") + public Set getConfiguration() { + return this.configuration; + } + + @JsonIgnore + public Map getConfigurationMap() { + Map result; + + if (getConfiguration() == null) { + result = Collections.emptyMap(); + } else { + result = new HashMap<>(); + for (ConnConfProperty prop : getConfiguration()) { + result.put(prop.getSchema().getName(), prop); + } + result = Collections.unmodifiableMap(result); + } + + return result; + } + + @XmlElementWrapper(name = "capabilities") + @XmlElement(name = "capability") + @JsonProperty("capabilities") + public Set getCapabilities() { + return capabilities; + } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(final String displayName) { + this.displayName = displayName; + } + + /** + * Get connector request timeout. + * It is not applied in case of sync, full reconciliation and search. + * + * @return timeout. + */ + public Integer getConnRequestTimeout() { + return connRequestTimeout; + } + + /** + * Set connector request timeout. + * It is not applied in case of sync, full reconciliation and search. + * + * @param connRequestTimeout timeout + */ + public void setConnRequestTimeout(final Integer connRequestTimeout) { + this.connRequestTimeout = connRequestTimeout; + } + + public ConnPoolConfTO getPoolConf() { + return poolConf; + } + + public void setPoolConf(final ConnPoolConfTO poolConf) { + this.poolConf = poolConf; + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnObjectTO.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnObjectTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnObjectTO.java new file mode 100644 index 0000000..78256ba --- /dev/null +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnObjectTO.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.common.lib.to; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +@XmlRootElement(name = "connObject") +@XmlType +public class ConnObjectTO extends AbstractAnnotatedBean { + + private static final long serialVersionUID = 5139554911265442497L; + + private final List attrs = new ArrayList<>(); + + @XmlElementWrapper(name = "attributes") + @XmlElement(name = "attribute") + @JsonProperty("attributes") + public List getPlainAttrs() { + return attrs; + } + + @JsonIgnore + public Map getPlainAttrMap() { + Map result = new HashMap<>(attrs.size()); + for (AttrTO attributeTO : attrs) { + result.put(attributeTO.getSchema(), attributeTO); + } + result = Collections.unmodifiableMap(result); + + return result; + } +}