Replace a few RuntimeExceptions with AlfrescoRuntimeExceptions.

This commit is contained in:
Tom Page
2018-01-12 14:52:37 +00:00
parent 965d86508e
commit bc07bbfb44
2 changed files with 15 additions and 13 deletions

View File

@@ -34,6 +34,8 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Random; import java.util.Random;
import org.alfresco.error.AlfrescoRuntimeException;
/** /**
* Content cleanser base implementation. * Content cleanser base implementation.
* *
@@ -41,22 +43,22 @@ import java.util.Random;
* @since 2.4.a * @since 2.4.a
*/ */
public abstract class ContentCleanser public abstract class ContentCleanser
{ {
/** /**
* Cleanse file * Cleanse file
* *
* @param file file to cleanse * @param file file to cleanse
*/ */
public abstract void cleanse(File file); public abstract void cleanse(File file);
/** /**
* Overwrite files bytes with provided overwrite operation * Overwrite files bytes with provided overwrite operation
* *
* @param file file * @param file file
* @param overwriteOperation overwrite operation * @param overwriteOperation overwrite operation
*/ */
protected void overwrite(File file, OverwriteOperation overwriteOperation) protected void overwrite(File file, OverwriteOperation overwriteOperation)
{ {
// get the number of bytes // get the number of bytes
long bytes = file.length(); long bytes = file.length();
try try
@@ -74,18 +76,18 @@ public abstract class ContentCleanser
catch (IOException ioException) catch (IOException ioException)
{ {
// re-throw // re-throw
throw new RuntimeException("Unable to overwrite file", ioException); throw new AlfrescoRuntimeException("Unable to overwrite file", ioException);
} }
} }
/** /**
* Overwrite operation * Overwrite operation
*/ */
protected abstract class OverwriteOperation protected abstract class OverwriteOperation
{ {
public abstract void operation(OutputStream os) throws IOException; public abstract void operation(OutputStream os) throws IOException;
} }
/** /**
* Overwrite with zeros operation * Overwrite with zeros operation
*/ */
@@ -96,7 +98,7 @@ public abstract class ContentCleanser
os.write(0); os.write(0);
} }
}; };
/** /**
* Overwrite with ones operation * Overwrite with ones operation
*/ */
@@ -107,14 +109,14 @@ public abstract class ContentCleanser
os.write(0xff); os.write(0xff);
} }
}; };
/** /**
* Overwrite with random operation * Overwrite with random operation
*/ */
protected OverwriteOperation overwriteRandom = new OverwriteOperation() protected OverwriteOperation overwriteRandom = new OverwriteOperation()
{ {
private Random random = new Random(); private Random random = new Random();
public void operation(OutputStream os) throws IOException public void operation(OutputStream os) throws IOException
{ {
byte[] randomByte = new byte[1]; byte[] randomByte = new byte[1];

View File

@@ -291,7 +291,7 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new RuntimeException("Unexpected exception thrown. Please refer to the log files for details.", ex); throw new AlfrescoRuntimeException("Unexpected exception thrown. Please refer to the log files for details.", ex);
} }
finally finally
{ {
@@ -304,7 +304,7 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode
} }
catch (IOException ex) catch (IOException ex)
{ {
throw new RuntimeException("Failed to close the input stream!", ex); throw new AlfrescoRuntimeException("Failed to close the input stream!", ex);
} }
} }
} }