http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/JobNamer.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/JobNamer.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/JobNamer.java new file mode 100644 index 0000000..2944fb1 --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/JobNamer.java @@ -0,0 +1,72 @@ +/* + * 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.core.provisioning.api.job; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.syncope.core.persistence.api.entity.Report; +import org.apache.syncope.core.persistence.api.entity.task.Task; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public final class JobNamer { + + private static final Logger LOG = LoggerFactory.getLogger(JobNamer.class); + + private static Long getIdFromJobName(final String name, final String pattern, final int prefixLength) { + Long result = null; + + Matcher jobMatcher = Pattern.compile(pattern).matcher(name); + if (jobMatcher.matches()) { + try { + result = Long.valueOf(name.substring(prefixLength)); + } catch (NumberFormatException e) { + LOG.error("Unparsable id: {}", name.substring(prefixLength), e); + } + } + + return result; + } + + public static Long getTaskIdFromJobName(final String name) { + return getIdFromJobName("taskJob[0-9]+", name, 7); + } + + public static Long getReportIdFromJobName(final String name) { + return getIdFromJobName("reportJob[0-9]+", name, 9); + } + + public static String getJobName(final Task task) { + return task == null + ? "taskNotificationJob" + : "taskJob" + task.getKey(); + } + + public static String getJobName(final Report report) { + return "reportJob" + report.getKey(); + } + + public static String getTriggerName(final String jobName) { + return "Trigger_" + jobName; + } + + private JobNamer() { + // private constructor for static utility class + } +}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/ProvisioningJob.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/ProvisioningJob.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/ProvisioningJob.java new file mode 100644 index 0000000..9a6386f --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/ProvisioningJob.java @@ -0,0 +1,28 @@ +/* + * 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.core.provisioning.api.job; + +import java.util.List; +import org.apache.syncope.core.persistence.api.entity.task.ProvisioningTask; +import org.apache.syncope.core.provisioning.api.sync.ProvisioningActions; + +public interface ProvisioningJob<T extends ProvisioningTask, A extends ProvisioningActions> extends TaskJob { + + void setActions(List<A> actions); +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/PushJob.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/PushJob.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/PushJob.java new file mode 100644 index 0000000..388d780 --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/PushJob.java @@ -0,0 +1,26 @@ +/* + * 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.core.provisioning.api.job; + +import org.apache.syncope.core.persistence.api.entity.task.PushTask; +import org.apache.syncope.core.provisioning.api.sync.PushActions; + +public interface PushJob extends ProvisioningJob<PushTask, PushActions> { + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/SyncJob.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/SyncJob.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/SyncJob.java new file mode 100644 index 0000000..147daa5 --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/SyncJob.java @@ -0,0 +1,26 @@ +/* + * 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.core.provisioning.api.job; + +import org.apache.syncope.core.persistence.api.entity.task.SyncTask; +import org.apache.syncope.core.provisioning.api.sync.SyncActions; + +public interface SyncJob extends ProvisioningJob<SyncTask, SyncActions> { + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/TaskJob.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/TaskJob.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/TaskJob.java new file mode 100644 index 0000000..9820406 --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/TaskJob.java @@ -0,0 +1,43 @@ +/* + * 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.core.provisioning.api.job; + +import org.quartz.DisallowConcurrentExecution; +import org.quartz.Job; + +/** + * Interface for Quartz jobs bound to a given Task. + */ +@DisallowConcurrentExecution +public interface TaskJob extends Job { + + public static final String DRY_RUN_JOBDETAIL_KEY = "dryRun"; + + /** + * Task execution status. + */ + public enum Status { + + SUCCESS, + FAILURE + + } + + void setTaskId(Long taskId); +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/notification/NotificationManager.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/notification/NotificationManager.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/notification/NotificationManager.java new file mode 100644 index 0000000..98281f2 --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/notification/NotificationManager.java @@ -0,0 +1,65 @@ +/* + * 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.core.provisioning.api.notification; + +import org.apache.syncope.common.lib.types.AuditElements; +import org.apache.syncope.core.persistence.api.entity.task.TaskExec; + +/** + * Create notification tasks that will be executed by NotificationJob. + * + * @see org.apache.syncope.core.persistence.api.entity.task.NotificationTask + */ +public interface NotificationManager { + + /** + * Count the number of task executions of a given task with a given status. + * + * @param taskId task id + * @param status status + * @return number of task executions + */ + long countExecutionsWithStatus(final Long taskId, final String status); + + /** + * Create notification tasks for each notification matching the given user id and (some of) tasks performed. + */ + void createTasks(final AuditElements.EventCategoryType type, final String category, final String subcategory, + final String event, final AuditElements.Result condition, final Object before, final Object output, + final Object... input); + + long getMaxRetries(); + + /** + * Set execution state of NotificationTask with provided id. + * + * @param taskId task to be updated + * @param executed execution state + */ + void setTaskExecuted(final Long taskId, final boolean executed); + + /** + * Store execution of a NotificationTask. + * + * @param execution task execution. + * @return merged task execution. + */ + TaskExec storeExec(final TaskExec execution); + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationActions.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationActions.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationActions.java new file mode 100644 index 0000000..864ec4b --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationActions.java @@ -0,0 +1,30 @@ +/* + * 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.core.provisioning.api.propagation; + +import org.apache.syncope.core.persistence.api.entity.task.PropagationTask; +import org.apache.syncope.core.persistence.api.entity.task.TaskExec; +import org.identityconnectors.framework.common.objects.ConnectorObject; + +public interface PropagationActions { + + void before(PropagationTask task, ConnectorObject beforeObj); + + void after(PropagationTask task, TaskExec execution, ConnectorObject afterObj); +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationException.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationException.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationException.java new file mode 100644 index 0000000..8e47872 --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationException.java @@ -0,0 +1,51 @@ +/* + * 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.core.provisioning.api.propagation; + +/** + * Bear stacktrace received during propagation towards a certain resource. + */ +public class PropagationException extends RuntimeException { + + private static final long serialVersionUID = -4828426289616526116L; + + /** + * The resource involved in this exception. + */ + private final String resourceName; + + /** + * Create a new instance based on resource name and original stacktrace received during propagation. + * + * @param resourceName name of resource involved in this exception + * @param stackTrace original stacktrace + */ + public PropagationException(final String resourceName, final String stackTrace) { + super("Exception during provision on resource " + resourceName + "\n" + stackTrace); + + this.resourceName = resourceName; + } + + /** + * @return name of resource involved in this exception + */ + public String getResourceName() { + return resourceName; + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationManager.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationManager.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationManager.java new file mode 100644 index 0000000..e11c5c8 --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationManager.java @@ -0,0 +1,249 @@ +/* + * 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.core.provisioning.api.propagation; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.apache.syncope.common.lib.mod.AttrMod; +import org.apache.syncope.common.lib.mod.MembershipMod; +import org.apache.syncope.common.lib.mod.UserMod; +import org.apache.syncope.common.lib.to.AttrTO; +import org.apache.syncope.common.lib.to.MembershipTO; +import org.apache.syncope.common.lib.types.PropagationByResource; +import org.apache.syncope.core.persistence.api.entity.Subject; +import org.apache.syncope.core.persistence.api.entity.task.PropagationTask; +import org.apache.syncope.core.persistence.api.entity.user.User; +import org.apache.syncope.core.provisioning.api.WorkflowResult; + +public interface PropagationManager { + + /** + * Create the role on every associated resource. + * + * @param wfResult user to be propagated (and info associated), as per result from workflow + * @param vAttrs virtual attributes to be set + * @return list of propagation tasks + */ + List<PropagationTask> getRoleCreateTaskIds(WorkflowResult<Long> wfResult, List<AttrTO> vAttrs); + + /** + * Create the role on every associated resource. + * + * @param wfResult role to be propagated (and info associated), as per result from workflow + * @param vAttrs virtual attributes to be set + * @param noPropResourceNames external resources performing not to be considered for propagation + * @return list of propagation tasks + */ + List<PropagationTask> getRoleCreateTaskIds( + WorkflowResult<Long> wfResult, Collection<AttrTO> vAttrs, Collection<String> noPropResourceNames); + + /** + * Create the role on every associated resource. + * + * @param key role id + * @param vAttrs virtual attributes to be set + * @param propByRes operation to be performed per resource + * @param noPropResourceNames external resources performing not to be considered for propagation + * @return list of propagation tasks + */ + List<PropagationTask> getRoleCreateTaskIds(Long key, Collection<AttrTO> vAttrs, PropagationByResource propByRes, + Collection<String> noPropResourceNames); + + /** + * Perform delete on each resource associated to the role. It is possible to ask for a mandatory provisioning for + * some resources specifying a set of resource names. Exceptions won't be ignored and the process will be stopped if + * the creation fails onto a mandatory resource. + * + * @param roleId to be deleted + * @return list of propagation tasks + */ + List<PropagationTask> getRoleDeleteTaskIds(Long roleId); + + /** + * Perform delete on each resource associated to the role. It is possible to ask for a mandatory provisioning for + * some resources specifying a set of resource names. Exceptions won't be ignored and the process will be stopped if + * the creation fails onto a mandatory resource. + * + * @param roleId to be deleted + * @param noPropResourceName name of external resource not to be considered for propagation + * @return list of propagation tasks + */ + List<PropagationTask> getRoleDeleteTaskIds(Long roleId, String noPropResourceName); + + /** + * Perform delete on each resource associated to the user. It is possible to ask for a mandatory provisioning for + * some resources specifying a set of resource names. Exceptions won't be ignored and the process will be stopped if + * the creation fails onto a mandatory resource. + * + * @param roleId to be deleted + * @param noPropResourceNames name of external resources not to be considered for propagation + * @return list of propagation tasks + */ + List<PropagationTask> getRoleDeleteTaskIds(Long roleId, Collection<String> noPropResourceNames); + + /** + * Perform delete on each resource associated to the user. It is possible to ask for a mandatory provisioning for + * some resources specifying a set of resource names. Exceptions won't be ignored and the process will be stopped if + * the creation fails onto a mandatory resource. + * + * @param roleId to be deleted + * @param noPropResourceNames name of external resources not to be considered for propagation + * @return list of propagation tasks + */ + List<PropagationTask> getRoleDeleteTaskIds( + Long roleId, Set<String> resourceNames, Collection<String> noPropResourceNames); + + /** + * Performs update on each resource associated to the role. + * + * @param wfResult role to be propagated (and info associated), as per result from workflow + * @param vAttrsToBeRemoved virtual attributes to be removed + * @param vAttrsToBeUpdated virtual attributes to be added + * @return list of propagation tasks + */ + List<PropagationTask> getRoleUpdateTaskIds(WorkflowResult<Long> wfResult, Set<String> vAttrsToBeRemoved, + Set<AttrMod> vAttrsToBeUpdated); + + /** + * Performs update on each resource associated to the role. + * + * @param wfResult role to be propagated (and info associated), as per result from workflow + * @param vAttrsToBeRemoved virtual attributes to be removed + * @param vAttrsToBeUpdated virtual attributes to be added + * @param noPropResourceNames external resource names not to be considered for propagation + * @return list of propagation tasks + */ + List<PropagationTask> getRoleUpdateTaskIds(WorkflowResult<Long> wfResult, Set<String> vAttrsToBeRemoved, + Set<AttrMod> vAttrsToBeUpdated, Set<String> noPropResourceNames); + + List<PropagationTask> getUpdateTaskIds(Subject<?, ?, ?> subject, String password, boolean changePwd, + Boolean enable, Set<String> vAttrsToBeRemoved, Set<AttrMod> vAttrsToBeUpdated, + PropagationByResource propByRes, Collection<String> noPropResourceNames, + Set<MembershipMod> membershipsToAdd); + + /** + * Create the user on every associated resource. + * + * @param wfResult user to be propagated (and info associated), as per result from workflow + * @param password to be set + * @param vAttrs virtual attributes to be set + * @param membershipTOs user memberships + * @return list of propagation tasks + */ + List<PropagationTask> getUserCreateTaskIds(WorkflowResult<Map.Entry<Long, Boolean>> wfResult, + String password, List<AttrTO> vAttrs, List<MembershipTO> membershipTOs); + + /** + * Create the user on every associated resource. + * + * @param wfResult user to be propagated (and info associated), as per result from workflow + * @param password to be set + * @param vAttrs virtual attributes to be set + * @param noPropResourceNames external resources not to be considered for propagation + * @param membershipTOs user memberships + * @return list of propagation tasks + */ + List<PropagationTask> getUserCreateTaskIds(WorkflowResult<Map.Entry<Long, Boolean>> wfResult, + String password, Collection<AttrTO> vAttrs, Set<String> noPropResourceNames, + List<MembershipTO> membershipTOs); + + List<PropagationTask> getUserCreateTaskIds(Long key, Boolean enabled, + PropagationByResource propByRes, String password, Collection<AttrTO> vAttrs, + Collection<MembershipTO> membershipTOs, Collection<String> noPropResourceNames); + + /** + * Perform delete on each resource associated to the user. It is possible to ask for a mandatory provisioning for + * some resources specifying a set of resource names. Exceptions won't be ignored and the process will be stopped if + * the creation fails onto a mandatory resource. + * + * @param userKey to be deleted + * @return list of propagation tasks + */ + List<PropagationTask> getUserDeleteTaskIds(Long userKey); + + /** + * Perform delete on each resource associated to the user. It is possible to ask for a mandatory provisioning for + * some resources specifying a set of resource names. Exceptions won't be ignored and the process will be stopped if + * the creation fails onto a mandatory resource. + * + * @param userKey to be deleted + * @param noPropResourceName name of external resource not to be considered for propagation + * @return list of propagation tasks + */ + List<PropagationTask> getUserDeleteTaskIds(Long userKey, String noPropResourceName); + + /** + * Perform delete on each resource associated to the user. It is possible to ask for a mandatory provisioning for + * some resources specifying a set of resource names. Exceptions won't be ignored and the process will be stopped if + * the creation fails onto a mandatory resource. + * + * @param userKey to be deleted + * @param noPropResourceNames name of external resources not to be considered for propagation + * @return list of propagation tasks + */ + List<PropagationTask> getUserDeleteTaskIds(Long userKey, Collection<String> noPropResourceNames); + + /** + * Perform delete on each resource associated to the user. It is possible to ask for a mandatory provisioning for + * some resources specifying a set of resource names. Exceptions won't be ignored and the process will be stopped if + * the creation fails onto a mandatory resource. + * + * @param userKey to be deleted + * @param noPropResourceNames name of external resources not to be considered for propagation + * @return list of propagation tasks + */ + List<PropagationTask> getUserDeleteTaskIds( + Long userKey, Set<String> resourceNames, Collection<String> noPropResourceNames); + + /** + * Perform delete on each resource associated to the user. It is possible to ask for a mandatory provisioning for + * some resources specifying a set of resource names. Exceptions won't be ignored and the process will be stopped if + * the creation fails onto a mandatory resource. + * + * @param wfResult user to be propagated (and info associated), as per result from workflow + * @return list of propagation tasks + */ + List<PropagationTask> getUserDeleteTaskIds(WorkflowResult<Long> wfResult); + + /** + * Performs update on each resource associated to the user excluding the specified into 'resourceNames' parameter. + * + * @param user to be propagated + * @param enable whether user must be enabled or not + * @param noPropResourceNames external resource names not to be considered for propagation + * @return list of propagation tasks + */ + List<PropagationTask> getUserUpdateTaskIds(User user, Boolean enable, Set<String> noPropResourceNames); + + /** + * Performs update on each resource associated to the user. + * + * @param wfResult user to be propagated (and info associated), as per result from workflow + * @param changePwd whether password should be included for propagation attributes or not + * @param noPropResourceNames external resources not to be considered for propagation + * @return list of propagation tasks + */ + List<PropagationTask> getUserUpdateTaskIds(WorkflowResult<Map.Entry<UserMod, Boolean>> wfResult, + boolean changePwd, Collection<String> noPropResourceNames); + + List<PropagationTask> getUserUpdateTaskIds(WorkflowResult<Map.Entry<UserMod, Boolean>> wfResult); + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationReporter.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationReporter.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationReporter.java new file mode 100644 index 0000000..20ae8df --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationReporter.java @@ -0,0 +1,58 @@ +/* + * 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.core.provisioning.api.propagation; + +import java.util.List; +import org.apache.syncope.common.lib.to.PropagationStatus; +import org.apache.syncope.common.lib.types.PropagationTaskExecStatus; +import org.apache.syncope.core.persistence.api.entity.task.PropagationTask; +import org.identityconnectors.framework.common.objects.ConnectorObject; + +/** + * Report propagation status after executions. + */ +public interface PropagationReporter { + + /** + * Report propagation status after executions in case of success or non-blocking failure + * (e.g. on secondary resources). + * + * @param resourceName resource name. + * @param execStatus propagation execution status. + * @param failureReason propagation execution failure message. + * @param beforeObj retrieved connector object before operation execution. + * @param afterObj retrieved connector object after operation execution. + */ + void onSuccessOrSecondaryResourceFailures(String resourceName, PropagationTaskExecStatus execStatus, + String failureReason, ConnectorObject beforeObj, ConnectorObject afterObj); + + /** + * Report propagation status after executions in case blocking failure (e.g. on primary resources). + * + * @param tasks propagation tasks performed before failure + */ + void onPrimaryResourceFailure(List<PropagationTask> tasks); + + /** + * Returns the list of propagation statuses. + * + * @return the list of propagation statuses + */ + List<PropagationStatus> getStatuses(); +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationTaskExecutor.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationTaskExecutor.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationTaskExecutor.java new file mode 100644 index 0000000..d3b8870 --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationTaskExecutor.java @@ -0,0 +1,77 @@ +/* + * 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.core.provisioning.api.propagation; + +import java.util.Collection; +import org.apache.syncope.core.persistence.api.entity.task.PropagationTask; +import org.apache.syncope.core.persistence.api.entity.task.TaskExec; + +/** + * Execute propagation tasks. + * + * @see PropagationTask + */ +public interface PropagationTaskExecutor { + + /** + * Name for special propagation attribute used to indicate whether there are attributes, marked as mandatory in the + * mapping but not to be propagated. + */ + String MANDATORY_MISSING_ATTR_NAME = "__MANDATORY_MISSING__"; + + /** + * Name for special propagation attribute used to indicate whether there are attributes, marked as mandatory in the + * mapping but about to be propagated as null or empty. + */ + String MANDATORY_NULL_OR_EMPTY_ATTR_NAME = "__MANDATORY_NULL_OR_EMPTY__"; + + /** + * Execute the given PropagationTask and returns the generated TaskExec. + * + * @param task to be executed + * @return the generated TaskExec + */ + TaskExec execute(PropagationTask task); + + /** + * Execute the given PropagationTask, invoke the given handler and returns the generated TaskExec. + * + * @param task to be executed + * @param reporter to report propagation execution status + * @return the generated TaskExec + */ + TaskExec execute(PropagationTask task, PropagationReporter reporter); + + /** + * Execute a collection of PropagationTask objects. + * The process is interrupted as soon as the result of the communication with a primary resource is in error. + * + * @param tasks to be executed + */ + void execute(Collection<PropagationTask> tasks); + + /** + * Execute a collection of PropagationTask objects and invoke the given handler on each of these. + * The process is interrupted as soon as the result of the communication with a primary resource is in error. + * + * @param tasks to be execute, in given order + * @param reporter to report propagation execution status + */ + void execute(Collection<PropagationTask> tasks, PropagationReporter reporter); +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/ProvisioningActions.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/ProvisioningActions.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/ProvisioningActions.java new file mode 100644 index 0000000..02e6979 --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/ProvisioningActions.java @@ -0,0 +1,40 @@ +/* + * 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.core.provisioning.api.sync; + +import org.quartz.JobExecutionException; + +public interface ProvisioningActions { + + /** + * Action to be executed before to start the synchronization task execution. + * + * @param profile sync profile + * @throws JobExecutionException in case of generic failure + */ + void beforeAll(final ProvisioningProfile<?, ?> profile) throws JobExecutionException; + + /** + * Action to be executed after the synchronization task completion. + * + * @param profile sync profile + * @throws JobExecutionException in case of generic failure + */ + void afterAll(final ProvisioningProfile<?, ?> profile) throws JobExecutionException; +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/ProvisioningProfile.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/ProvisioningProfile.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/ProvisioningProfile.java new file mode 100644 index 0000000..3f633a4 --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/ProvisioningProfile.java @@ -0,0 +1,81 @@ +/* + * 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.core.provisioning.api.sync; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import org.apache.syncope.common.lib.types.ConflictResolutionAction; +import org.apache.syncope.core.persistence.api.entity.task.ProvisioningTask; +import org.apache.syncope.core.provisioning.api.Connector; + +public class ProvisioningProfile<T extends ProvisioningTask, A extends ProvisioningActions> { + + /** + * Syncing connector. + */ + private final Connector connector; + + private final T task; + + private final List<ProvisioningResult> results = new ArrayList<>(); + + private boolean dryRun; + + private ConflictResolutionAction resAct; + + private List<A> actions = new ArrayList<>(); + + public ProvisioningProfile(final Connector connector, final T task) { + this.connector = connector; + this.task = task; + } + + public Connector getConnector() { + return connector; + } + + public T getTask() { + return task; + } + + public Collection<ProvisioningResult> getResults() { + return results; + } + + public boolean isDryRun() { + return dryRun; + } + + public void setDryRun(final boolean dryRun) { + this.dryRun = dryRun; + } + + public ConflictResolutionAction getResAct() { + return resAct; + } + + public void setResAct(final ConflictResolutionAction resAct) { + this.resAct = resAct; + } + + public List<A> getActions() { + return actions; + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/ProvisioningResult.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/ProvisioningResult.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/ProvisioningResult.java new file mode 100644 index 0000000..8061dba --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/ProvisioningResult.java @@ -0,0 +1,140 @@ +/* + * 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.core.provisioning.api.sync; + +import java.util.Collection; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import org.apache.syncope.common.lib.types.AttributableType; +import org.apache.syncope.common.lib.types.ResourceOperation; +import org.apache.syncope.common.lib.types.TraceLevel; + +public class ProvisioningResult { + + public enum Status { + + SUCCESS, + FAILURE + + } + + private String message; + + private Status status; + + private AttributableType subjectType; + + private ResourceOperation operation; + + private Long id; + + private String name; + + public String getMessage() { + return message; + } + + public void setMessage(final String message) { + this.message = message; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public Long getId() { + return id; + } + + public void setId(final Long id) { + this.id = id; + } + + public Status getStatus() { + return status; + } + + public void setStatus(final Status status) { + this.status = status; + } + + public AttributableType getSubjectType() { + return subjectType; + } + + public void setSubjectType(final AttributableType subjectType) { + this.subjectType = subjectType; + } + + public ResourceOperation getOperation() { + return operation; + } + + public void setOperation(final ResourceOperation operation) { + this.operation = operation; + } + + @Override + public String toString() { + return new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).toString(); + } + + /** + * Human readable report string, using the given trace level. + * + * @param level trace level + * @return String for certain levels, null for level NONE + */ + public String getReportString(final TraceLevel level) { + if (level == TraceLevel.SUMMARY) { + // No per entry log in this case. + return null; + } else if (level == TraceLevel.FAILURES && status == Status.FAILURE) { + // only report failures + return String.format("Failed %s (id/name): %d/%s with message: %s", operation, id, name, message); + } else { + // All + return String.format("%s %s (id/name): %d/%s %s", operation, status, id, name, + StringUtils.isBlank(message) + ? "" + : "with message: " + message); + } + } + + /** + * Helper method to invoke logging per synchronization result for the given trace level. + * + * @param results synchronization result + * @param level trace level + * @return report as string + */ + public static String produceReport(final Collection<ProvisioningResult> results, final TraceLevel level) { + StringBuilder sb = new StringBuilder(); + for (ProvisioningResult result : results) { + sb.append(result.getReportString(level)).append("\n"); + } + return sb.toString(); + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/PushActions.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/PushActions.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/PushActions.java new file mode 100644 index 0000000..a97d2dd --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/PushActions.java @@ -0,0 +1,137 @@ +/* + * 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.core.provisioning.api.sync; + +import org.apache.syncope.core.persistence.api.entity.Subject; +import org.quartz.JobExecutionException; + +/** + * Interface for actions to be performed during PushJob execution. + */ +public interface PushActions extends ProvisioningActions { + + /** + * Action to be executed before to assign (link & provision) a synchronized user / role to the resource. + * + * @param profile profile of the synchronization being executed. + * @param subject user / role to be created. + * @return subject. + * @throws JobExecutionException in case of generic failure + */ + <T extends Subject<?, ?, ?>> T beforeAssign( + final ProvisioningProfile<?, ?> profile, + final T subject) throws JobExecutionException; + + /** + * Action to be executed before to provision a synchronized user / role to the resource. + * + * @param profile profile of the synchronization being executed. + * @param subject user / role to be created. + * @return subject. + * @throws JobExecutionException in case of generic failure + */ + <T extends Subject<?, ?, ?>> T beforeProvision( + final ProvisioningProfile<?, ?> profile, + final T subject) throws JobExecutionException; + + /** + * Action to be executed before to update a synchronized user / role on the resource. + * + * @param profile profile of the synchronization being executed. + * @param subject user / role to be updated. + * @return subject. + * @throws JobExecutionException in case of generic failure + */ + <T extends Subject<?, ?, ?>> T beforeUpdate( + final ProvisioningProfile<?, ?> profile, + final T subject) throws JobExecutionException; + + /** + * Action to be executed before to link a synchronized user / role to the resource. + * + * @param profile profile of the synchronization being executed. + * @param subject user / role to be created. + * @return subject. + * @throws JobExecutionException in case of generic failure + */ + <T extends Subject<?, ?, ?>> T beforeLink( + final ProvisioningProfile<?, ?> profile, + final T subject) throws JobExecutionException; + + /** + * Action to be executed before to unlink a synchronized user / role from the resource. + * + * @param profile profile of the synchronization being executed. + * @param subject user / role to be created. + * @return subject. + * @throws JobExecutionException in case of generic failure + */ + <T extends Subject<?, ?, ?>> T beforeUnlink( + final ProvisioningProfile<?, ?> profile, + final T subject) throws JobExecutionException; + + /** + * Action to be executed before to unassign a synchronized user / role from the resource. + * + * @param profile profile of the synchronization being executed. + * @param subject user / role to be created. + * @return subject. + * @throws JobExecutionException in case of generic failure + */ + <T extends Subject<?, ?, ?>> T beforeUnassign( + final ProvisioningProfile<?, ?> profile, + final T subject) throws JobExecutionException; + + /** + * Action to be executed before to unassign a synchronized user / role from the resource. + * + * @param profile profile of the synchronization being executed. + * @param subject user / role to be created. + * @return subject. + * @throws JobExecutionException in case of generic failure + */ + <T extends Subject<?, ?, ?>> T beforeDeprovision( + final ProvisioningProfile<?, ?> profile, + final T subject) throws JobExecutionException; + + /** + * Action to be executed before delete a synchronized user / role locally and from the resource. + * + * @param profile profile of the synchronization being executed. + * @param subject user / role to be created. + * @return subject. + * @throws JobExecutionException in case of generic failure + */ + <T extends Subject<?, ?, ?>> T beforeDelete( + final ProvisioningProfile<?, ?> profile, + final T subject) throws JobExecutionException; + + /** + * Action to be executed after each local user / role synchronization. + * + * @param profile profile of the synchronization being executed. + * @param subject synchronized user / role. + * @param result operation result. + * @throws JobExecutionException in case of generic failure + */ + <T extends Subject<?, ?, ?>> void after( + final ProvisioningProfile<?, ?> profile, + final T subject, + final ProvisioningResult result) throws JobExecutionException; +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/RolePushResultHandler.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/RolePushResultHandler.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/RolePushResultHandler.java new file mode 100644 index 0000000..72f71b9 --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/RolePushResultHandler.java @@ -0,0 +1,23 @@ +/* + * 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.core.provisioning.api.sync; + +public interface RolePushResultHandler extends SyncopePushResultHandler { + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/RoleSyncResultHandler.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/RoleSyncResultHandler.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/RoleSyncResultHandler.java new file mode 100644 index 0000000..48508d7 --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/RoleSyncResultHandler.java @@ -0,0 +1,26 @@ +/* + * 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.core.provisioning.api.sync; + +import java.util.Map; + +public interface RoleSyncResultHandler extends SyncopeSyncResultHandler { + + Map<Long, String> getRoleOwnerMap(); +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncActions.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncActions.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncActions.java new file mode 100644 index 0000000..87f3d05 --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncActions.java @@ -0,0 +1,175 @@ +/* + * 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.core.provisioning.api.sync; + +import org.apache.syncope.common.lib.mod.AbstractSubjectMod; +import org.apache.syncope.common.lib.to.AbstractSubjectTO; +import org.identityconnectors.framework.common.objects.SyncDelta; +import org.quartz.JobExecutionException; + +/** + * Interface for actions to be performed during SyncJob execution. + */ +public interface SyncActions extends ProvisioningActions { + + /** + * Action to be executed before to create a synchronized user / role locally. + * User/role is created locally upon synchronization in case of the un-matching rule + * {@link org.apache.syncope.common.types.UnmatchingRule#PROVISION} (default un-matching rule) is applied. + * + * @param profile profile of the synchronization being executed. + * @param delta retrieved synchronization information + * @param subject user / role to be created + * @return synchronization information used for user status evaluation and to be passed to the 'after' method. + * @throws JobExecutionException in case of generic failure + */ + <T extends AbstractSubjectTO> SyncDelta beforeProvision( + final ProvisioningProfile<?, ?> profile, + final SyncDelta delta, + final T subject) throws JobExecutionException; + + /** + * Action to be executed before creating (and linking to the resource) a synchronized user / role locally. + * User/role is created locally and linked to the synchronized resource upon synchronization in case of the + * un-matching rule {@link org.apache.syncope.common.types.UnmatchingRule#ASSIGN} is applied. + * + * @param profile profile of the synchronization being executed. + * @param delta retrieved synchronization information + * @param subject user / role to be created + * @return synchronization information used for user status evaluation and to be passed to the 'after' method. + * @throws JobExecutionException in case of generic failure + */ + <T extends AbstractSubjectTO> SyncDelta beforeAssign( + final ProvisioningProfile<?, ?> profile, + final SyncDelta delta, + final T subject) throws JobExecutionException; + + /** + * Action to be executed before unlinking resource from the synchronized user / role and de-provisioning. + * User/role is unlinked and de-provisioned from the synchronized resource upon synchronization in case of the + * matching rule {@link org.apache.syncope.common.types.MatchingRule#UNASSIGN} is applied. + * + * @param profile profile of the synchronization being executed. + * @param delta retrieved synchronization information + * @param subject user / role to be created + * @return synchronization information used for user status evaluation and to be passed to the 'after' method. + * @throws JobExecutionException in case of generic failure + */ + <T extends AbstractSubjectTO> SyncDelta beforeUnassign( + final ProvisioningProfile<?, ?> profile, + final SyncDelta delta, + final T subject) throws JobExecutionException; + + /** + * Action to be executed before de-provisioning action only. + * User/role is de-provisioned (without unlinking) from the synchronized resource upon synchronization in case of + * the matching rule {@link org.apache.syncope.common.types.MatchingRule#DEPROVISION} is applied. + * + * @param profile profile of the synchronization being executed. + * @param delta retrieved synchronization information + * @param subject user / role to be created + * @return synchronization information used for user status evaluation and to be passed to the 'after' method. + * @throws JobExecutionException in case of generic failure + */ + <T extends AbstractSubjectTO> SyncDelta beforeDeprovision( + final ProvisioningProfile<?, ?> profile, + final SyncDelta delta, + final T subject) throws JobExecutionException; + + /** + * Action to be executed before unlinking resource from the synchronized user / role. + * User/role is unlinked (without de-provisioning) from the synchronized resource upon synchronization in case of + * the matching rule {@link org.apache.syncope.common.types.MatchingRule#UNLINK} is applied. + * + * @param profile profile of the synchronization being executed. + * @param delta retrieved synchronization information + * @param subject user / role to be created + * @return synchronization information used for user status evaluation and to be passed to the 'after' method. + * @throws JobExecutionException in case of generic failure + */ + <T extends AbstractSubjectTO> SyncDelta beforeUnlink( + final ProvisioningProfile<?, ?> profile, + final SyncDelta delta, + final T subject) throws JobExecutionException; + + /** + * Action to be executed before linking resource to the synchronized user / role. + * User/role is linked (without updating) to the synchronized resource upon synchronization in case of + * the matching rule {@link org.apache.syncope.common.types.MatchingRule#LINK} is applied. + * + * @param profile profile of the synchronization being executed. + * @param delta retrieved synchronization information + * @param subject user / role to be created + * @return synchronization information used for user status evaluation and to be passed to the 'after' method. + * @throws JobExecutionException in case of generic failure + */ + <T extends AbstractSubjectTO> SyncDelta beforeLink( + final ProvisioningProfile<?, ?> profile, + final SyncDelta delta, + final T subject) throws JobExecutionException; + + /** + * Action to be executed before to update a synchronized user / role locally. + * User/role is updated upon synchronization in case of the matching rule + * {@link org.apache.syncope.common.types.MatchingRule#UPDATE} (default matching rule) is applied. + * + * @param profile profile of the synchronization being executed. + * @param delta retrieved synchronization information + * @param subject local user / role information + * @param subjectMod modification + * @return synchronization information used for logging and to be passed to the 'after' method. + * @throws JobExecutionException in case of generic failure. + */ + <T extends AbstractSubjectTO, K extends AbstractSubjectMod> SyncDelta beforeUpdate( + final ProvisioningProfile<?, ?> profile, + final SyncDelta delta, + final T subject, + final K subjectMod) + throws JobExecutionException; + + /** + * Action to be executed before to delete a synchronized user / role locally. + * + * @param profile profile of the synchronization being executed. + * @param delta retrieved synchronization information + * @param subject local user / role to be deleted + * @return synchronization information used for logging and to be passed to the 'after' method. + * @throws JobExecutionException in case of generic failure + */ + <T extends AbstractSubjectTO> SyncDelta beforeDelete( + final ProvisioningProfile<?, ?> profile, + final SyncDelta delta, + final T subject) throws JobExecutionException; + + /** + * Action to be executed after each local user / role synchronization. + * + * @param profile profile of the synchronization being executed. + * @param delta retrieved synchronization information (may be modified by + * 'beforeProvision/beforeUpdate/beforeDelete') + * @param subject synchronized local user / role + * @param result global synchronization results at the current synchronization step + * @throws JobExecutionException in case of generic failure + */ + <T extends AbstractSubjectTO> void after( + final ProvisioningProfile<?, ?> profile, + final SyncDelta delta, + final T subject, + final ProvisioningResult result) throws JobExecutionException; +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncCorrelationRule.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncCorrelationRule.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncCorrelationRule.java new file mode 100644 index 0000000..52dfdb4 --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncCorrelationRule.java @@ -0,0 +1,36 @@ +/* + * 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.core.provisioning.api.sync; + +import org.apache.syncope.core.persistence.api.dao.search.SearchCond; +import org.identityconnectors.framework.common.objects.ConnectorObject; + +/** + * Interface for correlation rule to be evaluated during SyncJob execution. + */ +public interface SyncCorrelationRule { + + /** + * Return a search condition. + * + * @param connObj connector object. + * @return search condition. + */ + SearchCond getSearchCond(ConnectorObject connObj); +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncopePushResultHandler.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncopePushResultHandler.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncopePushResultHandler.java new file mode 100644 index 0000000..6ac156f --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncopePushResultHandler.java @@ -0,0 +1,26 @@ +/* + * 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.core.provisioning.api.sync; + +import org.apache.syncope.core.persistence.api.entity.task.PushTask; + +public interface SyncopePushResultHandler extends SyncopeResultHandler<PushTask, PushActions> { + + boolean handle(long subjectId); +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncopeResultHandler.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncopeResultHandler.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncopeResultHandler.java new file mode 100644 index 0000000..86e7cf0 --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncopeResultHandler.java @@ -0,0 +1,29 @@ +/* + * 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.core.provisioning.api.sync; + +import org.apache.syncope.core.persistence.api.entity.task.ProvisioningTask; + +public interface SyncopeResultHandler<T extends ProvisioningTask, A extends ProvisioningActions> { + + ProvisioningProfile<T, A> getProfile(); + + void setProfile(ProvisioningProfile<T, A> profile); + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncopeSyncResultHandler.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncopeSyncResultHandler.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncopeSyncResultHandler.java new file mode 100644 index 0000000..9eb8dc0 --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/SyncopeSyncResultHandler.java @@ -0,0 +1,29 @@ +/* + * 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.core.provisioning.api.sync; + +import org.apache.syncope.core.persistence.api.entity.task.SyncTask; +import org.identityconnectors.framework.common.objects.SyncDelta; +import org.identityconnectors.framework.common.objects.SyncResultsHandler; + +public interface SyncopeSyncResultHandler extends SyncopeResultHandler<SyncTask, SyncActions>, SyncResultsHandler { + + @Override + boolean handle(SyncDelta delta); +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/UserPushResultHandler.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/UserPushResultHandler.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/UserPushResultHandler.java new file mode 100644 index 0000000..6f0a3fc --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/UserPushResultHandler.java @@ -0,0 +1,23 @@ +/* + * 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.core.provisioning.api.sync; + +public interface UserPushResultHandler extends SyncopePushResultHandler { + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/UserSyncResultHandler.java ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/UserSyncResultHandler.java b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/UserSyncResultHandler.java new file mode 100644 index 0000000..9db1269 --- /dev/null +++ b/syncope620/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/UserSyncResultHandler.java @@ -0,0 +1,23 @@ +/* + * 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.core.provisioning.api.sync; + +public interface UserSyncResultHandler extends SyncopeSyncResultHandler { + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/core/provisioning-java/pom.xml ---------------------------------------------------------------------- diff --git a/syncope620/core/provisioning-java/pom.xml b/syncope620/core/provisioning-java/pom.xml new file mode 100644 index 0000000..f4966d6 --- /dev/null +++ b/syncope620/core/provisioning-java/pom.xml @@ -0,0 +1,156 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.syncope</groupId> + <artifactId>syncope-core</artifactId> + <version>2.0.0-SNAPSHOT</version> + </parent> + + <name>Apache Syncope Core Provisioning Java</name> + <description>Apache Syncope Core Provisioning Java</description> + <groupId>org.apache.syncope.core</groupId> + <artifactId>syncope-core-provisioning-java</artifactId> + <packaging>jar</packaging> + + <properties> + <rootpom.basedir>${basedir}/../..</rootpom.basedir> + </properties> + + <dependencies> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context-support</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.geronimo.javamail</groupId> + <artifactId>geronimo-javamail_1.4_mail</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.velocity</groupId> + <artifactId>velocity</artifactId> + </dependency> + <dependency> + <groupId>org.apache.velocity</groupId> + <artifactId>velocity-tools</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.syncope.core</groupId> + <artifactId>syncope-core-workflow-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.syncope.core</groupId> + <artifactId>syncope-core-misc</artifactId> + <version>${project.version}</version> + </dependency> + + <!-- TEST --> + <dependency> + <groupId>org.apache.syncope.core</groupId> + <artifactId>syncope-core-workflow-java</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>javax.el</groupId> + <artifactId>javax.el-api</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.syncope.core</groupId> + <artifactId>syncope-core-persistence-jpa</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + <version>${slf4j.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <inherited>true</inherited> + <executions> + <execution> + <id>set-bundles</id> + <phase>process-test-resources</phase> + <goals> + <goal>copy</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-pmd-plugin</artifactId> + </plugin> + </plugins> + + <resources> + <resource> + <directory>${basedir}/src/main/resources</directory> + <filtering>true</filtering> + </resource> + </resources> + <testResources> + <testResource> + <directory>${basedir}/src/test/resources</directory> + <filtering>true</filtering> + </testResource> + <testResource> + <directory>${basedir}/../persistence-jpa/src/test/resources</directory> + <filtering>true</filtering> + </testResource> + </testResources> + </build> +</project>
