org.dspace.ctask.general
Class BasicLinkChecker

java.lang.Object
  extended by org.dspace.curate.AbstractCurationTask
      extended by org.dspace.ctask.general.BasicLinkChecker
All Implemented Interfaces:
CurationTask
Direct Known Subclasses:
MetadataValueLinkChecker

public class BasicLinkChecker
extends AbstractCurationTask

A basic link checker that is designed to be extended. By default this link checker will check that all links stored in anyschema.anyelement.uri metadata fields return a 20x status code. This link checker can be enhanced by extending this class, and overriding the getURLs and checkURL methods.

Author:
Stuart Lewis

Field Summary
 
Fields inherited from class org.dspace.curate.AbstractCurationTask
curator, taskId
 
Constructor Summary
BasicLinkChecker()
           
 
Method Summary
protected  boolean checkURL(String url, StringBuilder results)
          Check the URL and perform appropriate reporting
protected  int getResponseStatus(String url)
          Get the response code for a URL.
protected  List<String> getURLs(Item item)
          Get the URLs to check
 int perform(DSpaceObject dso)
          Perform the link checking.
 
Methods inherited from class org.dspace.curate.AbstractCurationTask
dereference, distribute, init, perform, performItem, report, setResult, taskBooleanProperty, taskIntProperty, taskLongProperty, taskProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicLinkChecker

public BasicLinkChecker()
Method Detail

perform

public int perform(DSpaceObject dso)
            throws IOException
Perform the link checking.

Specified by:
perform in interface CurationTask
Specified by:
perform in class AbstractCurationTask
Parameters:
dso - The DSpaaceObject to be checked
Returns:
The curation task status of the checking
Throws:
IOException - THrown if something went wrong

getURLs

protected List<String> getURLs(Item item)
Get the URLs to check

Parameters:
item - The item to extract URLs from
Returns:
An array of URL Strings

checkURL

protected boolean checkURL(String url,
                           StringBuilder results)
Check the URL and perform appropriate reporting

Parameters:
url - The URL to check
Returns:
If the URL was OK or not

getResponseStatus

protected int getResponseStatus(String url)
Get the response code for a URL. If something goes wrong opening the URL, a response code of 0 is returned.

Parameters:
url - The url to open
Returns:
The HTTP response code (e.g. 200 / 301 / 404 / 500)


Copyright © 2011 DuraSpace. All Rights Reserved.