LiveStatusImpl.java 4.59 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.day.cq.wcm.msm.api.LiveStatus
 *  org.apache.commons.lang.StringUtils
 *  org.apache.sling.commons.json.JSONException
 *  org.apache.sling.commons.json.io.JSONWriter
 */
package com.day.cq.wcm.msm.impl;

import com.day.cq.wcm.msm.api.LiveStatus;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.io.JSONWriter;

public class LiveStatusImpl
implements LiveStatus {
    private boolean isCancelled;
    private boolean isCancelledForChildren;
    private boolean isMasterExisting;
    private boolean isSlaveExisting;
    private boolean isPage;
    private String rolledOutBy;
    private String cancelPath;
    private Date rolledOutOn;
    private List<String> canceledProperties = new ArrayList<String>();
    private Map<String, Boolean> advancedStatus = new HashMap<String, Boolean>();
    private static final String PARAM_IS_CANCELLED_ON = "msm:isCancelledOn";

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

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

    public void setMasterExisting(boolean masterExisting) {
        this.isMasterExisting = masterExisting;
    }

    public void setSlaveExisting(boolean slaveExisting) {
        this.isSlaveExisting = slaveExisting;
    }

    public boolean isCancelled() {
        return this.isCancelled;
    }

    public void setCancelled(boolean cancelled) {
        this.isCancelled = cancelled;
    }

    public boolean isCancelledForChildren() {
        return this.isCancelledForChildren;
    }

    public void setCancelledForChildren(boolean cancelledForChildren) {
        this.isCancelledForChildren = cancelledForChildren;
    }

    public void setCancelledPath(String path) {
        this.cancelPath = path;
    }

    public String getCancelledPath() {
        return this.cancelPath;
    }

    public boolean isEditable() {
        if (this.isPage()) {
            return !this.isCancelled();
        }
        return !this.isCancelled() || StringUtils.isEmpty((String)this.getCancelledPath());
    }

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

    public Boolean getAdvancedStatus(String statusName) {
        return this.advancedStatus.get(statusName);
    }

    public void setAdvancedStatus(String statusName, boolean value) {
        this.advancedStatus.put(statusName, value);
    }

    public void setPage(boolean page) {
        this.isPage = page;
    }

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

    public List<String> getCanceledProperties() {
        return Collections.unmodifiableList(this.canceledProperties);
    }

    void setCancelledProperties(List<String> canceledProps) {
        this.canceledProperties = canceledProps;
    }

    public String getLastRolledOutBy() {
        return this.rolledOutBy;
    }

    void setRolledOutBy(String rolledOutBy) {
        this.rolledOutBy = rolledOutBy;
    }

    public Date getLastRolledOut() {
        return this.rolledOutOn;
    }

    public void setRolledOutOn(Date rolledOutOn) {
        this.rolledOutOn = rolledOutOn;
    }

    public void write(JSONWriter out) throws JSONException {
        out.object();
        out.key("msm:isCancelled").value(this.isCancelled);
        out.key("msm:isCancelledForChildren").value(this.isCancelledForChildren);
        out.key("msm:isCancelledOn").value((Object)(this.getCancelledPath() == null ? "" : this.getCancelledPath()));
        out.key("msm:isEditable").value(this.isEditable());
        out.key("msm:isTargetExisting").value(this.isSlaveExisting);
        out.key("msm:isSourceExisting").value(this.isMasterExisting);
        out.key("msm:isPage").value(this.isPage);
        out.key("cq:lastRolledout").value((Object)(this.rolledOutOn == null ? "" : Long.valueOf(this.rolledOutOn.getTime())));
        out.key("cq:lastRolledoutBy").value((Object)(this.rolledOutBy == null ? "" : this.rolledOutBy));
        Set<String> keys = this.advancedStatus.keySet();
        for (String st : keys) {
            out.key(st).value((Object)this.advancedStatus.get(st));
        }
        out.key("msm:cancelledProperties").array();
        for (String cp : this.getCanceledProperties()) {
            out.value((Object)cp);
        }
        out.endArray();
        out.endObject();
    }
}