[cig-commits] r8048 - in cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org: cig/portal cig/portal/beans cig/portal/common cig/portal/portlets ogce/portlets

wei at geodynamics.org wei at geodynamics.org
Thu Sep 27 18:05:28 PDT 2007


Author: wei
Date: 2007-09-27 18:05:27 -0700 (Thu, 27 Sep 2007)
New Revision: 8048

Added:
   cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/FUActionRequest.java
   cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/common/
   cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/common/Memory.java
   cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/portlets/FileUploadPortlet.java
Modified:
   cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/beans/MagjobBean.java
   cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/portlets/CigMagPortlet.java
   cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/portlets/CreateMagjobPortlet.java
   cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/ogce/portlets/VelocityPortlet.java
Log:
More updates to the portal.

Added: cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/FUActionRequest.java
===================================================================
--- cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/FUActionRequest.java	2007-09-28 00:30:01 UTC (rev 8047)
+++ cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/FUActionRequest.java	2007-09-28 01:05:27 UTC (rev 8048)
@@ -0,0 +1,289 @@
+/**
+ *  Copyright (c) 2007 Computational Infrastructure for Geodynamics (CIG),
+ *  , All Rights Reserved.
+ */
+
+package org.cig.portal;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Hashtable;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.PortalContext;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletSession;
+import javax.portlet.WindowState;
+import javax.portlet.PortletException;
+
+import org.apache.commons.fileupload.*;
+import org.apache.commons.fileupload.portlet.*;
+import org.apache.commons.fileupload.disk.*;
+
+/**
+ * This is a wrapper over an existing ActionRequest
+ * This wrapper handles file upload
+ * 
+ */
+public class FUActionRequest implements ActionRequest {
+	boolean isMultiPart;
+	ActionRequest req;
+	String dataDir;
+	String tmpDir; // tmp dir Apache commons fileupload uses
+	int sizeMax; // maxRequestSize of a http request
+	
+	Map parameters;
+	
+	public FUActionRequest(ActionRequest r, String ddir) throws PortletException, IOException {
+		this.load(r, ddir, System.getProperty("java.io.tmpdir"), -1);
+	}
+	public FUActionRequest(ActionRequest r, String ddir, String tdir, int size) throws PortletException, IOException {
+		this.load(r, ddir, tdir, size);
+	}
+	private void load(ActionRequest r, String ddir, String tdir, int size) throws PortletException, IOException {
+		req = r;
+		if (!PortletFileUpload.isMultipartContent(r)) {
+			isMultiPart = false;
+			return;
+		}
+		isMultiPart = true;
+		
+		dataDir = ddir;
+		tmpDir = tdir;
+		sizeMax = size;
+		// take request's parameters
+		parameters = new Hashtable();
+		// setup tmp storage
+		File filestmpdir = new File(tmpDir);
+		if (!filestmpdir.isDirectory() || !filestmpdir.canWrite())
+			throw new PortletException("FUActionRequest.load(): cannot access tmp dir " + tmpDir);
+		// setup user data dir
+		File filesdir = new File(dataDir);
+		if (!filesdir.isDirectory() || !filesdir.canWrite())
+			throw new PortletException("FUActionRequest.load(): cannot access user data dir " + dataDir);
+		// create apache commons file upload instances
+		DiskFileItemFactory factory = new DiskFileItemFactory();
+		factory.setRepository(filesdir);
+		// create portlet file upload instance
+		PortletFileUpload upload = new PortletFileUpload(factory);
+		upload.setSizeMax(sizeMax);
+		System.out.println("FUActionRequest.load(): handle file uploading: datadir="+dataDir+", tmpdir="+tmpDir+", maxrequestsize="+sizeMax);
+		try {
+			// get all form items
+			List items = upload.parseRequest(req);
+			Iterator iter = items.iterator();
+			while (iter.hasNext()) 	{
+				FileItem item = (FileItem) iter.next();
+				if (!item.isFormField()) {
+					String fieldName = item.getFieldName();
+				    String fileName = item.getName();
+				    if (!(fileName == null || fileName.equals(""))) {
+					    String filePath = dataDir+File.separator+fileName;
+					    String contentType = item.getContentType();
+					    boolean isInMemory = item.isInMemory();
+					    long sizeInBytes = item.getSize();
+					    File f = new File(filePath);
+					    item.write(f);
+					    // put file input as a parameter
+					    parameters.put(fileName, filePath);
+					    System.out.println(fieldName+": "+sizeInBytes+" bytes, "+fileName+" -> "+dataDir+", "+contentType+", "+(isInMemory?"InMemo":"AsFile"));
+				    }
+				} else {
+					String fieldName = item.getFieldName();
+					String value = item.getString();
+					if (!value.equals("")) {
+						// put normal form data in request as parameters
+						String currentValue = (String)parameters.get(fieldName);
+						if (currentValue != null) {
+							value = currentValue + ","+ value;
+						}
+						parameters.put(fieldName, value);
+					}
+				}
+			}
+		} catch (FileUploadException fue) {
+			fue.printStackTrace();
+			throw new PortletException("FUActionRequest.load(): caught FileUploadException: " + fue.toString());
+		} catch (Exception e) {
+			e.printStackTrace();
+			throw new PortletException("FUActionRequest.load(): caught Exception: " + e.toString());
+		}
+	}
+	public String getCharacterEncoding() {
+		return req.getCharacterEncoding();
+	}
+
+	public int getContentLength() {
+		return req.getContentLength();
+	}
+
+	public String getContentType() {
+		return req.getContentType();
+	}
+
+	public InputStream getPortletInputStream() throws IOException {
+		return req.getPortletInputStream();
+	}
+
+	public BufferedReader getReader() throws UnsupportedEncodingException,
+			IOException {
+		return req.getReader();
+	}
+
+	public void setCharacterEncoding(String enc)
+			throws UnsupportedEncodingException {
+		req.setCharacterEncoding(enc);
+	}
+
+	public Object getAttribute(String name) {
+		return req.getAttribute(name);
+	}
+
+	public Enumeration getAttributeNames() {
+		return req.getAttributeNames();
+	}
+
+	public String getAuthType() {
+		return req.getAuthType();
+	}
+
+	public String getContextPath() {
+		return req.getContextPath();
+	}
+
+	public Locale getLocale() {
+		return req.getLocale();
+	}
+
+	public Enumeration getLocales() {
+		return req.getLocales();
+	}
+/* Extended for file upload handling */
+	public String getParameter(String name) {
+		return (isMultiPart)?(String)(parameters.get(name)):req.getParameter(name);
+	}
+
+	public Map getParameterMap() {
+		return (isMultiPart)?parameters:req.getParameterMap();
+	}
+
+	public Enumeration getParameterNames() {
+		return (isMultiPart)?((Hashtable)parameters).keys():req.getParameterNames();
+	}
+
+	public String[] getParameterValues(String name) {
+		if (!isMultiPart)
+			return req.getParameterValues(name);
+		String value = (String)parameters.get(name);
+		String[] values = value.split("\\s*,\\s*");
+		return values;
+	}
+/* end of file upload extension */
+	
+	public PortalContext getPortalContext() {
+		return req.getPortalContext();
+	}
+
+	public PortletMode getPortletMode() {
+		return req.getPortletMode();
+	}
+
+	public PortletSession getPortletSession() {
+		return req.getPortletSession();
+	}
+
+	public PortletSession getPortletSession(boolean create) {
+		return req.getPortletSession(create);
+	}
+
+	public PortletPreferences getPreferences() {
+		return req.getPreferences();
+	}
+
+	public Enumeration getProperties(String name) {
+		return req.getProperties(name);
+	}
+
+	public String getProperty(String name) {
+		return req.getProperty(name);
+	}
+
+	public Enumeration getPropertyNames() {
+		return req.getParameterNames();
+	}
+
+	public String getRemoteUser() {
+		return req.getRemoteUser();
+	}
+
+	public String getRequestedSessionId() {
+		return req.getRequestedSessionId();
+	}
+
+	public String getResponseContentType() {
+		return req.getResponseContentType();
+	}
+
+	public Enumeration getResponseContentTypes() {
+		return req.getResponseContentTypes();
+	}
+
+	public String getScheme() {
+		return req.getScheme();
+	}
+
+	public String getServerName() {
+		return req.getServerName();
+	}
+
+	public int getServerPort() {
+		return req.getServerPort();
+	}
+
+	public Principal getUserPrincipal() {
+		return req.getUserPrincipal();
+	}
+
+	public WindowState getWindowState() {
+		return req.getWindowState();
+	}
+
+	public boolean isPortletModeAllowed(PortletMode mode) {
+		return req.isPortletModeAllowed(mode);
+	}
+
+	public boolean isRequestedSessionIdValid() {
+		return req.isRequestedSessionIdValid();
+	}
+
+	public boolean isSecure() {
+		return req.isSecure();
+	}
+
+	public boolean isUserInRole(String role) {
+		return req.isUserInRole(role);
+	}
+
+	public boolean isWindowStateAllowed(WindowState state) {
+		return req.isWindowStateAllowed(state);
+	}
+
+	public void removeAttribute(String name) {
+		req.removeAttribute(name);
+	}
+
+	public void setAttribute(String name, Object o) {
+		req.setAttribute(name, o);
+	}
+
+}

