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$ --%> - - - -
- - - - -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