All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dspace.ctask.general.MetadataValueLinkChecker Maven / Gradle / Ivy

/**
 * The contents of this file are subject to the license and copyright
 * detailed in the LICENSE and NOTICE files at the root of the source
 * tree and available online at
 *
 * http://www.dspace.org/license/
 */
package org.dspace.ctask.general;

import org.dspace.content.DCValue;
import org.dspace.content.Item;

import java.util.ArrayList;
import java.util.List;

/**
 * A link checker that builds upon the BasicLinkChecker to check URLs that
 * appear in all metadata fields where the field starts with http:// or https://
 *
 * Of course thi assumes that there is no extra metadata following the URL.
 *
 * @author Stuart Lewis
 */
public class MetadataValueLinkChecker extends BasicLinkChecker {

    protected List getURLs(Item item)
    {
        // Get all metadata elements that start with http:// or https://
        DCValue[] urls = item.getMetadata(Item.ANY, Item.ANY, Item.ANY, Item.ANY);
        ArrayList theURLs = new ArrayList();
        for (DCValue url : urls)
        {
            if ((url.value.startsWith("http://")) || (url.value.startsWith("https://")))
            {
                theURLs.add(url.value);
            }
        }
        return theURLs;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy