// the destination is newly created, hence a create request
response.setCreateRequest(true);
}
Iterator<Resource> resources = getApplyToResources(request);
Item destItem = null;
if (resources == null) {
// ensure we have an item underlying the request's resource
Item item = resource.adaptTo(Item.class);
if (item == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND,
"Missing source " + resource + " for " + getOperationName());
return;
}
String dstName = trailingSlash ? null : ResourceUtil.getName(dest);
destItem = execute(changes, item, dstParent, dstName, versioningConfiguration);
} else {
// multiple applyTo requires trailing slash on destination
if (!trailingSlash) {
throw new IllegalArgumentException(
"Applying "
+ getOperationName()
+ " to multiple resources requires a trailing slash on the destination");
}
// multiple copy will never return 201/CREATED
response.setCreateRequest(false);
while (resources.hasNext()) {
Resource applyTo = resources.next();
Item item = applyTo.adaptTo(Item.class);
if (item != null) {
execute(changes, item, dstParent, null, versioningConfiguration);
}
}
destItem = session.getItem(dest);