Modified: cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/beans/MagjobBean.java
===================================================================
--- cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/beans/MagjobBean.java	2007-09-28 00:30:01 UTC (rev 8047)
+++ cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/beans/MagjobBean.java	2007-09-28 01:05:27 UTC (rev 8048)
@@ -11,6 +11,7 @@
 	int N;
 	int M;
 	String dataset;
+	String results[];
 	String status;
 	String site; // index of this site
 	String jobhandle[];
@@ -75,6 +76,18 @@
 	public String getDataset() {
 		return dataset;
 	}
+	public void setResults(String[] s) {
+		results = s;
+	}
+	public void setResults(int i, String s) {
+		results[i] = s;
+	}
+	public String[] getResults() {
+		return results;
+	}
+	public String getResults(int i) {
+		return results[i];
+	}
 	public void setSite(String s) {
 		site = s;
 	}

Added: cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/common/Memory.java
===================================================================
--- cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/common/Memory.java	2007-09-28 00:30:01 UTC (rev 8047)
+++ cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/common/Memory.java	2007-09-28 01:05:27 UTC (rev 8048)
@@ -0,0 +1,30 @@
+/**
+ * 
+ */
+package org.cig.portal.common;
+
+/**
+ * @author wei
+ *
+ */
+public class Memory implements{
+
+    // file upload 
+
+    // bi-use
+
+    public final static String FILEUPLOAD_NUM_FILES = "simplegrid_fileupload_num_datasets";
+
+    // inter-portlet only
+
+    public final static String FILEUPLOAD_INDICATOR = "simplegrid_fileupload_indicator";
+
+    // bi-use
+
+    public final static String FILEUPLOAD_APPNAME = "simplegrid_fileupload_app";
+
+    // inter-portlet only
+
+    public final static String FILEUPLOAD_LOCATION = "simplegrid_fileupload_upload_location";
+
+}

Modified: cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/portlets/CigMagPortlet.java
===================================================================
--- cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/portlets/CigMagPortlet.java	2007-09-28 00:30:01 UTC (rev 8047)
+++ cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/portlets/CigMagPortlet.java	2007-09-28 01:05:27 UTC (rev 8048)
@@ -87,13 +87,13 @@
 						numviz = item.getKnum();
 						for (int v=0; v<numviz; v++) {
 							// this job exists, check if result is there
-							String rfile = this.getPortletContext().getRealPath("storage/"+uid+"/mag/images/" + cursid+"."+item.getK(v) + ".jpg");
+							String rfile = this.getPortletContext().getRealPath("storage/"+uid+"/mag/results/" + cursid+"." + ".tar.gz");
 							File rF = new File(rfile);
 							if (rF.isFile()) 
 								numReady++;
 						}
 						if (numReady < numviz) {
-							error += "Visualization file not ready yet. Please wait for a while or click \"Next\" to refresh status\n";
+							error += "Result file not ready yet. Please wait for a while or click \"Next\" to refresh status\n";
 						}
 						break;
 					}
@@ -104,11 +104,11 @@
 					ArrayList<String> imagelink = new ArrayList<String>(numviz);
 					ArrayList<String> vizklist = new ArrayList<String>(numviz);
 					for (int v=0; v<numviz; v++) {
-						resultlink.add("/"+mywebappname+"/storage/"+uid+"/mag/results/" + cursid+"."+item.getK(v) + ".dat");
-						imagelink.add("/"+mywebappname+"/storage/"+uid+"/mag/images/" + cursid+"."+item.getK(v) + ".jpg");
+						resultlink.add("/"+mywebappname+"/storage/"+uid+"/mag/results/" + cursid+"." + ".tar.gz");
+						imagelink.add("/"+mywebappname+"/storage/"+uid+"/mag/images/" + cursid+"." + ".jpg");
 						vizklist.add(Integer.toString(item.getK(v)));
 					}
-					String rfile = this.getPortletContext().getRealPath("storage/"+uid+"/mag/results/" + cursid+"."+item.getK(0) + ".dat");
+					String rfile = this.getPortletContext().getRealPath("storage/"+uid+"/mag/results/" + cursid+"." + ".tar.gz");
 					String str_zrange = this.getZRange(rfile);
 					String[] minmax = str_zrange.split(",");
 					int zmax=0, zmin=0;
@@ -417,18 +417,18 @@
 					String opstatus = "";
 					String sprefix = job.getDataset() + "(jobId="+job.getId()+"): ";
 					if (job.getStatus().equals("cigportal:New")) {
-						goTransferDataset(mysession, uid, joblist, job);
+						opstatus = goTransferDataset(mysession, uid, joblist, job);
 					} else if (job.getStatus().equals("cigportal:Dataset Transferred")) {
-					    goSubmit(mysession, uid, joblist, job);
+					    opstatus = goSubmit(mysession, uid, joblist, job);
 					} else if (job.getStatus().equals("cigportal:Job Submitted")) {
-						goRefresh(mysession, uid, joblist, job);
+						opstatus = goRefresh(mysession, uid, joblist, job);
 					} else if (job.getStatus().equals("cigportal:Job Done")) {
-						goTransferResult(mysession, uid, joblist, job);
-					} else if (job.getStatus().equals("cigportal:Result Transferred")) { 
-						goViz(mysession, uid, joblist, job);
-					} else if (job.getStatus().equals("cigportal:Image Created")) {
-						goShowViz(mysession, uid, joblist, job);
-					}
+						opstatus = goTransferResult(mysession, uid, joblist, job);
+					} //else if (job.getStatus().equals("cigportal:Result Transferred")) { 
+						//opstatus = goViz(mysession, uid, joblist, job);
+					//} else if (job.getStatus().equals("cigportal:Image Created")) {
+						//opstatus = goShowViz(mysession, uid, joblist, job);
+					//}
 					mysession.setAttribute("cig_mag_status_info" + uid, sprefix+opstatus, PortletSession.APPLICATION_SCOPE);
 					//else throw new PortletException("Unknown job status for job " + selectedjobid + ": " +job.getStatus());
 				} else  throw new PortletException("Couldn't find this job: " + selectedjobid);

Modified: cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/portlets/CreateMagjobPortlet.java
===================================================================
--- cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/portlets/CreateMagjobPortlet.java	2007-09-28 00:30:01 UTC (rev 8047)
+++ cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/portlets/CreateMagjobPortlet.java	2007-09-28 01:05:27 UTC (rev 8048)
@@ -8,8 +8,6 @@
 //JSR-168
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Calendar;
 import java.util.*;
 
 import javax.portlet.ActionRequest;
@@ -31,6 +29,7 @@
 import org.cig.portal.util.Config;
 import org.cig.portal.util.MAGPortletConfig;
 import org.cig.portal.util.SimpleGridConstants;
+import org.cig.portal.common.*;
 import org.gisolve.demo.app.IDWVizThread;
 import org.gridsphere.portlet.impl.SportletProperties;
 import org.gridsphere.services.core.user.User;
@@ -79,57 +78,8 @@
 			String curPage = (String)mysession.getAttribute(SimpleGridConstants.MagPage + uid, PortletSession.APPLICATION_SCOPE);
 			if (curPage.equals("Upload")) {
 				MagjobBean item = null;
-				int i;
-				int numviz = 0, numReady = 0;
-				for (i=0; i<joblist.size(); i++) {
-					item = (MagjobBean)joblist.get(i);
-					if (item.getId().equals(cursid)) {
-						numviz = item.getKnum();
-						for (int v=0; v<numviz; v++) {
-							// this job exists, check if result is there
-							String rfile = this.getPortletContext().getRealPath("storage/"+uid+"/mag/images/" + cursid+"."+item.getK(v) + ".jpg");
-							File rF = new File(rfile);
-							if (rF.isFile()) 
-								numReady++;
-						}
-						if (numReady < numviz) {
-							error += "Visualization file not ready yet. Please wait for a while or click \"Next\" to refresh status\n";
-						}
-						break;
-					}
-				}
-				if (i<joblist.size() && numviz>0 && numReady==numviz) {
-					// set links
-					ArrayList<String> resultlink = new ArrayList<String>(numviz);
-					ArrayList<String> imagelink = new ArrayList<String>(numviz);
-					ArrayList<String> vizklist = new ArrayList<String>(numviz);
-					for (int v=0; v<numviz; v++) {
-						resultlink.add("/"+mywebappname+"/storage/"+uid+"/mag/results/" + cursid+"."+item.getK(v) + ".dat");
-						imagelink.add("/"+mywebappname+"/storage/"+uid+"/mag/images/" + cursid+"."+item.getK(v) + ".jpg");
-						vizklist.add(Integer.toString(item.getK(v)));
-					}
-					String rfile = this.getPortletContext().getRealPath("storage/"+uid+"/mag/results/" + cursid+"."+item.getK(0) + ".dat");
-					String str_zrange = this.getZRange(rfile);
-					String[] minmax = str_zrange.split(",");
-					int zmax=0, zmin=0;
-					if (minmax.length == 2) {
-						zmin=Integer.parseInt(minmax[0]);
-						zmax=Integer.parseInt(minmax[1]);
-					}
-					String legendlink = "/"+mywebappname+"/images/vizlegend.jpg";
-					aContext.put("cig_mag_viz_zmax", zmax);
-					aContext.put("cig_mag_viz_zmin", zmin);
-					aContext.put("cig_mag_viz_legendlink", legendlink);
-					aContext.put("cig_mag_viz_resultlink", resultlink);
-					aContext.put("cig_mag_viz_imagelink", imagelink);
-					aContext.put("cig_mag_viz_klist", vizklist);
-					aContext.put("cig_mag_viz_dataset", item.getDataset());
-					aContext.put("cig_mag_viz_jobid", item.getId());
-					
-					aContext.put(SimpleGridConstants.errorInfo, actionError + error);
-					setTemplate(req, "upload.vm");
+					setTemplate(req, "fie-upload.vm");
 					return;
-				}
 			} 
 			aContext.put(SimpleGridConstants.MagJobList, joblist);
 			aContext.put(SimpleGridConstants.MagJobSid, cursid);
