KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > portlets > htmlpages > action > EditHTMLPageAction


1 package com.dotmarketing.portlets.htmlpages.action;
2
3 import java.net.URLDecoder JavaDoc;
4 import java.net.URLEncoder JavaDoc;
5 import java.util.List JavaDoc;
6
7 import javax.portlet.ActionRequest;
8 import javax.portlet.ActionResponse;
9 import javax.portlet.PortletConfig;
10 import javax.portlet.WindowState;
11 import javax.servlet.http.HttpServletRequest JavaDoc;
12
13 import org.apache.commons.beanutils.BeanUtils;
14 import org.apache.struts.action.ActionForm;
15 import org.apache.struts.action.ActionMapping;
16
17 import com.dotmarketing.beans.Host;
18 import com.dotmarketing.beans.Identifier;
19 import com.dotmarketing.cache.IdentifierCache;
20 import com.dotmarketing.cache.LiveCache;
21 import com.dotmarketing.cache.WorkingCache;
22 import com.dotmarketing.db.DotHibernate;
23 import com.dotmarketing.factories.HostFactory;
24 import com.dotmarketing.factories.IdentifierFactory;
25 import com.dotmarketing.factories.InodeFactory;
26 import com.dotmarketing.factories.WebAssetFactory;
27 import com.dotmarketing.menubuilders.RefreshMenus;
28 import com.dotmarketing.portal.struts.DotPortletAction;
29 import com.dotmarketing.portal.struts.DotPortletActionInterface;
30 import com.dotmarketing.portlets.folders.factories.FolderFactory;
31 import com.dotmarketing.portlets.folders.model.Folder;
32 import com.dotmarketing.portlets.htmlpages.factories.HTMLPageFactory;
33 import com.dotmarketing.portlets.htmlpages.model.HTMLPage;
34 import com.dotmarketing.portlets.htmlpages.struts.HTMLPageForm;
35 import com.dotmarketing.portlets.templates.model.Template;
36 import com.dotmarketing.services.PageServices;
37 import com.dotmarketing.util.Config;
38 import com.dotmarketing.util.Logger;
39 import com.dotmarketing.util.UtilMethods;
40 import com.dotmarketing.util.Validator;
41 import com.dotmarketing.util.WebKeys;
42 import com.liferay.portal.model.User;
43 import com.liferay.portal.struts.ActionException;
44 import com.liferay.portal.util.Constants;
45 import com.liferay.portlet.ActionRequestImpl;
46 import com.liferay.util.servlet.SessionMessages;
47
48 /**
49  * @author Maria
50  */

