mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 05:53:08 +00:00
javadoc (doclint) and whitespace fixes
includes whitespace fixes as per Coding Conventions
This commit is contained in:
@@ -92,47 +92,48 @@ public class StructBuilder
|
||||
*
|
||||
* The output file will contain exactly the same as the source xml document, but
|
||||
* with the handle for each imported item added as an attribute.
|
||||
* @param argv commandline arguments
|
||||
*
|
||||
* @param argv the command line arguments given
|
||||
* @throws Exception if an error occurs
|
||||
*/
|
||||
public static void main(String[] argv)
|
||||
throws Exception
|
||||
throws Exception
|
||||
{
|
||||
CommandLineParser parser = new PosixParser();
|
||||
|
||||
Options options = new Options();
|
||||
Options options = new Options();
|
||||
|
||||
options.addOption( "f", "file", true, "file");
|
||||
options.addOption( "e", "eperson", true, "eperson");
|
||||
options.addOption("o", "output", true, "output");
|
||||
|
||||
CommandLine line = parser.parse( options, argv );
|
||||
|
||||
String file = null;
|
||||
String eperson = null;
|
||||
String output = null;
|
||||
|
||||
if (line.hasOption('f'))
|
||||
{
|
||||
file = line.getOptionValue('f');
|
||||
}
|
||||
|
||||
if (line.hasOption('e'))
|
||||
{
|
||||
eperson = line.getOptionValue('e');
|
||||
}
|
||||
|
||||
if (line.hasOption('o'))
|
||||
{
|
||||
output = line.getOptionValue('o');
|
||||
}
|
||||
|
||||
if (output == null || eperson == null || file == null)
|
||||
{
|
||||
usage();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
options.addOption( "f", "file", true, "file");
|
||||
options.addOption( "e", "eperson", true, "eperson");
|
||||
options.addOption("o", "output", true, "output");
|
||||
|
||||
CommandLine line = parser.parse( options, argv );
|
||||
|
||||
String file = null;
|
||||
String eperson = null;
|
||||
String output = null;
|
||||
|
||||
if (line.hasOption('f'))
|
||||
{
|
||||
file = line.getOptionValue('f');
|
||||
}
|
||||
|
||||
if (line.hasOption('e'))
|
||||
{
|
||||
eperson = line.getOptionValue('e');
|
||||
}
|
||||
|
||||
if (line.hasOption('o'))
|
||||
{
|
||||
output = line.getOptionValue('o');
|
||||
}
|
||||
|
||||
if (output == null || eperson == null || file == null)
|
||||
{
|
||||
usage();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// create a context
|
||||
Context context = new Context();
|
||||
|
||||
@@ -204,12 +205,12 @@ public class StructBuilder
|
||||
* Validate the XML document. This method does not return, but if validation
|
||||
* fails it generates an error and ceases execution
|
||||
*
|
||||
* @param document the XML document object
|
||||
* @param document the XML document object
|
||||
* @throws TransformerException if transformer error
|
||||
*
|
||||
*/
|
||||
private static void validate(org.w3c.dom.Document document)
|
||||
throws TransformerException
|
||||
throws TransformerException
|
||||
{
|
||||
StringBuffer err = new StringBuffer();
|
||||
boolean trip = false;
|
||||
@@ -245,13 +246,13 @@ public class StructBuilder
|
||||
*
|
||||
* @param communities the NodeList of communities to validate
|
||||
* @param level the level in the XML document that we are at, for the purposes
|
||||
* of error reporting
|
||||
* of error reporting
|
||||
*
|
||||
* @return the errors that need to be generated by the calling method, or null if
|
||||
* no errors.
|
||||
* no errors.
|
||||
*/
|
||||
private static String validateCommunities(NodeList communities, int level)
|
||||
throws TransformerException
|
||||
throws TransformerException
|
||||
{
|
||||
StringBuffer err = new StringBuffer();
|
||||
boolean trip = false;
|
||||
@@ -260,32 +261,32 @@ public class StructBuilder
|
||||
for (int i = 0; i < communities.getLength(); i++)
|
||||
{
|
||||
Node n = communities.item(i);
|
||||
NodeList name = XPathAPI.selectNodeList(n, "name");
|
||||
if (name.getLength() != 1)
|
||||
{
|
||||
String pos = Integer.toString(i + 1);
|
||||
err.append("-The level " + level + " community in position " + pos);
|
||||
err.append(" does not contain exactly one name field\n");
|
||||
trip = true;
|
||||
}
|
||||
|
||||
// validate sub communities
|
||||
NodeList subCommunities = XPathAPI.selectNodeList(n, "community");
|
||||
String comErrs = validateCommunities(subCommunities, level + 1);
|
||||
if (comErrs != null)
|
||||
{
|
||||
err.append(comErrs);
|
||||
trip = true;
|
||||
}
|
||||
|
||||
// validate collections
|
||||
NodeList collections = XPathAPI.selectNodeList(n, "collection");
|
||||
String colErrs = validateCollections(collections, level + 1);
|
||||
if (colErrs != null)
|
||||
{
|
||||
err.append(colErrs);
|
||||
trip = true;
|
||||
}
|
||||
NodeList name = XPathAPI.selectNodeList(n, "name");
|
||||
if (name.getLength() != 1)
|
||||
{
|
||||
String pos = Integer.toString(i + 1);
|
||||
err.append("-The level " + level + " community in position " + pos);
|
||||
err.append(" does not contain exactly one name field\n");
|
||||
trip = true;
|
||||
}
|
||||
|
||||
// validate sub communities
|
||||
NodeList subCommunities = XPathAPI.selectNodeList(n, "community");
|
||||
String comErrs = validateCommunities(subCommunities, level + 1);
|
||||
if (comErrs != null)
|
||||
{
|
||||
err.append(comErrs);
|
||||
trip = true;
|
||||
}
|
||||
|
||||
// validate collections
|
||||
NodeList collections = XPathAPI.selectNodeList(n, "collection");
|
||||
String colErrs = validateCollections(collections, level + 1);
|
||||
if (colErrs != null)
|
||||
{
|
||||
err.append(colErrs);
|
||||
trip = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (trip)
|
||||
@@ -306,7 +307,7 @@ public class StructBuilder
|
||||
* @return the errors to be generated by the calling method, or null if none
|
||||
*/
|
||||
private static String validateCollections(NodeList collections, int level)
|
||||
throws TransformerException
|
||||
throws TransformerException
|
||||
{
|
||||
StringBuffer err = new StringBuffer();
|
||||
boolean trip = false;
|
||||
@@ -315,14 +316,14 @@ public class StructBuilder
|
||||
for (int i = 0; i < collections.getLength(); i++)
|
||||
{
|
||||
Node n = collections.item(i);
|
||||
NodeList name = XPathAPI.selectNodeList(n, "name");
|
||||
if (name.getLength() != 1)
|
||||
{
|
||||
String pos = Integer.toString(i + 1);
|
||||
err.append("-The level " + level + " collection in position " + pos);
|
||||
err.append(" does not contain exactly one name field\n");
|
||||
trip = true;
|
||||
}
|
||||
NodeList name = XPathAPI.selectNodeList(n, "name");
|
||||
if (name.getLength() != 1)
|
||||
{
|
||||
String pos = Integer.toString(i + 1);
|
||||
err.append("-The level " + level + " collection in position " + pos);
|
||||
err.append(" does not contain exactly one name field\n");
|
||||
trip = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (trip)
|
||||
@@ -342,7 +343,7 @@ public class StructBuilder
|
||||
* @return the DOM representation of the XML file
|
||||
*/
|
||||
private static org.w3c.dom.Document loadXML(String filename)
|
||||
throws IOException, ParserConfigurationException, SAXException
|
||||
throws IOException, ParserConfigurationException, SAXException
|
||||
{
|
||||
DocumentBuilder builder = DocumentBuilderFactory.newInstance()
|
||||
.newDocumentBuilder();
|
||||
@@ -385,10 +386,10 @@ public class StructBuilder
|
||||
* @param parent the parent community of the nodelist of communities to create
|
||||
*
|
||||
* @return an element array containing additional information regarding the
|
||||
* created communities (e.g. the handles they have been assigned)
|
||||
* created communities (e.g. the handles they have been assigned)
|
||||
*/
|
||||
private static Element[] handleCommunities(Context context, NodeList communities, Community parent)
|
||||
throws TransformerException, SQLException, Exception
|
||||
throws TransformerException, SQLException, Exception
|
||||
{
|
||||
Element[] elements = new Element[communities.getLength()];
|
||||
|
||||
@@ -506,10 +507,10 @@ public class StructBuilder
|
||||
* @param parent the parent community to whom the collections belong
|
||||
*
|
||||
* @return an Element array containing additional information about the
|
||||
* created collections (e.g. the handle)
|
||||
* created collections (e.g. the handle)
|
||||
*/
|
||||
private static Element[] handleCollections(Context context, NodeList collections, Community parent)
|
||||
throws TransformerException, SQLException, AuthorizeException, IOException, Exception
|
||||
throws TransformerException, SQLException, AuthorizeException, IOException, Exception
|
||||
{
|
||||
Element[] elements = new Element[collections.getLength()];
|
||||
|
||||
|
Reference in New Issue
Block a user