KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > portlets > files > action > PublishFilesAction


1 package com.dotmarketing.portlets.files.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.files.model.File;
16 import com.dotmarketing.util.Logger;
17 import com.liferay.portal.model.User;
18 import com.liferay.portlet.ActionRequestImpl;
19 import com.liferay.util.servlet.SessionMessages;
20
21 /**
22  * <a HREF="ViewQuestionsAction.java.htm"><b><i>View Source</i></b></a>
23  *
24  * @author Maria Ahues
25  * @version $Revision: 1.3 $
26  *
27  */

28 public class PublishFilesAction extends DotPortletAction {
29
30     public void processAction(
31              ActionMapping mapping, ActionForm form, PortletConfig config,
32              ActionRequest req, ActionResponse res)
33          throws Exception JavaDoc {
34
35         Logger.debug(this, "Running PublishFilesAction!!!!");
36
37         String JavaDoc referer = req.getParameter("referer");
38         if ((referer!=null) && (referer.length()!=0)) {
39             referer = URLDecoder.decode(referer,"UTF-8");
40         }
41         
42         try {
43             //get the user
44
User user = _getUser(req);
45
46             _publishFiles(req, user);
47             
48             if ((referer!=null) && (referer.length()!=0)) {
49                 _sendToReferral(req, res, referer);
50             }
51             
52             setForward(req, "portlet.ext.files.publish_files");
53
54         }
55         catch (Exception JavaDoc e) {
56             _handleException(e, req);
57         }
58     }
59
60     private void _publishFiles(ActionRequest req, User user) throws Exception JavaDoc {
61         
62         String JavaDoc[] publishInode = req.getParameterValues("publishInode");
63         if (publishInode == null) return;
64         
65         ActionRequestImpl reqImpl = (ActionRequestImpl)req;
66         
67         for (int i=0;i<publishInode.length;i++) {
68             File file = (File) InodeFactory.getInode(publishInode[i],File.class);
69     
70             if (file.getInode()>0) {
71                 //calls the asset factory edit
72
PublishFactory.publishAsset(file,reqImpl.getHttpServletRequest());
73             }
74         }
75         SessionMessages.add(req, "message", "message.file_list.published");
76         
77     }
78
79 }
Popular Tags