001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portal.cms.workflow;
023:
024: import javax.naming.InitialContext;
025: import javax.servlet.ServletException;
026: import javax.servlet.UnavailableException;
027: import javax.servlet.http.HttpServlet;
028: import javax.servlet.http.HttpServletRequest;
029: import javax.servlet.http.HttpServletResponse;
030: import java.io.IOException;
031:
032: /**
033: * Created on : Dec 20, 2006
034: *
035: * @author Sohil Shah - sohil.shah@jboss.com
036: */
037: public class ApprovePublishServlet extends HttpServlet {
038: private ApprovePublish approvePublishWorkflow = null;
039:
040: /**
041: *
042: */
043: public void init() throws ServletException {
044: try {
045: super .init();
046: InitialContext context = new InitialContext();
047: approvePublishWorkflow = (ApprovePublish) context
048: .lookup("java:portal/ApprovePublishWorkflow");
049: } catch (Exception e) {
050: throw new UnavailableException(e.toString());
051: }
052: }
053:
054: /**
055: *
056: */
057: protected void doGet(HttpServletRequest request,
058: HttpServletResponse response) throws ServletException,
059: IOException {
060: this .doPost(request, response);
061: }
062:
063: /**
064: *
065: */
066: protected void doPost(HttpServletRequest request,
067: HttpServletResponse response) throws ServletException,
068: IOException {
069: try {
070: String processId = request.getParameter("pId");
071: String manager = request.getParameter("manager");
072: boolean approve = request.getRequestURI()
073: .indexOf("approve") != -1;
074:
075: this .approvePublishWorkflow.processManagerResponse(Long
076: .parseLong(processId), manager, approve);
077:
078: /**
079: * TODO: this is a hack job until a decent GUI is integrated
080: * with this workflow..Yes Yes, this will be based on JSP then
081: */
082: StringBuffer buffer = new StringBuffer();
083: buffer.append("<html>\n");
084: if (approve) {
085: buffer
086: .append("<span>The content was successfully published</span>\n");
087: } else {
088: buffer
089: .append("<span>The content publish request was rejected</span>\n");
090: }
091: buffer.append("</html>\n");
092:
093: response.getWriter().write(buffer.toString());
094: response.getWriter().flush();
095: } catch (Exception e) {
096: response.sendError(
097: HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e
098: .toString());
099: }
100: }
101: }
|