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

com.day.cq.wcm.api.Template Maven / Gradle / Ivy

There is a newer version: 2024.11.18751.20241128T090041Z-241100
Show newest version
/*
 * Copyright 1997-2008 Day Management AG
 * Barfuesserplatz 6, 4001 Basel, Switzerland
 * All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * Day Management AG, ("Confidential Information"). You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Day.
 */
package com.day.cq.wcm.api;


import com.day.cq.commons.JSONItem;
import com.day.cq.commons.LabeledResource;
import org.apache.sling.api.adapter.Adaptable;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.io.JSONWriter;
import org.osgi.annotation.versioning.ProviderType;

import java.util.Calendar;

/**
 * Defines the interface of a CQ WCM template.
 */
@ProviderType
public interface Template extends Adaptable, LabeledResource, JSONItem {

    /**
     * Returns the path of the template resource
     * @return path
     */
    public String getPath();

    /**
     * Returns the title of the template or the name of the resource (i.e.
     * last path segment) if not defined.
     * @return title
     */
    public String getTitle();

    /**
     * Returns the short title of the template or null
     * if not defined.
     * @return short title
     */
    public String getShortTitle();

    /**
     * Returns the description of the template or null if not
     * defined.
     * @return description
     */
    public String getDescription();

    /**
     * Returns the path to an icon for this template or null if
     * this template does not provide an icon.
     *
     * @return the path to an icon or null
     */
    String getIconPath();

    /**
     * Returns the path to a thumbnail for this template or null
     * if the template does not provide a thumbnail.
     * 
     * @return the path to a thumbnail or null
     */
    String getThumbnailPath();

    /**
     * Returns the ranking in the template list.
     *
     * @return the ranking
     */
    Long getRanking();

    /**
     * Checks if this template is allowed to be used for a new page below
     * the given path.
     *
     * Note: This template is not allowed, if the parent template cannot be
     * evaluated but the template specifies "allowedParents"
     *
     * Always use {@link #isAllowed(Resource)} in loops for better performance.
     *
     * @param parentPath parent path for the new page
     * @return true if it is allowed.
     */
    boolean isAllowed(String parentPath);

    /**
     * Checks if this template is allowed to be used for a new page below
     * the given parent.
     *
     * Note: This template is not allowed, if the parent template cannot be
     * evaluated but the template specifies "allowedParents"
     *
     * @param parent the parent resource for the new page
     * @return true if it is allowed.
     */
    boolean isAllowed(Resource parent);

    /**
     * Checks if the given template is allowed as a child template.
     * @param template the child template
     * @return true if the given template is allowed as child template.
     */
    boolean isAllowedChild(Template template);

    /**
     * {@inheritDoc}
     */
    public void write(JSONWriter jsonWriter) throws JSONException;


    /**
     * Get the initial content path.
     * @return String the initial content path.
     */
    public String getInitialContentPath();

    /**
     * Get the template's properties.
     *
     * @return The template's properties. Never returns null.
     */
    public ValueMap getProperties();

    /**
     * Check if it has structure support.
     * @return boolean.
     */
    public boolean hasStructureSupport();

    /**
     * Get page type
     * @return page type.
     */
    public String getPageTypePath();

    /**
     * Get last modified date of template.
     * @return last modified date of template.
     */
    public Calendar getLastModified();

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy