KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > portlets > contentlet > action > PublishContentletsAction


1 package com.dotmarketing.portlets.contentlet.action;
2
3 import java.net.URLDecoder JavaDoc;
4
5 import javax.portlet.ActionRequest;
6 import javax.portlet.ActionResponse;
7 import javax.portlet.PortletConfig;
8
9 import org.apache.struts.action.ActionForm;
10 import org.apache.struts.action.ActionMapping;
11
12 import com.dotmarketing.factories.InodeFactory;
13 import com.dotmarketing.factories.PublishFactory;
14 import com.dotmarketing.portal.struts.DotPortletAction;
15 import com.dotmarketing.portlets.contentlet.factories.ContentletFactory;
16 import com.dotmarketing.portlets.contentlet.model.Contentlet;
17 import com.dotmarketing.util.Config;
18 import com.dotmarketing.util.Logger;
19 import com.liferay.portal.model.User;
20 import com.liferay.portlet.ActionRequestImpl;
21 import com.liferay.util.servlet.SessionMessages;
22
23 /**
24  * <a HREF="ViewQuestionsAction.java.htm"><b><i>View Source</i></b></a>
25  *
26  * @author if(working==false){ author="Maria Ahues"; }else{ author="Rocco Maglio"; }
27  * @version $Revision: 1.3 $
28  *
29  */

30 public class PublishContentletsAction extends DotPortletAction {
31
32     public void processAction(
33              ActionMapping mapping, ActionForm form, PortletConfig config,
34              ActionRequest req, ActionResponse res)
35          throws Exception JavaDoc {
36
37         Logger.debug(this, "Running PublishContentletsAction!!!!");
38
39         String JavaDoc referer = req.getParameter("referer");
40         if ((referer!=null) && (referer.length()!=0)) {
41             referer = URLDecoder.decode(referer,"UTF-8");
42         }
43         
44         try {
45             //get the user
46
User user = com.liferay.portal.util.PortalUtil.getUser(req);
47
48             _publishContentlets(req, user);
49             
50             if ((referer!=null) && (referer.length()!=0)) {
51                 _sendToReferral(req, res, referer);
52             }
53             
54             setForward(req, "portlet.ext.contentlet.publish_contentlets");
55
56         }
57         catch (Exception JavaDoc e) {
58             _handleException(e, req);
59         }
60     }
61
62     private void _publishContentlets(ActionRequest req, User user) throws Exception JavaDoc {
63         
64         String JavaDoc[] publishInode = req.getParameterValues("publishInode");
65         
66         if (publishInode == null) return;
67
68         ActionRequestImpl reqImpl = (ActionRequestImpl)req;
69         
70         for (int i=0;i<publishInode.length;i++) {
71             Contentlet contentlet = (Contentlet) InodeFactory.getInode(publishInode[i],Contentlet.class);
72
73             Logger.debug(this, "Publishing contentlet inode=" + contentlet.getInode() + " publishinode=" + publishInode[i]);
74     
75             if (contentlet.getInode()>0) {
76                 //calls the asset factory edit
77
PublishFactory.publishAsset(contentlet,reqImpl.getHttpServletRequest());
78             }
79             ContentletFactory.reIndexContentlet(contentlet);
80         }
81         
82         
83         SessionMessages.add(req, "message", "message.contentlet_list.published");
84         
85     }
86
87 }
Popular Tags