1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.syncope.core.provisioning.api.rules; 20 21 import java.util.Optional; 22 import org.apache.syncope.common.lib.policy.PullCorrelationRuleConf; 23 import org.apache.syncope.common.lib.to.Provision; 24 import org.apache.syncope.common.lib.types.MatchType; 25 import org.apache.syncope.core.persistence.api.dao.search.SearchCond; 26 import org.apache.syncope.core.persistence.api.entity.Any; 27 import org.identityconnectors.framework.common.objects.SyncDelta; 28 29 /** 30 * Interface for correlation rule to be evaluated during PullJob execution. 31 */ 32 @FunctionalInterface 33 public interface PullCorrelationRule { 34 35 PullMatch NO_MATCH = new PullMatch(MatchType.ANY, null); 36 37 default void setConf(PullCorrelationRuleConf conf) { 38 } 39 40 /** 41 * Return a search condition. 42 * 43 * @param syncDelta change operation, including external attributes 44 * @param provision resource provision 45 * @return search condition. 46 */ 47 SearchCond getSearchCond(SyncDelta syncDelta, Provision provision); 48 49 /** 50 * Create matching information for the given Any, found matching for the given 51 * {@link SyncDelta} and {@link Provision}. 52 * For users, this might end with creating / updating / deleting a 53 * {@link org.apache.syncope.core.persistence.api.entity.user.LinkedAccount}. 54 * 55 * @param any any 56 * @param syncDelta change operation, including external attributes 57 * @param provision resource provision 58 * @return matching information 59 */ 60 default PullMatch matching(Any<?> any, SyncDelta syncDelta, Provision provision) { 61 return new PullMatch(MatchType.ANY, any); 62 } 63 64 /** 65 * Optionally create matching information in case no matching Any was found for the given 66 * {@link SyncDelta} and {@link Provision}. 67 * For users, this might end with creating a 68 * {@link org.apache.syncope.core.persistence.api.entity.user.LinkedAccount}. 69 * 70 * @param syncDelta change operation, including external attributes 71 * @param provision resource provision 72 * @return matching information 73 */ 74 default Optional<PullMatch> unmatching(SyncDelta syncDelta, Provision provision) { 75 return Optional.of(NO_MATCH); 76 } 77 }