Package org.dspace.app.sfx
Class SFXFileReaderServiceImpl
- java.lang.Object
-
- org.dspace.app.sfx.SFXFileReaderServiceImpl
-
- All Implemented Interfaces:
SFXFileReaderService
public class SFXFileReaderServiceImpl extends Object implements SFXFileReaderService
XML configuration file reader for DSpace metadata fields (DC) mapping to OpenURL parameters.This class reads the [dspace]/config/sfx.xml configuration file, which contains pairs of DSpace item metadata values and OpenURL parameter names. Then it takes an item and constructs an OpenURL for it with values of parameters filled in from the paired metadata fields.
- Version:
- $Revision$
- Author:
- Stuart Lewis, Graham Triggs
-
-
Field Summary
Fields Modifier and Type Field Description protected DocumentdocThe SFX configuration fileprotected ItemServiceitemService
-
Constructor Summary
Constructors Modifier Constructor Description protectedSFXFileReaderServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringdoNodes(Node node, Item item)Process the item, mapping each of its metadata fields defined in the configuration file to an OpenURL parameterStringgetAttribute(Node e, String name)Returns the value of the node's attribute named<name>NodegetElement(Node node)Returns element nodeStringgetValue(Node node)Returns the value found in the Text node (if any) in the node list that's passed in.booleanisEmptyTextNode(Node nd)Is Empty text Node *StringloadSFXFile(String fileName, Item item)Loads the SFX configuration fileDocumentparseFile(String fileName)Parses XML file and returns XML document.protected StringprocessFields(Node e, Item item)Process the field nodes, mapping each metadata field defined in the configuration file to an OpenURL parameter
-
-
-
Field Detail
-
doc
protected Document doc
The SFX configuration file
-
itemService
@Autowired(required=true) protected ItemService itemService
-
-
Method Detail
-
loadSFXFile
public String loadSFXFile(String fileName, Item item) throws IOException
Description copied from interface:SFXFileReaderServiceLoads the SFX configuration file- Specified by:
loadSFXFilein interfaceSFXFileReaderService- Parameters:
fileName- The name of the SFX configuration fileitem- The item to process, from which metadata values will be taken- Returns:
- the SFX string
- Throws:
IOException- if IO error
-
parseFile
public Document parseFile(String fileName)
Description copied from interface:SFXFileReaderServiceParses XML file and returns XML document.- Specified by:
parseFilein interfaceSFXFileReaderService- Parameters:
fileName- XML file to parse- Returns:
- XML document or null if error occurred. The error is caught and logged.
-
doNodes
public String doNodes(Node node, Item item) throws IOException
Description copied from interface:SFXFileReaderServiceProcess the item, mapping each of its metadata fields defined in the configuration file to an OpenURL parameter- Specified by:
doNodesin interfaceSFXFileReaderService- Parameters:
node- DOM node of the mapping pair in the XML file (field element)item- The item to process, from which metadata values will be taken- Returns:
- processed fields.
- Throws:
IOException- if IO error
-
processFields
protected String processFields(Node e, Item item) throws IOException
Process the field nodes, mapping each metadata field defined in the configuration file to an OpenURL parameter- Parameters:
e- DOM node of the mapping pair in the XML file (field element)item- The item to process, from which metadata values will be taken- Returns:
- assembled OpenURL query.
- Throws:
IOException- if IO error
-
getElement
public Node getElement(Node node)
Description copied from interface:SFXFileReaderServiceReturns element node- Specified by:
getElementin interfaceSFXFileReaderService- Parameters:
node- element (it is XML tag)- Returns:
- Element node otherwise null
-
isEmptyTextNode
public boolean isEmptyTextNode(Node nd)
Description copied from interface:SFXFileReaderServiceIs Empty text Node *- Specified by:
isEmptyTextNodein interfaceSFXFileReaderService- Parameters:
nd- node- Returns:
- true or false
-
getAttribute
public String getAttribute(Node e, String name)
Description copied from interface:SFXFileReaderServiceReturns the value of the node's attribute named<name>- Specified by:
getAttributein interfaceSFXFileReaderService- Parameters:
e- nodename- name- Returns:
- value
-
getValue
public String getValue(Node node)
Description copied from interface:SFXFileReaderServiceReturns the value found in the Text node (if any) in the node list that's passed in.- Specified by:
getValuein interfaceSFXFileReaderService- Parameters:
node- node- Returns:
- value
-
-