public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException, CommunicationException, NamingException {
String finalForward = ".view.files.list";
String dataSource = Settings.getInstance().getSiteInfo(
CVUtility.getHostName(super.getServlet().getServletContext())).getDataSource();
HttpSession session = request.getSession(true);
UserObject userObject = (UserObject) session.getAttribute("userobject");
int individualId = userObject.getIndividualID();
// Check the session for an existing error message (possibly from the delete
// handler)
ActionErrors allErrors = (ActionErrors) session.getAttribute("listErrorMessage");
if (allErrors != null) {
saveErrors(request, allErrors);
session.removeAttribute("listErrorMessage");
}
// Check wheather the actionType is it Lookup or not
String actionType = request.getParameter("actionType");
GlobalMasterLists globalMasterLists = GlobalMasterLists.getGlobalMasterLists(dataSource);
HashMap moduleList = new HashMap();
if (globalMasterLists.get("moduleList") != null) {
moduleList = (HashMap) globalMasterLists.get("moduleList");
}
ListPreference listPreference = userObject.getListPreference("File");
ListView view = listPreference.getListView(String.valueOf(listPreference.getDefaultView()));
ValueListParameters listParameters = null;
ValueListParameters requestListParameters = (ValueListParameters) request.getAttribute("listParameters");
if (requestListParameters == null) { // build up new Parameters
listParameters = new ValueListParameters(ValueListConstants.FILE_LIST_TYPE, listPreference.getRecordsPerPage(), 1);
} else { // paging or sorting or something, use the parameters from the
// request.
listParameters = requestListParameters;
}
if (listParameters.getSortColumn() == 0) {
FieldDescriptor sortField = (FieldDescriptor) ValueListConstants.fileViewMap.get(listPreference.getSortElement());
listParameters.setSortColumn(sortField.getQueryIndex());
if (listPreference.getsortOrder())
listParameters.setSortDirection("ASC");
else
listParameters.setSortDirection("DESC");
}
int defaultFolder = userObject.getUserPref().getDefaultFolderID();
int folderID = defaultFolder;
String param = request.getParameter("folderId");
if (param != null) {
if (param.indexOf("*") == -1) {
folderID = Integer.parseInt(param);
} else {
folderID = Integer.parseInt(param.substring(0, param.indexOf("*")));
}
}
listParameters.setFolderID(folderID);
request.setAttribute("folderId", String.valueOf(folderID));
String scope = request.getParameter(FileConstantKeys.TYPEOFFILELIST);
if (scope != null && !scope.equals("")) {
request.setAttribute("fileTypeRequest", scope);
request.setAttribute(FileConstantKeys.TYPEOFFILELIST, scope);
} else {
scope = "MY";
request.setAttribute("fileTypeRequest", "MY");
request.setAttribute(FileConstantKeys.TYPEOFFILELIST, "MY");
}
// Search handling
String filter = null;
String filterParameter = request.getParameter("filter");
if (filterParameter != null) {
filter = (String) session.getAttribute("listFilter");
if (scope.equals("MY")) {
filter += " AND Owner = " + individualId;
session.setAttribute("listFilter", filter);
}
request.setAttribute("appliedSearch", filterParameter);
} else {
// TODO Need to handle folder access too.
if (scope.equals("MY"))
filter = "SELECT FileID FROM cvfile WHERE Owner = " + individualId;
session.removeAttribute("listFilter");
}
listParameters.setFilter(filter);
// Build up the breadcrumbs on the folder bar.
// the crumbs will be the complete FolderRootPath except in the