// Path: src/java/org/onesocialweb/openfire/exception/AuthenticationException.java
// @SuppressWarnings("serial")
// public class AuthenticationException extends Exception {
// 
// }
// 
// Path: src/java/org/onesocialweb/openfire/exception/InvalidParameterValueException.java
// @SuppressWarnings("serial")
// public class InvalidParameterValueException extends Exception {
// 
// 	private final String parameter;
// 	
// 	private final String value;
// 
// 	public InvalidParameterValueException(String parameter, String value) {
// 		this.parameter = parameter;
// 		this.value = value;
// 	}
// 	
// 	public String getParameter() {
// 		return parameter;
// 	}
// 
// 	public String getValue() {
// 		return value;
// 	}
// 	
// }
// 
// Path: src/java/org/onesocialweb/openfire/exception/MissingParameterException.java
// @SuppressWarnings("serial")
// public class MissingParameterException extends Exception {
// 
// 	private final String parameter;
// 	
// 	public MissingParameterException(String parameter) {
// 		this.parameter = parameter;
// 	}
// 	
// 	public String getParameter() {
// 		return parameter;
// 	}
// 	
// }
// 
// Path: src/java/org/onesocialweb/openfire/model/FileEntry.java
// public interface FileEntry {
// 
// 	public String getId();
// 
// 	public void setId(String id);
// 
// 	public String getName();
// 
// 	public void setName(String name);
// 
// 	public String getType();
// 
// 	public void setType(String type);
// 
// 	public String getOwner();
// 
// 	public void setOwner(String owner);
// 
// 	public long getSize();
// 
// 	public void setSize(long size);
// 
// }


import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.UUID;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.ProgressListener;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.jivesoftware.admin.AuthCheckFilter;
import org.jivesoftware.util.JiveGlobals;
import org.onesocialweb.openfire.exception.AuthenticationException;
import org.onesocialweb.openfire.exception.InvalidParameterValueException;
import org.onesocialweb.openfire.exception.MissingParameterException;
import org.onesocialweb.openfire.model.FileEntry;
import org.xmpp.packet.JID;
		catch (Exception e) {
			out.println("Exception occured: " + e.getMessage());
			e.printStackTrace(out);		
		}

		out.flush();
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
			IOException {
		
		final PrintWriter out = response.getWriter();

		try {
			processPost(request, response);
		} catch (Exception e) {
			out.println("Exception occured: " + e.getMessage());
			e.printStackTrace(out);
		}

		out.flush();
	}

	private void processPost(HttpServletRequest request, HttpServletResponse response) throws Exception {
		final PrintWriter out = response.getWriter();
		
		// 1- Bind this request to a XMPP JID
		final JID user = getAuthenticatedUser(request);
		if (user == null) {
// Path: src/java/org/onesocialweb/openfire/exception/AuthenticationException.java
// @SuppressWarnings("serial")
// public class AuthenticationException extends Exception {
// 
// }
// 
// Path: src/java/org/onesocialweb/openfire/exception/InvalidParameterValueException.java
// @SuppressWarnings("serial")
// public class InvalidParameterValueException extends Exception {
// 
// 	private final String parameter;
// 	
// 	private final String value;
// 
// 	public InvalidParameterValueException(String parameter, String value) {
// 		this.parameter = parameter;
// 		this.value = value;
// 	}
// 	
// 	public String getParameter() {
// 		return parameter;
// 	}
// 
// 	public String getValue() {
// 		return value;
// 	}
// 	
// }
// 
// Path: src/java/org/onesocialweb/openfire/exception/MissingParameterException.java
// @SuppressWarnings("serial")
// public class MissingParameterException extends Exception {
// 
// 	private final String parameter;
// 	
// 	public MissingParameterException(String parameter) {
// 		this.parameter = parameter;
// 	}
// 	
// 	public String getParameter() {
// 		return parameter;
// 	}
// 	
// }
// 
// Path: src/java/org/onesocialweb/openfire/model/FileEntry.java
// public interface FileEntry {
// 
// 	public String getId();
// 
// 	public void setId(String id);
// 
// 	public String getName();
// 
// 	public void setName(String name);
// 
// 	public String getType();
// 
// 	public void setType(String type);
// 
// 	public String getOwner();
// 
// 	public void setOwner(String owner);
// 
// 	public long getSize();
// 
// 	public void setSize(long size);
// 
// }


// Path: src/java/org/onesocialweb/openfire/web/FileServlet.java
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.UUID;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.ProgressListener;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.jivesoftware.admin.AuthCheckFilter;
import org.jivesoftware.util.JiveGlobals;
import org.onesocialweb.openfire.exception.AuthenticationException;
import org.onesocialweb.openfire.exception.InvalidParameterValueException;
import org.onesocialweb.openfire.exception.MissingParameterException;
import org.onesocialweb.openfire.model.FileEntry;
import org.xmpp.packet.JID;

		catch (Exception e) {
			out.println("Exception occured: " + e.getMessage());
			e.printStackTrace(out);		
		}

		out.flush();
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
			IOException {
		
		final PrintWriter out = response.getWriter();

		try {
			processPost(request, response);
		} catch (Exception e) {
			out.println("Exception occured: " + e.getMessage());
			e.printStackTrace(out);
		}

		out.flush();
	}

	private void processPost(HttpServletRequest request, HttpServletResponse response) throws Exception {
		final PrintWriter out = response.getWriter();
		
		// 1- Bind this request to a XMPP JID
		final JID user = getAuthenticatedUser(request);
		if (user == null) {
			throw new AuthenticationException();