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

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

There is a newer version: 2024.9.17689.20240905T073330Z-240800
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 java.util.Calendar;
import java.util.Iterator;
import java.util.Locale;

import org.apache.sling.api.adapter.Adaptable;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import org.osgi.annotation.versioning.ProviderType;

import com.day.cq.commons.Filter;
import com.day.cq.commons.LabeledResource;
import com.day.cq.tagging.Tag;

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

    /**
     * Returns the path of the page.
     * @return path of the page.
     */
    String getPath();

    /**
     * Convenience method that returns the manager of this page.
     * @return the page manager.
     */
    PageManager getPageManager();

    /**
     * Returns the resource of the page's content or null if
     * the page has no content.
     * @return resource or null
     *
     * @see #hasContent()
     */
    Resource getContentResource();

    /**
     * Returns the addressed resource of the page's content or null
     * if the respective resource does not exist. If relPath is
     * null or an empty string the toplevel content resource is
     * returned.
     *
     * @param relPath relative path into content
     * @return resource or null
     *
     * @throws IllegalArgumentException if path is not relative.
     */
    Resource getContentResource(String relPath);

    /**
     * Returns an iterator over all child resources that adapt to a page.
     * other child resources are skipped.
     * @return iterator of child pages
     */
    Iterator listChildren();

    /**
     * Returns an iterator over all child resources that adapt to a page and
     * that are included in the given filter. other child resources are skipped.
     * @param filter for iteration. may be null
     * @return iterator of child pages
     */
    Iterator listChildren(Filter filter);

    /**
     * Returns an iterator over descendant resources that adapt to a page and
     * that are included in the given filter. other child resources are skipped.
     * @param filter for iteration. may be null
     * @param deep false traverses only children; true traverses all descendants
     * @return iterator of child pages
     */
    Iterator listChildren(final Filter filter, final boolean deep);

    /**
    * Checks if the page has a child page named name
    * @param name Name of the child
    * @return true if the page has this child;
    *         false otherwise.
    */
    boolean hasChild(String name);

    /**
     * Returns the hierarchical depth of the page. The depth is the number of
     * {@link #getParent()} calls would be needed to reach the root node.
     * @return the depth of the page.
     */
    int getDepth();

    /**
     * Returns the parent page if it's resource adapts to page.
     * @return the parent page or null
     */
    Page getParent();

    /**
     * Returns the relative parent page. If no page exists at that level,
     * null is returned.
     *
     * Example (this path == /content/geometrixx/en/products)
     * 
     * | level | returned                        |
     * |     0 | /content/geometrixx/en/products |
     * |     1 | /content/geometrixx/en          |
     * |     2 | /content/geometrixx             |
     * |     3 | /content                        |
     * |     4 | null                            |
     * 
* * @param level hierarchy level of the parent page to retrieve * @return the respective parent page or null */ Page getParent(int level); /** * Returns the absolute parent page. If no page exists at that level, * null is returned. * * Example (this path == /content/geometrixx/en/products) *
     * | level | returned                        |
     * |     0 | /content                        |
     * |     1 | /content/geometrixx             |
     * |     2 | /content/geometrixx/en          |
     * |     3 | /content/geometrixx/en/products |
     * |     4 | null                            |
     * 
* * @param level hierarchy level of the parent page to retrieve * @return the respective parent page or null */ Page getAbsoluteParent(int level); /** * Returns a value map of the page content. If the page has no content * an empty map is returned. * * @return a value map * @see #hasContent() */ ValueMap getProperties(); /** * Returns a value map of the address content of the page. If the addressed * content does not exit, null is returned. If relPath is * null or an empty string the toplevel content properties are * returned. * * @param relPath relative path to the content * @return a property map or null * * @throws IllegalArgumentException of the given path is not relative. */ ValueMap getProperties(String relPath); /** * Returns the name of the page. this is the last path segment of the * page path. * @return page name */ String getName(); /** * Returns the title of the page or null if none defined. * The title is a short form of the page title, usually displayed in the * site admin. * @return title of the page */ String getTitle(); /** * Returns the page title of the page or null if none defined. * @return page title */ String getPageTitle(); /** * Returns the navigation title of the page or null if none * defined. The navigation title is usually used when drawing navigation * links. * @return navigation title */ String getNavigationTitle(); /** * Returns the "hideInNav" flag or false if non defined. * The hideInNav flag is usually used to control if a page should be * displayed in a navigation. * @return hide in navigation flag */ boolean isHideInNav(); /** * Checks if the page has content attached. * @return true if the page has content; * false otherwise. */ boolean hasContent(); /** * Checks if the page is valid. It is valid if it has content and if * the on-/off time range spans the current time. * @return true if the page is valid; * false otherwise. */ boolean isValid(); /** * Returns the number of milliseconds when this page gets valid. If the page * is already valid, 0 is returned. If the page is out dated, * i.e. the offTime is in the past, a negative number is returned. If this * page has no content {@link Long#MIN_VALUE} is returned. * @return milliseconds until page gets valid. */ long timeUntilValid(); /** * Returns the onTime of the page. The onTime defines after * which time it is valid. If no onTime is specified null is * returned and the onTime is not respected in the {@link #isValid()} * calculation. * @return onTime or null */ Calendar getOnTime(); /** * Returns the offTime of the page. The offTime defines before * which time it is valid. If no offTime is specified null is * returned and the offTime is not respected in the {@link #isValid()} * calculation. * @return offTime or null */ Calendar getOffTime(); /** * Checks if the page is in a deletion process * * @return modification date if the page is in process to be deleted * null otherwise. */ Calendar getDeleted(); /** * Return the user id that triggered the deletion of page * or null if the page was not deleted. * * @return user id or null */ String getDeletedBy(); /** * Return the user id that last modified the page or null if this * information is not available or if the page has no content. * @return user id or null */ String getLastModifiedBy(); /** * Returns the time when the page was last modified or null if * this information is not available or if the page has no content. * @return last modification date or null */ Calendar getLastModified(); /** * Returns the vanity url. * @return The vanity url for this page or null */ String getVanityUrl(); /** * Returns the tags set on this page. * @return The tags set on this page. */ Tag[] getTags(); /** * Lock a page. * * @throws WCMException if an error during this operation occurs. */ void lock() throws WCMException; /** * Checks if this page is locked. * @return true if this page is locked. */ boolean isLocked(); /** * Return the lock owner of a page. * * @return lock owner; null if the page is not locked */ String getLockOwner(); /** * Return a flag indicating whether the current user can unlock a page. * * @return true if the page can be unlocked; * false otherwise */ boolean canUnlock(); /** * Unlock a page. * * @throws WCMException if an error during this operation occurs. */ void unlock() throws WCMException; /** * Returns the template that was used to create this page or null * if none defined or the current user does not have read access to the * template resource specified by the path in the page's template property. * This is the case on publish instances using default ACL configuration * (anonymous cannot read templates). * * @return template or null */ Template getTemplate(); /** * Returns the content language of the page. The language is usually defined * on the page content via a jcr:language property containing * the iso codes for language and country. if the property is not defined * on this page all ancestors are search for such an property. If no language * is defined at all, the path is examined if it contains a iso label. If no * language can be found at all, the systems default locale is returned. * * If ignoreConent is true, only the names of the * path is used to determine the language. * * Note that this has nothing to do with i18n of the cq5 itself. * * @param ignoreContent if true only the path is used to * determine the language. * @return the language of the content */ Locale getLanguage(boolean ignoreContent); /** * Returns the content language of the page. The language is usually defined * on the page content via a jcr:language property containing * the iso codes for language and country. if the property is not defined * on this page all ancestors are search for such an property. If no language * is defined at all, the path is examined if it contains a iso label. If no * language can be found at all, the systems default locale is returned. * * Note that this has nothing to do with i18n of the cq5 itself. * * @return the language of the content */ Locale getLanguage(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy