//not exactly what we want but, it ~works
backup.delete();
resfile.renameTo(backup);
}
//perform the put
Reply r = super.putFileResource(request);
int rstatus = r.getStatus();
// if OK
if ((rstatus / 100 ) == 2 ) {
// Do a CVS commit with user name
commit(request);
}
//well done, remove the backup file now
backup.delete();
// update the file attrs
getFileResource().checkContent();
//return the reply.
if ((rstatus / 100 ) == 2 ) {
return createDefaultReply(request,
r.getStatus());
} else {
return r;
}
} else {
// fail
String msg =
"File is not up to date, "+
"please update the file manually "+
"or use the CVS form.";
return error( request,
HTTP.CONFLICT,
"Error",
msg );
}
} catch (UpToDateCheckFailedException utd_ex) {
resfile.delete();
//restore the backup file
backup.renameTo(resfile);
//send error
String msg = utd_ex.getFilename()+
" is not up to date, "+
"please update the file manually "+
"or use the CVS form.";
return error( request,
HTTP.CONFLICT,
"Error",
msg );
} catch (CvsException ex) {
backup.delete();
// fail too
String msg = "CvsException : "+ex.getMessage();
getServer().errlog(getIdentifier()+" : "
+ex.getMessage());
return error( request,
HTTP.SERVICE_UNAVAILABLE,
"Error",
msg );
}
} else {
// Write the file to web space
Reply r = super.putFileResource(request);
try {
// Do a CVS add with user name
add(request);
// Do a CVS commit with user name
commit(request);
getFileResource().checkContent();
} catch (CvsAddException ex) {
String msg = "Cvs add failed : <br>'"+
ex.getMessage()+
"'<br>please update the file manually "+
"or use the CVS form";
return error( request,
HTTP.SERVICE_UNAVAILABLE,
"Error",
msg );
} catch (CvsException ex) {
ex.printStackTrace();
String msg = "Problem during cvs process : "+
ex.getMessage();
getServer().errlog(getIdentifier()+" : "+msg);
return error( request,
HTTP.INTERNAL_SERVER_ERROR,
"Internal Server Error",
msg );
}
if (r.getStatus() == HTTP.CREATED) {
Reply reply = request.makeReply(r.getStatus());
reply.setContent("<P>Resource succesfully created");
if (request.hasState(STATE_CONTENT_LOCATION))
reply.setContentLocation(
getURL(request).toExternalForm());
r = createDefaultReply(request, HTTP.CREATED);
reply.setETag(r.getETag());
return reply;
}
return createDefaultReply(request, r.getStatus());
}
} else {