01: /*
02: * (C) Copyright 2000 - 2007 Nabh Information Systems, Inc.
03: *
04: * This program is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU General Public License
06: * as published by the Free Software Foundation; either version 2
07: * of the License, or (at your option) any later version.
08: *
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: *
18: */
19: package com.nabhinc.portal.processor;
20:
21: import java.io.IOException;
22: import java.io.Writer;
23:
24: import javax.servlet.ServletException;
25: import javax.servlet.http.HttpServletRequest;
26: import javax.servlet.http.HttpServletResponse;
27:
28: import com.nabhinc.portal.api.EntityLockedException;
29: import com.nabhinc.portal.api.PortalInformationStoreLocator;
30: import com.nabhinc.portal.core.PortalConstants;
31: import com.nabhinc.portal.core.PortalUtil;
32: import com.nabhinc.portal.core.SessionCache;
33: import com.nabhinc.portal.model.PortalApplicationView;
34: import com.nabhinc.portal.model.PortalPageState;
35: import com.nabhinc.ws.core.WebServiceSecurityException;
36:
37: /**
38: * Processor to lock a psite.
39: *
40: * @author Padmanabh Dabke
41: * (c) 2007 Nabh Information Systems, Inc. All Rights Reserved.
42: */
43: public class LockPsiteProcessor extends BasePortalActionProcessor {
44:
45: public boolean isAccessible(HttpServletRequest request,
46: PortalApplicationView portalAppView,
47: PortalPageState pageState) throws ServletException {
48: return portalAppView.getPortalApplication().isEditable(request);
49:
50: }
51:
52: public boolean isLoginRequired(PortalApplicationView portalAppView,
53: PortalPageState pageState) {
54: return portalAppView.getPortalApplication()
55: .requiresLoginForEdit();
56: }
57:
58: public void process(HttpServletRequest request,
59: HttpServletResponse response, SessionCache sCache,
60: PortalApplicationView portalAppView,
61: PortalPageState pageState, int startIndex,
62: String[] portalParams, String displayMode,
63: String targetWindowId, boolean isAJAXRequest)
64: throws ServletException, IOException {
65:
66: try {
67: PortalInformationStoreLocator.getPortalInformationStore()
68: .lockPortalApplication(
69: portalAppView.getPortalApplication()
70: .getPath());
71: if (isAJAXRequest) {
72: Writer w = response.getWriter();
73: w.write(PortalConstants.AJAX_SUCCESS_TOKEN);
74: } else {
75: ViewProcessor.getInstance().process(request, response,
76: sCache, portalAppView, pageState, startIndex,
77: portalParams, displayMode, targetWindowId,
78: isAJAXRequest);
79: }
80: } catch (WebServiceSecurityException e) {
81: response.setStatus(HttpServletResponse.SC_FORBIDDEN);
82: return;
83: } catch (EntityLockedException e) {
84: PortalUtil.handlePortalError(
85: "Psite is already locked by another user.",
86: request, response, isAJAXRequest);
87: if (!isAJAXRequest) {
88: ViewProcessor.getInstance().process(request, response,
89: sCache, portalAppView, pageState, startIndex,
90: portalParams, displayMode, targetWindowId,
91: isAJAXRequest);
92: }
93: }
94: }
95: }
|