001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.taglib.ui;
016    
017    import com.liferay.portal.kernel.comment.Comment;
018    import com.liferay.portal.kernel.repository.model.FileEntry;
019    import com.liferay.portal.kernel.search.RelatedSearchResult;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.PropsKeys;
022    import com.liferay.portal.kernel.util.PropsUtil;
023    import com.liferay.taglib.util.IncludeTag;
024    
025    import java.util.List;
026    
027    import javax.servlet.ServletContext;
028    import javax.servlet.http.HttpServletRequest;
029    
030    /**
031     * @author Eudaldo Alonso
032     * @author Tibor Lipusz
033     */
034    public class AppViewSearchEntryTag extends IncludeTag {
035    
036            @Override
037            public int doStartTag() {
038                    return EVAL_BODY_INCLUDE;
039            }
040    
041            public void setActionJsp(String actionJsp) {
042                    _actionJsp = actionJsp;
043            }
044    
045            public void setActionJspServletContext(
046                    ServletContext actionJspServletContext) {
047    
048                    _actionJspServletContext = actionJspServletContext;
049            }
050    
051            public void setCommentRelatedSearchResults(
052                    List<RelatedSearchResult<Comment>> commentRelatedSearchResults) {
053    
054                    _commentRelatedSearchResults = commentRelatedSearchResults;
055            }
056    
057            public void setContainerName(String containerName) {
058                    _containerName = containerName;
059            }
060    
061            public void setContainerType(String containerType) {
062                    _containerType = containerType;
063            }
064    
065            public void setCssClass(String cssClass) {
066                    _cssClass = cssClass;
067            }
068    
069            public void setDescription(String description) {
070                    _description = description;
071            }
072    
073            public void setEscape(boolean escape) {
074                    _escape = escape;
075            }
076    
077            public void setFileEntryRelatedSearchResults(
078                    List<RelatedSearchResult<FileEntry>> fileEntryRelatedSearchResults) {
079    
080                    _fileEntryRelatedSearchResults = fileEntryRelatedSearchResults;
081            }
082    
083            public void setHighlightEnabled(boolean highlightEnabled) {
084                    _highlightEnabled = highlightEnabled;
085            }
086    
087            public void setLocked(boolean locked) {
088                    _locked = locked;
089            }
090    
091            public void setQueryTerms(String[] queryTerms) {
092                    _queryTerms = queryTerms;
093            }
094    
095            public void setRowCheckerId(String rowCheckerId) {
096                    _rowCheckerId = rowCheckerId;
097            }
098    
099            public void setRowCheckerName(String rowCheckerName) {
100                    _rowCheckerName = rowCheckerName;
101            }
102    
103            public void setShowCheckbox(boolean showCheckbox) {
104                    _showCheckbox = showCheckbox;
105            }
106    
107            public void setStatus(int status) {
108                    _status = status;
109            }
110    
111            public void setThumbnailSrc(String thumbnailSrc) {
112                    _thumbnailSrc = thumbnailSrc;
113            }
114    
115            public void setTitle(String title) {
116                    _title = title;
117            }
118    
119            public void setUrl(String url) {
120                    _url = url;
121            }
122    
123            public void setVersions(List<String> versions) {
124                    _versions = versions;
125            }
126    
127            @Override
128            protected void cleanUp() {
129                    _actionJsp = null;
130                    _commentRelatedSearchResults = null;
131                    _containerName = null;
132                    _containerType = null;
133                    _cssClass = null;
134                    _description = null;
135                    _escape = true;
136                    _fileEntryRelatedSearchResults = null;
137                    _highlightEnabled = _HIGHLIGHT_ENABLED;
138                    _locked = false;
139                    _queryTerms = null;
140                    _rowCheckerId = null;
141                    _rowCheckerName = null;
142                    _showCheckbox = false;
143                    _status = 0;
144                    _thumbnailSrc = null;
145                    _title = null;
146                    _url = null;
147                    _versions = null;
148            }
149    
150            protected ServletContext getActionJspServletContext() {
151                    if (_actionJspServletContext != null) {
152                            return _actionJspServletContext;
153                    }
154    
155                    return servletContext;
156            }
157    
158            @Override
159            protected String getPage() {
160                    return _PAGE;
161            }
162    
163            @Override
164            protected boolean isCleanUpSetAttributes() {
165                    return _CLEAN_UP_SET_ATTRIBUTES;
166            }
167    
168            @Override
169            protected void setAttributes(HttpServletRequest request) {
170                    request.setAttribute(
171                            "liferay-ui:app-view-search-entry:actionJsp", _actionJsp);
172                    request.setAttribute(
173                            "liferay-ui:app-view-entry:actionJspServletContext",
174                            getActionJspServletContext());
175                    request.setAttribute(
176                            "liferay-ui:app-view-search-entry:commentRelatedSearchResults",
177                            _commentRelatedSearchResults);
178                    request.setAttribute(
179                            "liferay-ui:app-view-search-entry:containerName", _containerName);
180                    request.setAttribute(
181                            "liferay-ui:app-view-search-entry:containerType", _containerType);
182                    request.setAttribute(
183                            "liferay-ui:app-view-search-entry:cssClass", _cssClass);
184                    request.setAttribute(
185                            "liferay-ui:app-view-search-entry:description", _description);
186                    request.setAttribute(
187                            "liferay-ui:app-view-search-entry:escape", _escape);
188                    request.setAttribute(
189                            "liferay-ui:app-view-search-entry:fileEntryRelatedSearchResults",
190                            _fileEntryRelatedSearchResults);
191                    request.setAttribute(
192                            "liferay-ui:app-view-search-entry:highlightEnabled",
193                            _highlightEnabled);
194                    request.setAttribute(
195                            "liferay-ui:app-view-search-entry:locked", _locked);
196                    request.setAttribute(
197                            "liferay-ui:app-view-search-entry:queryTerms", _queryTerms);
198                    request.setAttribute(
199                            "liferay-ui:app-view-search-entry:rowCheckerId", _rowCheckerId);
200                    request.setAttribute(
201                            "liferay-ui:app-view-search-entry:rowCheckerName", _rowCheckerName);
202                    request.setAttribute(
203                            "liferay-ui:app-view-search-entry:showCheckbox", _showCheckbox);
204                    request.setAttribute(
205                            "liferay-ui:app-view-search-entry:status", _status);
206                    request.setAttribute(
207                            "liferay-ui:app-view-search-entry:thumbnailSrc", _thumbnailSrc);
208                    request.setAttribute("liferay-ui:app-view-search-entry:title", _title);
209                    request.setAttribute("liferay-ui:app-view-search-entry:url", _url);
210                    request.setAttribute(
211                            "liferay-ui:app-view-search-entry:versions", _versions);
212            }
213    
214            private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
215    
216            private static final boolean _HIGHLIGHT_ENABLED = GetterUtil.getBoolean(
217                    PropsUtil.get(PropsKeys.INDEX_SEARCH_HIGHLIGHT_ENABLED));
218    
219            private static final String _PAGE =
220                    "/html/taglib/ui/app_view_search_entry/page.jsp";
221    
222            private String _actionJsp;
223            private ServletContext _actionJspServletContext;
224            private List<RelatedSearchResult<Comment>> _commentRelatedSearchResults;
225            private String _containerName;
226            private String _containerType;
227            private String _cssClass;
228            private String _description;
229            private boolean _escape;
230            private List<RelatedSearchResult<FileEntry>> _fileEntryRelatedSearchResults;
231            private boolean _highlightEnabled = _HIGHLIGHT_ENABLED;
232            private boolean _locked;
233            private String[] _queryTerms;
234            private String _rowCheckerId;
235            private String _rowCheckerName;
236            private boolean _showCheckbox = false;
237            private int _status = 0;
238            private String _thumbnailSrc;
239            private String _title;
240            private String _url;
241            private List<String> _versions;
242    
243    }