001/*
002 * (C) Copyright 2010 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Anahide Tchertchian
016 */
017package org.nuxeo.ecm.platform.contentview.jsf;
018
019import java.io.Serializable;
020import java.util.List;
021import java.util.Set;
022
023import javax.faces.context.FacesContext;
024
025import org.nuxeo.ecm.core.api.DocumentModel;
026import org.nuxeo.ecm.core.api.SortInfo;
027import org.nuxeo.ecm.platform.query.api.PageProvider;
028
029/**
030 * Service handling content views and associated page providers.
031 *
032 * @author Anahide Tchertchian
033 * @since 5.4
034 */
035public interface ContentViewService extends Serializable {
036
037    /**
038     * Returns the content view with given name, or null if not found.
039     *
040     */
041    ContentView getContentView(String name);
042
043    /**
044     * Returns the content view header, or null if not found.
045     */
046    ContentViewHeader getContentViewHeader(String name);
047
048    /**
049     * Returns all the registered content view names, or an empty set if no content view is registered.
050     */
051    Set<String> getContentViewNames();
052
053    /**
054     * Returns all the registered content view headers, or an empty set if no content view is registered.
055     */
056    Set<ContentViewHeader> getContentViewHeaders();
057
058    /**
059     * Returns all the registered content view names with given flag declared on their definition
060     */
061    Set<String> getContentViewNames(String flag);
062
063    /**
064     * Returns all the registered content view headers with given flag declared on their definition
065     *
066     * @since 5.4.2
067     */
068    Set<ContentViewHeader> getContentViewHeaders(String flag);
069
070    /**
071     * Returns the page provider computed from the content view with given name. Its properties are resolved using
072     * current {@link FacesContext} instance if they are EL Expressions.
073     * <p>
074     * If not null, parameters sortInfos and pageSize will override information computed in the XML file. If not null,
075     * currentPage will override default current page (0).
076     *
077     * @since 5.7
078     */
079    PageProvider<?> getPageProvider(String contentViewName, List<SortInfo> sortInfos, Long pageSize, Long currentPage,
080            DocumentModel searchDocument, Object... parameters);
081
082    /**
083     * Returns the state of this content view.
084     * <p>
085     * This state can be used to restore the content view in another context.
086     *
087     * @see #restoreContentView(ContentViewState)
088     * @since 5.4.2
089     * @param contentView
090     */
091    ContentViewState saveContentView(ContentView contentView);
092
093    /**
094     * Restores a content view given a state.
095     *
096     * @see #saveContentView(ContentView)
097     * @since 5.4.2
098     */
099    ContentView restoreContentView(ContentViewState contentViewState);
100
101    /**
102     * Restores a content view to a given state.
103     *
104     * @since 7.3
105     */
106    void restoreContentViewState(ContentView contentView, ContentViewState contentViewState);
107
108}