Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private class Profile extends AbstractModalPanel<T> {
protected Iterator<String> getChoices(final String input) {
return realmRestClient.search(fullRealmsTree
? RealmsUtils.buildBaseQuery()
: RealmsUtils.buildKeywordQuery(input)).getResult().stream().
: RealmsUtils.buildNameQuery(input)).getResult().stream().
map(RealmTO::getFullPath).iterator();
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ public void onClick(final AjaxRequestTarget target) {

List<ConnObject> listOfItems = reloadItems(resource.getKey(), anyType, null, null);

ListViewPanel.Builder<ConnObject> builder = new ListViewPanel.Builder<>(
ConnObject.class, pageRef) {
ListViewPanel.Builder<ConnObject> builder = new ListViewPanel.Builder<>(ConnObject.class, pageRef) {

private static final long serialVersionUID = -8251750413385566738L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ protected Iterator<String> getChoices(final String input) {
return (RealmsUtils.checkInput(input)
? (realmRestClient.search(fullRealmsTree
? RealmsUtils.buildBaseQuery()
: RealmsUtils.buildKeywordQuery(input)).getResult())
: RealmsUtils.buildNameQuery(input)).getResult())
: List.<RealmTO>of()).stream().
map(RealmTO::getFullPath).iterator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected Iterator<String> getChoices(final String input) {
return (RealmsUtils.checkInput(input)
? (realmRestClient.search(fullRealmsTree
? RealmsUtils.buildBaseQuery()
: RealmsUtils.buildKeywordQuery(input)).getResult())
: RealmsUtils.buildNameQuery(input)).getResult())
: List.<RealmTO>of()).stream().
map(RealmTO::getFullPath).iterator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public static boolean checkInput(final String input) {
return StringUtils.isNotBlank(input) && !"*".equals(input);
}

public static RealmQuery buildKeywordQuery(final String input) {
return new RealmQuery.Builder().keyword(input.contains("*") ? input : "*" + input + "*").build();
public static RealmQuery buildNameQuery(final String input) {
return new RealmQuery.Builder().fiql("name=~" + (input.contains("*") ? input : "*" + input + "*")).build();
}

public static RealmQuery buildBaseQuery() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ protected List<Pair<String, RealmTO>> load() {
Stream<Pair<String, RealmTO>> full;
if (fullRealmsTree) {
full = map.values().stream().
map(realmTOListPair ->
Pair.of(realmTOListPair.getLeft().getFullPath(), realmTOListPair.getKey())).
map(realmTOListPair
-> Pair.of(realmTOListPair.getLeft().getFullPath(), realmTOListPair.getKey())).
sorted(Comparator.comparing(Pair::getLeft));
} else {
full = map.entrySet().stream().
Expand Down Expand Up @@ -163,7 +163,7 @@ protected List<DynRealmTO> load() {
String rootRealmName = StringUtils.substringAfterLast(rootRealm, "/");

List<RealmTO> realmTOs = realmRestClient.search(
RealmsUtils.buildKeywordQuery(SyncopeConstants.ROOT_REALM.equals(rootRealm)
RealmsUtils.buildNameQuery(SyncopeConstants.ROOT_REALM.equals(rootRealm)
? SyncopeConstants.ROOT_REALM : rootRealmName)).getResult();

return realmTOs.stream().
Expand Down Expand Up @@ -455,7 +455,7 @@ public final RealmChoicePanel reloadRealmTree(final AjaxRequestTarget target, fi
protected Map<String, Pair<RealmTO, List<RealmTO>>> reloadRealmParentMap() {
List<RealmTO> realmsToList = realmRestClient.search(fullRealmsTree
? RealmsUtils.buildBaseQuery()
: RealmsUtils.buildKeywordQuery(searchQuery)).getResult();
: RealmsUtils.buildNameQuery(searchQuery)).getResult();

return reloadRealmParentMap(realmsToList.stream().
sorted(Comparator.comparing(RealmTO::getName)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected WizardModel buildModelSteps(final SchedTaskTO modelObject, final Wizar
protected List<String> searchRealms(final String realmQuery) {
return realmRestClient.search(fullRealmsTree
? RealmsUtils.buildBaseQuery()
: RealmsUtils.buildKeywordQuery(realmQuery)).
: RealmsUtils.buildNameQuery(realmQuery)).
getResult().stream().map(RealmTO::getFullPath).collect(Collectors.toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected Iterator<String> getChoices(final String input) {
? getRealmsFromLinks(realms.getRealmChoicePanel().getLinks())
: (fullRealmsTree
? realmRestClient.search(RealmsUtils.buildBaseQuery())
: realmRestClient.search(RealmsUtils.buildKeywordQuery(input))).getResult()).
: realmRestClient.search(RealmsUtils.buildNameQuery(input))).getResult()).
stream().map(RealmTO::getFullPath).
filter(fullPath -> authRealms.stream().anyMatch(
authRealm -> fullPath.startsWith(authRealm))).iterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public Realms(final RoleTO modelObject) {
protected Iterator<String> getChoices(final String input) {
return realmRestClient.search(fullRealmsTree
? RealmsUtils.buildBaseQuery()
: RealmsUtils.buildKeywordQuery(input)).getResult().stream().
: RealmsUtils.buildNameQuery(input)).getResult().stream().
map(RealmTO::getFullPath).iterator();
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.apache.syncope.common.lib.search.ConnObjectTOFiqlSearchConditionBuilder;
import org.apache.syncope.common.lib.search.GroupFiqlSearchConditionBuilder;
import org.apache.syncope.common.lib.search.OrderByClauseBuilder;
import org.apache.syncope.common.lib.search.RealmFiqlSearchConditionBuilder;
import org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder;
import org.apache.syncope.common.lib.to.UserTO;
import org.apache.syncope.common.rest.api.Preference;
Expand Down Expand Up @@ -77,6 +78,15 @@ public record JwtInfo(String value, OffsetDateTime expiration)

}

/**
* Returns a new instance of {@link RealmFiqlSearchConditionBuilder}, for assisted building of FIQL queries.
*
* @return default instance of {@link RealmFiqlSearchConditionBuilder}
*/
public static RealmFiqlSearchConditionBuilder getRealmFiqlSearchConditionBuilder() {
return new RealmFiqlSearchConditionBuilder();
}

/**
* Returns a new instance of {@link UserFiqlSearchConditionBuilder}, for assisted building of FIQL queries.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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 interface RealmCompleteCondition extends SyncopeCompleteCondition<RealmPartialCondition, RealmProperty> {
}
Original file line number Diff line number Diff line change
@@ -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;

import java.util.Map;

public class RealmFiqlSearchConditionBuilder
extends AbstractFiqlSearchConditionBuilder<RealmProperty, RealmPartialCondition, RealmCompleteCondition> {

private static final long serialVersionUID = 324753886224642253L;

protected static class Builder extends AbstractFiqlSearchConditionBuilder.Builder<
RealmProperty, RealmPartialCondition, RealmCompleteCondition>
implements RealmProperty, RealmPartialCondition, RealmCompleteCondition {

public Builder(final Map<String, String> properties) {
super(properties);
}

public Builder(final RealmFiqlSearchConditionBuilder.Builder parent) {
super(parent);
}
}

@Override
protected Builder newBuilderInstance() {
return new Builder(properties);
}

@Override
public RealmProperty is(final String property) {
return newBuilderInstance().is(property);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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 interface RealmPartialCondition extends SyncopePartialCondition<RealmProperty, RealmCompleteCondition> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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 interface RealmProperty extends SyncopeProperty<RealmCompleteCondition> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public Builder fiql(final String fiql) {
+ "primarily meant for containing Users, Groups and Any Objects", schema =
@Schema(implementation = String.class, defaultValue = SyncopeConstants.ROOT_REALM, externalDocs =
@ExternalDocumentation(description = "Apache Syncope Reference Guide",
url = "https://syncope.apache.org/docs/3.0/reference-guide.html#realms")))
url = "https://syncope.apache.org/docs/4.0/reference-guide.html#realms")))
public String getRealm() {
return realm;
}
Expand Down Expand Up @@ -120,7 +120,7 @@ public String getFiql() {
+ "feed.", example = "username==rossini", schema =
@Schema(implementation = String.class, externalDocs =
@ExternalDocumentation(description = "Apache Syncope Reference Guide",
url = "https://syncope.apache.org/docs/3.0/reference-guide.html#search")))
url = "https://syncope.apache.org/docs/4.0/reference-guide.html#search")))
@QueryParam(JAXRSService.PARAM_FIQL)
public void setFiql(final String fiql) {
this.fiql = fiql;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
package org.apache.syncope.common.rest.api.beans;

import io.swagger.v3.oas.annotations.ExternalDocumentation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.ws.rs.QueryParam;
import java.util.Collection;
import java.util.HashSet;
Expand All @@ -27,6 +30,7 @@
import java.util.stream.Stream;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.syncope.common.rest.api.service.JAXRSService;

public class RealmQuery extends AbstractQuery {

Expand All @@ -39,8 +43,8 @@ protected RealmQuery newInstance() {
return new RealmQuery();
}

public Builder keyword(final String keyword) {
getInstance().setKeyword(keyword);
public Builder fiql(final String fiql) {
getInstance().setFiql(fiql);
return this;
}

Expand All @@ -63,17 +67,23 @@ public Builder bases(final Collection<String> bases) {
}
}

private String keyword;
private String fiql;

private Set<String> bases;

public String getKeyword() {
return keyword;
public String getFiql() {
return fiql;
}

@QueryParam("keyword")
public void setKeyword(final String keyword) {
this.keyword = keyword;
@Parameter(name = JAXRSService.PARAM_FIQL, description = "Feed Item Query Language (FIQL, pronounced “fickle”) is "
+ "a simple but flexible, URI-friendly syntax for expressing filters across the entries in a syndicated "
+ "feed.", example = "name==department1", schema =
@Schema(implementation = String.class, externalDocs =
@ExternalDocumentation(description = "Apache Syncope Reference Guide",
url = "https://syncope.apache.org/docs/4.0/reference-guide.html#search")))
@QueryParam(JAXRSService.PARAM_FIQL)
public void setFiql(final String fiql) {
this.fiql = fiql;
}

public Set<String> getBases() {
Expand All @@ -99,7 +109,7 @@ public boolean equals(final Object obj) {
RealmQuery other = (RealmQuery) obj;
return new EqualsBuilder().
appendSuper(super.equals(obj)).
append(keyword, other.keyword).
append(fiql, other.fiql).
append(bases, other.bases).
build();
}
Expand All @@ -108,7 +118,7 @@ public boolean equals(final Object obj) {
public int hashCode() {
return new HashCodeBuilder().
appendSuper(super.hashCode()).
append(keyword).
append(fiql).
append(bases).
build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ public List<ProvisioningReport> push(
orElseThrow(() -> new NotFoundException("Realm " + realm));

Set<String> adminRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(entitlement), realm);
SearchCond effectiveCond = searchCond == null ? anyUtils.dao().getAllMatchingCond() : searchCond;
SearchCond effectiveCond = searchCond == null ? anySearchDAO.getAllMatchingCond() : searchCond;

List<Any> matching;
if (spec.getIgnorePaging()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.apache.syncope.core.logic.RemediationLogic;
import org.apache.syncope.core.logic.ResourceLogic;
import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
import org.apache.syncope.core.persistence.api.search.SearchCondVisitor;
import org.apache.syncope.core.persistence.api.search.AnySearchCondVisitor;
import org.apache.syncope.core.rest.cxf.service.ConnectorServiceImpl;
import org.apache.syncope.core.rest.cxf.service.ReconciliationServiceImpl;
import org.apache.syncope.core.rest.cxf.service.RemediationServiceImpl;
Expand All @@ -48,7 +48,7 @@ public ConnectorService connectorService(final ConnectorLogic connectorLogic) {
@ConditionalOnMissingBean
@Bean
public ReconciliationService reconciliationService(
final SearchCondVisitor searchCondVisitor,
final AnySearchCondVisitor searchCondVisitor,
final ReconciliationLogic reconciliationLogic) {

return new ReconciliationServiceImpl(searchCondVisitor, reconciliationLogic);
Expand Down
Loading