in src/main/java/org/apache/sling/pipes/internal/MovePipe.java [96:123]
private Iterator<Resource> moveToTarget(Resource input, String targetPath) throws RepositoryException {
logger.info("moving resource {} to {}", input.getPath(), targetPath);
Session session = resolver.adaptTo(Session.class);
if (!isDryRun() && session != null) {
if (input.adaptTo(Node.class) != null) {
session.move(input.getPath(), targetPath);
} else {
logger.debug("resource is a property");
int lastLevel = targetPath.lastIndexOf("/");
// /a/b/c will get cut in /a/b for parent path, and c for name
String parentPath = targetPath.substring(0, lastLevel);
String name = targetPath.substring(lastLevel + 1, targetPath.length());
Property sourceProperty = input.adaptTo(Property.class);
if (sourceProperty != null) {
Node destNode = session.getNode(parentPath);
if (sourceProperty.isMultiple()){
destNode.setProperty(name, sourceProperty.getValues(), sourceProperty.getType());
} else {
destNode.setProperty(name, sourceProperty.getValue(), sourceProperty.getType());
}
sourceProperty.remove();
}
}
Resource target = resolver.getResource(targetPath);
return Collections.singleton(target).iterator();
}
return EMPTY_ITERATOR;
}