All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.day.cq.replication.ReplicationOptions Maven / Gradle / Ivy

/*************************************************************************
 *
 * ADOBE CONFIDENTIAL
 * __________________
 *
 *  Copyright 2011 Adobe Systems Incorporated
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Adobe Systems Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Adobe Systems Incorporated and its
 * suppliers and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe Systems Incorporated.
 **************************************************************************/

package com.day.cq.replication;

import java.util.HashSet;
import java.util.Set;

/**
 * The ReplicationOptions encapsulate optional
 * configuration parameters for a replication.
 */
public class ReplicationOptions {

    /**
     * Should the replication happen synchronously? (default is false)
     */
    private boolean synchronous = false;

    /**
     * Agent filter
     */
    private AgentFilter filter;

    /**
     * the replication listener
     */
    private ReplicationListener listener;

    /**
     * the revision to replicate
     */
    private String revision;

    /**
     * if true, the replication status properties are not updated
     */
    private boolean suppressStatusUpdate;

    /**
     * if true the implicit versioning should not be triggered
     */
    private boolean suppressVersions;

    /**
     * handler to use for generating aggregates
     * @since 5.5
     */
    private AggregateHandler aggregateHandler;
    private boolean updateAlias;

    /**
     * @link {@link Set} to hold all alias which are already replicated.
     */
    private Set aliasReplicated = new HashSet();

    /**
     * Create a new options object with default values
     */
    public ReplicationOptions() {
        // default values
    }

    /**
     * Should the replication be done synchronous or asynchronous?
     * The default is asynchronously.
     * @return true for synchronous replication
     */
    public boolean isSynchronous() {
        return synchronous;
    }

    /**
     * Set the synchronous flag.
     * @param synchronous true for synchronous replication
     */
    public void setSynchronous(boolean synchronous) {
        this.synchronous = synchronous;
    }

    /**
     * Set the desired agent ids. Please note, that this method internally
     * sets a new {@link AgentIdFilter}.
     *
     * @param desiredAgentId agent ids
     * @deprecated use {@link #setFilter(AgentFilter)} instead.
     */
    public void setDesiredAgentIDs(String ... desiredAgentId) {
        if (desiredAgentId != null) {
            setFilter(new AgentIdFilter(desiredAgentId));
        }
    }

    /**
     * Sets the filter for selecting the agents for the replication.
     * @param filter agent filter
     */
    public void setFilter(AgentFilter filter) {
        this.filter = filter;
    }

    /**
     * Returns the filter for selecting the agents.
     * @return the filter
     */
    public AgentFilter getFilter() {
        return filter;
    }

    /**
     * Returns the revision to replicate
     * @return the revision
     */
    public String getRevision() {
        return revision;
    }

    /**
     * Sets the revision to replicate.
     * @param revision the revision name.
     */
    public void setRevision(String revision) {
        this.revision = revision;
    }

    /**
     * Returns the replication listener.
     * @return the listener or null
     */
    public ReplicationListener getListener() {
        return listener;
    }

    /**
     * Sets the replication listener. Please note that a listener is currently
     * only called for synchronous replication.
     *  
     * @param listener the replication listener.
     */
    public void setListener(ReplicationListener listener) {
        this.listener = listener;
    }

    /**
     * If true, the replication will not update the replication
     * status properties after a replication.
     * @return true if status updates should be suppressed.
     *
     * @since 5.4
     */
    public boolean isSuppressStatusUpdate() {
        return suppressStatusUpdate;
    }

    /**
     * If set to true the replication will not update the
     * replication status properties after a replication.
     * @param suppressStatusUpdate true if status updates should be suppressed
     *
     * @since 5.4
     */
    public void setSuppressStatusUpdate(boolean suppressStatusUpdate) {
        this.suppressStatusUpdate = suppressStatusUpdate;
    }

    /**
     * If true the replication will not trigger implicit versioning.
     * @return true if implicit versioning should be suppressed
     *
     * @since 5.4
     */
    public boolean isSuppressVersions() {
        return suppressVersions;
    }

    /**
     * If set to true the replication will not trigger implicit
     * versioning.
     * @param suppressVersions set to true if implicit versioning should be suppressed
     *
     * @since 5.4
     */
    public void setSuppressVersions(boolean suppressVersions) {
        this.suppressVersions = suppressVersions;
    }

    /**
     * Returns the defined aggregate handler or null
     * @return the aggregate handler.
     *
     * @since 5.5
     */
    public AggregateHandler getAggregateHandler() {
        return aggregateHandler;
    }

    /**
     * Sets the aggregate handler.
     * @param aggregateHandler the aggregate handler
     * 
     * @since 5.5
     */
    public void setAggregateHandler(AggregateHandler aggregateHandler) {
        this.aggregateHandler = aggregateHandler;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append("ReplicationOptions");
        sb.append("{synchronous=").append(synchronous);
        sb.append(", revision='").append(revision).append('\'');
        sb.append(", suppressStatusUpdate=").append(suppressStatusUpdate);
        sb.append(", suppressVersions=").append(suppressVersions);
        sb.append(", filter=").append(filter);
        sb.append(", aggregateHandler=").append(aggregateHandler);
        sb.append('}');
        return sb.toString();
    }

    /**
     *
     * @param updateAlias the boolean value to set the updateAlias to
     * @since 5.9
     */
    public void setUpdateAlias(boolean updateAlias) {
        this.updateAlias = updateAlias;
    }

    /**
     *
     * @return the boolean value for the updateAlias
     * @since 5.9
     */
    public boolean isUpdateAlias() {
        return updateAlias;
    }

    /**
     * Add path to already replicated alias set.
     * @param path the path
     */
    public void addToAliasReplicated(String path) {
        aliasReplicated.add(path);
    }

    /**
     * Returns true if path is already replicated else false.
     * @param path the path
     * @return {@code true} if path is already replicated, else {@code false}
     */
    public boolean isAliasReplicated(String path) {
        return aliasReplicated.contains(path);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy