ReverseLiveRelationship.java 5.44 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.cq.launches.api.Launch
 *  com.day.cq.wcm.msm.api.LiveCopy
 *  com.day.cq.wcm.msm.api.LiveRelationship
 *  com.day.cq.wcm.msm.api.LiveStatus
 *  com.day.cq.wcm.msm.api.RolloutConfig
 *  com.day.cq.wcm.msm.api.RolloutManager
 *  com.day.cq.wcm.msm.api.RolloutManager$Trigger
 *  org.apache.sling.api.resource.Resource
 *  org.apache.sling.commons.json.JSONException
 *  org.apache.sling.commons.json.io.JSONWriter
 */
package com.adobe.cq.wcm.launches.impl;

import com.adobe.cq.launches.api.Launch;
import com.day.cq.wcm.msm.api.LiveCopy;
import com.day.cq.wcm.msm.api.LiveRelationship;
import com.day.cq.wcm.msm.api.LiveStatus;
import com.day.cq.wcm.msm.api.RolloutConfig;
import com.day.cq.wcm.msm.api.RolloutManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.io.JSONWriter;

public class ReverseLiveRelationship
implements LiveRelationship {
    private final String blueprintPath;
    private final String livecopyPath;
    private final String syncPath;
    private final String sourcePath;
    private boolean isSourceExisting;
    private final String targetPath;
    private boolean isTargetExisting;
    private final List<RolloutConfig> reverseRolloutConfigs;
    private final boolean isPage;
    private Map<String, Boolean> advancedStatus = new HashMap<String, Boolean>();

    ReverseLiveRelationship(Launch launch, String sourcePath, boolean isSourceExisting, String targetPath, boolean isTargetExisting, List<RolloutConfig> reverseRolloutConfigs, boolean isPage) {
        this.blueprintPath = launch.getRootResource().getPath();
        this.syncPath = sourcePath.substring(this.blueprintPath.length());
        this.livecopyPath = targetPath.substring(0, targetPath.length() - this.syncPath.length());
        this.sourcePath = sourcePath;
        this.isSourceExisting = isSourceExisting;
        this.targetPath = targetPath;
        this.isTargetExisting = isTargetExisting;
        this.reverseRolloutConfigs = reverseRolloutConfigs;
        this.isPage = isPage;
        this.advancedStatus.put("msm:isLaunch", true);
    }

    public LiveCopy getLiveCopy() {
        return new LiveCopy(){

            public String getPath() {
                return ReverseLiveRelationship.this.livecopyPath;
            }

            public String getBlueprintPath() {
                return ReverseLiveRelationship.this.blueprintPath;
            }

            public boolean isDeep() {
                return false;
            }

            public boolean isRoot() {
                return true;
            }

            public List<RolloutConfig> getRolloutConfigs() {
                return ReverseLiveRelationship.this.reverseRolloutConfigs;
            }

            public List<RolloutConfig> getRolloutConfigs(RolloutManager.Trigger trigger) {
                ArrayList<RolloutConfig> configs = new ArrayList<RolloutConfig>();
                if (ReverseLiveRelationship.this.reverseRolloutConfigs != null) {
                    for (RolloutConfig rc : ReverseLiveRelationship.this.reverseRolloutConfigs) {
                        if (!trigger.equals((Object)rc.getTrigger())) continue;
                        configs.add(rc);
                    }
                }
                return configs;
            }

            public boolean isTrigger(RolloutManager.Trigger trigger) {
                return true;
            }
        };
    }

    public String getSyncPath() {
        return this.syncPath;
    }

    public String getSourcePath() {
        return this.sourcePath;
    }

    public String getTargetPath() {
        return this.targetPath;
    }

    public LiveStatus getStatus() {
        return new LiveStatus(){

            public boolean isCancelled() {
                return false;
            }

            public boolean isCancelledForChildren() {
                return false;
            }

            public boolean isEditable() {
                return false;
            }

            public boolean isSourceExisting() {
                return ReverseLiveRelationship.this.isSourceExisting;
            }

            public boolean isTargetExisting() {
                return ReverseLiveRelationship.this.isTargetExisting;
            }

            public Map<String, Boolean> getAdvancedStatus() {
                return ReverseLiveRelationship.this.advancedStatus;
            }

            public Boolean getAdvancedStatus(String statusName) {
                return false;
            }

            public boolean isPage() {
                return ReverseLiveRelationship.this.isPage;
            }

            public void write(JSONWriter out) throws JSONException {
            }

            public List<String> getCanceledProperties() {
                return Collections.emptyList();
            }
        };
    }

    public List<RolloutConfig> getRolloutConfigs() {
        return this.reverseRolloutConfigs;
    }

    public List<RolloutConfig> getRolloutConfigs(RolloutManager.Trigger trigger) {
        return this.getLiveCopy().getRolloutConfigs(trigger);
    }

    public boolean isTrigger(RolloutManager.Trigger trigger) {
        return this.getLiveCopy().isTrigger(trigger);
    }

    public void write(JSONWriter jsonWriter) throws JSONException {
    }

}