getLogger().info("upload source called by '"+principal+"' for '"+uri+"'");
Object uploadedFile = request.get(UPLOAD_FILE);
if (( uploadedFile != null) && (uploadedFile instanceof Part)) {
Part part = (Part) uploadedFile;
try {
if ((filename == null) || (filename.length() == 0)) {
filename = part.getFileName();
}
if ((uri == null) || (uri.length() == 0))
uri = filename;
else if (uri.endsWith("/"))
uri = uri + filename;
else
uri = uri + "/" + filename;
Source source = resolver.resolveURI(uri);
if (source instanceof RestrictableSource)
((RestrictableSource)source).setSourceCredential(new SourceCredential(principal, password));
if (source instanceof ModifiableSource) {
ModifiableSource writeablesource = (ModifiableSource)source;
OutputStream out = writeablesource.getOutputStream();
byte[] buffer = new byte[8192];
int length = -1;
InputStream in = part.getInputStream();
while ((length = in.read(buffer)) > -1) {
out.write(buffer, 0, length);
getLogger().debug("="+length);
}
in.close();