-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BXC-4694 - Handle RangeNotSatisfiable (#1785)
* Added new RangeNotSatisfiableException, which gets thrown if the range header exceeds the size of the file. Handle this error with a 416 response * Log headers when an uncaught exception occurs in fedora content controller * Add test for exception
- Loading branch information
Showing
9 changed files
with
126 additions
and
6 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...-utils/src/main/java/edu/unc/lib/boxc/fcrepo/exceptions/RangeNotSatisfiableException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package edu.unc.lib.boxc.fcrepo.exceptions; | ||
|
||
import edu.unc.lib.boxc.model.api.exceptions.FedoraException; | ||
|
||
/** | ||
* Error indicates that a HTTP range request could not be satisfied | ||
* | ||
* @author bbpennel | ||
*/ | ||
public class RangeNotSatisfiableException extends FedoraException { | ||
private static final long serialVersionUID = 1L; | ||
|
||
public RangeNotSatisfiableException(String message) { | ||
super(message); | ||
} | ||
|
||
public RangeNotSatisfiableException(Throwable cause) { | ||
super(cause); | ||
} | ||
|
||
public RangeNotSatisfiableException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...ls/src/test/java/edu/unc/lib/boxc/fcrepo/exceptions/RangeNotSatisfiableExceptionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package edu.unc.lib.boxc.fcrepo.exceptions; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
/** | ||
* @author bbpennel | ||
*/ | ||
public class RangeNotSatisfiableExceptionTest { | ||
@Test | ||
public void testConstructorWithMessage() { | ||
var ex = new RangeNotSatisfiableException("Bad range"); | ||
assertEquals("Bad range", ex.getMessage()); | ||
assertNull(ex.getCause()); | ||
} | ||
|
||
@Test | ||
public void testConstructorWithThrowable() { | ||
var causeEx = new RuntimeException(); | ||
var ex = new RangeNotSatisfiableException(causeEx); | ||
assertEquals(causeEx, ex.getCause()); | ||
} | ||
|
||
@Test | ||
public void testConstructorWithMessageThrowable() { | ||
var causeEx = new RuntimeException(); | ||
var ex = new RangeNotSatisfiableException("Bad range", causeEx); | ||
assertEquals("Bad range", ex.getMessage()); | ||
assertEquals(causeEx, ex.getCause()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters