// Path: repository/src/main/java/de/acosix/alfresco/mtsupport/repo/sync/TenantAwareChainingUserRegistrySynchronizer.java
// @FunctionalInterface
// public static interface ComponentLookupCallback
// {
// 
//     /**
//      * Retrieves the matching component from an enclosing {@link TenantAwareChainingUserRegistrySynchronizer} instance.
//      *
//      * @param name
//      *            the name of the component
//      * @return the component
//      * @throws IllegalStateException
//      *             if the requested component is not available
//      */
// 
//     Object getComponent(String name);
// 
//     /**
//      * Retrieves the matching component from an enclosing {@link TenantAwareChainingUserRegistrySynchronizer} instance.
//      *
//      * @param <T>
//      *            the expected base type of the component
//      * @param name
//      *            the name of the component
//      * @param iface
//      *            the interface of the component
//      * @return the service
//      * @throws IllegalStateException
//      *             if the requested component is not available
//      */
//     default <T> T getComponent(final String name, final Class<T> iface)
//     {
//         final Object service = this.getComponent(name);
//         return iface.cast(service);
//     }
// }


import de.acosix.alfresco.mtsupport.repo.sync.TenantAwareChainingUserRegistrySynchronizer.ComponentLookupCallback;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import org.alfresco.repo.batch.BatchProcessor.BatchProcessWorkerAdaptor;
import org.alfresco.repo.tenant.TenantContextHolder;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.repo.tenant.TenantUtil;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.ParameterCheck;
/*
 * Copyright 2016 Acosix GmbH
 *
 * Licensed 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 de.acosix.alfresco.mtsupport.repo.sync;




/**
 * @author Axel Faust, <a href="http://acosix.de">Acosix GmbH</a>
 */
public abstract class AbstractSyncBatchWorker<T> extends BatchProcessWorkerAdaptor<T>
{

    protected final String tenantDomain = TenantUtil.getCurrentDomain();

    protected final AuthorityService authorityService;

    protected final PersonService personService;

    protected final TenantService tenantService;

// Path: repository/src/main/java/de/acosix/alfresco/mtsupport/repo/sync/TenantAwareChainingUserRegistrySynchronizer.java
// @FunctionalInterface
// public static interface ComponentLookupCallback
// {
// 
//     /**
//      * Retrieves the matching component from an enclosing {@link TenantAwareChainingUserRegistrySynchronizer} instance.
//      *
//      * @param name
//      *            the name of the component
//      * @return the component
//      * @throws IllegalStateException
//      *             if the requested component is not available
//      */
// 
//     Object getComponent(String name);
// 
//     /**
//      * Retrieves the matching component from an enclosing {@link TenantAwareChainingUserRegistrySynchronizer} instance.
//      *
//      * @param <T>
//      *            the expected base type of the component
//      * @param name
//      *            the name of the component
//      * @param iface
//      *            the interface of the component
//      * @return the service
//      * @throws IllegalStateException
//      *             if the requested component is not available
//      */
//     default <T> T getComponent(final String name, final Class<T> iface)
//     {
//         final Object service = this.getComponent(name);
//         return iface.cast(service);
//     }
// }


// Path: repository/src/main/java/de/acosix/alfresco/mtsupport/repo/sync/AbstractSyncBatchWorker.java
import de.acosix.alfresco.mtsupport.repo.sync.TenantAwareChainingUserRegistrySynchronizer.ComponentLookupCallback;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import org.alfresco.repo.batch.BatchProcessor.BatchProcessWorkerAdaptor;
import org.alfresco.repo.tenant.TenantContextHolder;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.repo.tenant.TenantUtil;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.ParameterCheck;

/*
 * Copyright 2016 Acosix GmbH
 *
 * Licensed 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 de.acosix.alfresco.mtsupport.repo.sync;




/**
 * @author Axel Faust, <a href="http://acosix.de">Acosix GmbH</a>
 */
public abstract class AbstractSyncBatchWorker<T> extends BatchProcessWorkerAdaptor<T>
{

    protected final String tenantDomain = TenantUtil.getCurrentDomain();

    protected final AuthorityService authorityService;

    protected final PersonService personService;

    protected final TenantService tenantService;

    public AbstractSyncBatchWorker(final ComponentLookupCallback componentLookup)