Code with Misuse: |
class ToolsListerFrame {
public Reply handle (Request request, URLDecoder data)
throws ProtocolException
{
Reply r;
Enumeration e = data.keys() ;
while ( e.hasMoreElements () ) {
String name = (String) e.nextElement() ;
if (name.equals("SUBMIT"))
continue;
// delete file now... avoit deleting CVS and lister
// (should be in an attribute)
synchronized (this) {
DirectoryResource dr;
Resource toDeleteRes;
ResourceReference rr;
File dir, toDeleteFile;
try {
dr = (DirectoryResource) getDirResourceRef().lock();
dir = dr.getDirectory();
if (debug)
System.out.println("Deleting " + name);
rr = dr.lookup(name);
if (rr != null) {
try {
toDeleteFile = new File(dir, name);
toDeleteFile.delete();
} catch (Exception ex) {
// fancy message. file not present
// Or security manager forbiding deletion.
}
// and now, at least remove the resource
try {
toDeleteRes = (Resource) rr.lock();
toDeleteRes.delete();
} catch (Exception ex) {
// some other locks... or pb with the resource
} finally {
rr.unlock();
}
}
} catch (Exception ex) {
// some other locks... abort
} finally {
getDirResourceRef().unlock();
}
}
}
try {
r = getDirectoryListing(request);
} catch (ResourceException ex) {
r = createDefaultReply(request, HTTP.INTERNAL_SERVER_ERROR);
}
return r;
}
}
|