/*
* (C) Copyright 2004 Nabh Information Systems, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
package com.nabhinc.portlet.survey;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import com.nabhinc.portlet.mvcportlet.core.ActionConfig;
import com.nabhinc.portlet.mvcportlet.core.ActionProcessor;
import com.nabhinc.portlet.mvcportlet.core.BaseRequestProcessor;
import com.nabhinc.util.db.DBUtil;
/**
* Edit Survey Action processor.
*
* @author Padmanabh Dabke
* (c) 2004 Nabh Information Systems, Inc. All Rights Reserved.
*/
public class EditSurveyActionProcessor extends BaseRequestProcessor
implements ActionProcessor {
/* (non-Javadoc)
* @see com.nabhinc.portlet.mvcportlet.core.ActionProcessor#process(javax.portlet.ActionRequest, javax.portlet.ActionResponse, com.nabhinc.portlet.mvcportlet.core.ActionConfig)
*/
public String process(ActionRequest request, ActionResponse response,
ActionConfig actionConfig) throws PortletException, IOException {
String optionSQL = "SELECT optionnum, optiontext FROM SB_SURVEY_DATA WHERE surveyid = ?";
int surveyID = Integer.parseInt(request.getParameter("survey_id"));
Connection conn = null;
PreparedStatement st = null;
ResultSet results = null;
try {
// Get database connection
conn = brpConfig.getDataSource().getConnection();
// Retrieve survey options
st = conn.prepareStatement(optionSQL);
st.setInt(1, surveyID);
results = st.executeQuery();
while (results.next()) {
int optionNum = results.getInt(1);
String optionText = results.getString(2);
response.setRenderParameter("survey_option_" + optionNum, optionText);
}
return "success";
} catch (SQLException sqlex) {
try {
conn.rollback();
} catch (Exception ex) {
// Ignore
}
throw new PortletException("Database exception.", sqlex);
} catch (Exception ex) {
try {
conn.rollback();
} catch (Exception ex1) {
// Ignore
}
throw new PortletException(ex);
} finally {
DBUtil.close(results);
DBUtil.close(st);
DBUtil.close(conn);
}
}
}
|