@@ -239,6 +189,55 @@
     	this.fillTemplate(aContext, req, res, error);
     }
     
+   //upload input file from client site
+	public void doStart_upload_datasets ( ActionRequest req, ActionResponse res, Context aContext ) throws Exception {
+		String error = "";
+		try {
+			PortletSession mysession = req.getPortletSession(true);
+			User user = (User) req.getAttribute(SportletProperties.PORTLET_USER);
+			String uid = user.getUserID();
+			// set number of datasets to upload
+			int numDatasets = 1;
+			mysession.setAttribute(Memory.FILEUPLOAD_NUM_FILES + uid, numDatasets, PortletSession.APPLICATION_SCOPE);
+			// set template to file-upload by indicating fillTemplate() to redirect
+			// any portlet using fileupload function must set this to call file upload
+			// after it is done, this attr will be removed, which is a "finish" indicator
+			mysession.setAttribute(Memory.FILEUPLOAD_INDICATOR + uid, "FILEUPLOAD", PortletSession.APPLICATION_SCOPE);
+			mysession.setAttribute(Memory.FILEUPLOAD_APPNAME + uid, "SAMPLE", PortletSession.APPLICATION_SCOPE);
+			mysession.setAttribute(SimpleGridConstants.MagPage + uid, "Upload", PortletSession.APPLICATION_SCOPE);
+            // tell velocity portlet where to store uploaded files
+			String uploadDir = this.getPortletContext().getRealPath("storage/"+uid+"/mag/datasets");
+			mysession.setAttribute(Memory.FILEUPLOAD_LOCATION + uid, uploadDir, PortletSession.APPLICATION_SCOPE);
+		}catch (Exception e) {
+		    e.printStackTrace();
+		}
+		this.fillTemplate(aContext, req, res, error);
+	}
+	// file upload action handlers
+	//TODO: put it in a dynamic invocation method as a general way to call another portlet
+	// action handler inside this portlet
+	public void doFileupload_upload ( ActionRequest req, ActionResponse res, Context aContext ) throws Exception {
+		String error = "";
+		// Everything is done in FUActionRequest at time of VelocityPortlet invocation
+		this.fillTemplate(aContext, req, res, error);		
+	}
+
+	public void doFileupload_done ( ActionRequest req, ActionResponse res, Context aContext ) throws Exception {
+		String error = "";
+		try {
+			PortletSession mysession = req.getPortletSession(true);
+			User user = (User) req.getAttribute(SportletProperties.PORTLET_USER);
+			String uid = user.getUserID();
+			mysession.removeAttribute(Memory.FILEUPLOAD_INDICATOR + uid, PortletSession.APPLICATION_SCOPE);
+			mysession.removeAttribute(Memory.FILEUPLOAD_APPNAME + uid, PortletSession.APPLICATION_SCOPE);
+			mysession.removeAttribute(Memory.FILEUPLOAD_NUM_FILES + uid, PortletSession.APPLICATION_SCOPE);
+			mysession.removeAttribute(Memory.FILEUPLOAD_LOCATION + uid, PortletSession.APPLICATION_SCOPE);
+		}catch (Exception e) {
+			e.printStackTrace();
+		}
+		this.fillTemplate(aContext, req, res, error);
+	}
+    
     //added file upload handling
 //     public void doMag_file_upload ( ActionRequest req, ActionResponse res, Context aContext ) throws Exception
 //    {

Added: cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/portlets/FileUploadPortlet.java
===================================================================
--- cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/portlets/FileUploadPortlet.java	2007-09-28 00:30:01 UTC (rev 8047)
+++ cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/cig/portal/portlets/FileUploadPortlet.java	2007-09-28 01:05:27 UTC (rev 8048)
@@ -0,0 +1,98 @@
+package org.cig.portal.portlets;
+
+//JSR-168
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.portlet.PortletSession;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.velocity.context.Context;
+import org.cig.portal.beans.MagjobBean;
+import org.cig.portal.grid.data.SimpleTransferThread;
+import org.cig.portal.grid.job.SimpleRSL;
+import org.cig.portal.grid.job.SimpleRunGT2;
+import org.cig.portal.grid.job.SimpleRunGT4;
+import org.cig.portal.grid.security.SimpleCred;
+import org.cig.portal.util.Config;
+import org.cig.portal.util.MAGPortletConfig;
+import org.cig.portal.util.SimpleGridConstants;
+import org.gisolve.demo.app.IDWVizThread;
+import org.gridsphere.portlet.impl.SportletProperties;
+import org.gridsphere.services.core.user.User;
+import org.ietf.jgss.GSSCredential;
+import org.ogce.portlets.VelocityPortlet;
+
+public class FileUploadPortlet extends VelocityPortlet {
+
+//..............................
+//           skipped
+//..............................
+
+	public void doStart_upload_datasets ( ActionRequest req, ActionResponse res, Context aContext ) throws Exception {
+		String error = "";
+		try {
+			PortletSession mysession = req.getPortletSession(true);
+			User user = (User) req.getAttribute(SportletProperties.PORTLET_USER);
+			String uid = user.getUserID();
+			// set number of datasets to upload
+			int numDatasets = 6;
+			mysession.setAttribute(Memory.FILEUPLOAD_NUM_FILES + uid, numDatasets, PortletSession.APPLICATION_SCOPE);
+			// set template to file-upload by indicating fillTemplate() to redirect
+			// any portlet using fileupload function must set this to call file upload
+			// after it is done, this attr will be removed, which is a "finish" indicator
+			mysession.setAttribute(Memory.FILEUPLOAD_INDICATOR + uid, "FILEUPLOAD", PortletSession.APPLICATION_SCOPE);
+			mysession.setAttribute(Memory.FILEUPLOAD_APPNAME + uid, "SAMPLE", PortletSession.APPLICATION_SCOPE);
+            // tell velocity portlet where to store uploaded files
+			String uploadDir = "/tmp";
+			mysession.setAttribute(Memory.FILEUPLOAD_LOCATION + uid, uploadDir, PortletSession.APPLICATION_SCOPE);
+		}catch (Exception e) {
+		    e.printStackTrace();
+		}
+		this.fillTemplate(aContext, req, res, error);
+	}
+	// file upload action handlers
+	//TODO: put it in a dynamic invocation method as a general way to call another portlet
+	// action handler inside this portlet
+	public void doFileupload_upload ( ActionRequest req, ActionResponse res, Context aContext ) throws Exception {
+		String error = "";
+		// Everything is done in FUActionRequest at time of VelocityPortlet invocation
+		this.fillTemplate(aContext, req, res, error);		
+	}
+
+	public void doFileupload_done ( ActionRequest req, ActionResponse res, Context aContext ) throws Exception {
+		String error = "";
+		try {
+			PortletSession mysession = req.getPortletSession(true);
+			User user = (User) req.getAttribute(SportletProperties.PORTLET_USER);
+			String uid = user.getUserID();
+			mysession.removeAttribute(Memory.FILEUPLOAD_INDICATOR + uid, PortletSession.APPLICATION_SCOPE);
+			mysession.removeAttribute(Memory.FILEUPLOAD_APPNAME + uid, PortletSession.APPLICATION_SCOPE);
+			mysession.removeAttribute(Memory.FILEUPLOAD_NUM_FILES + uid, PortletSession.APPLICATION_SCOPE);
+			mysession.removeAttribute(Memory.FILEUPLOAD_LOCATION + uid, PortletSession.APPLICATION_SCOPE);
+		}catch (Exception e) {
+			e.printStackTrace();
+		}
+		this.fillTemplate(aContext, req, res, error);
+	}
+    public void doView(RenderRequest req, RenderResponse res) throws PortletException, java.io.IOException {
+    	PortletSession mysession = req.getPortletSession(true);
+    	User user = (User) req.getAttribute(SportletProperties.PORTLET_USER);
+		String uid = user.getUserID();
+		String storedSid = (String)mysession.getAttribute(SimpleGridConstants.SESSION_ATTR_ID + uid, PortletSession.APPLICATION_SCOPE);
+		if (storedSid == null || !storedSid.equals(mysession.getId())) {
+			storedSid = mysession.getId();
+			MAGPortletConfig.init(req, this);
+			mysession.setAttribute(SimpleGridConstants.SESSION_ATTR_ID + uid, storedSid, PortletSession.APPLICATION_SCOPE);
+		}
+    	super.doView(req, res);
+    }
+    
+}

Modified: cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/ogce/portlets/VelocityPortlet.java
===================================================================
--- cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/ogce/portlets/VelocityPortlet.java	2007-09-28 00:30:01 UTC (rev 8047)
+++ cs/cigtg/trunk/cigtg-dev/CigPortal/cigportal/src/org/ogce/portlets/VelocityPortlet.java	2007-09-28 01:05:27 UTC (rev 8048)
@@ -1,7 +1,6 @@
 package org.ogce.portlets;
 
