// verify that the target resource is putable
ResourceReference rr = request.getTargetResource();
if (rr != null) {
try {
FramedResource target = (FramedResource) rr.lock();
HTTPFrame frame = null;
try {
frame = (HTTPFrame) target.getFrame(
Class.forName("org.w3c.jigsaw.frames.HTTPFrame"));
} catch (ClassNotFoundException cex) {
cex.printStackTrace();
//big big problem ...
}
if (frame == null) // can't be putable
return null;
// now we can verify if the target resource is putable
if (! frame.getPutableFlag()) {
return null;
}
// and that the PUT can happen (taken from putFileResource
int cim = frame.checkIfMatch(request);
if ((cim == HTTPFrame.COND_FAILED)
|| (cim == HTTPFrame.COND_WEAK)
|| (frame.checkIfNoneMatch(request) ==
HTTPFrame.COND_FAILED)
|| (frame.checkIfModifiedSince(request) ==
HTTPFrame.COND_FAILED)
|| (frame.checkIfUnmodifiedSince(request) ==
HTTPFrame.COND_FAILED)) {
Reply r = request.makeReply(HTTP.PRECONDITION_FAILED);
r.setContent("Pre-condition failed.");
return r;