protected Iterator computeOutput()

in src/main/java/org/apache/sling/pipes/internal/MovePipe.java [150:183]


    protected Iterator<Resource> computeOutput() {
        Iterator<Resource> output = EMPTY_ITERATOR;
        Resource input = getInput();
        if (input == null || input.adaptTo(Item.class) == null) {
            logger.error("bad configuration, input is either not here, or not something that can be moved");
            return output;
        }
        String targetPath = getExpr();
        if (! targetPath.startsWith(SLASH)) {
            logger.debug("relative path requested as target path: we'll take current path's parent");
            targetPath = StringUtils.substringBeforeLast(input.getPath(), SLASH) + SLASH + targetPath;
        }
        Resource targetResource = resolver.getResource(targetPath);
        try {
            if (targetResource == null) {
                if (orderBefore) {
                    logger.warn("target resource {} doesn't exist ordering not possible", targetPath);
                } else {
                    output = moveToTarget(input, targetPath);
                }
            } else {
                if (overwriteTarget) {
                    output = overwriteTarget(input, targetResource);
                } else if (orderBefore) {
                    output = reorder(input, targetResource);
                } else {
                    logger.warn("{} already exists, nothing will be done here, nothing outputed", targetPath);
                }
            }
        } catch (PersistenceException | RepositoryException e){
            logger.error("unable to move the resource", e);
        }
        return output;
    }