software/ncimappingtool/src/java/gov/nih/nci/evs/browser/servlet/UploadServlet.java
public void execute(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        // Determine request by attributes
        String action = (String) request.getParameter("action");
        String type = (String) request.getParameter("type");


System.out.println("(*) UploadServlet ...action " + action);
        if (action == null) {
			action = "upload_data";
		}

		DiskFileItemFactory  fileItemFactory = new DiskFileItemFactory ();
		/*
		 *Set the size threshold, above which content will be stored on disk.
		 */
		fileItemFactory.setSizeThreshold(1*1024*1024); //1 MB
		/*
		 * Set the temporary directory to store the uploaded files of size above threshold.
		 */
		//fileItemFactory.setRepository(tmpDir);

		ServletFileUpload uploadHandler = new ServletFileUpload(fileItemFactory);
		try {
			/*
			 * Parse the request
			 */
			List items = uploadHandler.parseRequest(request);
			Iterator itr = items.iterator();
			while(itr.hasNext()) {
				FileItem item = (FileItem) itr.next();
				/*
				 * Handle Form Fields.
				 */
				if(item.isFormField()) {
					System.out.println("File Name = "+item.getFieldName()+", Value = "+item.getString());
					//String s = convertStreamToString(item.getInputStream(), item.getSize());
					//System.out.println(s);


				} else {
					//Handle Uploaded files.
					System.out.println("Field Name = "+item.getFieldName()+
						", File Name = "+item.getName()+
						", Content type = "+item.getContentType()+
						", File Size = "+item.getSize());

					String s = convertStreamToString(item.getInputStream(), item.getSize());
					//System.out.println(s);

					request.getSession().setAttribute("action", action);

					if (action.compareTo("upload_data") == 0) {
						request.getSession().setAttribute("codes", s);
					} else {
						Mapping mapping = new Mapping().toMapping(s);

						System.out.println("Mapping " + mapping.getMappingName() + " uploaded.");
						System.out.println("Mapping version: " + mapping.getMappingVersion());

						MappingObject obj = mapping.toMappingObject();
						HashMap mappings = (HashMap) request.getSession().getAttribute("mappings");
						if (mappings == null) {
							mappings = new HashMap();
						}
						mappings.put(obj.getKey(), obj);
						request.getSession().setAttribute("mappings", mappings);
					}
				}
			}
		}catch(FileUploadException ex) {
			log("Error encountered while parsing the request",ex);
		} catch(Exception ex) {
			log("Error encountered while uploading file",ex);
		}


        //long ms = System.currentTimeMillis();

        if (action.compareTo("upload_data") == 0) {
			if (type.compareTo("codingscheme") == 0) {
        		response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/pages/codingscheme_data.jsf"));
			} else if (type.compareTo("ncimeta") == 0) {
				response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/pages/ncimeta_data.jsf"));
			} else if (type.compareTo("valueset") == 0) {
				response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/pages/valueset_data.jsf"));
			}		} else {
			response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/pages/home.jsf"));
		}

    }
/**
     * Process the specified HTTP request, and create the corresponding HTTP
     * response (or forward to another web component that will create it).
     *
     * @param request The HTTP request we are processing
     * @param response The HTTP response we are creating
     *
     * @exception IOException if an input/output error occurs
     * @exception ServletException if a servlet exception occurs
     */
Process the specified HTTP request, and create the corresponding HTTP
response (or forward to another web component that will create it).

@param request The HTTP request we are processing
@param response The HTTP response we are creating

@exception IOException if an input/output error occurs
@exception ServletException if a servlet exception occurs
Process the specified HTTP request and create the corresponding HTTP response ( or forward to another web component that will create it ) . @param request The HTTP request we are processing @param response The HTTP response we are creating @exception IOException if an input / output error occurs @exception ServletException if a servlet exception occurs
public void execute(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        String action = (String) request.getParameter("action");
        String type = (String) request.getParameter("type");
System.out.println("(*) UploadServlet ...action " + action);
        if (action == null) {
			action = "upload_data";
		}
		DiskFileItemFactory  fileItemFactory = new DiskFileItemFactory ();
		/*
		 *Set the size threshold, above which content will be stored on disk.
		 */
		fileItemFactory.setSizeThreshold(1*1024*1024); 
		/*
		 * Set the temporary directory to store the uploaded files of size above threshold.
		 */
		ServletFileUpload uploadHandler = new ServletFileUpload(fileItemFactory);
		try {
			/*
			 * Parse the request
			 */
			List items = uploadHandler.parseRequest(request);
			Iterator itr = items.iterator();
			while(itr.hasNext()) {
				FileItem item = (FileItem) itr.next();
				/*
				 * Handle Form Fields.
				 */
				if(item.isFormField()) {
					System.out.println("File Name = "+item.getFieldName()+", Value = "+item.getString());
				} else {
					System.out.println("Field Name = "+item.getFieldName()+
						", File Name = "+item.getName()+
						", Content type = "+item.getContentType()+
						", File Size = "+item.getSize());
					String s = convertStreamToString(item.getInputStream(), item.getSize());
					request.getSession().setAttribute("action", action);
					if (action.compareTo("upload_data") == 0) {
						request.getSession().setAttribute("codes", s);
					} else {
						Mapping mapping = new Mapping().toMapping(s);
						System.out.println("Mapping " + mapping.getMappingName() + " uploaded.");
						System.out.println("Mapping version: " + mapping.getMappingVersion());
						MappingObject obj = mapping.toMappingObject();
						HashMap mappings = (HashMap) request.getSession().getAttribute("mappings");
						if (mappings == null) {
							mappings = new HashMap();
						}
						mappings.put(obj.getKey(), obj);
						request.getSession().setAttribute("mappings", mappings);
					}
				}
			}
		}catch(FileUploadException ex) {
			log("Error encountered while parsing the request",ex);
		} catch(Exception ex) {
			log("Error encountered while uploading file",ex);
		}
        if (action.compareTo("upload_data") == 0) {
			if (type.compareTo("codingscheme") == 0) {
        		response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/pages/codingscheme_data.jsf"));
			} else if (type.compareTo("ncimeta") == 0) {
				response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/pages/ncimeta_data.jsf"));
			} else if (type.compareTo("valueset") == 0) {
				response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/pages/valueset_data.jsf"));
			}		} else {
			response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/pages/home.jsf"));
		}
    }
