diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/EndpointInfos.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/EndpointInfos.java index bedb1fee55a..5aeefa55720 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/EndpointInfos.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/EndpointInfos.java @@ -68,6 +68,8 @@ public EndpointInfoListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @QueryParam("usage") String usage, @QueryParam("endpointType") @DefaultValue(EndpointInfo.ENDPOINT_TYPE_RESOURCE) String endpointType, + @QueryParam("matchTerm") String matchTerm, + @QueryParam("askTotalCount") boolean askTotalCount, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { EndpointInfoQuery query = endpointInfoFactory.newQuery(scopeId); @@ -76,10 +78,14 @@ public EndpointInfoListResult simpleQuery( if (!Strings.isNullOrEmpty(usage)) { andPredicate.and(query.attributePredicate(EndpointInfoAttributes.USAGES, endpointInfoFactory.newEndpointUsage(usage))); } + if (matchTerm != null && !matchTerm.isEmpty()) { + andPredicate.and(query.matchPredicate(matchTerm)); + } query.setPredicate(andPredicate); query.setOffset(offset); query.setLimit(limit); + query.setAskTotalCount(askTotalCount); return query(scopeId, endpointType, query); } diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Groups.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Groups.java index e4d0861a898..cbb0c31b273 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Groups.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Groups.java @@ -66,6 +66,8 @@ public class Groups extends AbstractKapuaResource { public GroupListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @QueryParam("name") String name, + @QueryParam("askTotalCount") boolean askTotalCount, + @QueryParam("matchTerm") String matchTerm, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { GroupQuery query = groupFactory.newQuery(scopeId); @@ -74,10 +76,14 @@ public GroupListResult simpleQuery( if (!Strings.isNullOrEmpty(name)) { andPredicate.and(query.attributePredicate(KapuaNamedEntityAttributes.NAME, name)); } + if (matchTerm != null && !matchTerm.isEmpty()) { + andPredicate.and(query.matchPredicate(matchTerm)); + } query.setPredicate(andPredicate); query.setOffset(offset); query.setLimit(limit); + query.setAskTotalCount(askTotalCount); return query(scopeId, query); } diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Roles.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Roles.java index cffa096e37a..48b32750aa6 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Roles.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Roles.java @@ -79,6 +79,7 @@ public class Roles extends AbstractKapuaResource { public RoleListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @QueryParam("name") String name, + @QueryParam("matchTerm") String matchTerm, @QueryParam("askTotalCount") boolean askTotalCount, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { @@ -88,6 +89,9 @@ public RoleListResult simpleQuery( if (!Strings.isNullOrEmpty(name)) { andPredicate.and(query.attributePredicate(KapuaNamedEntityAttributes.NAME, name)); } + if (matchTerm != null && !matchTerm.isEmpty()) { + andPredicate.and(query.matchPredicate(matchTerm)); + } query.setPredicate(andPredicate); query.setAskTotalCount(askTotalCount); diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Tags.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Tags.java index 4c9a701fe5f..9c811d66fd7 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Tags.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Tags.java @@ -68,6 +68,7 @@ public TagListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @QueryParam("name") String name, @QueryParam("askTotalCount") boolean askTotalCount, + @QueryParam("matchTerm") String matchTerm, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { TagQuery query = tagFactory.newQuery(scopeId); @@ -76,6 +77,9 @@ public TagListResult simpleQuery( if (!Strings.isNullOrEmpty(name)) { andPredicate.and(query.attributePredicate(KapuaNamedEntityAttributes.NAME, name)); } + if (matchTerm != null && !matchTerm.isEmpty()) { + andPredicate.and(query.matchPredicate(matchTerm)); + } query.setPredicate(andPredicate); query.setOffset(offset); diff --git a/rest-api/resources/src/main/resources/openapi/endpointInfo/endpointInfo-scopeId.yaml b/rest-api/resources/src/main/resources/openapi/endpointInfo/endpointInfo-scopeId.yaml index 6094fb5cf37..926c37737f1 100644 --- a/rest-api/resources/src/main/resources/openapi/endpointInfo/endpointInfo-scopeId.yaml +++ b/rest-api/resources/src/main/resources/openapi/endpointInfo/endpointInfo-scopeId.yaml @@ -26,6 +26,17 @@ paths: schema: type: string - $ref: './endpointInfo.yaml#/components/parameters/endpointType' + - $ref: '../openapi.yaml#/components/parameters/askTotalCount' + - name: matchTerm + in: query + description: | + A term to match on different fields. Every entity whose at least one of the specified fields starts with this value will be matched. + Matches on the following fields: + + - SCHEMA + - DNS + schema: + type: string - $ref: '../openapi.yaml#/components/parameters/limit' - $ref: '../openapi.yaml#/components/parameters/offset' responses: diff --git a/rest-api/resources/src/main/resources/openapi/group/group-scopeId.yaml b/rest-api/resources/src/main/resources/openapi/group/group-scopeId.yaml index 7ef42c83ab0..2e5ea2dced3 100644 --- a/rest-api/resources/src/main/resources/openapi/group/group-scopeId.yaml +++ b/rest-api/resources/src/main/resources/openapi/group/group-scopeId.yaml @@ -25,6 +25,17 @@ paths: description: The group name to filter results schema: type: string + - $ref: '../openapi.yaml#/components/parameters/askTotalCount' + - name: matchTerm + in: query + description: | + A term to match on different fields. Every entity whose at least one of the specified fields starts with this value will be matched. + Matches on the following fields: + + - DESCRIPTION + - NAME + schema: + type: string - $ref: '../openapi.yaml#/components/parameters/limit' - $ref: '../openapi.yaml#/components/parameters/offset' responses: diff --git a/rest-api/resources/src/main/resources/openapi/role/role-scopeId.yaml b/rest-api/resources/src/main/resources/openapi/role/role-scopeId.yaml index c575c7d4cc6..d98f7d20ef3 100644 --- a/rest-api/resources/src/main/resources/openapi/role/role-scopeId.yaml +++ b/rest-api/resources/src/main/resources/openapi/role/role-scopeId.yaml @@ -25,6 +25,16 @@ paths: description: The role name to filter results schema: type: string + - name: matchTerm + in: query + description: | + A term to match on different fields. Every entity whose at least one of the specified fields starts with this value will be matched. + Matches on the following fields: + + - DESCRIPTION + - NAME + schema: + type: string - $ref: '../openapi.yaml#/components/parameters/askTotalCount' - $ref: '../openapi.yaml#/components/parameters/limit' - $ref: '../openapi.yaml#/components/parameters/offset' diff --git a/rest-api/resources/src/main/resources/openapi/tag/tag-scopeId.yaml b/rest-api/resources/src/main/resources/openapi/tag/tag-scopeId.yaml index 85599901219..b2ecaf3c50d 100644 --- a/rest-api/resources/src/main/resources/openapi/tag/tag-scopeId.yaml +++ b/rest-api/resources/src/main/resources/openapi/tag/tag-scopeId.yaml @@ -25,6 +25,16 @@ paths: description: The tag name to filter results schema: type: string + - name: matchTerm + in: query + description: | + A term to match on different fields. Every entity whose at least one of the specified fields starts with this value will be matched. + Matches on the following fields: + + - DESCRIPTION + - NAME + schema: + type: string - $ref: '../openapi.yaml#/components/parameters/askTotalCount' - $ref: '../openapi.yaml#/components/parameters/limit' - $ref: '../openapi.yaml#/components/parameters/offset' diff --git a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoMatchPredicate.java b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoMatchPredicate.java new file mode 100644 index 00000000000..1f7a40b870e --- /dev/null +++ b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoMatchPredicate.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2017, 2022 Eurotech and/or its affiliates and others + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Eurotech - initial API and implementation + *******************************************************************************/ +package org.eclipse.kapua.service.endpoint; + +import org.eclipse.kapua.model.query.predicate.MatchPredicate; + +public interface EndpointInfoMatchPredicate extends MatchPredicate { + +} diff --git a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoQuery.java b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoQuery.java index 3dc466f95fd..8e0fcf05e6d 100644 --- a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoQuery.java +++ b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoQuery.java @@ -29,5 +29,13 @@ @XmlAccessorType(XmlAccessType.PROPERTY) @XmlType(factoryClass = EndpointInfoXmlRegistry.class, factoryMethod = "newQuery") public interface EndpointInfoQuery extends KapuaQuery { - + /** + * Instantiates a new {@link EndpointInfoMatchPredicate}. + * + * @param matchTerm The term to use to match. + * @param The type of the term + * @return The newly instantiated {@link EndpointInfoMatchPredicate}. + * @since 2.1.0 + */ + EndpointInfoMatchPredicate matchPredicate(T matchTerm); } diff --git a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoMatchPredicateImpl.java b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoMatchPredicateImpl.java new file mode 100644 index 00000000000..f239431346f --- /dev/null +++ b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoMatchPredicateImpl.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2017, 2022 Eurotech and/or its affiliates and others + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Eurotech - initial API and implementation + *******************************************************************************/ +package org.eclipse.kapua.service.endpoint.internal; + +import org.eclipse.kapua.commons.model.query.predicate.AbstractMatchPredicate; +import org.eclipse.kapua.service.endpoint.EndpointInfoAttributes; +import org.eclipse.kapua.service.endpoint.EndpointInfoMatchPredicate; + +import java.util.Arrays; + +public class EndpointInfoMatchPredicateImpl extends AbstractMatchPredicate implements EndpointInfoMatchPredicate { + + /** + * Constructor. + * + * @param matchTerm + * @since 2.1.0 + */ + public EndpointInfoMatchPredicateImpl(T matchTerm) { + this.attributeNames = Arrays.asList( + EndpointInfoAttributes.SCHEMA, + EndpointInfoAttributes.DNS + ); + this.matchTerm = matchTerm; + } + +} diff --git a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoQueryImpl.java b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoQueryImpl.java index c9c3b449a95..7ceed548388 100644 --- a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoQueryImpl.java +++ b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoQueryImpl.java @@ -14,6 +14,7 @@ import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.service.endpoint.EndpointInfoMatchPredicate; import org.eclipse.kapua.service.endpoint.EndpointInfoQuery; /** @@ -32,4 +33,9 @@ public class EndpointInfoQueryImpl extends AbstractKapuaQuery implements Endpoin public EndpointInfoQueryImpl(KapuaId scopeId) { super(scopeId); } + + @Override + public EndpointInfoMatchPredicate matchPredicate(T matchTerm) { + return new EndpointInfoMatchPredicateImpl<>(matchTerm); + } } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupMatchPredicate.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupMatchPredicate.java new file mode 100644 index 00000000000..23afb4f1acc --- /dev/null +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupMatchPredicate.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2017, 2022 Eurotech and/or its affiliates and others + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Eurotech - initial API and implementation + *******************************************************************************/ +package org.eclipse.kapua.service.authorization.group; + +import org.eclipse.kapua.model.query.predicate.MatchPredicate; + +public interface GroupMatchPredicate extends MatchPredicate { + +} diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupQuery.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupQuery.java index 6c91e5798ab..94b9a53d183 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupQuery.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupQuery.java @@ -29,4 +29,13 @@ @XmlAccessorType(XmlAccessType.PROPERTY) @XmlType(factoryClass = GroupXmlRegistry.class, factoryMethod = "newQuery") public interface GroupQuery extends KapuaQuery { + /** + * Instantiates a new {@link GroupMatchPredicate}. + * + * @param matchTerm The term to use to match. + * @param The type of the term + * @return The newly instantiated {@link GroupMatchPredicate}. + * @since 2.1.0 + */ + GroupMatchPredicate matchPredicate(T matchTerm); } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleAttributes.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleAttributes.java index cecde1df90d..ac9c457a1c5 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleAttributes.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleAttributes.java @@ -21,4 +21,5 @@ * @since 1.0.0 */ public class RoleAttributes extends KapuaNamedEntityAttributes { + } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleMatchPredicate.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleMatchPredicate.java new file mode 100644 index 00000000000..5f1e7edbfc6 --- /dev/null +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleMatchPredicate.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2017, 2022 Eurotech and/or its affiliates and others + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Eurotech - initial API and implementation + *******************************************************************************/ +package org.eclipse.kapua.service.authorization.role; + +import org.eclipse.kapua.model.query.predicate.MatchPredicate; + +public interface RoleMatchPredicate extends MatchPredicate { + +} diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleQuery.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleQuery.java index 57899c0df00..36d8b3a692b 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleQuery.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleQuery.java @@ -28,4 +28,14 @@ @XmlAccessorType(XmlAccessType.PROPERTY) @XmlType(factoryClass = RoleXmlRegistry.class, factoryMethod = "newQuery") public interface RoleQuery extends KapuaQuery { + /** + * Instantiates a new {@link RoleMatchPredicate}. + * + * @param matchTerm The term to use to match. + * @param The type of the term + * @return The newly instantiated {@link RoleMatchPredicate}. + * @since 2.1.0 + */ + RoleMatchPredicate matchPredicate(T matchTerm); + } diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoAttributes.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoAttributes.java index 5957848c611..3f4b23f7ec6 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoAttributes.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoAttributes.java @@ -21,7 +21,6 @@ * @since 1.1.0 */ public class CertificateInfoAttributes extends KapuaNamedEntityAttributes { - public static final String CA_ID = "caId"; public static final String FORWARDABLE = "forwardable"; @@ -34,4 +33,12 @@ public class CertificateInfoAttributes extends KapuaNamedEntityAttributes { public static final String USAGE_NAME = USAGE + ".name"; + public static final String SERIAL = "serial"; + + public static final String ALGORITHM = "algorithm"; + + public static final String SUBJECT = "subject"; + + + } diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoMatchPredicate.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoMatchPredicate.java new file mode 100644 index 00000000000..80d1166cb16 --- /dev/null +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoMatchPredicate.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2018, 2022 Eurotech and/or its affiliates and others + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Eurotech - initial API and implementation + *******************************************************************************/ +package org.eclipse.kapua.service.certificate.info; + +import org.eclipse.kapua.model.query.predicate.MatchPredicate; + +public interface CertificateInfoMatchPredicate extends MatchPredicate { + +} \ No newline at end of file diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoQuery.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoQuery.java index e8fc64aca09..1bf1f33dee5 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoQuery.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoQuery.java @@ -51,4 +51,14 @@ public interface CertificateInfoQuery extends KapuaForwardableEntityQuery { * @since 1.1.0 */ void setIncludeInherited(Boolean includeInherited); + + /** + * Instantiates a new {@link CertificateInfoMatchPredicate}. + * + * @param matchTerm The term to use to match. + * @param The type of the term + * @return The newly instantiated {@link CertificateInfoMatchPredicate}. + * @since 2.1.0 + */ + CertificateInfoMatchPredicate matchPredicate(T matchTerm); } diff --git a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoMatchPredicateImpl.java b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoMatchPredicateImpl.java new file mode 100644 index 00000000000..4d42434e7a5 --- /dev/null +++ b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoMatchPredicateImpl.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2018, 2022 Eurotech and/or its affiliates and others + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Eurotech - initial API and implementation + *******************************************************************************/ +package org.eclipse.kapua.service.certificate.info.internal; + +import org.eclipse.kapua.commons.model.query.predicate.AbstractMatchPredicate; +import org.eclipse.kapua.service.certificate.info.CertificateInfoAttributes; +import org.eclipse.kapua.service.certificate.info.CertificateInfoMatchPredicate; + +import java.util.Arrays; + +public class CertificateInfoMatchPredicateImpl extends AbstractMatchPredicate implements CertificateInfoMatchPredicate { + + /** + * Constructor. + * + * @param matchTerm + * @since 2.1.0 + */ + public CertificateInfoMatchPredicateImpl(T matchTerm) { + this.attributeNames = Arrays.asList( + CertificateInfoAttributes.NAME, + CertificateInfoAttributes.SERIAL, + CertificateInfoAttributes.SIGNATURE, + CertificateInfoAttributes.ALGORITHM, + CertificateInfoAttributes.SUBJECT + ); + this.matchTerm = matchTerm; + } + +} diff --git a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoQueryImpl.java b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoQueryImpl.java index fbc765ed32c..3c64874d30f 100644 --- a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoQueryImpl.java +++ b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoQueryImpl.java @@ -14,6 +14,7 @@ import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.service.certificate.info.CertificateInfoMatchPredicate; import org.eclipse.kapua.service.certificate.info.CertificateInfoQuery; /** @@ -54,4 +55,9 @@ public Boolean getIncludeInherited() { public void setIncludeInherited(Boolean includeInherited) { this.includeInherited = includeInherited; } + + @Override + public CertificateInfoMatchPredicate matchPredicate(T matchTerm) { + return new CertificateInfoMatchPredicateImpl<>(matchTerm); + } } diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupMatchPredicateImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupMatchPredicateImpl.java new file mode 100644 index 00000000000..d99618d07a1 --- /dev/null +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupMatchPredicateImpl.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2017, 2022 Eurotech and/or its affiliates and others + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Eurotech - initial API and implementation + *******************************************************************************/ +package org.eclipse.kapua.service.authorization.group.shiro; + +import org.eclipse.kapua.commons.model.query.predicate.AbstractMatchPredicate; +import org.eclipse.kapua.service.authorization.group.GroupAttributes; +import org.eclipse.kapua.service.authorization.group.GroupMatchPredicate; + +import java.util.Arrays; + +public class GroupMatchPredicateImpl extends AbstractMatchPredicate implements GroupMatchPredicate { + + /** + * Constructor. + * + * @param matchTerm + * @since 2.1.0 + */ + public GroupMatchPredicateImpl(T matchTerm) { + this.attributeNames = Arrays.asList( + GroupAttributes.DESCRIPTION, + GroupAttributes.NAME + ); + this.matchTerm = matchTerm; + } + +} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupQueryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupQueryImpl.java index 89a11fd970a..809a08a6564 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupQueryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupQueryImpl.java @@ -14,6 +14,7 @@ import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.service.authorization.group.GroupMatchPredicate; import org.eclipse.kapua.service.authorization.group.GroupQuery; /** @@ -32,4 +33,9 @@ public class GroupQueryImpl extends AbstractKapuaNamedQuery implements GroupQuer public GroupQueryImpl(KapuaId scopeId) { super(scopeId); } + + @Override + public GroupMatchPredicate matchPredicate(T matchTerm) { + return new GroupMatchPredicateImpl<>(matchTerm); + } } diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleMatchPredicateImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleMatchPredicateImpl.java new file mode 100644 index 00000000000..a9d67a14ce7 --- /dev/null +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleMatchPredicateImpl.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2017, 2022 Eurotech and/or its affiliates and others + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Eurotech - initial API and implementation + *******************************************************************************/ +package org.eclipse.kapua.service.authorization.role.shiro; + +import org.eclipse.kapua.commons.model.query.predicate.AbstractMatchPredicate; +import org.eclipse.kapua.service.authorization.role.RoleAttributes; +import org.eclipse.kapua.service.authorization.role.RoleMatchPredicate; +import java.util.Arrays; + +public class RoleMatchPredicateImpl extends AbstractMatchPredicate implements RoleMatchPredicate { + + /** + * Constructor. + * + * @param matchTerm + * @since 2.1.0 + */ + public RoleMatchPredicateImpl(T matchTerm) { + this.attributeNames = Arrays.asList( + RoleAttributes.DESCRIPTION, + RoleAttributes.NAME + ); + this.matchTerm = matchTerm; + } +} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleQueryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleQueryImpl.java index 1418916ab01..45a19a65914 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleQueryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleQueryImpl.java @@ -14,6 +14,7 @@ import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.service.authorization.role.RoleMatchPredicate; import org.eclipse.kapua.service.authorization.role.RoleQuery; /** @@ -42,4 +43,10 @@ public RoleQueryImpl(KapuaId scopeId) { this(); setScopeId(scopeId); } + + @Override + public RoleMatchPredicate matchPredicate(T matchTerm) { + return new RoleMatchPredicateImpl<>(matchTerm); + } + } diff --git a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagAttributes.java b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagAttributes.java index c806162df93..0c28a5207a0 100644 --- a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagAttributes.java +++ b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagAttributes.java @@ -22,5 +22,4 @@ * @since 1.0.0 */ public class TagAttributes extends KapuaNamedEntityAttributes { - public static final String DESCRIPTION = "description"; } diff --git a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagMatchPredicate.java b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagMatchPredicate.java new file mode 100644 index 00000000000..a1df13b4279 --- /dev/null +++ b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagMatchPredicate.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2017, 2022 Eurotech and/or its affiliates and others + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Eurotech - initial API and implementation + *******************************************************************************/ +package org.eclipse.kapua.service.tag; + +import org.eclipse.kapua.model.query.predicate.MatchPredicate; +public interface TagMatchPredicate extends MatchPredicate { + +} diff --git a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagQuery.java b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagQuery.java index b6817e477b7..0bbfc29faeb 100644 --- a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagQuery.java +++ b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagQuery.java @@ -29,4 +29,15 @@ @XmlAccessorType(XmlAccessType.PROPERTY) @XmlType(factoryClass = TagXmlRegistry.class, factoryMethod = "newQuery") public interface TagQuery extends KapuaQuery { + + /** + * Instantiates a new {@link TagMatchPredicate}. + * + * @param matchTerm The term to use to match. + * @param The type of the term + * @return The newly instantiated {@link TagMatchPredicate}. + * @since 2.1.0 + */ + TagMatchPredicate matchPredicate(T matchTerm); + } diff --git a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagMatchPredicateImpl.java b/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagMatchPredicateImpl.java new file mode 100644 index 00000000000..e785c278463 --- /dev/null +++ b/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagMatchPredicateImpl.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2017, 2022 Eurotech and/or its affiliates and others + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Eurotech - initial API and implementation + *******************************************************************************/ +package org.eclipse.kapua.service.tag.internal; + +import org.eclipse.kapua.commons.model.query.predicate.AbstractMatchPredicate; +import org.eclipse.kapua.service.tag.TagAttributes; +import org.eclipse.kapua.service.tag.TagMatchPredicate; +import java.util.Arrays; + +public class TagMatchPredicateImpl extends AbstractMatchPredicate implements TagMatchPredicate { + +/** + * Constructor. + * + * @param matchTerm + * @since 2.1.0 + */ + public TagMatchPredicateImpl(T matchTerm) { + this.attributeNames = Arrays.asList( + TagAttributes.DESCRIPTION, + TagAttributes.NAME + ); + this.matchTerm = matchTerm; + } +} diff --git a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagQueryImpl.java b/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagQueryImpl.java index 582e31d52c1..612e77fe43f 100644 --- a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagQueryImpl.java +++ b/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagQueryImpl.java @@ -14,6 +14,7 @@ import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.service.tag.TagMatchPredicate; import org.eclipse.kapua.service.tag.TagQuery; /** @@ -32,4 +33,10 @@ public class TagQueryImpl extends AbstractKapuaNamedQuery implements TagQuery { public TagQueryImpl(KapuaId scopeId) { super(scopeId); } + + @Override + public TagMatchPredicate matchPredicate(T matchTerm) { + return new TagMatchPredicateImpl<>(matchTerm); + } + }