From 0418489ec13de84614c0251ed8b08dd3578a74c1 Mon Sep 17 00:00:00 2001 From: jeb228 Date: Tue, 23 Nov 2010 20:19:48 +0000 Subject: [PATCH] Remove unreferenced files. --- webapp/web/fileupload/fileUploadForm.jsp | 23 ---- webapp/web/fileupload/fileUploadProcess.jsp | 127 -------------------- 2 files changed, 150 deletions(-) delete mode 100644 webapp/web/fileupload/fileUploadForm.jsp delete mode 100644 webapp/web/fileupload/fileUploadProcess.jsp diff --git a/webapp/web/fileupload/fileUploadForm.jsp b/webapp/web/fileupload/fileUploadForm.jsp deleted file mode 100644 index 8c7b26db3..000000000 --- a/webapp/web/fileupload/fileUploadForm.jsp +++ /dev/null @@ -1,23 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - - - - - - - - - file upload for ${projectName} - - -
-
-
- -
- -
- -
- - diff --git a/webapp/web/fileupload/fileUploadProcess.jsp b/webapp/web/fileupload/fileUploadProcess.jsp deleted file mode 100644 index 2f2cee889..000000000 --- a/webapp/web/fileupload/fileUploadProcess.jsp +++ /dev/null @@ -1,127 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory" %> -<%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload" %> -<%@ page import="org.apache.commons.fileupload.FileItem" %> -<%@ page import="java.util.Iterator" %> -<%@ page import="java.util.List" %> -<%@ page import="java.io.File" %> - -<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> - -<%-- This is a jsp to handle uploading files. --%> -<%-- It was written with Datastar in mind --%> - -<%-- This JSP code expects that the user is logged in, - that a datastar project is specified, and that the - request is a multipart POST. --%> - -<%-- Since this is for Datastar we need the URI of the user - who is uploading this file, the URI of the project it is - associated with and a project spcific directory to save - the file to. %> - -<%! static final int MAX_IN_MEM_SIZE = 1024*1024 * 50 ; //50 Mbyte file limit %> - - -<%-- http://vivo.library.cornell.edu/ns/0.1#coordinatorOf --%> -<%-- http://vivo.library.cornell.edu/ns/0.1#resourceAuthor --%> - -<%! static final int MAX_IN_MEM_SIZE = 1024*1024 * 50; %> - -<% -if( ! ServletFileUpload.isMultipartContent(request) ){ - //return an error message0. - out.write("

you need to submit a file.

"); - return; -} - -//Create a factory for disk-based file items -DiskFileItemFactory factory = new DiskFileItemFactory(); -factory.setSizeThreshold(MAX_IN_MEM_SIZE); - -// Create a new file upload handler -ServletFileUpload upload = new ServletFileUpload(factory); -upload.setSizeMax(MAX_IN_MEM_SIZE); - -// Parse the request -List /* FileItem */ items = upload.parseRequest(request); - -String user = getUserUri(request); -String project = getProjectUri(request); -String dir = getDirectory(user,project,request); - -if( ! canWriteDirectory( dir )){ - out.write( doDirectoryWriteError( dir ) ); - return; -} - -Iterator iter = items.iterator(); -while( iter.hasNext()){ - - FileItem item = (FileItem)iter.next(); - if( item.isFormField()){ - out.write("

"); - out.write("fieldname: " + item.getFieldName() + " value: " + item.getString() ); - out.write("

"); - }else{ - out.write("

"); - out.write("form field name: " + item.getFieldName() - +" filename: " + item.getName() - +" type: " + item.getContentType() - +" isInMem: " + item.isInMemory() ); - out.write("

"); - - String fileLocation = dir + '/' + item.getName(); - if( fileWithNameAlreadyExists( fileLocation ) ){ - doFileExistsError( fileLocation ); - return; - } - - File uploadedFile = new File( fileLocation ); - item.write( uploadedFile ); - } -} -%> - -<%! -public String getDirectory(String userUri, String projectUri, HttpServletRequest request){ - //this should be stored in the model as a dataproperty on the project - return "/usr/local/datastar/data"; -} - -public String getUserUri( HttpServletRequest request ){ - return "http://vivo.library.cornell.edu/ns/0.1#individual762"; //Medha Devare -} - -public String getProjectUri( HttpServletRequest request ){ - return "http://vivo.library.cornell.edu/ns/0.1#individual1"; //Mann Lib. -} -%> - -<%! -public boolean canWriteDirectory( String dir ){ - File df = new File(dir); - //attempt to create directory if not found - if( ! df.exists() ){ - if( !df.mkdir() ) - return false; - } - return df.canWrite(); -} - -public String doDirectoryWriteError( String dir ) { - return "The system could not save your file, contact you system" - +" administrators and inform them that the directory " - + dir + " is not writeable"; -} - -public boolean fileWithNameAlreadyExists( String fileLocation ){ - File f = new File(fileLocation); - return f.exists(); -} - -public String doFileExistsError( String file ) { - return "There is already a file named " + file + " on the system. Please rename your file " ; -} -%> \ No newline at end of file