51
52 public class EditHTMLPageAction extends DotPortletAction implements
53         DotPortletActionInterface {
54
55     public void processAction(ActionMapping mapping, ActionForm form,
56             PortletConfig config, ActionRequest req, ActionResponse res)
57             throws Exception JavaDoc {
58
59         String JavaDoc cmd = req.getParameter(Constants.CMD);
60         String JavaDoc referer = req.getParameter("referer");
61
62         //wraps request to get session object
63
ActionRequestImpl reqImpl = (ActionRequestImpl) req;
64         HttpServletRequest JavaDoc httpReq = reqImpl.getHttpServletRequest();
65
66         if ((referer != null) && (referer.length() != 0)) {
67             referer = URLDecoder.decode(referer, "UTF-8");
68         }
69
70         Logger.debug(this, "EditHTMLPageAction cmd=" + cmd);
71
72         DotHibernate.startTransaction();
73
74         User user = _getUser(req);
75
76         try {
77             Logger.debug(this, "Calling Retrieve method");
78             _retrieveWebAsset(req, res, config, form, user, HTMLPage.class,
79                     WebKeys.HTMLPAGE_EDIT);
80
81         } catch (Exception JavaDoc ae) {
82             _handleException(ae, req);
83             return;
84         }
85
86         /*
87          * We are editing the html page
88          */

89         if ((cmd != null) && cmd.equals(Constants.EDIT)) {
90             try {
91                 Logger.debug(this, "Calling Edit Method");
92                 _editWebAsset(req, res, config, form, user);
93
94             } catch (Exception JavaDoc ae) {
95                 if ((referer != null) && (referer.length() != 0)) {
96                     if (ae.getMessage().equals(WebKeys.EDIT_ASSET_EXCEPTION)) {
97
98                         //The web asset edit threw an exception because it's
99
// locked so it should redirect back with message
100
java.util.Map JavaDoc<String JavaDoc,String JavaDoc[]> params = new java.util.HashMap JavaDoc<String JavaDoc,String JavaDoc[]>();
101                         params.put("struts_action",new String JavaDoc[] { "/ext/director/direct" });
102                         params.put("cmd", new String JavaDoc[] { "editHTMLPage" });
103                         params.put("htmlPage", new String JavaDoc[] { req.getParameter("inode") });
104                         params.put("referer", new String JavaDoc[] { URLEncoder.encode(referer, "UTF-8") });
105
106                         String JavaDoc directorURL = com.dotmarketing.util.PortletURLUtil
107                                 .getActionURL(httpReq, WindowState.MAXIMIZED
108                                         .toString(), params);
109
110                         _sendToReferral(req, res, directorURL);
111                         return;
112                     }
113                 }
114                 _handleException(ae, req);
115                 return;
116             }
117         }
118
119         if ((cmd != null) && cmd.equals("newedit")) {
120             try {
121
122                 Logger.debug(this, "Calling newEdit Method");
123                 String JavaDoc url = req.getParameter("url");
124                 String JavaDoc folderPath = url.substring(0, url.lastIndexOf("/"));
125                 long hostId = Long.parseLong(req.getParameter("hostId"));
126                 Folder folder = FolderFactory.createFolders(folderPath,hostId,req);
127
128                 String JavaDoc page = url.substring(url.lastIndexOf("/")+1, url.length());
129                 String JavaDoc pageName = page.replaceAll(
130                         "." + Config.getStringProperty("VELOCITY_PAGE_EXTENSION"), "");
131
132                 HTMLPage htmlpage = new HTMLPage();
133                 htmlpage.setParent(folder.getInode());
134                 htmlpage.setPageUrl(url);
135                 htmlpage.setTitle(pageName);
136                 htmlpage.setFriendlyName(pageName);
137
138                 req.setAttribute(WebKeys.HTMLPAGE_EDIT,htmlpage);
139
140
141                 HTMLPageForm htmlForm = new HTMLPageForm();
142                 htmlForm.setParent(folder.getInode());
143                 htmlForm.setSelectedparent(folder.getName());
144                 htmlForm.setSelectedparentPath(folder.getPath());
145                 htmlForm.setPageUrl(pageName);
146                 htmlForm.setTitle(pageName);
147                 htmlForm.setFriendlyName(pageName);
148
149
150
151                 BeanUtils.copyProperties(form, htmlpage);
152                 BeanUtils.copyProperties(form, htmlForm);
153
154                 req.setAttribute(WebKeys.PERMISSION_INODE_EDIT, folder);
155
156
157             } catch (Exception JavaDoc ae) {
158                 if ((referer != null) && (referer.length() != 0)) {
159                     if (ae.getMessage().equals(WebKeys.EDIT_ASSET_EXCEPTION)) {
160
161                         //The web asset edit threw an exception because it's
162
// locked so it should redirect back with message
163
java.util.Map JavaDoc<String JavaDoc,String JavaDoc[]> params = new java.util.HashMap JavaDoc<String JavaDoc,String JavaDoc[]>();
164                         params.put("struts_action",new String JavaDoc[] { "/ext/director/direct" });
165                         params.put("cmd", new String JavaDoc[] { "editHTMLPage" });
166                         params.put("htmlPage", new String JavaDoc[] { req.getParameter("inode") });
167                         params.put("referer", new String JavaDoc[] { URLEncoder.encode(referer, "UTF-8") });
168
169                         String JavaDoc directorURL = com.dotmarketing.util.PortletURLUtil
170                                 .getActionURL(httpReq, WindowState.MAXIMIZED
171                                         .toString(), params);
172
173                         _sendToReferral(req, res, directorURL);
174                         return;
175                     }
176                 }
177                 _handleException(ae, req);
178                 return;
179             }
180         }
181
182         /*
183          * If we are updating the html page, copy the information from the
184          * struts bean to the hbm inode and run the update action and return to
185          * the list
186          */

187         if ((cmd != null) && cmd.equals(Constants.ADD)) {
188             try {
189
190                 if (Validator.validate(req, form, mapping)) {
191
192                     Logger.debug(this, "Calling Save Method");
193
194                     _saveWebAsset(req, res, config, form, user);
195
196                     String JavaDoc subcmd = req.getParameter("subcmd");
197
198                     if ((subcmd != null) && subcmd.equals(com.dotmarketing.util.Constants.PUBLISH))
199                     {
200                         Logger.debug(this, "Calling Publish Method");
201                         _publishWebAsset(req, res, config, form, user, WebKeys.HTMLPAGE_FORM_EDIT);
202                     }
203
204                     //Obtain the URL for the preview page
205
referer = getPreviewPageURL(req, referer);
206
207                     _sendToReferral(req, res, referer);
208                 }
209
210             } catch (Exception JavaDoc ae) {
211                 _handleException(ae, req);
212             }
213
214         }
215
216         /*
217          * If we are deleteing the html page, run the delete action and return
218          * to the list
219          *
220          */

221         else if ((cmd != null) && cmd.equals(Constants.DELETE)) {
222             try {
223                 Logger.debug(this, "Calling Delete Method");
224
225                 _deleteWebAsset(req, res, config, form, user,
226                         WebKeys.HTMLPAGE_EDIT);
227
228             } catch (Exception JavaDoc ae) {
229                 _handleException(ae, req);
230                 return;
231             }
232             _sendToReferral(req, res, referer);
233         }
234         /*
235          * If we are undeleting the html page, run the undelete action and
236          * return to the list
237          *
238          */

239         else if ((cmd != null)
240                 && cmd.equals(com.dotmarketing.util.Constants.UNDELETE)) {
241             try {
242                 Logger.debug(this, "Calling UnDelete Method");
243
244                 _undeleteWebAsset(req, res, config, form, user,
245                         WebKeys.HTMLPAGE_EDIT);
246
247             } catch (Exception JavaDoc ae) {
248                 _handleException(ae, req);
249                 return;
250             }
251             _sendToReferral(req, res, referer);
252
253         }
254         /*
255          * If we are deleting the html page version, run the deeleteversion
256          * action and return to the list
257          */

258         else if ((cmd != null)
259                 && cmd.equals(com.dotmarketing.util.Constants.DELETEVERSION)) {
260             try {
261                 Logger.debug(this, "Calling Delete Version Method");
262
263                 _deleteVersionWebAsset(req, res, config, form, user,
264                         WebKeys.HTMLPAGE_EDIT);
265
266             } catch (Exception JavaDoc ae) {
267                 _handleException(ae, req);
268                 return;
269             }
270             _sendToReferral(req, res, referer);
271         }
272         /*
273          * If we are unpublishing the html page, run the unpublish action and
274          * return to the list
275          */

276         else if ((cmd != null)
277                 && cmd.equals(com.dotmarketing.util.Constants.UNPUBLISH)) {
278             try {
279                 Logger.debug(this, "Calling Unpublish Method");
280
281                 _unPublishWebAsset(req, res, config, form, user,
282                         WebKeys.HTMLPAGE_EDIT);
283
284             } catch (Exception JavaDoc ae) {
285                 _handleException(ae, req);
286                 return;
287             }
288             _sendToReferral(req, res, referer);
289
290         }
291         /*
292          * If we are getting the html page version back, run the getversionback
293          * action and return to the list
294          */

295         else if ((cmd != null)
296                 && cmd.equals(com.dotmarketing.util.Constants.GETVERSIONBACK)) {
297             try {
298                 Logger.debug(this, "Calling Get Version Back Method");
299
300                 _getVersionBackWebAsset(req, res, config, form, user);
301
302             } catch (Exception JavaDoc ae) {
303                 _handleException(ae, req);
304                 return;
305             }
306             _sendToReferral(req, res, referer);
307         }
308         /*
309          * If we are getting the html page versions, run the assetversions
310          * action and return to the list
311          */

312         else if ((cmd != null)
313                 && cmd.equals(com.dotmarketing.util.Constants.ASSETVERSIONS)) {
314             try {
315                 Logger.debug(this, "Calling Get Versions Method");
316
317                 _getVersionsWebAsset(req, res, config, form, user,
318                         WebKeys.HTMLPAGE_EDIT, WebKeys.HTMLPAGE_VERSIONS);
319
320             } catch (Exception JavaDoc ae) {
321                 _handleException(ae, req);
322                 return;
323             }
324         }
325         /*
326          * If we are unlocking the html page, run the unlock action and return
327          * to the list
328          */

329         else if ((cmd != null)
330                 && cmd.equals(com.dotmarketing.util.Constants.UNLOCK)) {
331             try {
332                 Logger.debug(this, "Calling Unlock Method");
333
334                 _unLockWebAsset(req, res, config, form, user,
335                         WebKeys.HTMLPAGE_EDIT);
336
337             } catch (Exception JavaDoc ae) {
338                 _handleException(ae, req);
339                 return;
340             }
341             _sendToReferral(req, res, referer);
342
343         }
344         /*
345          * If we are copying the html page, run the copy action and return to
346          * the list
347          */

348         else if ((cmd != null)
349                 && cmd.equals(com.dotmarketing.util.Constants.COPY)) {
350             try {
351                 Logger.debug(this, "Calling Copy Method");
352
353                 _copyWebAsset(req, res, config, form, user);
354
355             } catch (Exception JavaDoc ae) {
356                 _handleException(ae, req);
357             }
358             _sendToReferral(req, res, referer);
359         }
360         /*
361          * If we are moving the html page, run the copy action and return to the
362          * list
363          */

364         else if ((cmd != null)
365                 && cmd.equals(com.dotmarketing.util.Constants.MOVE)) {
366             try {
367                 Logger.debug(this, "Calling Move Method");
368
369                 _moveWebAsset(req, res, config, form, user);
370
371             } catch (ActionException ae) {
372             } catch (Exception JavaDoc ae) {
373                 _handleException(ae, req);
374             }
375             _sendToReferral(req, res, referer);
376         } else
377             Logger.debug(this, "Unspecified Action");
378
379         DotHibernate.commitTransaction();
380
381         setForward(req, "portlet.ext.htmlpages.edit_htmlpage");
382     }
383
384     ///// ************** ALL METHODS HERE *************************** ////////
385

386     protected String JavaDoc getPreviewPageURL(ActionRequest req, String JavaDoc referer) {
387         //Obtain the URL for the preview page
388
//Retreiving the current HTMLPage
389
HTMLPage existingHTMLPage = (HTMLPage) req.getAttribute(WebKeys.HTMLPAGE_EDIT);
390         if (existingHTMLPage.getInode() == 0 || !UtilMethods.isSet(referer))
391         {
392             existingHTMLPage = (HTMLPage) req.getAttribute(WebKeys.HTMLPAGE_FORM_EDIT);
393             Host host = HostFactory.getParentHost(existingHTMLPage);
394             long host_id = host.getInode();
395             //go to preview mode for this page
396
java.util.Map JavaDoc<String JavaDoc,String JavaDoc[]> params = new java.util.HashMap JavaDoc<String JavaDoc,String JavaDoc[]>();
397             params.put("struts_action",new String JavaDoc[] {"/ext/htmlpages/preview_htmlpage"});
398             params.put("inode",new String JavaDoc[] { existingHTMLPage.getInode() + "" });
399             params.put("host_id",new String JavaDoc[] { host_id + "" });
400             return com.dotmarketing.util.PortletURLUtil.getActionURL(req,WindowState.MAXIMIZED.toString(),params);
401         }
402         return referer;
403     }
404
405
406     //this method is implemented again here because it has some differences
407
// with cache updates!!!!
408
public void _moveWebAsset(ActionRequest req, ActionResponse res,
409             PortletConfig config, ActionForm form, User user) throws Exception JavaDoc {
410
411         //wraps request to get session object
412
ActionRequestImpl reqImpl = (ActionRequestImpl) req;
413         HttpServletRequest JavaDoc httpReq = reqImpl.getHttpServletRequest();
414
415         Logger.debug(this, "I'm moving the web page");
416
417         //gets the current container being edited from the request object
418
HTMLPage webAsset = (HTMLPage) req.getAttribute(WebKeys.HTMLPAGE_EDIT);
419
420         String JavaDoc parentInode = req.getParameter("parent");
421
422         if (parentInode != null && parentInode.length() != 0
423                 && !parentInode.equals("0")) {
424             //the new parent is being passed through the request
425
Folder parent = (Folder) InodeFactory.getInode(parentInode,
426                     Folder.class);
427             if(HTMLPageFactory.moveHTMLPage(webAsset, parent)) {
428                 SessionMessages.add(httpReq, "message", "message.htmlpage.move");
429             } else {
430                 SessionMessages.add(httpReq, "message", "message.htmlpage.error.htmlpage.exists");
431                 throw new ActionException("Another page with the same page url exists in this folder");
432             }
433         }
434
435     }
436
437     public void _editWebAsset(ActionRequest req, ActionResponse res,
438             PortletConfig config, ActionForm form, User user) throws Exception JavaDoc {
439
440         //calls edit method from super class that returns parent folder
441
Folder parentFolder = super._editWebAsset(req, res, config, form, user,
442                 WebKeys.HTMLPAGE_EDIT);
443
444                 //setting parent folder path and inode on the form bean
445
HTMLPageForm hf = (HTMLPageForm) form;
446
447         hf.setSelectedparent(parentFolder.getName());
448         hf.setParent(parentFolder.getInode());
449         hf.setSelectedparentPath(parentFolder.getPath());
450
451         //This can't be done on the WebAsset so it needs to be done here.
452
HTMLPage htmlpage = (HTMLPage) req.getAttribute(WebKeys.HTMLPAGE_EDIT);
453         htmlpage.setParent(parentFolder.getInode());
454
455         //removes the extension .jsp from page url
456
String JavaDoc pageName = htmlpage.getPageUrl();
457         if (pageName != null) {
458             pageName = pageName.replaceAll(
459                     "." + Config.getStringProperty("VELOCITY_PAGE_EXTENSION"), "");
460         }
461         //to remove the page extension on the bean
462
hf.setPageUrl(pageName);
463
464         //Permission variable
465
if (htmlpage.getInode()>0)
466             req.setAttribute(WebKeys.PERMISSION_INODE_EDIT, htmlpage);
467         else //if the html page is new the parentfolder permissions are used
468
req.setAttribute(WebKeys.PERMISSION_INODE_EDIT, parentFolder);
469     }
470
471     @SuppressWarnings JavaDoc("unchecked")
472     public void _saveWebAsset(ActionRequest req, ActionResponse res,
473             PortletConfig config, ActionForm form, User user) throws Exception JavaDoc {
474
475         //wraps request to get session object
476
ActionRequestImpl reqImpl = (ActionRequestImpl) req;
477         HttpServletRequest JavaDoc httpReq = reqImpl.getHttpServletRequest();
478
479         //Retreiving the current HTMLPage
480
HTMLPage existingHTMLPage = (HTMLPage) req.getAttribute(WebKeys.HTMLPAGE_EDIT);
481
482         boolean previousShowMenu = existingHTMLPage.isShowOnMenu();
483         
484         //parent folder or inode for this file
485
Folder parentFolder = (Folder) InodeFactory.getInode(req
486                 .getParameter("parent"), Folder.class);
487
488         //Checking permissions
489
_checkPermissions(existingHTMLPage, parentFolder, user, httpReq);
490
491         //parent identifier for this file
492
Identifier identifier = (Identifier) IdentifierFactory.getParentIdentifier(existingHTMLPage);
493
494         //Creating the new page
495
HTMLPage newHtmlPage = new HTMLPage();
496         req.setAttribute(WebKeys.HTMLPAGE_FORM_EDIT, newHtmlPage);
497         BeanUtils.copyProperties(newHtmlPage, form);
498         newHtmlPage.setFriendlyName(newHtmlPage.getTitle());
499
500         //add VELOCITY_PAGE_EXTENSION to the pagename
501
if (!newHtmlPage.getPageUrl().endsWith(
502                 "." + Config.getStringProperty("VELOCITY_PAGE_EXTENSION"))) {
503             newHtmlPage.setPageUrl(newHtmlPage.getPageUrl() + "."
504                     + Config.getStringProperty("VELOCITY_PAGE_EXTENSION"));
505         }
506
507         //Some checks
508

509         //Get asset host based on the parentFolder of the asset
510
Host host = HostFactory.getParentHost(parentFolder);
511
512         //get an identifier based on this new uri
513
Identifier testIdentifier = (Identifier) IdentifierFactory
514                 .getIdentifierByURI(newHtmlPage.getURI(parentFolder), host);
515
516         // if this is a new htmlpage and there is already an identifier with
517
// this uri, return
518
if (existingHTMLPage.getInode() == 0 && testIdentifier.getInode() > 0) {
519             SessionMessages.add(httpReq, "message",
520                     "message.htmlpage.error.htmlpage.exists");
521             throw new ActionException(
522                     "Another page with the same page url exists in this folder");
523         }
524         // if this is an existing htmlpage and there is already an identifier
525
// with this uri, return
526
else if (existingHTMLPage.getInode() > 0
527                 && testIdentifier.getInode() != identifier.getInode()
528                 && testIdentifier.getInode() > 0) {
529             SessionMessages.add(httpReq, "message",
530                     "message.htmlpage.error.htmlpage.exists");
531             //when there is an error saving should unlock working asset
532
WebAssetFactory.unLockAsset(existingHTMLPage);
533             throw new ActionException(
534                     "Another page with the same page url exists in this folder");
535         }
536
537         HTMLPage workingAsset = null;
538         //Versioning
539
if (existingHTMLPage.getInode() > 0) {
540             //Creation the version asset
541
WebAssetFactory.createAsset(newHtmlPage, user.getUserId(),
542                     parentFolder, identifier, false);
543             DotHibernate.flush();
544
545             workingAsset = (HTMLPage) WebAssetFactory.saveAsset(newHtmlPage, identifier);
546
547             //if we need to update the identifier
548
if (parentFolder.getInode() > 0 && !workingAsset.getURI(parentFolder).equals(identifier.getURI())) {
549
550                 //assets cache
551
LiveCache.removeAssetFromCache(newHtmlPage);
552                 WorkingCache.removeAssetFromCache(newHtmlPage);
553                 IdentifierCache.removeAssetFromIdCache(newHtmlPage);
554
555                 IdentifierFactory
556                         .updateIdentifierURI(workingAsset, parentFolder);
557
558             }
559         } //Creating the new page
560
else {
561             WebAssetFactory.createAsset(newHtmlPage, user.getUserId(), parentFolder);
562             workingAsset = newHtmlPage;
563         }
564
565         //Setting HTML Page relations
566

567         String JavaDoc template = req.getParameter("template");
568         if (template != null) {
569             //Removing old templates
570
List JavaDoc<Template> oldTemplates = InodeFactory.getParentsOfClass(workingAsset, Template.class);
571             for (Template oldTemplate : oldTemplates) {
572                 oldTemplate.deleteChild(workingAsset);
573             }
574
575             //Adds template children from selected box
576
Template templateInode = (Template) InodeFactory.getInode(template,
577                     Template.class);
578             Identifier templateIdentifier = IdentifierFactory
579                     .getParentIdentifier(templateInode);
580             Template templateWorking = (Template) IdentifierFactory
581                     .getWorkingChildOfClass(templateIdentifier, Template.class);
582             templateWorking.addChild(workingAsset);
583         }
584
585         DotHibernate.flush();
586         DotHibernate.getSession().refresh(workingAsset);
587
588         //Saving page permissions
589
_applyPermissions(req, workingAsset);
590
591
592         //Refreshing the menues
593
if (previousShowMenu != workingAsset.isShowOnMenu()) {
594             //existing folder with different show on menu ... need to regenerate menu
595
RefreshMenus.deleteMenus();
596         }
597         
598         //Setting the new working page to publish tasks
599
req.setAttribute(WebKeys.HTMLPAGE_FORM_EDIT, workingAsset);
600         String JavaDoc this_page = workingAsset.getURI(parentFolder);
601         req.setAttribute(WebKeys.HTMLPAGE_REFERER, this_page);
602     }
603
604     public void _copyWebAsset(ActionRequest req, ActionResponse res,
605             PortletConfig config, ActionForm form, User user) throws Exception JavaDoc {
606
607         //wraps request to get session object
608
ActionRequestImpl reqImpl = (ActionRequestImpl) req;
609         HttpServletRequest JavaDoc httpReq = reqImpl.getHttpServletRequest();
610
611         //gets the current template being edited from the request object
612
HTMLPage currentHTMLPage = (HTMLPage) req
613                 .getAttribute(WebKeys.HTMLPAGE_EDIT);
614
615         //gets folder parent
616
String JavaDoc parentInode = req.getParameter("parent");
617         Folder parent = null;
618         if (parentInode != null && parentInode.length() != 0
619                 && !parentInode.equals("0")) {
620             //the parent is being passed through the request
621
parent = (Folder) InodeFactory.getInode(parentInode, Folder.class);
622             Logger.debug(this, "Parent Folder=" + parent.getInode());
623         } else {
624             parent = (Folder) InodeFactory.getParentOfClass(currentHTMLPage,
625                     Folder.class);
626             Logger.debug(this, "Parent Folder=" + parent.getInode());
627         }
628
629         //Checking permissions
630
_checkCopyAndMovePermissions(currentHTMLPage, parent, user, httpReq,"copy");
631
632         HTMLPageFactory.copyHTMLPage (currentHTMLPage, parent);
633
634         SessionMessages.add(httpReq, "message", "message.htmlpage.copy");
635     }
636
637     public void _getVersionBackWebAsset(ActionRequest req, ActionResponse res,
638             PortletConfig config, ActionForm form, User user) throws Exception JavaDoc {
639
640         super._getVersionBackWebAsset(req, res, config, form, user, HTMLPage.class, WebKeys.HTMLPAGE_EDIT);
641
642     }
643 }
Popular Tags