001/* 002 * (C) Copyright 2010 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Anahide Tchertchian 018 */ 019package org.nuxeo.ecm.platform.contentview.jsf; 020 021import java.io.Serializable; 022import java.util.List; 023import java.util.Set; 024 025import javax.faces.context.FacesContext; 026 027import org.nuxeo.ecm.core.api.DocumentModel; 028import org.nuxeo.ecm.core.api.SortInfo; 029import org.nuxeo.ecm.platform.query.api.PageProvider; 030 031/** 032 * Service handling content views and associated page providers. 033 * 034 * @author Anahide Tchertchian 035 * @since 5.4 036 */ 037public interface ContentViewService extends Serializable { 038 039 /** 040 * Returns the content view with given name, or null if not found. 041 * 042 */ 043 ContentView getContentView(String name); 044 045 /** 046 * Returns the content view header, or null if not found. 047 */ 048 ContentViewHeader getContentViewHeader(String name); 049 050 /** 051 * Returns all the registered content view names, or an empty set if no content view is registered. 052 */ 053 Set<String> getContentViewNames(); 054 055 /** 056 * Returns all the registered content view headers, or an empty set if no content view is registered. 057 */ 058 Set<ContentViewHeader> getContentViewHeaders(); 059 060 /** 061 * Returns all the registered content view names with given flag declared on their definition 062 */ 063 Set<String> getContentViewNames(String flag); 064 065 /** 066 * Returns all the registered content view headers with given flag declared on their definition 067 * 068 * @since 5.4.2 069 */ 070 Set<ContentViewHeader> getContentViewHeaders(String flag); 071 072 /** 073 * Returns the page provider computed from the content view with given name. Its properties are resolved using 074 * current {@link FacesContext} instance if they are EL Expressions. 075 * <p> 076 * If not null, parameters sortInfos and pageSize will override information computed in the XML file. If not null, 077 * currentPage will override default current page (0). 078 * 079 * @since 5.7 080 */ 081 PageProvider<?> getPageProvider(String contentViewName, List<SortInfo> sortInfos, Long pageSize, Long currentPage, 082 DocumentModel searchDocument, Object... parameters); 083 084 /** 085 * Returns the state of this content view. 086 * <p> 087 * This state can be used to restore the content view in another context. 088 * 089 * @see #restoreContentView(ContentViewState) 090 * @since 5.4.2 091 * @param contentView 092 */ 093 ContentViewState saveContentView(ContentView contentView); 094 095 /** 096 * Restores a content view given a state. 097 * 098 * @see #saveContentView(ContentView) 099 * @since 5.4.2 100 */ 101 ContentView restoreContentView(ContentViewState contentViewState); 102 103 /** 104 * Restores a content view to a given state. 105 * 106 * @since 7.3 107 */ 108 void restoreContentViewState(ContentView contentView, ContentViewState contentViewState); 109 110}