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.aui;
016    
017    import com.liferay.portal.kernel.util.Validator;
018    import com.liferay.portal.kernel.workflow.WorkflowConstants;
019    import com.liferay.taglib.aui.base.BaseWorkflowStatusTag;
020    
021    import javax.servlet.http.HttpServletRequest;
022    
023    /**
024     * @author Julio Camarero
025     * @author Jorge Ferrer
026     * @author Brian Wing Shun Chan
027     */
028    public class WorkflowStatusTag extends BaseWorkflowStatusTag {
029    
030            @Override
031            protected String getPage() {
032                    String markupView = getMarkupView();
033    
034                    if (Validator.isNotNull(markupView)) {
035                            return
036                                    "/html/taglib/aui/workflow_status/" + markupView + "/page.jsp";
037                    }
038    
039                    return "/html/taglib/aui/workflow_status/page.jsp";
040            }
041    
042            @Override
043            protected boolean isCleanUpSetAttributes() {
044                    return _CLEAN_UP_SET_ATTRIBUTES;
045            }
046    
047            @Override
048            protected void setAttributes(HttpServletRequest request) {
049                    super.setAttributes(request);
050    
051                    Object bean = getBean();
052    
053                    if (bean == null) {
054                            bean = pageContext.getAttribute("aui:model-context:bean");
055                    }
056    
057                    String helpMessage = getHelpMessage();
058    
059                    if (Validator.isNull(helpMessage) &&
060                            (getStatus() == WorkflowConstants.STATUS_APPROVED) &&
061                            Validator.isNotNull(getVersion())) {
062    
063                            helpMessage = _HELP_MESSAGE_DEFAULT;
064                    }
065    
066                    Class<?> model = getModel();
067    
068                    if (model == null) {
069                            model = (Class<?>)pageContext.getAttribute(
070                                    "aui:model-context:model");
071                    }
072    
073                    setNamespacedAttribute(request, "bean", bean);
074                    setNamespacedAttribute(request, "helpMessage", helpMessage);
075                    setNamespacedAttribute(request, "model", model);
076            }
077    
078            private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
079    
080            private static final String _HELP_MESSAGE_DEFAULT =
081                    "a-new-version-is-created-automatically-if-this-content-is-" +
082                            "modified";
083    
084    }