Remove unreferenced files.

This commit is contained in:
jeb228 2010-11-23 20:19:48 +00:00
parent 1f91fc7f0a
commit 0418489ec1
2 changed files with 0 additions and 150 deletions

View file

@ -1,23 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script src="../js/jquery.js" type="text/javascript" language="javascript"></script>
<script src="../js/jquery_plugins/jquery.MultiFile.js" type="text/javascript" language="javascript"></script>
<title> file upload for ${projectName} </title>
</head>
<body>
<form action="fileUploadProcess.jsp" method="post" enctype="multipart/form-data">
<input type="text" name="creator" value="Brian Caruso"/></br>
<input type="file" class="multi" name="file1" value="file1"/></br>
<input type="submit" name="submit" value="Submit"/>
</form>
<form action="" class="P10">
<input type="file" class="multi" accept="gif|jpg"/>
</form>
</body>
</html>

View file

@ -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("<html><p>you need to submit a file.</p></html>");
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("<p>");
out.write("fieldname: " + item.getFieldName() + " value: " + item.getString() );
out.write("</p>");
}else{
out.write("<p>");
out.write("form field name: " + item.getFieldName()
+" filename: " + item.getName()
+" type: " + item.getContentType()
+" isInMem: " + item.isInMemory() );
out.write("</p>");
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 " ;
}
%>