mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 18:14:26 +00:00
Don't close the current sitemap if we never opened one
This commit is contained in:
@@ -33,7 +33,7 @@ import java.util.zip.GZIPOutputStream;
|
|||||||
* }
|
* }
|
||||||
* g.finish();
|
* g.finish();
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author Robert Tansley
|
* @author Robert Tansley
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractGenerator
|
public abstract class AbstractGenerator
|
||||||
@@ -59,7 +59,7 @@ public abstract class AbstractGenerator
|
|||||||
/**
|
/**
|
||||||
* Initialize this generator to write to the given directory. This must be
|
* Initialize this generator to write to the given directory. This must be
|
||||||
* called by any subclass constructor.
|
* called by any subclass constructor.
|
||||||
*
|
*
|
||||||
* @param outputDirIn
|
* @param outputDirIn
|
||||||
* directory to write sitemap files to
|
* directory to write sitemap files to
|
||||||
*/
|
*/
|
||||||
@@ -73,7 +73,7 @@ public abstract class AbstractGenerator
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Start writing a new sitemap file.
|
* Start writing a new sitemap file.
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* if an error occurs creating the file
|
* if an error occurs creating the file
|
||||||
*/
|
*/
|
||||||
@@ -97,7 +97,7 @@ public abstract class AbstractGenerator
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the given URL to the sitemap.
|
* Add the given URL to the sitemap.
|
||||||
*
|
*
|
||||||
* @param url
|
* @param url
|
||||||
* Full URL to add
|
* Full URL to add
|
||||||
* @param lastMod
|
* @param lastMod
|
||||||
@@ -129,7 +129,7 @@ public abstract class AbstractGenerator
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Finish with the current sitemap file.
|
* Finish with the current sitemap file.
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* if an error occurs writing
|
* if an error occurs writing
|
||||||
*/
|
*/
|
||||||
@@ -144,15 +144,18 @@ public abstract class AbstractGenerator
|
|||||||
* Complete writing sitemap files and write the index files. This is invoked
|
* Complete writing sitemap files and write the index files. This is invoked
|
||||||
* when all calls to {@link AbstractGenerator#addURL(String, Date)} have
|
* when all calls to {@link AbstractGenerator#addURL(String, Date)} have
|
||||||
* been completed, and invalidates the generator.
|
* been completed, and invalidates the generator.
|
||||||
*
|
*
|
||||||
* @return number of sitemap files written.
|
* @return number of sitemap files written.
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* if an error occurs writing
|
* if an error occurs writing
|
||||||
*/
|
*/
|
||||||
public int finish() throws IOException
|
public int finish() throws IOException
|
||||||
{
|
{
|
||||||
closeCurrentFile();
|
if (null != currentOutput)
|
||||||
|
{
|
||||||
|
closeCurrentFile();
|
||||||
|
}
|
||||||
|
|
||||||
OutputStream fo = new FileOutputStream(new File(outputDir,
|
OutputStream fo = new FileOutputStream(new File(outputDir,
|
||||||
getIndexFilename()));
|
getIndexFilename()));
|
||||||
@@ -165,13 +168,13 @@ public abstract class AbstractGenerator
|
|||||||
PrintStream out = new PrintStream(fo);
|
PrintStream out = new PrintStream(fo);
|
||||||
writeIndex(out, fileCount);
|
writeIndex(out, fileCount);
|
||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
return fileCount;
|
return fileCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return marked-up text to be included in a sitemap about a given URL.
|
* Return marked-up text to be included in a sitemap about a given URL.
|
||||||
*
|
*
|
||||||
* @param url
|
* @param url
|
||||||
* URL to add information about
|
* URL to add information about
|
||||||
* @param lastMod
|
* @param lastMod
|
||||||
@@ -183,14 +186,14 @@ public abstract class AbstractGenerator
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the boilerplate at the top of a sitemap file.
|
* Return the boilerplate at the top of a sitemap file.
|
||||||
*
|
*
|
||||||
* @return The boilerplate markup.
|
* @return The boilerplate markup.
|
||||||
*/
|
*/
|
||||||
public abstract String getLeadingBoilerPlate();
|
public abstract String getLeadingBoilerPlate();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the boilerplate at the end of a sitemap file.
|
* Return the boilerplate at the end of a sitemap file.
|
||||||
*
|
*
|
||||||
* @return The boilerplate markup.
|
* @return The boilerplate markup.
|
||||||
*/
|
*/
|
||||||
public abstract String getTrailingBoilerPlate();
|
public abstract String getTrailingBoilerPlate();
|
||||||
@@ -198,7 +201,7 @@ public abstract class AbstractGenerator
|
|||||||
/**
|
/**
|
||||||
* Return the maximum size in bytes that an individual sitemap file should
|
* Return the maximum size in bytes that an individual sitemap file should
|
||||||
* be.
|
* be.
|
||||||
*
|
*
|
||||||
* @return the size in bytes.
|
* @return the size in bytes.
|
||||||
*/
|
*/
|
||||||
public abstract int getMaxSize();
|
public abstract int getMaxSize();
|
||||||
@@ -206,7 +209,7 @@ public abstract class AbstractGenerator
|
|||||||
/**
|
/**
|
||||||
* Return the maximum number of URLs that an individual sitemap file should
|
* Return the maximum number of URLs that an individual sitemap file should
|
||||||
* contain.
|
* contain.
|
||||||
*
|
*
|
||||||
* @return the maximum number of URLs.
|
* @return the maximum number of URLs.
|
||||||
*/
|
*/
|
||||||
public abstract int getMaxURLs();
|
public abstract int getMaxURLs();
|
||||||
@@ -214,7 +217,7 @@ public abstract class AbstractGenerator
|
|||||||
/**
|
/**
|
||||||
* Return whether the written sitemap files and index should be
|
* Return whether the written sitemap files and index should be
|
||||||
* GZIP-compressed.
|
* GZIP-compressed.
|
||||||
*
|
*
|
||||||
* @return {@code true} if GZIP compression should be used, {@code false}
|
* @return {@code true} if GZIP compression should be used, {@code false}
|
||||||
* otherwise.
|
* otherwise.
|
||||||
*/
|
*/
|
||||||
@@ -222,7 +225,7 @@ public abstract class AbstractGenerator
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the filename a sitemap at the given index should be stored at.
|
* Return the filename a sitemap at the given index should be stored at.
|
||||||
*
|
*
|
||||||
* @param number
|
* @param number
|
||||||
* index of the sitemap file (zero is first).
|
* index of the sitemap file (zero is first).
|
||||||
* @return the filename to write the sitemap to.
|
* @return the filename to write the sitemap to.
|
||||||
@@ -231,14 +234,14 @@ public abstract class AbstractGenerator
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the filename the index should be written to.
|
* Get the filename the index should be written to.
|
||||||
*
|
*
|
||||||
* @return the filename of the index.
|
* @return the filename of the index.
|
||||||
*/
|
*/
|
||||||
public abstract String getIndexFilename();
|
public abstract String getIndexFilename();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the index file.
|
* Write the index file.
|
||||||
*
|
*
|
||||||
* @param output
|
* @param output
|
||||||
* stream to write the index to
|
* stream to write the index to
|
||||||
* @param sitemapCount
|
* @param sitemapCount
|
||||||
|
Reference in New Issue
Block a user