public void execute ( HttpServletRequest request , HttpServletResponse response ) throws IOException , ServletException { String action = ( String ) request . getParameter ( "action" ) ; String type = ( String ) request . getParameter ( "type" ) ; System . out . println ( "(*) UploadServlet ...action " + action ) ; if ( action == null ) { action = "upload_data" ; } DiskFileItemFactory fileItemFactory = new DiskFileItemFactory ( ) ; /*
		 *Set the size threshold, above which content will be stored on disk.
		 */ fileItemFactory . setSizeThreshold ( 1 * 1024 * 1024 ) ; /*
		 * Set the temporary directory to store the uploaded files of size above threshold.
		 */ ServletFileUpload uploadHandler = new ServletFileUpload ( fileItemFactory ) ; try { /*
			 * Parse the request
			 */ List items = uploadHandler . parseRequest ( request ) ; Iterator itr = items . iterator ( ) ; while ( itr . hasNext ( ) ) { FileItem item = ( FileItem ) itr . next ( ) ; /*
				 * Handle Form Fields.
				 */ if ( item . isFormField ( ) ) { System . out . println ( "File Name = " + item . getFieldName ( ) + ", Value = " + item . getString ( ) ) ; } else { System . out . println ( "Field Name = " + item . getFieldName ( ) + ", File Name = " + item . getName ( ) + ", Content type = " + item . getContentType ( ) + ", File Size = " + item . getSize ( ) ) ; String s = convertStreamToString ( item . getInputStream ( ) , item . getSize ( ) ) ; request . getSession ( ) . setAttribute ( "action" , action ) ; if ( action . compareTo ( "upload_data" ) == 0 ) { request . getSession ( ) . setAttribute ( "codes" , s ) ; } else { Mapping mapping = new Mapping ( ) . toMapping ( s ) ; System . out . println ( "Mapping " + mapping . getMappingName ( ) + " uploaded." ) ; System . out . println ( "Mapping version: " + mapping . getMappingVersion ( ) ) ; MappingObject obj = mapping . toMappingObject ( ) ; HashMap mappings = ( HashMap ) request . getSession ( ) . getAttribute ( "mappings" ) ; if ( mappings == null ) { mappings = new HashMap ( ) ; } mappings . put ( obj . getKey ( ) , obj ) ; request . getSession ( ) . setAttribute ( "mappings" , mappings ) ; } } } } catch ( FileUploadException ex ) { log ( "Error encountered while parsing the request" , ex ) ; } catch ( Exception ex ) { log ( "Error encountered while uploading file" , ex ) ; } if ( action . compareTo ( "upload_data" ) == 0 ) { if ( type . compareTo ( "codingscheme" ) == 0 ) { response . sendRedirect ( response . encodeRedirectURL ( request . getContextPath ( ) + "/pages/codingscheme_data.jsf" ) ) ; } else if ( type . compareTo ( "ncimeta" ) == 0 ) { response . sendRedirect ( response . encodeRedirectURL ( request . getContextPath ( ) + "/pages/ncimeta_data.jsf" ) ) ; } else if ( type . compareTo ( "valueset" ) == 0 ) { response . sendRedirect ( response . encodeRedirectURL ( request . getContextPath ( ) + "/pages/valueset_data.jsf" ) ) ; } } else { response . sendRedirect ( response . encodeRedirectURL ( request . getContextPath ( ) + "/pages/home.jsf" ) ) ; } }
Process the specified HTTP request, and create the corresponding HTTP
 response (or forward to another web component that will create it).
Process the specified HTTP request and create the corresponding HTTP response ( or forward to another web component that will create it ) .
// Determine request by attributes
 //1 MB
 //fileItemFactory.setRepository(tmpDir);
 //String s = convertStreamToString(item.getInputStream(), item.getSize());
 //System.out.println(s);
 //Handle Uploaded files.
 //System.out.println(s);
 //long ms = System.currentTimeMillis();
