Skip to content

Commit

Permalink
Merge branch 'backport-4080' into release-1.6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Coduz committed Jul 11, 2024
2 parents 7e95ee2 + 9213d4b commit ae6fdf6
Show file tree
Hide file tree
Showing 31 changed files with 430 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,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);
Expand All @@ -75,10 +77,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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,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);
Expand All @@ -73,10 +75,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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,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 {
Expand All @@ -100,6 +101,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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,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);
Expand All @@ -75,6 +76,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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
10 changes: 10 additions & 0 deletions rest-api/resources/src/main/resources/openapi/tag/tag-scopeId.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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<T> extends MatchPredicate<T> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T> The type of the term
* @return The newly instantiated {@link EndpointInfoMatchPredicate}.
* @since 2.1.0
*/
<T> EndpointInfoMatchPredicate<T> matchPredicate(T matchTerm);
}
Original file line number Diff line number Diff line change
@@ -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<T> extends AbstractMatchPredicate<T> implements EndpointInfoMatchPredicate<T> {

/**
* Constructor.
*
* @param matchTerm
* @since 2.1.0
*/
public EndpointInfoMatchPredicateImpl(T matchTerm) {
this.attributeNames = Arrays.asList(
EndpointInfoAttributes.SCHEMA,
EndpointInfoAttributes.DNS
);
this.matchTerm = matchTerm;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -32,4 +33,9 @@ public class EndpointInfoQueryImpl extends AbstractKapuaQuery implements Endpoin
public EndpointInfoQueryImpl(KapuaId scopeId) {
super(scopeId);
}

@Override
public <T> EndpointInfoMatchPredicate<T> matchPredicate(T matchTerm) {
return new EndpointInfoMatchPredicateImpl<>(matchTerm);
}
}
Original file line number Diff line number Diff line change
@@ -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<T> extends MatchPredicate<T> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T> The type of the term
* @return The newly instantiated {@link GroupMatchPredicate}.
* @since 2.1.0
*/
<T> GroupMatchPredicate<T> matchPredicate(T matchTerm);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
* @since 1.0.0
*/
public class RoleAttributes extends KapuaNamedEntityAttributes {

}
Original file line number Diff line number Diff line change
@@ -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<T> extends MatchPredicate<T> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T> The type of the term
* @return The newly instantiated {@link RoleMatchPredicate}.
* @since 2.1.0
*/
<T> RoleMatchPredicate<T> matchPredicate(T matchTerm);

}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";



}
Original file line number Diff line number Diff line change
@@ -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<T> extends MatchPredicate<T> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,14 @@ public interface CertificateInfoQuery extends KapuaQuery {
* @since 1.1.0
*/
void setIncludeInherited(Boolean includeInherited);

/**
* Instantiates a new {@link CertificateInfoMatchPredicate}.
*
* @param matchTerm The term to use to match.
* @param <T> The type of the term
* @return The newly instantiated {@link CertificateInfoMatchPredicate}.
* @since 2.1.0
*/
<T> CertificateInfoMatchPredicate<T> matchPredicate(T matchTerm);
}
Loading

0 comments on commit ae6fdf6

Please sign in to comment.