001    /**
002     * Copyright (c) 2000-2010 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.portlet.messageboards.asset;
016    
017    import com.liferay.portal.kernel.portlet.LiferayPortletRequest;
018    import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
019    import com.liferay.portal.util.PortletKeys;
020    import com.liferay.portal.util.WebKeys;
021    import com.liferay.portlet.messageboards.model.MBMessage;
022    
023    import javax.portlet.PortletURL;
024    import javax.portlet.RenderRequest;
025    import javax.portlet.RenderResponse;
026    
027    /**
028     * @author Jorge Ferrer
029     */
030    public class MBDiscussionAssetRenderer extends MBMessageAssetRenderer {
031    
032            public MBDiscussionAssetRenderer(MBMessage message) {
033                    super(message);
034    
035                    _message = message;
036            }
037    
038            public PortletURL getURLEdit(
039                    LiferayPortletRequest liferayPortletRequest,
040                    LiferayPortletResponse liferayPortletResponse) {
041    
042                    PortletURL editPortletURL = liferayPortletResponse.createRenderURL(
043                            PortletKeys.MESSAGE_BOARDS);
044    
045                    editPortletURL.setParameter(
046                            "struts_action", "/message_boards/edit_discussion");
047                    editPortletURL.setParameter(
048                            "messageId", String.valueOf(_message.getMessageId()));
049    
050                    return editPortletURL;
051            }
052            public String getURLViewInContext(
053                    LiferayPortletRequest liferayPortletRequest,
054                    LiferayPortletResponse liferayPortletResponse,
055                    String noSuchEntryRedirect) {
056    
057                    return null;
058            }
059    
060            public String render(
061                            RenderRequest renderRequest, RenderResponse renderResponse,
062                            String template)
063                    throws Exception {
064    
065                    if (template.equals(TEMPLATE_ABSTRACT) ||
066                            template.equals(TEMPLATE_FULL_CONTENT)) {
067    
068                            renderRequest.setAttribute(
069                                    WebKeys.MESSAGE_BOARDS_MESSAGE, _message);
070    
071                            return
072                                    "/html/portlet/message_boards/asset/discussion_" + template +
073                                            ".jsp";
074                    }
075                    else {
076                            return null;
077                    }
078            }
079    
080            private MBMessage _message;
081    
082    }