Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
da862cf
specific exceptions
hellikopter May 24, 2023
0f2ad81
test all specialized exceptions
hellikopter May 24, 2023
30281af
Merge branch 'main' into JCL-309_specific_exceptions
hellikopter May 24, 2023
cbb1a57
Update solid/src/main/java/com/inrupt/client/solid/BadRequestExceptio…
hellikopter May 24, 2023
856e21c
Update solid/src/main/java/com/inrupt/client/solid/ConflictException.…
hellikopter May 24, 2023
c4bdec5
Update solid/src/main/java/com/inrupt/client/solid/ForbiddenException…
hellikopter May 24, 2023
50f845f
Update solid/src/main/java/com/inrupt/client/solid/GoneException.java
hellikopter May 24, 2023
3f96557
Update solid/src/main/java/com/inrupt/client/solid/InternalServerErro…
hellikopter May 24, 2023
558e63d
Update solid/src/main/java/com/inrupt/client/solid/MethodNotAllowedEx…
hellikopter May 24, 2023
6e0552c
Update solid/src/main/java/com/inrupt/client/solid/NotFoundException.…
hellikopter May 24, 2023
39a6d82
Update solid/src/main/java/com/inrupt/client/solid/NotAcceptableExcep…
hellikopter May 24, 2023
014f354
Update solid/src/main/java/com/inrupt/client/solid/PreconditionFailed…
hellikopter May 24, 2023
04ebc5b
Update solid/src/main/java/com/inrupt/client/solid/TooManyRequestsExc…
hellikopter May 24, 2023
14258f0
Update solid/src/main/java/com/inrupt/client/solid/UnauthorizedExcept…
hellikopter May 24, 2023
71d8d85
Update solid/src/main/java/com/inrupt/client/solid/UnsupportedMediaTy…
hellikopter May 24, 2023
a709784
Merge branch 'main' into JCL-309_specific_exceptions
hellikopter May 24, 2023
629cef3
Merge branch 'main' into JCL-309_specific_exceptions
hellikopter May 24, 2023
66496f4
Merge branch 'main' into JCL-309_specific_exceptions
acoburn May 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@
import com.inrupt.client.auth.Session;
import com.inrupt.client.openid.OpenIdException;
import com.inrupt.client.openid.OpenIdSession;
import com.inrupt.client.solid.SolidClientException;
import com.inrupt.client.solid.SolidNonRDFSource;
import com.inrupt.client.solid.SolidRDFSource;
import com.inrupt.client.solid.SolidSyncClient;
import com.inrupt.client.solid.*;
import com.inrupt.client.spi.RDFFactory;
import com.inrupt.client.util.URIBuilder;
import com.inrupt.client.vocabulary.ACL;
Expand Down Expand Up @@ -240,7 +237,7 @@ void accessGrantIssuanceLifecycleTest(final Session session) {

//unauthorized request test
final SolidSyncClient client = SolidSyncClient.getClientBuilder().build();
final SolidClientException err = assertThrows(SolidClientException.class,
final var err = assertThrows(UnauthorizedException.class,
() -> client.read(sharedTextFileURI, SolidNonRDFSource.class));
assertEquals(Utils.UNAUTHORIZED, err.getStatusCode());
final Request reqRead =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.inrupt.client.solid.SolidClientException;
import com.inrupt.client.solid.SolidRDFSource;
import com.inrupt.client.solid.SolidSyncClient;
import com.inrupt.client.solid.UnauthorizedException;
import com.inrupt.client.util.URIBuilder;
import com.inrupt.client.webid.WebIdProfile;

Expand Down Expand Up @@ -190,7 +191,7 @@ void fetchPrivateResourceUnauthenticatedTest(final Session session) {
assertDoesNotThrow(() -> authClient.create(testResource));

final SolidSyncClient client = SolidSyncClient.getClient();
final SolidClientException err = assertThrows(SolidClientException.class,
final var err = assertThrows(UnauthorizedException.class,
() -> client.read(privateResourceURL, SolidRDFSource.class));
assertEquals(Utils.UNAUTHORIZED, err.getStatusCode());

Expand Down Expand Up @@ -242,7 +243,7 @@ void fetchPrivateResourceUnauthAuthTest(final Session session) {
assertDoesNotThrow(() -> authClient.create(testResource));

final SolidSyncClient client = SolidSyncClient.getClient();
final SolidClientException err = assertThrows(SolidClientException.class,
final var err = assertThrows(UnauthorizedException.class,
() -> client.read(privateResourceURL, SolidRDFSource.class));
assertEquals(Utils.UNAUTHORIZED, err.getStatusCode());

Expand Down Expand Up @@ -278,7 +279,7 @@ void multiSessionTest(final Session session) {
assertDoesNotThrow(() -> authClient2.read(privateResourceURL, SolidRDFSource.class));

final SolidSyncClient client = SolidSyncClient.getClient();
final SolidClientException err = assertThrows(SolidClientException.class,
final var err = assertThrows(UnauthorizedException.class,
() -> client.read(privateResourceURL, SolidRDFSource.class));
assertEquals(Utils.UNAUTHORIZED, err.getStatusCode());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@
import com.inrupt.client.Request;
import com.inrupt.client.Response;
import com.inrupt.client.auth.Session;
import com.inrupt.client.solid.SolidClientException;
import com.inrupt.client.solid.SolidContainer;
import com.inrupt.client.solid.SolidRDFSource;
import com.inrupt.client.solid.SolidResourceHandlers;
import com.inrupt.client.solid.SolidSyncClient;
import com.inrupt.client.solid.*;
import com.inrupt.client.spi.RDFFactory;
import com.inrupt.client.util.URIBuilder;
import com.inrupt.client.vocabulary.PIM;
Expand Down Expand Up @@ -261,7 +257,7 @@ void findStorageTest() {
}

final var missingWebId = URIBuilder.newBuilder(URI.create(webidUrl)).path(UUID.randomUUID().toString()).build();
final var err = assertThrows(SolidClientException.class, () -> client.read(missingWebId, WebIdProfile.class));
final var err = assertThrows(NotFoundException.class, () -> client.read(missingWebId, WebIdProfile.class));
assertEquals(404, err.getStatusCode());
assertEquals(missingWebId, err.getUri());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2023 Inrupt Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.inrupt.client.solid;

import com.inrupt.client.Headers;

import java.net.URI;

/**
* A runtime exception that represents an HTTP bad request (400) response.
*
* @see <a href="https://www.rfc-editor.org/rfc/rfc9110#status.400">RFC 9110 (15.5.1.) 400 Bad Request</a>
*/
public class BadRequestException extends SolidClientException {
private static final long serialVersionUID = -3379457428921025570L;

public static final int STATUS_CODE = 400;

/**
* Create a BadRequestException exception.
*
* @param message the message
* @param uri the uri
* @param headers the response headers
* @param body the body
*/
public BadRequestException(
final String message,
final URI uri,
final Headers headers,
final String body) {
super(message, uri, STATUS_CODE, headers, body);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2023 Inrupt Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.inrupt.client.solid;

import com.inrupt.client.Headers;

import java.net.URI;

/**
* A runtime exception that represents an HTTP conflict (409) response..
*
* @see <a href="https://www.rfc-editor.org/rfc/rfc9110#status.409">RFC 9110 (15.5.10.) 409 Conflict</a>
*/
public class ConflictException extends SolidClientException {
private static final long serialVersionUID = -203198307847520748L;

public static final int STATUS_CODE = 409;

/**
* Create a ConflictException exception.
*
* @param message the message
* @param uri the uri
* @param headers the response headers
* @param body the body
*/
public ConflictException(
final String message,
final URI uri,
final Headers headers,
final String body) {
super(message, uri, STATUS_CODE, headers, body);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2023 Inrupt Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.inrupt.client.solid;

import com.inrupt.client.Headers;

import java.net.URI;

/**
* A runtime exception that represents an HTTP forbidden (403) response.
*
* @see <a href="https://www.rfc-editor.org/rfc/rfc9110#status.403">RFC 9110 (15.5.4.) 403 Forbidden</a>
*/
public class ForbiddenException extends SolidClientException {
private static final long serialVersionUID = 3299286274724874244L;

public static final int STATUS_CODE = 403;

/**
* Create a ForbiddenException exception.
*
* @param message the message
* @param uri the uri
* @param headers the response headers
* @param body the body
*/
public ForbiddenException(
final String message,
final URI uri,
final Headers headers,
final String body) {
super(message, uri, STATUS_CODE, headers, body);
}
}
52 changes: 52 additions & 0 deletions solid/src/main/java/com/inrupt/client/solid/GoneException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2023 Inrupt Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.inrupt.client.solid;

import com.inrupt.client.Headers;

import java.net.URI;

/**
* A runtime exception that represents an HTTP gone (410) response.
*
* @see <a href="https://www.rfc-editor.org/rfc/rfc9110#status.410">RFC 9110 (15.5.11.) 410 Gone</a>
*/
public class GoneException extends SolidClientException {
private static final long serialVersionUID = -6892345582498100242L;

public static final int STATUS_CODE = 410;

/**
* Create a GoneException exception.
*
* @param message the message
* @param uri the uri
* @param headers the response headers
* @param body the body
*/
public GoneException(
final String message,
final URI uri,
final Headers headers,
final String body) {
super(message, uri, STATUS_CODE, headers, body);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2023 Inrupt Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.inrupt.client.solid;

import com.inrupt.client.Headers;

import java.net.URI;

/**
* A runtime exception that represents an HTTP internal server error (500) response.
*
* @see <a href="https://www.rfc-editor.org/rfc/rfc9110#status.500">RFC 9110 (15.6.1.) 500 Internal Server Error</a>
*/
public class InternalServerErrorException extends SolidClientException {
private static final long serialVersionUID = -6672490715281719330L;

public static final int STATUS_CODE = 500;

/**
* Create an InternalServerErrorException exception.
*
* @param message the message
* @param uri the uri
* @param headers the response headers
* @param body the body
*/
public InternalServerErrorException(
final String message,
final URI uri,
final Headers headers,
final String body) {
super(message, uri, STATUS_CODE, headers, body);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2023 Inrupt Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.inrupt.client.solid;

import com.inrupt.client.Headers;

import java.net.URI;

/**
* A runtime exception that represents an HTTP method not allowed (405) response.
*
* @see <a href="https://www.rfc-editor.org/rfc/rfc9110#status.405">RFC 9110 (15.5.6.) 405 Method Not Allowed</a>
*/
public class MethodNotAllowedException extends SolidClientException {
private static final long serialVersionUID = -9125437562813923030L;

public static final int STATUS_CODE = 405;

/**
* Create a MethodNotAllowedException exception.
*
* @param message the message
* @param uri the uri
* @param headers the response headers
* @param body the body
*/
public MethodNotAllowedException(
final String message,
final URI uri,
final Headers headers,
final String body) {
super(message, uri, STATUS_CODE, headers, body);
}
}
Loading