private void moveWithinRepository( DAVTransaction transaction, DAVResource resource, DAVResource dest) throws IOException { int depth = transaction.getDepth(); boolean recursive = false; if (depth == 0) { recursive = false; } else if (depth == DAVTransaction.INFINITY) { recursive = true; } else { throw new DAVException(412, "Invalid Depth specified"); } try { int status; if (!dest.isNull() && !transaction.getOverwrite()) { status = 412; // MOVE-on-existing should fail with 412 } else { resource.copy(dest, transaction.getOverwrite(), recursive); resource.delete(); if (transaction.getOverwrite()) { status = 204; // No Content } else { status = 201; // Created } } transaction.setStatus(status); } catch (DAVMultiStatus multistatus) { multistatus.write(transaction); } }
/** Process the <code>MOVE</code> method. */ public void process(DAVTransaction transaction, DAVResource resource) throws IOException { URI target = transaction.getDestination(); if (target == null) throw new DAVException(412, "No destination"); if (target.getScheme() == null) { // This is a relative file system destination target. DAVResource dest = resource.getRepository().getResource(target); moveWithinRepository(transaction, resource, dest); } else { // This is a inter-repository move request. URI dest = target; moveInterRepository(transaction, resource, dest); } }