-
-//marcus' sample
+// marcus' sample
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -34,426 +33,446 @@
 import java.util.Map;
 import java.util.HashMap;
 
+import org.cig.portal.common.Memory;
+import org.cig.portal.FUActionRequest;
+import org.gridsphere.portlet.impl.SportletProperties;
+import org.gridsphere.services.core.user.User;
+
 /**
-* This code is an extension to Marcus' original version.
-* Added functions are:
-* + Accommodate multiple portlets on the same screen  
-*   Original VelocityPortlet does not render correctly under the layout
-*   which has multiple portlets displaying on the same screen. It used
-*   a global session attribute ACTION_SETS_CONTEXT to avoid calling
-*   buildViewContext() for a portlet that is just triggered by an action.
-*   This was just to save calling setTemplate() twice (once in doAction(),
-*   the other in buildViewContext(). However, it has two side effects in
-*   muliti-portlet-single-screen scenario:
-*     - The first rendered portlet (might not be the one with action 
-*       triggered) is set to have the template of the actioned portlet
-*     - Other portlets than the first will call buildViewContext() again
-*       because ACTION_SETS_CONTEXT is reset in doView() of the first one
-*   
-* + Avoid exceptions in original version when a portlet has unsupported
-*   modes configured in portlet.xml 
-*/
+ * This code is an extension to Marcus' original version.
+ * Added functions are:
+ * + Accommodate multiple portlets on the same screen  
+ *   Original VelocityPortlet does not render correctly under the layout
+ *   which has multiple portlets displaying on the same screen. It used
+ *   a global session attribute ACTION_SETS_CONTEXT to avoid calling
+ *   buildViewContext() for a portlet that is just triggered by an action.
+ *   This was just to save calling setTemplate() twice (once in doAction(),
+ *   the other in buildViewContext(). However, it has two side effects in
+ *   muliti-portlet-single-screen scenario:
+ *     - The first rendered portlet (might not be the one with action 
+ *       triggered) is set to have the template of the actioned portlet
+ *     - Other portlets than the first will call buildViewContext() again
+ *       because ACTION_SETS_CONTEXT is reset in doView() of the first one
+ *   
+ * + Avoid exceptions in original version when a portlet has unsupported
+ *   modes configured in portlet.xml 
+ */
 
 
 
 /**
-* The <code>VelocityPortlet</code> class acts as a bridge between
-* Jetspeed 1 style Velocity portlets and JSR 168 portlets.
-* <code>VelocityPortlet</code> allows one to use Velocity templates
-* for rendering the portlet markup fragments.
-*
-* <h5>Specifying Templates</h5>
-*
-* <p>
-* So how does Velocity know where to find your templates?  There are
-* a few things that need to be done.  First, you can use the
-* defaults.  By default, the templates are expected in a directory
-* called <code>templates/</code> in the root of the web application.
-* The default VIEW template is called <code>view.vm</code>, the
-* default EDIT template is called <code>edit.vm</code>, and the
-* default HELP template is called <code>help.vm</code>. </p>
-*
-* <p>If you want to put your templates in a different location, this
-* can be specified in a Velocity properties file.  By default, the
-* VelocityPortlet looks for such a file named
-* <code>velocity.properties</code> in the root of the web
-* application.  You can name your properties file differently, giving
-* the name of the file as the value of the init parameter with name
-* defined by the constant {@link #VP_VELOCITY_PROP}.  See the <a
-* href="http://jakarta.apache.org/velocity">Velocity Home Page</a>
-* for more information about Velocity properties files.  See also the
-* example <code>velocity.properties</code> file that comes with this
-* code to see how the <code>templates</code> directory is set.</p>
-*
-* <p>If you want to call your default VIEW template something other
-* than <code>view.vm</code>, etc., you do this with init parameters
-* in your <code>portlet.xml</code> file.  The name of the init
-* parameter for setting the name of the VIEW template file is defined
-* by the constants {@link #VP_DEFAULT_VIEW}, {@link
-* #VP_DEFAULT_EDIT}, and {@link #VP_DEFAULT_HELP}.</p>
-*
-* <h5>Render methods</h5>
-*
-* <p>The render methods you need to override to support the various
-* portlet modes are {@link #buildViewContext}, {@link
-* #buildEditContext}, and {@link #buildHelpContext}. These methods
-* are called in order to create a context for the default View, Edit,
-* and Help templates.</p>
-*
-* <h5>Action methods</h5>
-* 
-* <p>Action methods are implemented as usual, taking an
-* <code>ActionRequest</code> and <code>ActionResponse</code> pair
-* along with a <code>Context</code> object.  The names of the action
-* methods are mapped to from the Velocity templates by appending a
-* special prefix to them.  This prefix is specified by the {@link
-* #VP_ACTION_PREFIX} constant.
-* 
-*
-* <p>There is also a special action method, {@link #doCustomize} which
-* is called by {@link #processAction} when the portlet is in EDIT
-* mode.  This method must be overridden if your portlet supports the
-* EDIT mode.</p>
-*
-* <h5>The Default Context</h5>
-*
-* See {@link #getContext} for information on what is used to
-* prepopulate the context.
-*
-* @author <a href="mailto:machrist at cs.indiana.edu">Marcus Christie</a>
-* @version $Id: VelocityPortlet.java,v 1.11 2005/08/02 01:49:56 machrist Exp $
-*/
+ * The <code>VelocityPortlet</code> class acts as a bridge between
+ * Jetspeed 1 style Velocity portlets and JSR 168 portlets.
+ * <code>VelocityPortlet</code> allows one to use Velocity templates
+ * for rendering the portlet markup fragments.
+ *
+ * <h5>Specifying Templates</h5>
+ *
+ * <p>
+ * So how does Velocity know where to find your templates?  There are
+ * a few things that need to be done.  First, you can use the
+ * defaults.  By default, the templates are expected in a directory
+ * called <code>templates/</code> in the root of the web application.
+ * The default VIEW template is called <code>view.vm</code>, the
+ * default EDIT template is called <code>edit.vm</code>, and the
+ * default HELP template is called <code>help.vm</code>. </p>
+ *
+ * <p>If you want to put your templates in a different location, this
+ * can be specified in a Velocity properties file.  By default, the
+ * VelocityPortlet looks for such a file named
+ * <code>velocity.properties</code> in the root of the web
+ * application.  You can name your properties file differently, giving
+ * the name of the file as the value of the init parameter with name
+ * defined by the constant {@link #VP_VELOCITY_PROP}.  See the <a
+ * href="http://jakarta.apache.org/velocity">Velocity Home Page</a>
+ * for more information about Velocity properties files.  See also the
+ * example <code>velocity.properties</code> file that comes with this
+ * code to see how the <code>templates</code> directory is set.</p>
+ *
+ * <p>If you want to call your default VIEW template something other
+ * than <code>view.vm</code>, etc., you do this with init parameters
+ * in your <code>portlet.xml</code> file.  The name of the init
+ * parameter for setting the name of the VIEW template file is defined
+ * by the constants {@link #VP_DEFAULT_VIEW}, {@link
+ * #VP_DEFAULT_EDIT}, and {@link #VP_DEFAULT_HELP}.</p>
+ *
+ * <h5>Render methods</h5>
+ *
+ * <p>The render methods you need to override to support the various
+ * portlet modes are {@link #buildViewContext}, {@link
+ * #buildEditContext}, and {@link #buildHelpContext}. These methods
+ * are called in order to create a context for the default View, Edit,
+ * and Help templates.</p>
+ *
+ * <h5>Action methods</h5>
+ * 
+ * <p>Action methods are implemented as usual, taking an
+ * <code>ActionRequest</code> and <code>ActionResponse</code> pair
+ * along with a <code>Context</code> object.  The names of the action
+ * methods are mapped to from the Velocity templates by appending a
+ * special prefix to them.  This prefix is specified by the {@link
+ * #VP_ACTION_PREFIX} constant.
+ * 
+ *
+ * <p>There is also a special action method, {@link #doCustomize} which
+ * is called by {@link #processAction} when the portlet is in EDIT
+ * mode.  This method must be overridden if your portlet supports the
+ * EDIT mode.</p>
+ *
+ * <h5>The Default Context</h5>
+ *
+ * See {@link #getContext} for information on what is used to
+ * prepopulate the context.
+ *
+ * @author <a href="mailto:machrist at cs.indiana.edu">Marcus Christie</a>
+ * @version $Id: VelocityPortlet.java,v 1.11 2005/08/02 01:49:56 machrist Exp $
+ */
 public abstract class VelocityPortlet extends GenericPortlet {
 
 
- private static final String VP_TEMPLATE = "org.ogce.portlets.VelocityPortlet.template";
- private static final String VP_CONTEXT = "org.ogce.portlets.VelocityPortlet.context";
- /**
-  *  The prefix to the action method expected in the template.
-  *  Currently equal to <b>actionMethod_</b>.
-  */
- public static final String VP_ACTION_PREFIX = "actionMethod_";
- /**
-  *  The prefix to the action method expected in the template.
-  *  Currently equal to <b>eventSubmit_</b>.
-  */
- public static final String VP_ACTION_PREFIX_LEGACY = "eventSubmit_";
- /**
-  *  The name of the init parameter for setting the name of the
-  *  default VIEW template.  Currently <b>default-view</b>.
-  */
- public static final String VP_DEFAULT_VIEW = "default-view";
- /**
-  *  The name of the init parameter for setting the name of the
-  *  default EDIT template.  Currently <b>default-edit</b>.
-  */
- public static final String VP_DEFAULT_EDIT = "default-edit";
- /**
-  *  The name of the init parameter for setting the name of the
-  *  default HELP template.  Currently <b>default-help</b>.
-  */
- public static final String VP_DEFAULT_HELP = "default-help";
- /**
-  *  The name of the init parameter for setting the name of the
-  *  Velocity properties file.  Currently
-  *  <b>org.apache.velocity.properties</b>.
-  */
- public static final String VP_VELOCITY_PROP = "org.apache.velocity.properties";
+    private static final String VP_TEMPLATE = "org.ogce.portlets.VelocityPortlet.template";
+    private static final String VP_CONTEXT = "org.ogce.portlets.VelocityPortlet.context";
+    /**
+     *  The prefix to the action method expected in the template.
+     *  Currently equal to <b>actionMethod_</b>.
+     */
+    public static final String VP_ACTION_PREFIX = "actionMethod_";
+    /**
+     *  The prefix to the action method expected in the template.
+     *  Currently equal to <b>eventSubmit_</b>.
+     */
+    public static final String VP_ACTION_PREFIX_LEGACY = "eventSubmit_";
+    /**
+     *  The name of the init parameter for setting the name of the
+     *  default VIEW template.  Currently <b>default-view</b>.
+     */
+    public static final String VP_DEFAULT_VIEW = "default-view";
+    /**
+     *  The name of the init parameter for setting the name of the
+     *  default EDIT template.  Currently <b>default-edit</b>.
+     */
+    public static final String VP_DEFAULT_EDIT = "default-edit";
+    /**
+     *  The name of the init parameter for setting the name of the
+     *  default HELP template.  Currently <b>default-help</b>.
+     */
+    public static final String VP_DEFAULT_HELP = "default-help";
+    /**
+     *  The name of the init parameter for setting the name of the
+     *  Velocity properties file.  Currently
+     *  <b>org.apache.velocity.properties</b>.
+     */
+    public static final String VP_VELOCITY_PROP = "org.apache.velocity.properties";
 
- private static final String ACTION_SETS_CONTEXT = "org.ogce.portlets.VelocityPortlet.action_sets_context";
- private String defaultViewVM;
- private String defaultEditVM;
- private String defaultHelpVM;
+    private static final String ACTION_SETS_CONTEXT = "org.ogce.portlets.VelocityPortlet.action_sets_context";
+    private String defaultViewVM;
+    private String defaultEditVM;
+    private String defaultHelpVM;
 
- /**
-  * Initializes Velocity, sets default portlet mode templates.
-  *
-  * @param portletConfig a <code>PortletConfig</code> value
-  * @exception PortletException if an error occurs
-  */
- public void init(PortletConfig portletConfig) throws PortletException {
-     super.init(portletConfig);
-     initVelocity(portletConfig);
+    /**
+     * Initializes Velocity, sets default portlet mode templates.
+     *
+     * @param portletConfig a <code>PortletConfig</code> value
+     * @exception PortletException if an error occurs
+     */
+    public void init(PortletConfig portletConfig) throws PortletException {
+        super.init(portletConfig);
+        initVelocity(portletConfig);
 
-     // get view, edit and help templates out of initParams
-     defaultViewVM = portletConfig.getInitParameter(VP_DEFAULT_VIEW);
-     if (defaultViewVM == null) {
-         defaultViewVM = "gisolve_notfound.vm";
-     }
-     defaultEditVM = portletConfig.getInitParameter(VP_DEFAULT_EDIT);
-     if (defaultEditVM == null) {
-         defaultEditVM = "gisolve_notfound.vm";
-     }
-     defaultHelpVM = portletConfig.getInitParameter(VP_DEFAULT_HELP);
-     if (defaultHelpVM == null) {
-         defaultHelpVM = "gisolve_notfound.vm";
-     }
- }
- 
- private void initVelocity(PortletConfig portletConfig) {
-     PortletContext pc = getPortletContext();
-     String props = portletConfig.getInitParameter(VP_VELOCITY_PROP);
-     if (props == null || props.length() == 0) {
-         props = "/velocity.properties";
-     }
-     Properties p = new Properties();
-     String realPath = pc.getRealPath(props);
-     File propFile = new File(realPath);
-     if (propFile.exists()) {
-         try {
-             p.load(new FileInputStream(realPath));
-             p.setProperty(Velocity.RUNTIME_LOG, 
-                           pc.getRealPath(p.getProperty(Velocity.RUNTIME_LOG)));
-             p.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH,
-                           pc.getRealPath(p.getProperty(Velocity.FILE_RESOURCE_LOADER_PATH)));
-             Velocity.init(p);
-             
-         } catch (Exception e) {
-             getPortletContext().log("Error reading in velocity properties file", e);
-         }
-     } else {
-         // If no Velocity properties file, then use defaults
-         p.setProperty(Velocity.RUNTIME_LOG,
-                       pc.getRealPath("/velocity.log"));
-         p.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH,
-                       pc.getRealPath("/templates"));
-         try {
-             Velocity.init(p);
-         } catch (Exception e) {
-             getPortletContext().log("Error setting default velocity properties", e);
-         }
-     }
- }
+        // get view, edit and help templates out of initParams
+        defaultViewVM = portletConfig.getInitParameter(VP_DEFAULT_VIEW);
+        if (defaultViewVM == null) {
+            defaultViewVM = "gisolve_notfound.vm";
+        }
+        defaultEditVM = portletConfig.getInitParameter(VP_DEFAULT_EDIT);
+        if (defaultEditVM == null) {
+            defaultEditVM = "gisolve_notfound.vm";
+        }
+        defaultHelpVM = portletConfig.getInitParameter(VP_DEFAULT_HELP);
+        if (defaultHelpVM == null) {
+            defaultHelpVM = "gisolve_notfound.vm";
+        }
+    }
+    
+    private void initVelocity(PortletConfig portletConfig) {
+        PortletContext pc = getPortletContext();
+        String props = portletConfig.getInitParameter(VP_VELOCITY_PROP);
+        if (props == null || props.length() == 0) {
+            props = "/velocity.properties";
+        }
+        Properties p = new Properties();
+        String realPath = pc.getRealPath(props);
+        File propFile = new File(realPath);
+        if (propFile.exists()) {
+            try {
+                p.load(new FileInputStream(realPath));
+                p.setProperty(Velocity.RUNTIME_LOG, 
+                              pc.getRealPath(p.getProperty(Velocity.RUNTIME_LOG)));
+                p.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH,
+                              pc.getRealPath(p.getProperty(Velocity.FILE_RESOURCE_LOADER_PATH)));
+                Velocity.init(p);
+                
+            } catch (Exception e) {
+                getPortletContext().log("Error reading in velocity properties file", e);
+            }
+        } else {
+            // If no Velocity properties file, then use defaults
+            p.setProperty(Velocity.RUNTIME_LOG,
+                          pc.getRealPath("/velocity.log"));
+            p.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH,
+                          pc.getRealPath("/templates"));
+            try {
+                Velocity.init(p);
+            } catch (Exception e) {
+                getPortletContext().log("Error setting default velocity properties", e);
+            }
+        }
+    }
 
 
- /**
-  * From the Java Portlet API (JSR 168).  Calls {@link
-  * #buildViewContext}, renders template.
-  *
-  * @param request a <code>RenderRequest</code> value
-  * @param response a <code>RenderResponse</code> value
-  * @exception PortletException if an error occurs
-  * @exception IOException if an error occurs
-  */
- public void doView(RenderRequest request, RenderResponse response)
-     throws PortletException, IOException {
-     response.setContentType("text/html");
+    /**
+     * From the Java Portlet API (JSR 168).  Calls {@link
+     * #buildViewContext}, renders template.
+     *
+     * @param request a <code>RenderRequest</code> value
+     * @param response a <code>RenderResponse</code> value
+     * @exception PortletException if an error occurs
+     * @exception IOException if an error occurs
+     */
+    public void doView(RenderRequest request, RenderResponse response)
+        throws PortletException, IOException {
+        response.setContentType("text/html");
 
-     PortletSession session = request.getPortletSession(true);
-     // Log session id
-     getPortletContext().log("VelocityPortlet:" + getPortletName() + 
-                             "session id is " + session.getId());
-     VelocityContext context = getContext(request, response);
-     // Only build a context if an action method hasn't already done so
-     
-     if ( (session.getAttribute(ACTION_SETS_CONTEXT) == null) ||
-          (! ((String)session.getAttribute(ACTION_SETS_CONTEXT)).equals(this.getClass().getName()))) {
-         buildViewContext(request, response, context);
-     }
-     String template = getTemplate(request);
-     renderTemplate(template, response, context);
-     // invalidate context
-     setContext(request, null);
-     setTemplate(request, null);
-     session.setAttribute(ACTION_SETS_CONTEXT, "");
- }
- 
- /**
-  * From the Java Portlet API (JSR 168).  Calls {@link
-  * #buildEditContext}, renders template.
-  *
-  * @param request a <code>RenderRequest</code> value
-  * @param response a <code>RenderResponse</code> value
-  * @exception PortletException if an error occurs
-  * @exception IOException if an error occurs
-  */
- public void doEdit(RenderRequest request, RenderResponse response)
-     throws PortletException, IOException {
-     // Population with current default values, then dispatch to
-     // jsp to display form with default values, allowing user to
-     // set new values
-     response.setContentType("text/html");
-     
-     PortletSession session = request.getPortletSession(true);
-     VelocityContext context = getContext(request, response);
-     // Only build a context if an action method hasn't already done so
-     if ( (session.getAttribute(ACTION_SETS_CONTEXT) == null) ||
-     	 (! ((String)session.getAttribute(ACTION_SETS_CONTEXT)).equals(this.getClass().getName()))) {
-         buildEditContext(request, response, context);
-     }
-     String template = getTemplate(request);
-     renderTemplate(template, response, context);
-     // invalidate context
-     setContext(request, null);
-     setTemplate(request, null);
-     session.setAttribute(ACTION_SETS_CONTEXT, "");
- }
+        PortletSession session = request.getPortletSession(true);
+        // Log session id
+        getPortletContext().log("VelocityPortlet:" + getPortletName() + 
+                                "session id is " + session.getId());
+        VelocityContext context = getContext(request, response);
+        // Only build a context if an action method hasn't already done so
+        
+        if ( (session.getAttribute(ACTION_SETS_CONTEXT) == null) ||
+             (! ((String)session.getAttribute(ACTION_SETS_CONTEXT)).equals(this.getClass().getName()))) {
+            buildViewContext(request, response, context);
+        }
+        String template = getTemplate(request);
+        renderTemplate(template, response, context);
+        // invalidate context
+        setContext(request, null);
+        setTemplate(request, null);
+        session.setAttribute(ACTION_SETS_CONTEXT, "");
+    }
+    
+    /**
+     * From the Java Portlet API (JSR 168).  Calls {@link
+     * #buildEditContext}, renders template.
+     *
+     * @param request a <code>RenderRequest</code> value
+     * @param response a <code>RenderResponse</code> value
+     * @exception PortletException if an error occurs
+     * @exception IOException if an error occurs
+     */
+    public void doEdit(RenderRequest request, RenderResponse response)
+        throws PortletException, IOException {
+        // Population with current default values, then dispatch to
+        // jsp to display form with default values, allowing user to
+        // set new values
+        response.setContentType("text/html");
+        
+        PortletSession session = request.getPortletSession(true);
+        VelocityContext context = getContext(request, response);
+        // Only build a context if an action method hasn't already done so
+        if ( (session.getAttribute(ACTION_SETS_CONTEXT) == null) ||
+        	 (! ((String)session.getAttribute(ACTION_SETS_CONTEXT)).equals(this.getClass().getName()))) {
+            buildEditContext(request, response, context);
+        }
+        String template = getTemplate(request);
+        renderTemplate(template, response, context);
+        // invalidate context
+        setContext(request, null);
+        setTemplate(request, null);
+        session.setAttribute(ACTION_SETS_CONTEXT, "");
+    }
 
 
- /**
-  * From the Java Portlet API (JSR 168).  Calls {@link
-  * #buildHelpContext}, renders template.
-  *
-  * @param request a <code>RenderRequest</code> value
-  * @param response a <code>RenderResponse</code> value
-  * @exception PortletException if an error occurs
-  * @exception IOException if an error occurs
-  */
- public void doHelp(RenderRequest request, RenderResponse response)
-     throws PortletException, IOException {
-     response.setContentType("text/html");
+    /**
+     * From the Java Portlet API (JSR 168).  Calls {@link
+     * #buildHelpContext}, renders template.
+     *
+     * @param request a <code>RenderRequest</code> value
+     * @param response a <code>RenderResponse</code> value
+     * @exception PortletException if an error occurs
+     * @exception IOException if an error occurs
+     */
+    public void doHelp(RenderRequest request, RenderResponse response)
+        throws PortletException, IOException {
+        response.setContentType("text/html");
 
-     PortletSession session = request.getPortletSession(true);
-     VelocityContext context = getContext(request, response);
-     // Only build a context if an action method hasn't already done so
-     if ( (session.getAttribute(ACTION_SETS_CONTEXT) == null) ||
-          (! ((String)session.getAttribute(ACTION_SETS_CONTEXT)).equals(this.getClass().getName()))) {
-     	buildHelpContext(request, response, context);
+        PortletSession session = request.getPortletSession(true);
+        VelocityContext context = getContext(request, response);
+        // Only build a context if an action method hasn't already done so
+        if ( (session.getAttribute(ACTION_SETS_CONTEXT) == null) ||
+             (! ((String)session.getAttribute(ACTION_SETS_CONTEXT)).equals(this.getClass().getName()))) {
+        	buildHelpContext(request, response, context);
+        }
+        String template = getTemplate(request);
+        renderTemplate(template, response, context);
+        // invalidate context
+        setContext(request, null);
+        setTemplate(request, null);
+        session.setAttribute(ACTION_SETS_CONTEXT, "");
      }
-     String template = getTemplate(request);
-     renderTemplate(template, response, context);
-     // invalidate context
-     setContext(request, null);
-     setTemplate(request, null);
-     session.setAttribute(ACTION_SETS_CONTEXT, "");
-  }
 
- /**
-  * From the Java Portlet API (JSR 168).  If in VIEW mode, looks
-  * for a request parameter with a special prefix ({@link
-  * #VP_ACTION_PREFIX} or {@link #VP_ACTION_PREFIX_LEGACY}), and
-  * uses introspection to call that method.  If in EDIT mode, calls
-  * {@link #doCustomize}.
-  *
-  * @param actionRequest an <code>ActionRequest</code> value
-  * @param actionResponse an <code>ActionResponse</code> value
-  * @exception PortletException if an error occurs
-  * @exception IOException if an error occurs
-  */
- public void processAction(ActionRequest actionRequest, 
-                           ActionResponse actionResponse) 
-     throws PortletException, IOException {
-     /* Basically, we want to inspect the parameters, looking for a
-      * submit marker, and using reflection to call the associated
-      * method.
-      */
-     VelocityContext context = getContext(actionRequest,
-                                          actionResponse);
-     PortletSession session = actionRequest.getPortletSession();
-     // Check portlet state
-     if (actionRequest.getPortletMode().equals(PortletMode.VIEW)) {
-         // Search for VP_ACTION_PREFIX or VP_ACTION_PREFIX_LEGACY
-         // in parameters
-         String actionParam = "";
-         String action = "";
-         Enumeration paramNames = actionRequest.getParameterNames();
-         while (paramNames.hasMoreElements()) {
-             String param = (String)paramNames.nextElement();
-             if (param.startsWith(VP_ACTION_PREFIX) || 
-                 param.startsWith(VP_ACTION_PREFIX_LEGACY)) {
-                 if (!actionParam.equals("")) {
-                     getPortletContext().log("!!! More than one action param in form");
-                 }
-                 actionParam = param;
-                 action = actionParam.substring(actionParam.indexOf('_') + 1);
-                 getPortletContext().log("Found action " + action);
-             }
-         }
-
-         // Now, do reflection and call actionParam
-         Class portlet = this.getClass();
-         Class[] methodSignature = {ActionRequest.class,
-                                    ActionResponse.class,
-                                    Context.class};
-         try {
-             Method actionMethod = portlet.getMethod(action, methodSignature);
-             actionMethod.invoke(this, new Object[]{actionRequest,
-                                                    actionResponse,
-                                                    context});
-             // it's quite possible to try to do the customization
-             // without having set the PortletMode to EDIT, so if
-             // we have executed doCustomize, we need to let
-             // buildViewContext be called
-             if (!action.equals("doCustomize"))
-                 session.setAttribute(ACTION_SETS_CONTEXT, this.getClass().getName());
-         } catch (Exception e) {
-             getPortletContext().log("Error invoking action method", e);
-         }
-             
-         
-     } else if (actionRequest.getPortletMode().equals(PortletMode.EDIT)) {
-         doCustomize(actionRequest, actionResponse, context);
-         //session.setAttribute(ACTION_SETS_CONTEXT, new Boolean(true));
-         /*
-         boolean edited = false;
-         try {
-             // try to edit portlet prefs, if fails, throw an exception
-             doCustomize(actionRequest, actionResponse, 
-                                   context);
-             edited = true;
-         } catch (Exception ex) {
-             //Create an error message 
-             actionResponse.setRenderParameter(VP_PREF_ERR, ex.getMessage());
-         }
-         if (edited) {
-             actionResponse.setPortletMode(PortletMode.VIEW);
-             actionResponse.setWindowState(WindowState.NORMAL);
-         }
+    /**
+     * From the Java Portlet API (JSR 168).  If in VIEW mode, looks
+     * for a request parameter with a special prefix ({@link
+     * #VP_ACTION_PREFIX} or {@link #VP_ACTION_PREFIX_LEGACY}), and
+     * uses introspection to call that method.  If in EDIT mode, calls
+     * {@link #doCustomize}.
+     *
+     * @param actionRequest an <code>ActionRequest</code> value
+     * @param actionResponse an <code>ActionResponse</code> value
+     * @exception PortletException if an error occurs
+     * @exception IOException if an error occurs
+     */
+    public void processAction(ActionRequest actionRequest, 
+                              ActionResponse actionResponse) 
+        throws PortletException, IOException {
+        /* Basically, we want to inspect the parameters, looking for a
+         * submit marker, and using reflection to call the associated
+         * method.
          */
-     }
-     // store context
-     setContext(actionRequest, context);
- }
+        VelocityContext context = getContext(actionRequest,
+                                             actionResponse);
+        PortletSession session = actionRequest.getPortletSession();
+        // Check portlet state
+        if (actionRequest.getPortletMode().equals(PortletMode.VIEW)) {
+            // Search for VP_ACTION_PREFIX or VP_ACTION_PREFIX_LEGACY
+            // in parameters
+            String actionParam = "";
+            String action = "";
+            // modified to support file upload (multipart/form-data)
+            // by Wei Mi: modified for cigportal
+            //TODO: load config param from configuration file
+            PortletSession mysession = actionRequest.getPortletSession();
+			User user = (User) actionRequest.getAttribute(SportletProperties.PORTLET_USER);
+			String uid = user.getUserID();
+            org.cig.portal.util.Config config = (org.cig.portal.util.Config)mysession.getAttribute(Memory.config2 + uid, PortletSession.APPLICATION_SCOPE);
+			String tmpdir = config.get("fileupload.tmpdir");
+			if (!tmpdir.startsWith("/")) {
+				String dataRoot = (String)mysession.getAttribute(Memory.dataroot + uid, PortletSession.APPLICATION_SCOPE);
+				tmpdir = dataRoot+File.separator+tmpdir;
+			}
+			int sizemax = Integer.parseInt(config.get("fileupload.maxrequestsize"));
+			String uploadDir = (String)mysession.getAttribute(Memory.FILEUPLOAD_LOCATION + uid, PortletSession.APPLICATION_SCOPE);
+            FUActionRequest fuActionRequest = new FUActionRequest(actionRequest, uploadDir, tmpdir, sizemax);
+            Enumeration paramNames = fuActionRequest.getParameterNames();
+            while (paramNames.hasMoreElements()) {
+                String param = (String)paramNames.nextElement();
+                if (param.startsWith(VP_ACTION_PREFIX) || 
+                    param.startsWith(VP_ACTION_PREFIX_LEGACY)) {
+                    if (!actionParam.equals("")) {
+                        getPortletContext().log("!!! More than one action param in form");
+                    }
+                    actionParam = param;
+                    action = actionParam.substring(actionParam.indexOf('_') + 1);
+                    getPortletContext().log("Found action " + action);
+                }
+            }
 
- /**
-  * Returns context from <code>PortletSession</code>, or builds up
-  * a new default session.  By default, the context has the
-  * following objects in it:
-  * <ul>
-  *    <li><b>prefs</b> - <code>PortletPreferences</code></li>
-  *    <li><b>request</b> - <code>PortletRequest</code></li>
-  *    <li><b>response</b> - <code>PortletResponse</code></li>
-  *    <li><b>actionURL</b> - a <code>PortletURL</code></li>
-  *    <li><b>renderURL</b> - a <code>PortletURL</code></li>
-  *    <li><b>viewURL</b> - a <code>PortletURL</code> that puts the portlet
-  *    	back in VIEW mode, in NORMAL window state</li>
-  *    <li><b>editURL</b> - a <code>PortletURL</code> that puts the portlet
-  *    	back in EDIT mode, in NORMAL window state</li>
-  *    <li><b>helpURL</b> - a <code>PortletURL</code> that puts the portlet
-  *    	back in HELP mode, in NORMAL window state</li>
-  *    <li><b>contextPath</b> - the current context path of the portlet/web 
-  *        application</li>
-  *    <li><b>portlet</b> - <code>VelocityPortlet</code>, giving access to
-  *        convenience methods, etc.  <b>portlet</b> always refers to this
-  *        portlet and can be thought of as analogous to Java's <i>this</i>.
-  *        </li>
-  * </ul>
-  *
-  * @param request a <code>PortletRequest</code> value
-  * @param response a <code>PortletResponse</code> value
-  * @return a <code>VelocityContext</code> value
-  */
- protected VelocityContext getContext(PortletRequest request, 
-                                    PortletResponse response) {
- 	// capture current window state, portlet mode
- 	WindowState currWindowState = request.getWindowState();
- 	PortletMode currPortletMode = request.getPortletMode();
- 	
-     PortletSession session = request.getPortletSession(true);
-     VelocityContext context = null;
-     context = (VelocityContext) session.getAttribute(VP_CONTEXT);
-     if (context == null) {
-         context = new VelocityContext();
-     }
-     PortletPreferences pref = request.getPreferences();
-     context.put("prefs", pref);
-     context.put("request", request);
-     context.put("response", response);
-     if (response instanceof RenderResponse) {
-         context.put("actionURL", ((RenderResponse)response).createActionURL());
-         context.put("renderURL", ((RenderResponse)response).createRenderURL());
-         try {
-             PortletURL viewURL = ((RenderResponse)response).createRenderURL();
+            // Now, do reflection and call actionParam
+            Class portlet = this.getClass();
+            Class[] methodSignature = {ActionRequest.class,
+                                       ActionResponse.class,
+                                       Context.class};
+            try {
+                Method actionMethod = portlet.getMethod(action, methodSignature);
+                actionMethod.invoke(this, new Object[]{fuActionRequest,
+                                                       actionResponse,
+                                                       context});
+                // it's quite possible to try to do the customization
+                // without having set the PortletMode to EDIT, so if
+                // we have executed doCustomize, we need to let
+                // buildViewContext be called
+                if (!action.equals("doCustomize"))
+                    session.setAttribute(ACTION_SETS_CONTEXT, this.getClass().getName());
+            } catch (Exception e) {
+                getPortletContext().log("Error invoking action method", e);
+            }
+                
+            
+        } else if (actionRequest.getPortletMode().equals(PortletMode.EDIT)) {
+            doCustomize(actionRequest, actionResponse, context);
+            //session.setAttribute(ACTION_SETS_CONTEXT, new Boolean(true));
+            /*
+            boolean edited = false;
+            try {
+                // try to edit portlet prefs, if fails, throw an exception
+                doCustomize(actionRequest, actionResponse, 
+                                      context);
+                edited = true;
+            } catch (Exception ex) {
+                //Create an error message 
+                actionResponse.setRenderParameter(VP_PREF_ERR, ex.getMessage());
+            }
+            if (edited) {
+                actionResponse.setPortletMode(PortletMode.VIEW);
+                actionResponse.setWindowState(WindowState.NORMAL);
+            }
+            */
+        }
+        // store context
+        setContext(actionRequest, context);
+    }
+
+    /**
+     * Returns context from <code>PortletSession</code>, or builds up
+     * a new default session.  By default, the context has the
+     * following objects in it:
+     * <ul>
+     *    <li><b>prefs</b> - <code>PortletPreferences</code></li>
+     *    <li><b>request</b> - <code>PortletRequest</code></li>
+     *    <li><b>response</b> - <code>PortletResponse</code></li>
+     *    <li><b>actionURL</b> - a <code>PortletURL</code></li>
+     *    <li><b>renderURL</b> - a <code>PortletURL</code></li>
+     *    <li><b>viewURL</b> - a <code>PortletURL</code> that puts the portlet
+     *    	back in VIEW mode, in NORMAL window state</li>
+     *    <li><b>editURL</b> - a <code>PortletURL</code> that puts the portlet
+     *    	back in EDIT mode, in NORMAL window state</li>
+     *    <li><b>helpURL</b> - a <code>PortletURL</code> that puts the portlet
+     *    	back in HELP mode, in NORMAL window state</li>
+     *    <li><b>contextPath</b> - the current context path of the portlet/web 
+     *        application</li>
+     *    <li><b>portlet</b> - <code>VelocityPortlet</code>, giving access to
+     *        convenience methods, etc.  <b>portlet</b> always refers to this
+     *        portlet and can be thought of as analogous to Java's <i>this</i>.
+     *        </li>
+     * </ul>
+     *
+     * @param request a <code>PortletRequest</code> value
+     * @param response a <code>PortletResponse</code> value
+     * @return a <code>VelocityContext</code> value
+     */
+    protected VelocityContext getContext(PortletRequest request, 
+                                       PortletResponse response) {
+    	// capture current window state, portlet mode
+    	WindowState currWindowState = request.getWindowState();
+    	PortletMode currPortletMode = request.getPortletMode();
+    	
+        PortletSession session = request.getPortletSession(true);
+        VelocityContext context = null;
+        context = (VelocityContext) session.getAttribute(VP_CONTEXT);
+        if (context == null) {
+            context = new VelocityContext();
+        }
+        PortletPreferences pref = request.getPreferences();
+        context.put("prefs", pref);
+        context.put("request", request);
+        context.put("response", response);
+        if (response instanceof RenderResponse) {
+            context.put("actionURL", ((RenderResponse)response).createActionURL());
+            context.put("renderURL", ((RenderResponse)response).createRenderURL());
+            try {
+                PortletURL viewURL = ((RenderResponse)response).createRenderURL();
 				viewURL.setPortletMode(PortletMode.VIEW);
 				viewURL.setWindowState(WindowState.NORMAL);
 				context.put("viewURL", viewURL);
@@ -489,152 +508,151 @@
 							"window state", e);
 				}
 			}
-     }
-     context.put("contextPath", request.getContextPath());
-     context.put("portlet", this);
-     
-     // Work around bug in GridSphere 2.0.2 (seems fixed in CVS, may be
-     // okay in 2.0.4)
-     // reset portlet mode, window state to values when entering this
-     // method
-     if (response instanceof RenderResponse) {
-     	PortletURL dummyURL = ((RenderResponse)response).createRenderURL();
-     	try {
-     		dummyURL.setPortletMode(currPortletMode);
-     		dummyURL.setWindowState(currWindowState);
-     	} catch (PortletModeException pme) {
-     		getPortletContext().log("Error setting portlet mode", pme);
-     	} catch (WindowStateException wse) {
-     		getPortletContext().log("Error setting window state", wse);
+        }
+        context.put("contextPath", request.getContextPath());
+        context.put("portlet", this);
+        
+        // Work around bug in GridSphere 2.0.2 (seems fixed in CVS, may be
+        // okay in 2.0.4)
+        // reset portlet mode, window state to values when entering this
+        // method
+        if (response instanceof RenderResponse) {
+        	PortletURL dummyURL = ((RenderResponse)response).createRenderURL();
+        	try {
+        		dummyURL.setPortletMode(currPortletMode);
+        		dummyURL.setWindowState(currWindowState);
+        	} catch (PortletModeException pme) {
+        		getPortletContext().log("Error setting portlet mode", pme);
+        	} catch (WindowStateException wse) {
+        		getPortletContext().log("Error setting window state", wse);
 			}
-     }
-     return context;
- }
+        }
+        return context;
+    }
 
- private void setContext(PortletRequest request,
-                         VelocityContext context) {
-     // Put context into Portlet session
-     PortletSession session = request.getPortletSession(true);
-     session.setAttribute(VP_CONTEXT, context);
+    private void setContext(PortletRequest request,
+                            VelocityContext context) {
+        // Put context into Portlet session
+        PortletSession session = request.getPortletSession(true);
+        session.setAttribute(VP_CONTEXT, context);
 
-     return;
- }
+        return;
+    }
 
- private String getTemplate(PortletRequest request) {
-     PortletSession session = request.getPortletSession(true);
-     String template = null;
-     template = (String) session.getAttribute(VP_TEMPLATE);
-     if (template == null) { 
-         PortletMode mode = request.getPortletMode();
-         if (mode.equals(PortletMode.VIEW)) {
-             template = defaultViewVM;
-         } else if (mode.equals(PortletMode.EDIT)) {
-             template = defaultEditVM;
-         } else if (mode.equals(PortletMode.HELP)) {
-             template = defaultHelpVM;
-         }
-     }
-     return template;
- }
+    private String getTemplate(PortletRequest request) {
+        PortletSession session = request.getPortletSession(true);
+        String template = null;
+        template = (String) session.getAttribute(VP_TEMPLATE);
+        if (template == null) { 
+            PortletMode mode = request.getPortletMode();
+            if (mode.equals(PortletMode.VIEW)) {
+                template = defaultViewVM;
+            } else if (mode.equals(PortletMode.EDIT)) {
+                template = defaultEditVM;
+            } else if (mode.equals(PortletMode.HELP)) {
+                template = defaultHelpVM;
+            }
+        }
+        return template;
+    }
 
- /**
-  * Set the name of the template to use on the next render phase.
-  * Note that the full name of the template file is required.
-  *
-  * @param request a <code>PortletRequest</code> value
-  * @param templateName a <code>String</code> value
-  */
- public void setTemplate(PortletRequest request, String templateName) {
-     PortletSession session = request.getPortletSession(true);
-     session.setAttribute(VP_TEMPLATE, templateName);
- }
+    /**
+     * Set the name of the template to use on the next render phase.
+     * Note that the full name of the template file is required.
+     *
+     * @param request a <code>PortletRequest</code> value
+     * @param templateName a <code>String</code> value
+     */
+    public void setTemplate(PortletRequest request, String templateName) {
+        PortletSession session = request.getPortletSession(true);
+        session.setAttribute(VP_TEMPLATE, templateName);
+    }
 
- private void renderTemplate(String templateName, 
-                             RenderResponse response,
-                             VelocityContext context) {
+    private void renderTemplate(String templateName, 
+                                RenderResponse response,
+                                VelocityContext context) {
 
-     PrintWriter pw = null;
-     try {
-         pw = response.getWriter();
-     } catch (Exception e) {
-         getPortletContext().log("Error getting PrintWriter", e);
-     }
-     String encoding = response.getCharacterEncoding();
-     try {
-         Velocity.mergeTemplate(templateName, encoding, context, pw);
-     } catch (Exception e) {
-         getPortletContext().log("Error in merging template", e);
-     }
+        PrintWriter pw = null;
+        try {
+            pw = response.getWriter();
+        } catch (Exception e) {
+            getPortletContext().log("Error getting PrintWriter", e);
+        }
+        String encoding = response.getCharacterEncoding();
+        try {
+            Velocity.mergeTemplate(templateName, encoding, context, pw);
+        } catch (Exception e) {
+            getPortletContext().log("Error in merging template", e);
+        }
 
- }
+    }
 
- public abstract void buildViewContext(RenderRequest request,
-                               RenderResponse response,
-                               Context context);
- public abstract void buildEditContext(RenderRequest request,
-                               RenderResponse response,
-                               Context context);
+    public abstract void buildViewContext(RenderRequest request,
+                                  RenderResponse response,
+                                  Context context);
+    public abstract void buildEditContext(RenderRequest request,
+                                  RenderResponse response,
+                                  Context context);
 
- public abstract void buildHelpContext(RenderRequest request,
-                               RenderResponse response,
-                               Context context);
- 
- /**
-  *  <code>doCustomize</code> is the method called by
-  *  <code>processAction</code> when in EDIT mode.
-  *
-  *  Note: if the edit is successful, you'll likely want something
-  *  like the following in your <code>doCustomize</code> to switch
-  *  from EDIT mode to VIEW mode
-  *
-  *  <pre>
-  *     if (edited) {
-  *          actionResponse.setPortletMode(PortletMode.VIEW);
-  *          actionResponse.setWindowState(WindowState.NORMAL);
-  *     }
-  *  </pre>
-  */
- public void doCustomize(ActionRequest request,
-                         ActionResponse response,
-                         Context context) throws PortletException {
+    public abstract void buildHelpContext(RenderRequest request,
+                                  RenderResponse response,
+                                  Context context);
+    
+    /**
+     *  <code>doCustomize</code> is the method called by
+     *  <code>processAction</code> when in EDIT mode.
+     *
+     *  Note: if the edit is successful, you'll likely want something
+     *  like the following in your <code>doCustomize</code> to switch
+     *  from EDIT mode to VIEW mode
+     *
+     *  <pre>
+     *     if (edited) {
+     *          actionResponse.setPortletMode(PortletMode.VIEW);
+     *          actionResponse.setWindowState(WindowState.NORMAL);
+     *     }
+     *  </pre>
+     */
+    public void doCustomize(ActionRequest request,
+                            ActionResponse response,
+                            Context context) throws PortletException {
 
 
- }
+    }
 
- /**
-  * <code>createActionURLWithParams</code> is a utility method for
-  * creating an action <code>PortletURL</code> within a Velocity template.
-  *
-  * <p>
-  * To use, put something like the following in your template:
-  * <pre>
-  *  #set ($action_url = $portlet.createActionURLWithParams($response,
-  *           ["name1", "name2", "name3"], ["value1", "value2", "value3"]))
-  * </pre>
-  *
-  * @param response a <code>PortletResponse</code> value
-  * @param paramNames an <code>ArrayList</code> of names
-  * @param paramValues an <code>ArrayList</code> of values
-  * @return an action <code>PortletURL</code> 
-  */
- public static PortletURL createActionURLWithParams(PortletResponse response,
-                                                    ArrayList paramNames,
-                                                    ArrayList paramValues) {
-     PortletURL url = null;
-     if (response instanceof RenderResponse) {
-         url = ((RenderResponse)response).createActionURL();
-     }
-     HashMap paramMap = new HashMap();
-     for (int i=0; i < paramNames.size(); i++) {
-         paramMap.put((String)paramNames.get(i), new String[] {(String)paramValues.get(i)});
-         /*
-         System.out.println("Putting into paramMap: " + (String)paramNames.get(i) + ":" +
-                            (String)paramValues.get(i));
-         */
-     }
-     url.setParameters(paramMap);
-     return url;
- }
- 
+    /**
+     * <code>createActionURLWithParams</code> is a utility method for
+     * creating an action <code>PortletURL</code> within a Velocity template.
+     *
+     * <p>
+     * To use, put something like the following in your template:
+     * <pre>
+     *  #set ($action_url = $portlet.createActionURLWithParams($response,
+     *           ["name1", "name2", "name3"], ["value1", "value2", "value3"]))
+     * </pre>
+     *
+     * @param response a <code>PortletResponse</code> value
+     * @param paramNames an <code>ArrayList</code> of names
+     * @param paramValues an <code>ArrayList</code> of values
+     * @return an action <code>PortletURL</code> 
+     */
+    public static PortletURL createActionURLWithParams(PortletResponse response,
+                                                       ArrayList paramNames,
+                                                       ArrayList paramValues) {
+        PortletURL url = null;
+        if (response instanceof RenderResponse) {
+            url = ((RenderResponse)response).createActionURL();
+        }
+        HashMap paramMap = new HashMap();
+        for (int i=0; i < paramNames.size(); i++) {
+            paramMap.put((String)paramNames.get(i), new String[] {(String)paramValues.get(i)});
+            /*
+            System.out.println("Putting into paramMap: " + (String)paramNames.get(i) + ":" +
+                               (String)paramValues.get(i));
+            */
+        }
+        url.setParameters(paramMap);
+        return url;
+    }
+    
 }
-



More information about the cig-commits mailing list