Skip to content

Commit 608e632

Browse files
committed
Refactor specialized exception constructors
The exception are now built taking a ProblemDetails in. Use HttpStatus from API module as reference
1 parent 16a6143 commit 608e632

14 files changed

+360
-15
lines changed

solid/src/main/java/com/inrupt/client/solid/BadRequestException.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
package com.inrupt.client.solid;
2222

2323
import com.inrupt.client.Headers;
24+
import com.inrupt.client.HttpStatus;
25+
import com.inrupt.client.ProblemDetails;
2426

2527
import java.net.URI;
2628

@@ -32,7 +34,7 @@
3234
public class BadRequestException extends SolidClientException {
3335
private static final long serialVersionUID = -3379457428921025570L;
3436

35-
public static final int STATUS_CODE = 400;
37+
public static final int STATUS_CODE = HttpStatus.BAD_REQUEST;
3638

3739
/**
3840
* Create a BadRequestException exception.
@@ -41,6 +43,7 @@ public class BadRequestException extends SolidClientException {
4143
* @param uri the uri
4244
* @param headers the response headers
4345
* @param body the body
46+
* @deprecated
4447
*/
4548
public BadRequestException(
4649
final String message,
@@ -49,4 +52,22 @@ public BadRequestException(
4952
final String body) {
5053
super(message, uri, STATUS_CODE, headers, body);
5154
}
55+
56+
/**
57+
* Create a BadRequestException exception.
58+
*
59+
* @param message the message
60+
* @param pd the ProblemDetails instance
61+
* @param uri the uri
62+
* @param headers the response headers
63+
* @param body the body
64+
*/
65+
public BadRequestException(
66+
final String message,
67+
final ProblemDetails pd,
68+
final URI uri,
69+
final Headers headers,
70+
final String body) {
71+
super(message, pd, uri, headers, body);
72+
}
5273
}

solid/src/main/java/com/inrupt/client/solid/ConflictException.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
package com.inrupt.client.solid;
2222

2323
import com.inrupt.client.Headers;
24+
import com.inrupt.client.HttpStatus;
25+
import com.inrupt.client.ProblemDetails;
2426

2527
import java.net.URI;
2628

@@ -32,7 +34,7 @@
3234
public class ConflictException extends SolidClientException {
3335
private static final long serialVersionUID = -203198307847520748L;
3436

35-
public static final int STATUS_CODE = 409;
37+
public static final int STATUS_CODE = HttpStatus.CONFLICT;
3638

3739
/**
3840
* Create a ConflictException exception.
@@ -41,6 +43,7 @@ public class ConflictException extends SolidClientException {
4143
* @param uri the uri
4244
* @param headers the response headers
4345
* @param body the body
46+
* @deprecated
4447
*/
4548
public ConflictException(
4649
final String message,
@@ -49,4 +52,22 @@ public ConflictException(
4952
final String body) {
5053
super(message, uri, STATUS_CODE, headers, body);
5154
}
55+
56+
/**
57+
* Create a ConflictException exception.
58+
*
59+
* @param message the message
60+
* @param pd the ProblemDetails instance
61+
* @param uri the uri
62+
* @param headers the response headers
63+
* @param body the body
64+
*/
65+
public ConflictException(
66+
final String message,
67+
final ProblemDetails pd,
68+
final URI uri,
69+
final Headers headers,
70+
final String body) {
71+
super(message, pd, uri, headers, body);
72+
}
5273
}

solid/src/main/java/com/inrupt/client/solid/ForbiddenException.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
package com.inrupt.client.solid;
2222

2323
import com.inrupt.client.Headers;
24+
import com.inrupt.client.HttpStatus;
25+
import com.inrupt.client.ProblemDetails;
2426

2527
import java.net.URI;
2628

@@ -32,7 +34,7 @@
3234
public class ForbiddenException extends SolidClientException {
3335
private static final long serialVersionUID = 3299286274724874244L;
3436

35-
public static final int STATUS_CODE = 403;
37+
public static final int STATUS_CODE = HttpStatus.FORBIDDEN;
3638

3739
/**
3840
* Create a ForbiddenException exception.
@@ -41,6 +43,7 @@ public class ForbiddenException extends SolidClientException {
4143
* @param uri the uri
4244
* @param headers the response headers
4345
* @param body the body
46+
* @deprecated
4447
*/
4548
public ForbiddenException(
4649
final String message,
@@ -49,4 +52,22 @@ public ForbiddenException(
4952
final String body) {
5053
super(message, uri, STATUS_CODE, headers, body);
5154
}
55+
56+
/**
57+
* Create a ForbiddenException exception.
58+
*
59+
* @param message the message
60+
* @param pd the ProblemDetails instance
61+
* @param uri the uri
62+
* @param headers the response headers
63+
* @param body the body
64+
*/
65+
public ForbiddenException(
66+
final String message,
67+
final ProblemDetails pd,
68+
final URI uri,
69+
final Headers headers,
70+
final String body) {
71+
super(message, pd, uri, headers, body);
72+
}
5273
}

solid/src/main/java/com/inrupt/client/solid/GoneException.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
package com.inrupt.client.solid;
2222

2323
import com.inrupt.client.Headers;
24+
import com.inrupt.client.HttpStatus;
25+
import com.inrupt.client.ProblemDetails;
2426

2527
import java.net.URI;
2628

@@ -32,7 +34,7 @@
3234
public class GoneException extends SolidClientException {
3335
private static final long serialVersionUID = -6892345582498100242L;
3436

35-
public static final int STATUS_CODE = 410;
37+
public static final int STATUS_CODE = HttpStatus.GONE;
3638

3739
/**
3840
* Create a GoneException exception.
@@ -41,6 +43,7 @@ public class GoneException extends SolidClientException {
4143
* @param uri the uri
4244
* @param headers the response headers
4345
* @param body the body
46+
* @deprecated
4447
*/
4548
public GoneException(
4649
final String message,
@@ -49,4 +52,22 @@ public GoneException(
4952
final String body) {
5053
super(message, uri, STATUS_CODE, headers, body);
5154
}
55+
56+
/**
57+
* Create a GoneException exception.
58+
*
59+
* @param message the message
60+
* @param pd the ProblemDetails instance
61+
* @param uri the uri
62+
* @param headers the response headers
63+
* @param body the body
64+
*/
65+
public GoneException(
66+
final String message,
67+
final ProblemDetails pd,
68+
final URI uri,
69+
final Headers headers,
70+
final String body) {
71+
super(message, pd, uri, headers, body);
72+
}
5273
}

solid/src/main/java/com/inrupt/client/solid/InternalServerErrorException.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
package com.inrupt.client.solid;
2222

2323
import com.inrupt.client.Headers;
24+
import com.inrupt.client.HttpStatus;
25+
import com.inrupt.client.ProblemDetails;
2426

2527
import java.net.URI;
2628

@@ -32,7 +34,7 @@
3234
public class InternalServerErrorException extends SolidClientException {
3335
private static final long serialVersionUID = -6672490715281719330L;
3436

35-
public static final int STATUS_CODE = 500;
37+
public static final int STATUS_CODE = HttpStatus.INTERNAL_SERVER_ERROR;
3638

3739
/**
3840
* Create an InternalServerErrorException exception.
@@ -41,6 +43,7 @@ public class InternalServerErrorException extends SolidClientException {
4143
* @param uri the uri
4244
* @param headers the response headers
4345
* @param body the body
46+
* @deprecated
4447
*/
4548
public InternalServerErrorException(
4649
final String message,
@@ -49,4 +52,22 @@ public InternalServerErrorException(
4952
final String body) {
5053
super(message, uri, STATUS_CODE, headers, body);
5154
}
55+
56+
/**
57+
* Create an InternalServerErrorException exception.
58+
*
59+
* @param message the message
60+
* @param pd the ProblemDetails instance
61+
* @param uri the uri
62+
* @param headers the response headers
63+
* @param body the body
64+
*/
65+
public InternalServerErrorException(
66+
final String message,
67+
final ProblemDetails pd,
68+
final URI uri,
69+
final Headers headers,
70+
final String body) {
71+
super(message, pd, uri, headers, body);
72+
}
5273
}

solid/src/main/java/com/inrupt/client/solid/MethodNotAllowedException.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
package com.inrupt.client.solid;
2222

2323
import com.inrupt.client.Headers;
24+
import com.inrupt.client.HttpStatus;
25+
import com.inrupt.client.ProblemDetails;
2426

2527
import java.net.URI;
2628

@@ -32,7 +34,7 @@
3234
public class MethodNotAllowedException extends SolidClientException {
3335
private static final long serialVersionUID = -9125437562813923030L;
3436

35-
public static final int STATUS_CODE = 405;
37+
public static final int STATUS_CODE = HttpStatus.METHOD_NOT_ALLOWED;
3638

3739
/**
3840
* Create a MethodNotAllowedException exception.
@@ -41,6 +43,7 @@ public class MethodNotAllowedException extends SolidClientException {
4143
* @param uri the uri
4244
* @param headers the response headers
4345
* @param body the body
46+
* @deprecated
4447
*/
4548
public MethodNotAllowedException(
4649
final String message,
@@ -49,4 +52,22 @@ public MethodNotAllowedException(
4952
final String body) {
5053
super(message, uri, STATUS_CODE, headers, body);
5154
}
55+
56+
/**
57+
* Create a MethodNotAllowedException exception.
58+
*
59+
* @param message the message
60+
* @param pd the ProblemDetails instance
61+
* @param uri the uri
62+
* @param headers the response headers
63+
* @param body the body
64+
*/
65+
public MethodNotAllowedException(
66+
final String message,
67+
final ProblemDetails pd,
68+
final URI uri,
69+
final Headers headers,
70+
final String body) {
71+
super(message, pd, uri, headers, body);
72+
}
5273
}

solid/src/main/java/com/inrupt/client/solid/NotAcceptableException.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
package com.inrupt.client.solid;
2222

2323
import com.inrupt.client.Headers;
24+
import com.inrupt.client.HttpStatus;
25+
import com.inrupt.client.ProblemDetails;
2426

2527
import java.net.URI;
2628

@@ -32,7 +34,7 @@
3234
public class NotAcceptableException extends SolidClientException {
3335
private static final long serialVersionUID = 6594993822477388733L;
3436

35-
public static final int STATUS_CODE = 406;
37+
public static final int STATUS_CODE = HttpStatus.NOT_ACCEPTABLE;
3638

3739
/**
3840
* Create a NotAcceptableException exception.
@@ -41,6 +43,7 @@ public class NotAcceptableException extends SolidClientException {
4143
* @param uri the uri
4244
* @param headers the response headers
4345
* @param body the body
46+
* @deprecated
4447
*/
4548
public NotAcceptableException(
4649
final String message,
@@ -49,4 +52,22 @@ public NotAcceptableException(
4952
final String body) {
5053
super(message, uri, STATUS_CODE, headers, body);
5154
}
55+
56+
/**
57+
* Create a NotAcceptableException exception.
58+
*
59+
* @param message the message
60+
* @param pd the ProblemDetails instance
61+
* @param uri the uri
62+
* @param headers the response headers
63+
* @param body the body
64+
*/
65+
public NotAcceptableException(
66+
final String message,
67+
final ProblemDetails pd,
68+
final URI uri,
69+
final Headers headers,
70+
final String body) {
71+
super(message, pd, uri, headers, body);
72+
}
5273
}

solid/src/main/java/com/inrupt/client/solid/NotFoundException.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
package com.inrupt.client.solid;
2222

2323
import com.inrupt.client.Headers;
24+
import com.inrupt.client.HttpStatus;
25+
import com.inrupt.client.ProblemDetails;
2426

2527
import java.net.URI;
2628

@@ -32,7 +34,7 @@
3234
public class NotFoundException extends SolidClientException {
3335
private static final long serialVersionUID = -2256628528500739683L;
3436

35-
public static final int STATUS_CODE = 404;
37+
public static final int STATUS_CODE = HttpStatus.NOT_FOUND;
3638

3739
/**
3840
* Create a NotFoundException exception.
@@ -41,6 +43,7 @@ public class NotFoundException extends SolidClientException {
4143
* @param uri the uri
4244
* @param headers the response headers
4345
* @param body the body
46+
* @deprecated
4447
*/
4548
public NotFoundException(
4649
final String message,
@@ -49,4 +52,22 @@ public NotFoundException(
4952
final String body) {
5053
super(message, uri, STATUS_CODE, headers, body);
5154
}
55+
56+
/**
57+
* Create a NotFoundException exception.
58+
*
59+
* @param message the message
60+
* @param pd the ProblemDetails instance
61+
* @param uri the uri
62+
* @param headers the response headers
63+
* @param body the body
64+
*/
65+
public NotFoundException(
66+
final String message,
67+
final ProblemDetails pd,
68+
final URI uri,
69+
final Headers headers,
70+
final String body) {
71+
super(message, pd, uri, headers, body);
72+
}
5273
}

0 commit comments

Comments
 (0)