View Javadoc
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.java.pushpull.stream;
20  
21  import java.util.Set;
22  import java.util.stream.Stream;
23  import org.apache.commons.lang3.tuple.Pair;
24  import org.apache.syncope.common.lib.to.Item;
25  import org.apache.syncope.common.lib.to.Provision;
26  import org.apache.syncope.common.lib.to.ProvisioningReport;
27  import org.apache.syncope.common.lib.types.ResourceOperation;
28  import org.apache.syncope.core.persistence.api.entity.Any;
29  import org.apache.syncope.core.provisioning.api.DerAttrHandler;
30  import org.apache.syncope.core.provisioning.api.propagation.PropagationReporter;
31  import org.apache.syncope.core.provisioning.api.propagation.PropagationTaskInfo;
32  import org.apache.syncope.core.provisioning.java.propagation.DefaultPropagationReporter;
33  import org.apache.syncope.core.provisioning.java.pushpull.DefaultGroupPushResultHandler;
34  import org.apache.syncope.core.provisioning.java.utils.MappingUtils;
35  import org.identityconnectors.framework.common.objects.Attribute;
36  import org.springframework.beans.factory.annotation.Autowired;
37  
38  public class StreamGroupPushResultHandler extends DefaultGroupPushResultHandler {
39  
40      @Autowired
41      private DerAttrHandler derAttrHandler;
42  
43      @Override
44      protected void provision(final Any<?> any, final Boolean enabled, final ProvisioningReport result) {
45          Provision provision = profile.getTask().getResource().getProvisions().get(0);
46  
47          Stream<Item> items = MappingUtils.getPropagationItems(provision.getMapping().getItems().stream());
48  
49          Pair<String, Set<Attribute>> preparedAttrs = mappingManager.prepareAttrsFromAny(
50                  any, null, false, enabled, profile.getTask().getResource(), provision);
51  
52          PropagationTaskInfo propagationTask = propagationManager.newTask(
53                  derAttrHandler,
54                  any,
55                  profile.getTask().getResource(),
56                  ResourceOperation.CREATE,
57                  provision,
58                  items,
59                  preparedAttrs);
60          propagationTask.setConnector(profile.getConnector());
61          LOG.debug("PropagationTask created: {}", propagationTask);
62  
63          PropagationReporter reporter = new DefaultPropagationReporter();
64          taskExecutor.execute(propagationTask, reporter, profile.getExecutor());
65          reportPropagation(result, reporter);
66      }
67  }