Package org.dspace.ctask.general
Class BasicLinkChecker
java.lang.Object
org.dspace.curate.AbstractCurationTask
org.dspace.ctask.general.BasicLinkChecker
- All Implemented Interfaces:
CurationTask
- Direct Known Subclasses:
MetadataValueLinkChecker
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
FieldsFields inherited from class org.dspace.curate.AbstractCurationTask
communityService, curator, handleService, itemService, taskId -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancheckURL(String url, StringBuilder results) Check the URL and perform appropriate reportingprotected StringgetItemHandle(Item item) Internal utility method to get a description of the handleprotected intgetResponseStatus(String url, int redirects) Get the response code for a URL.Get the URLs to checkintperform(DSpaceObject dso) Perform the link checking.Methods inherited from class org.dspace.curate.AbstractCurationTask
dereference, distribute, init, perform, performItem, performObject, report, setResult, taskArrayProperty, taskBooleanProperty, taskIntProperty, taskLongProperty, taskProperty
-
Field Details
-
configurationService
-
-
Constructor Details
-
BasicLinkChecker
public BasicLinkChecker()
-
-
Method Details
-
perform
Perform the link checking.- Specified by:
performin interfaceCurationTask- Specified by:
performin classAbstractCurationTask- Parameters:
dso- The DSpaaceObject to be checked- Returns:
- The curation task status of the checking
- Throws:
IOException- THrown if something went wrong
-
getURLs
Get the URLs to check- Parameters:
item- The item to extract URLs from- Returns:
- An array of URL Strings
-
checkURL
Check the URL and perform appropriate reporting- Parameters:
url- The URL to checkresults- Result string with HTTP status codes- Returns:
- If the URL was OK or not
-
getResponseStatus
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)
-
getItemHandle
Internal utility method to get a description of the handle- Parameters:
item- The item to get a description of- Returns:
- The handle, or in workflow
-