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

com.day.cq.wcm.api.components.ChildEditor Maven / Gradle / Ivy

There is a newer version: 2024.11.18751.20241128T090041Z-241100
Show newest version
package com.day.cq.wcm.api.components;

import com.day.cq.commons.JSONItem;
import org.apache.jackrabbit.commons.JcrUtils;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.io.JSONWriter;

import javax.jcr.Node;
import javax.jcr.RepositoryException;

/**
 * Specifies a child editor as configured in the inplace edit config.
 */
public class ChildEditor implements JSONItem {

    /**
     * Name of property containing the inplace child editor's title
     */
    private final String PN_CE_TITLE = "title";

    /**
     * Name of property containing the inplace child editor's type
     */
    private final String PN_CE_TYPE = "type";

    /**
     * Name of property containing the inplace child editor's icon
     */
    private final String PN_CE_ICON = "icon";

    private final String name;

    private final String id;

    private final String title;

    private final String icon;

    private final String type;

    public ChildEditor(Node node) throws RepositoryException {
        name = node.getName();
        id = name;
        type = JcrUtils.getStringProperty(node, PN_CE_TYPE, "");
        title = JcrUtils.getStringProperty(node, PN_CE_TITLE, "");
        icon = JcrUtils.getStringProperty(node, PN_CE_ICON, "");
    }

    public String getName() {
        return name;
    }

    public String getId() {
        return id;
    }

    public String getTitle() { return title; }

    public String getType() {
        return type;
    }

    public String getIcon() {
        return icon;
    }

    public void write(JSONWriter out) throws JSONException {
        out.object();
        out.key("id").value(name);
        out.key(PN_CE_TYPE).value(type);
        out.key(PN_CE_TITLE).value(title);
        out.key(PN_CE_ICON).value(icon);
        out.endObject();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy