KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > vfs > actions > ShowVfsLocksDispatchAction


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.vfs.actions;
21
22 import java.util.Collection JavaDoc;
23
24 import javax.servlet.http.HttpServletRequest JavaDoc;
25 import javax.servlet.http.HttpServletResponse JavaDoc;
26
27 import org.apache.struts.action.ActionForm;
28 import org.apache.struts.action.ActionForward;
29 import org.apache.struts.action.ActionMapping;
30
31 import com.sslexplorer.policyframework.Permission;
32 import com.sslexplorer.policyframework.PolicyConstants;
33 import com.sslexplorer.security.SessionInfo;
34 import com.sslexplorer.table.actions.AbstractPagerAction;
35 import com.sslexplorer.vfs.VFSFileLock;
36 import com.sslexplorer.vfs.VFSLockManager;
37 import com.sslexplorer.vfs.forms.ShowVfsLocksForm;
38
39 /**
40  *
41  */

42 public final class ShowVfsLocksDispatchAction extends AbstractPagerAction {
43
44     /**
45      * Default constructor
46      */

47     public ShowVfsLocksDispatchAction() {
48         super(PolicyConstants.STATUS_TYPE_RESOURCE_TYPE, new Permission[] { PolicyConstants.PERM_VIEW });
49     }
50
51     /* (non-Javadoc)
52      * @see com.sslexplorer.core.actions.CoreAction#getNavigationContext(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
53      */

54     public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) {
55         return SessionInfo.MANAGEMENT_CONSOLE_CONTEXT;
56     }
57
58     /* (non-Javadoc)
59      * @see org.apache.struts.actions.DispatchAction#unspecified(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
60      */

61     public ActionForward filter(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
62                     throws Exception JavaDoc {
63         return unspecified(mapping, form, request, response);
64     }
65
66     /* (non-Javadoc)
67      * @see org.apache.struts.actions.DispatchAction#unspecified(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
68      */

69     public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
70                     throws Exception JavaDoc {
71         ShowVfsLocksForm locksForm = (ShowVfsLocksForm) form;
72         Collection JavaDoc<VFSFileLock> currentLocks = VFSLockManager.getInstance().getCurrentLocks();
73         locksForm.initialize(request.getSession(), currentLocks);
74         return mapping.findForward("display");
75     }
76     
77     /**
78      * @param mapping
79      * @param form
80      * @param request
81      * @param response
82      * @return ActionForward
83      * @throws Exception
84      */

85     public ActionForward unlockFile(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
86                     throws Exception JavaDoc {
87         String JavaDoc handle = request.getParameter("selectedResource");
88         VFSLockManager.getInstance().unlock(handle);
89         return unspecified(mapping, form, request, response);
90     }
91 }
Popular Tags