001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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 boolean isCleanUpSetAttributes() {
032                    return _CLEAN_UP_SET_ATTRIBUTES;
033            }
034    
035            @Override
036            protected void setAttributes(HttpServletRequest request) {
037                    super.setAttributes(request);
038    
039                    Object bean = getBean();
040    
041                    if (bean == null) {
042                            bean = pageContext.getAttribute("aui:model-context:bean");
043                    }
044    
045                    String helpMessage = getHelpMessage();
046    
047                    if (Validator.isNull(helpMessage) &&
048                            (getStatus() == WorkflowConstants.STATUS_APPROVED) &&
049                            Validator.isNotNull(getVersion())) {
050    
051                            helpMessage = _HELP_MESSAGE_DEFAULT;
052                    }
053    
054                    Class<?> model = getModel();
055    
056                    if (model == null) {
057                            model = (Class<?>)pageContext.getAttribute(
058                                    "aui:model-context:model");
059                    }
060    
061                    setNamespacedAttribute(request, "bean", bean);
062                    setNamespacedAttribute(request, "helpMessage", helpMessage);
063                    setNamespacedAttribute(request, "model", model);
064            }
065    
066            private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
067    
068            private static final String _HELP_MESSAGE_DEFAULT =
069                    "a-new-version-will-be-created-automatically-if-this-content-is-" +
070                            "modified";
071    
072    }