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;
20  
21  import org.apache.syncope.common.lib.request.AnyUR;
22  import org.apache.syncope.common.lib.to.AnyTO;
23  import org.apache.syncope.core.persistence.api.entity.Any;
24  import org.apache.syncope.core.persistence.api.entity.AnyUtils;
25  import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
26  import org.apache.syncope.core.persistence.api.entity.task.ProvisioningTask;
27  import org.apache.syncope.core.provisioning.api.WorkflowResult;
28  import org.apache.syncope.core.provisioning.api.data.AnyObjectDataBinder;
29  import org.apache.syncope.core.provisioning.api.data.GroupDataBinder;
30  import org.apache.syncope.core.provisioning.api.data.UserDataBinder;
31  import org.apache.syncope.core.provisioning.api.propagation.PropagationManager;
32  import org.apache.syncope.core.provisioning.api.propagation.PropagationTaskExecutor;
33  import org.apache.syncope.core.provisioning.api.pushpull.ProvisioningActions;
34  import org.apache.syncope.core.provisioning.api.pushpull.ProvisioningProfile;
35  import org.apache.syncope.core.provisioning.api.pushpull.SyncopeResultHandler;
36  import org.apache.syncope.core.spring.security.SecurityProperties;
37  import org.apache.syncope.core.workflow.api.AnyObjectWorkflowAdapter;
38  import org.apache.syncope.core.workflow.api.GroupWorkflowAdapter;
39  import org.apache.syncope.core.workflow.api.UserWorkflowAdapter;
40  import org.slf4j.Logger;
41  import org.slf4j.LoggerFactory;
42  import org.springframework.beans.factory.annotation.Autowired;
43  
44  public abstract class AbstractSyncopeResultHandler<T extends ProvisioningTask<?>, A extends ProvisioningActions>
45          implements SyncopeResultHandler<T, A> {
46  
47      protected static final Logger LOG = LoggerFactory.getLogger(SyncopeResultHandler.class);
48  
49      /**
50       * Propagation manager.
51       */
52      @Autowired
53      protected PropagationManager propagationManager;
54  
55      /**
56       * Task executor.
57       */
58      @Autowired
59      protected PropagationTaskExecutor taskExecutor;
60  
61      @Autowired
62      protected AnyObjectWorkflowAdapter awfAdapter;
63  
64      /**
65       * User workflow adapter.
66       */
67      @Autowired
68      protected UserWorkflowAdapter uwfAdapter;
69  
70      /**
71       * Group workflow adapter.
72       */
73      @Autowired
74      protected GroupWorkflowAdapter gwfAdapter;
75  
76      @Autowired
77      protected AnyObjectDataBinder anyObjectDataBinder;
78  
79      @Autowired
80      protected UserDataBinder userDataBinder;
81  
82      @Autowired
83      protected GroupDataBinder groupDataBinder;
84  
85      @Autowired
86      protected AnyUtilsFactory anyUtilsFactory;
87  
88      @Autowired
89      protected SecurityProperties securityProperties;
90  
91      /**
92       * Provisioning profile.
93       */
94      protected ProvisioningProfile<T, A> profile;
95  
96      protected abstract AnyUtils getAnyUtils();
97  
98      protected abstract AnyTO getAnyTO(Any<?> any);
99  
100     protected abstract WorkflowResult<? extends AnyUR> update(AnyUR req);
101 
102     @Override
103     public void setProfile(final ProvisioningProfile<T, A> profile) {
104         this.profile = profile;
105     }
106 
107     protected String getContext() {
108         return (getClass().getSimpleName().contains("Pull") ? "PullTask" : "PushTask")
109                 + " " + profile.getTask().getKey() + " '" + profile.getTask().getName() + "'";
110     }
111 }