You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by bd...@apache.org on 2022/07/27 21:10:56 UTC

[directory-scimple] 01/01: Remove extra client exception types

This is an automated email from the ASF dual-hosted git repository.

bdemers pushed a commit to branch reduce-client-classes
in repository https://gitbox.apache.org/repos/asf/directory-scimple.git

commit 9c6fa9366fc724a961019685e5649be179773728
Author: Brian Demers <bd...@apache.org>
AuthorDate: Wed Jul 27 17:10:50 2022 -0400

    Remove extra client exception types
    
    There now only `RestException`
---
 .../exception/InvalidValueFilterExpression.java    |  29 ----
 .../client/rest/BackingStoreChangedException.java  |  61 -------
 .../scim/client/rest/BadUrlException.java          |  25 ---
 .../directory/scim/client/rest/BaseScimClient.java |  37 ++--
 .../scim/client/rest/ConflictingDataException.java |  61 -------
 .../directory/scim/client/rest/ErrorMessage.java   | 188 ---------------------
 .../scim/client/rest/JaxRsStatusAdapterType.java   |  65 -------
 .../scim/client/rest/ResourceTypesClient.java      |   8 +-
 .../directory/scim/client/rest/RestCall.java       |   2 +-
 .../directory/scim/client/rest/RestClientUtil.java |  67 ++------
 ...RestClientException.java => RestException.java} |  32 ++--
 .../scim/client/rest/RestServerException.java      |  46 -----
 .../directory/scim/client/rest/ScimSelfClient.java |  16 +-
 .../scim/client/rest/ServiceAuthException.java     |  46 -----
 .../scim/client/rest/XmlStatusAdapter.java         |  37 ----
 15 files changed, 67 insertions(+), 653 deletions(-)

diff --git a/scim-client/src/main/java/org/apache/directory/scim/client/filter/exception/InvalidValueFilterExpression.java b/scim-client/src/main/java/org/apache/directory/scim/client/filter/exception/InvalidValueFilterExpression.java
deleted file mode 100644
index 722c5ba..0000000
--- a/scim-client/src/main/java/org/apache/directory/scim/client/filter/exception/InvalidValueFilterExpression.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements.  See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership.  The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License.  You may obtain a copy of the License at
- 
-* http://www.apache.org/licenses/LICENSE-2.0
-
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied.  See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-
-package org.apache.directory.scim.client.filter.exception;
-
-public class InvalidValueFilterExpression extends Exception {
-
-  private static final long serialVersionUID = -5165945768240326983L;
-
-  public InvalidValueFilterExpression(String what) {
-    super(what);
-  }
-}
diff --git a/scim-client/src/main/java/org/apache/directory/scim/client/rest/BackingStoreChangedException.java b/scim-client/src/main/java/org/apache/directory/scim/client/rest/BackingStoreChangedException.java
deleted file mode 100644
index 5877797..0000000
--- a/scim-client/src/main/java/org/apache/directory/scim/client/rest/BackingStoreChangedException.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * The Pennsylvania State University © 2016
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.directory.scim.client.rest;
-
-import jakarta.ws.rs.ProcessingException;
-import jakarta.ws.rs.core.Response;
-
-public class BackingStoreChangedException extends Exception {
-  private static final long serialVersionUID = 7360783673606191576L;
-
-  private int statusCode;
-  private ErrorMessage errorMessage;
-
-  public BackingStoreChangedException(Response response) {
-    statusCode = response.getStatus();
-    try {
-      errorMessage = response.readEntity(ErrorMessage.class);
-    } catch (ProcessingException e) {
-      errorMessage = null;
-    }
-  }
-
-  public BackingStoreChangedException(int statusCode, ErrorMessage errorMessage) {
-    this.statusCode = statusCode;
-    this.errorMessage = errorMessage;
-  }
-
-  public int getStatusCode() {
-    return statusCode;
-  }
-
-  public ErrorMessage getErrorMessage() {
-    return errorMessage;
-  }
-
-  @Override
-  public String getMessage() {
-    String message = "Rest Client Exception: Status Code: " + statusCode + " ";
-    if (errorMessage != null) {
-      message += "Error Messages: " + errorMessage.getErrorMessageList();
-    }
-
-    return message;
-
-  }
-
-}
diff --git a/scim-client/src/main/java/org/apache/directory/scim/client/rest/BadUrlException.java b/scim-client/src/main/java/org/apache/directory/scim/client/rest/BadUrlException.java
deleted file mode 100644
index 0092cd8..0000000
--- a/scim-client/src/main/java/org/apache/directory/scim/client/rest/BadUrlException.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * The Pennsylvania State University © 2016
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.directory.scim.client.rest;
-
-public class BadUrlException extends RuntimeException {
-  private static final long serialVersionUID = 7360783673606191577L;
-
-  public BadUrlException(String what) {
-    super(what);
-  }
-}
diff --git a/scim-client/src/main/java/org/apache/directory/scim/client/rest/BaseScimClient.java b/scim-client/src/main/java/org/apache/directory/scim/client/rest/BaseScimClient.java
index dc15dc0..523b662 100644
--- a/scim-client/src/main/java/org/apache/directory/scim/client/rest/BaseScimClient.java
+++ b/scim-client/src/main/java/org/apache/directory/scim/client/rest/BaseScimClient.java
@@ -195,13 +195,8 @@ public abstract class BaseScimClient<T extends ScimResource> implements AutoClos
     }
   }
 
-  static ScimException toScimException(RestClientException restClientException) {
-    ScimException scimException;
-    Status status = restClientException.getErrorMessage().getStatus();
-    ErrorResponse errorResponse = new ErrorResponse(status, String.join("\n", restClientException.getErrorMessage().getErrorMessageList()));
-    scimException = new ScimException(errorResponse, status);
-
-    return scimException;
+  static ScimException toScimException(RestException restException) {
+    return new ScimException(restException.getError(), restException.getStatus());
   }
 
   public RestCall getInvoke() {
@@ -234,8 +229,8 @@ public abstract class BaseScimClient<T extends ScimResource> implements AutoClos
         response = BaseScimClient.this.invoke.apply(request);
 
         return response;
-      } catch (RestClientException restClientException) {
-        throw toScimException(restClientException);
+      } catch (RestException restException) {
+        throw toScimException(restException);
       }
     }
 
@@ -257,8 +252,8 @@ public abstract class BaseScimClient<T extends ScimResource> implements AutoClos
         response = BaseScimClient.this.invoke.apply(request);
 
         return response;
-      } catch (RestClientException restClientException) {
-        throw toScimException(restClientException);
+      } catch (RestException restException) {
+        throw toScimException(restException);
       }
     }
 
@@ -275,8 +270,8 @@ public abstract class BaseScimClient<T extends ScimResource> implements AutoClos
         response = BaseScimClient.this.invoke.apply(request);
 
         return response;
-      } catch (RestClientException restClientException) {
-        throw toScimException(restClientException);
+      } catch (RestException restException) {
+        throw toScimException(restException);
       }
     }
 
@@ -292,8 +287,8 @@ public abstract class BaseScimClient<T extends ScimResource> implements AutoClos
         response = BaseScimClient.this.invoke.apply(request);
 
         return response;
-      } catch (RestClientException restClientException) {
-        throw toScimException(restClientException);
+      } catch (RestException restException) {
+        throw toScimException(restException);
       }
     }
 
@@ -311,8 +306,8 @@ public abstract class BaseScimClient<T extends ScimResource> implements AutoClos
         response = BaseScimClient.this.invoke.apply(request);
 
         return response;
-      } catch (RestClientException restClientException) {
-        throw toScimException(restClientException);
+      } catch (RestException restException) {
+        throw toScimException(restException);
       }
     }
 
@@ -330,8 +325,8 @@ public abstract class BaseScimClient<T extends ScimResource> implements AutoClos
         response = BaseScimClient.this.invoke.apply(request);
 
         return response;
-      } catch (RestClientException restClientException) {
-        throw toScimException(restClientException);
+      } catch (RestException restException) {
+        throw toScimException(restException);
       }
     }
 
@@ -347,8 +342,8 @@ public abstract class BaseScimClient<T extends ScimResource> implements AutoClos
         response = BaseScimClient.this.invoke.apply(request);
 
         return response;
-      } catch (RestClientException restClientException) {
-        throw toScimException(restClientException);
+      } catch (RestException restException) {
+        throw toScimException(restException);
       }
     }
     
diff --git a/scim-client/src/main/java/org/apache/directory/scim/client/rest/ConflictingDataException.java b/scim-client/src/main/java/org/apache/directory/scim/client/rest/ConflictingDataException.java
deleted file mode 100644
index 9a37b30..0000000
--- a/scim-client/src/main/java/org/apache/directory/scim/client/rest/ConflictingDataException.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * The Pennsylvania State University © 2016
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.directory.scim.client.rest;
-
-import jakarta.ws.rs.ProcessingException;
-import jakarta.ws.rs.core.Response;
-
-public class ConflictingDataException extends Exception {
-  private static final long serialVersionUID = 7360783673606191577L;
-
-  private int statusCode;
-  private ErrorMessage errorMessage;
-
-  public ConflictingDataException(Response response) {
-    statusCode = response.getStatus();
-    try {
-      errorMessage = response.readEntity(ErrorMessage.class);
-    } catch (ProcessingException e) {
-      errorMessage = null;
-    }
-  }
-
-  public ConflictingDataException(int statusCode, ErrorMessage errorMessage) {
-    this.statusCode = statusCode;
-    this.errorMessage = errorMessage;
-  }
-
-  public int getStatusCode() {
-    return statusCode;
-  }
-
-  public ErrorMessage getErrorMessage() {
-    return errorMessage;
-  }
-
-  @Override
-  public String getMessage() {
-    String message = "Rest Client Exception: Status Code: " + statusCode + " ";
-    if (errorMessage != null) {
-      message += "Error Messages: " + errorMessage.getErrorMessageList();
-    }
-
-    return message;
-
-  }
-
-}
diff --git a/scim-client/src/main/java/org/apache/directory/scim/client/rest/ErrorMessage.java b/scim-client/src/main/java/org/apache/directory/scim/client/rest/ErrorMessage.java
deleted file mode 100644
index d9a52c3..0000000
--- a/scim-client/src/main/java/org/apache/directory/scim/client/rest/ErrorMessage.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * The Pennsylvania State University © 2016
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.directory.scim.client.rest;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.core.Response.ResponseBuilder;
-import jakarta.ws.rs.core.Response.Status;
-import jakarta.xml.bind.annotation.XmlAccessType;
-import jakarta.xml.bind.annotation.XmlAccessorType;
-import jakarta.xml.bind.annotation.XmlElement;
-import jakarta.xml.bind.annotation.XmlElementWrapper;
-import jakarta.xml.bind.annotation.XmlRootElement;
-import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
-public class ErrorMessage
-{
-
-  @XmlElement(name="status")
-  @XmlJavaTypeAdapter(XmlStatusAdapter.class)
-  private Status status;
-
-  @XmlElementWrapper(name="errorMessageList")
-  @XmlElement(name="errorMessage")
-  List<String> errorMessages = new ArrayList<>();
-
-  @XmlElementWrapper(name="referenceList", nillable = true)
-  @XmlElement(name = "link", nillable = true)
-  List<String> externalLinks = null;
-
-  Map<String, Object> headerMap = new HashMap<>();
-
-  public ErrorMessage()
-  {}
-
-  public ErrorMessage(Status status)
-  {
-    this.status = status;
-  }
-
-  public void setStatus(Status status)
-  {
-    this.status = status;
-  }
-
-  public Status getStatus()
-  {
-    return status;
-  }
-
-  public Map<String, Object> getHeaderMap() {
-    return headerMap;
-  }
-
-  public void setHeader(String header, Object value) {
-    this.headerMap.put(header, value);
-  }
-
-  public Object removeHeader(String header) {
-    return this.headerMap.remove(header);
-  }
-
-
-  public void setErrorMessageList(List<String> messageList)
-  {
-    if (messageList == null)
-    {
-      errorMessages.clear();
-    }
-    else
-    {
-      errorMessages = messageList;
-    }
-  }
-
-  public void addErrorMessage(String message)
-  {
-    errorMessages.add(message);
-  }
-
-  public List<String> getErrorMessageList()
-  {
-    return Collections.unmodifiableList(errorMessages);
-  }
-
-  public void setExternalLinkList(List<String> linkList)
-  {
-    externalLinks = linkList;
-  }
-
-  public void addExtenalLink(URL link)
-  {
-    if (externalLinks == null)
-    {
-      externalLinks  = new ArrayList<>();
-    }
-
-    externalLinks.add(link.toString());
-  }
-
-  public List<String> getExternalLinkList()
-  {
-    return externalLinks;
-  }
-
-  public Response toResponse()
-  {
-    return buildResponse(status).build();
-  }
-
-  public Response toResponse(String mediaType)
-  {
-    return buildResponse(status).type(mediaType).build();
-  }  
-
-  public Response toResponse(MediaType mediaType)
-  {
-    return buildResponse(status).type(mediaType).build();
-  }  
-
-  @Override
-  public String toString()
-  {
-    StringBuilder sb = new StringBuilder();
-    sb.append("Status = ");
-    sb.append(status.getStatusCode());
-    sb.append("\n");
-
-    if (errorMessages != null)
-    {
-      sb.append("Error Messages");
-      sb.append("\n");
-      for (String s : errorMessages)
-      {
-        sb.append(s);
-        sb.append("\n");
-      }
-    }
-
-    if (externalLinks != null)
-    {
-      sb.append("External Links");
-      for (String s : externalLinks)
-      {
-        sb.append(s);
-        sb.append("\n");
-      }
-    }
-    return sb.toString();
-  }
-
-
-  private ResponseBuilder buildResponse(Status status){
-    ResponseBuilder builder = Response.status(status);
-
-    for(Map.Entry<String, Object> entry : headerMap.entrySet()) {
-      String key = entry.getKey();
-      Object value = entry.getValue();
-      builder.header(key, value);
-    }
-    builder.entity(this);
-
-    return builder;
-  }
-}
diff --git a/scim-client/src/main/java/org/apache/directory/scim/client/rest/JaxRsStatusAdapterType.java b/scim-client/src/main/java/org/apache/directory/scim/client/rest/JaxRsStatusAdapterType.java
deleted file mode 100644
index 8bbf4b7..0000000
--- a/scim-client/src/main/java/org/apache/directory/scim/client/rest/JaxRsStatusAdapterType.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * The Pennsylvania State University © 2016
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.directory.scim.client.rest;
-
-import jakarta.ws.rs.core.Response.Status;
-import jakarta.xml.bind.annotation.XmlAccessType;
-import jakarta.xml.bind.annotation.XmlAccessorType;
-import jakarta.xml.bind.annotation.XmlElement;
-import jakarta.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement(name = "error-message")
-@XmlAccessorType(XmlAccessType.NONE)
-public class JaxRsStatusAdapterType
-{
-  @XmlElement(name="code")
-  private int code;
-  
-  @XmlElement(name="message")
-  private String message;
-  
-  public JaxRsStatusAdapterType() {
-    // Required no-argument constructor for JAXB marshalling/unmarshalling
-  }
-  
-  public JaxRsStatusAdapterType(Status status)
-  {
-    code = status.getStatusCode();
-    message  = status.name();
-  }
-  
-  public void setStatus(Status status)
-  {
-    code = status.getStatusCode();
-    message = status.name();
-  }
-  
-  public Status getStatus()
-  {
-    return Status.fromStatusCode(code);
-  }
-  
-  public int getCode()
-  {
-    return code;
-  }
-  
-  public String getMessage()
-  {
-    return message;
-  }
-}
diff --git a/scim-client/src/main/java/org/apache/directory/scim/client/rest/ResourceTypesClient.java b/scim-client/src/main/java/org/apache/directory/scim/client/rest/ResourceTypesClient.java
index 24cd504..a1f247f 100644
--- a/scim-client/src/main/java/org/apache/directory/scim/client/rest/ResourceTypesClient.java
+++ b/scim-client/src/main/java/org/apache/directory/scim/client/rest/ResourceTypesClient.java
@@ -44,7 +44,7 @@ public class ResourceTypesClient implements AutoCloseable {
     this.target = this.client.target(baseUrl).path("ResourceTypes");
   }
 
-  public List<ResourceType> getAllResourceTypes(String filter) throws RestClientException, RestServerException, BackingStoreChangedException, ConflictingDataException, ServiceAuthException {
+  public List<ResourceType> getAllResourceTypes(String filter) throws RestException {
     List<ResourceType> resourceTypes;
     Response response = this.resourceTypesResourceClient.getAllResourceTypes(filter);
 
@@ -58,7 +58,7 @@ public class ResourceTypesClient implements AutoCloseable {
     return resourceTypes;
   }
 
-  public Optional<ResourceType> getResourceType(String name) throws RestClientException, ProcessingException, IllegalStateException, RestServerException, BackingStoreChangedException, ConflictingDataException, ServiceAuthException {
+  public Optional<ResourceType> getResourceType(String name) throws RestException, ProcessingException, IllegalStateException {
     Optional<ResourceType> resourceType;
     Response response = this.resourceTypesResourceClient.getResourceType(name);
 
@@ -78,7 +78,7 @@ public class ResourceTypesClient implements AutoCloseable {
   private class ResourceTypesResourceClient implements ResourceTypesResource {
 
     @Override
-    public Response getAllResourceTypes(String filter) throws RestClientException {
+    public Response getAllResourceTypes(String filter) throws RestException {
       Response response = ResourceTypesClient.this.target
           .queryParam("filter", filter)
           .request("application/scim+json")
@@ -88,7 +88,7 @@ public class ResourceTypesClient implements AutoCloseable {
     }
 
     @Override
-    public Response getResourceType(String name) throws RestClientException {
+    public Response getResourceType(String name) throws RestException {
       Response response = ResourceTypesClient.this.target
           .path(name)
           .request("application/scim+json")
diff --git a/scim-client/src/main/java/org/apache/directory/scim/client/rest/RestCall.java b/scim-client/src/main/java/org/apache/directory/scim/client/rest/RestCall.java
index fc41245..a6fe628 100644
--- a/scim-client/src/main/java/org/apache/directory/scim/client/rest/RestCall.java
+++ b/scim-client/src/main/java/org/apache/directory/scim/client/rest/RestCall.java
@@ -24,5 +24,5 @@ import jakarta.ws.rs.core.Response;
  */
 @FunctionalInterface
 public interface RestCall {
-  Response apply(Invocation request) throws RestClientException;
+  Response apply(Invocation request) throws RestException;
 }
diff --git a/scim-client/src/main/java/org/apache/directory/scim/client/rest/RestClientUtil.java b/scim-client/src/main/java/org/apache/directory/scim/client/rest/RestClientUtil.java
index 2d6561b..bfa6362 100644
--- a/scim-client/src/main/java/org/apache/directory/scim/client/rest/RestClientUtil.java
+++ b/scim-client/src/main/java/org/apache/directory/scim/client/rest/RestClientUtil.java
@@ -33,23 +33,9 @@ public final class RestClientUtil {
 
   }
 
-  public static void checkForSuccess(Response response) throws RestClientException, BackingStoreChangedException, ConflictingDataException, ServiceAuthException, RestServerException {
+  public static void checkForSuccess(Response response) throws RestException{
     if (!isSuccessful(response)) {
-      int status = response.getStatus();
-      if (response.getStatusInfo().getFamily() == Family.SERVER_ERROR) {
-        throw new RestServerException(response);
-      } else if (status == 401 || status == 403) {
-        throw new ServiceAuthException(response);
-      } else if (status == 409) {
-        throw new ConflictingDataException(response);
-      } else if (status == 412) {
-        throw new BackingStoreChangedException(response);
-      } else if (status == Status.NOT_FOUND.getStatusCode()) {
-        //If the record doesn't exist let the client handle gracefully
-        return;
-      } else {
-        throw new RestClientException(response);
-      }
+      throw new RestException(response);
     }
   }
   
@@ -57,19 +43,14 @@ public final class RestClientUtil {
     try {
       verifyNotFourOhFour(target, response);
       return false;
-    } catch (RestClientException e) {
+    } catch (RestException e) {
       return true;
     }
   }
   
-  public static void verifyNotFourOhFour(WebTarget target, Response response) throws RestClientException {
+  public static void verifyNotFourOhFour(WebTarget target, Response response) throws RestException {
     if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
-      try {
-        ErrorMessage em = response.readEntity(ErrorMessage.class);
-        throw new RestClientException(Status.NOT_FOUND.getStatusCode(), em);
-      } catch (ProcessingException pe) {
-        throw new BadUrlException(target.getUri().toASCIIString() + " could not be found");
-      }
+      throw new RestException(response);
     }
   }
 
@@ -119,19 +100,16 @@ public final class RestClientUtil {
    *          the type of entity
    * @return <code>Optional.empty()</code> if <b>Not Found</b> or empty
    *         response, otherwise <code>Optional.ofNullable(T)</code>
-   * @throws RestClientException
+   * @throws RestException
    *           if <code>response</code> is an error response other than
    *           <code>404 Not Found</code>
    * @throws ProcessingException
    *           see {@link Response#readEntity(Class)}
    * @throws IllegalStateException
    *           see {@link Response#readEntity(Class)}
-   * @throws RestServerException 
-   * @throws ServiceAuthException 
-   * @throws ConflictingDataException 
-   * @throws BackingStoreChangedException 
+   * @throws RestException
    */
-  public <T> Optional<T> tryReadEntity(Response response, Class<T> entityType) throws RestClientException, ProcessingException, IllegalStateException, BackingStoreChangedException, ConflictingDataException, ServiceAuthException, RestServerException {
+  public <T> Optional<T> tryReadEntity(Response response, Class<T> entityType) throws RestException, ProcessingException, IllegalStateException{
     return readEntity(response, entityType, response::readEntity, Optional::ofNullable);
   }
 
@@ -144,19 +122,16 @@ public final class RestClientUtil {
    *          the type of entity
    * @return <code>Optional.empty()</code> if <code>Not Found</code> or empty
    *         response, otherwise <code>Optional.ofNullable(T)</code>
-   * @throws RestClientException
+   * @throws RestException
    *           if <code>response</code> is an error response other than
    *           <code>404 Not Found</code>
    * @throws ProcessingException
    *           see {@link Response#readEntity(GenericType)}
    * @throws IllegalStateException
    *           see {@link Response#readEntity(GenericType)}
-   * @throws RestServerException 
-   * @throws ServiceAuthException 
-   * @throws ConflictingDataException 
-   * @throws BackingStoreChangedException 
+   * @throws RestException
    */
-  public <T> Optional<T> tryReadEntity(Response response, GenericType<T> entityType) throws RestClientException, ProcessingException, IllegalStateException, BackingStoreChangedException, ConflictingDataException, ServiceAuthException, RestServerException {
+  public <T> Optional<T> tryReadEntity(Response response, GenericType<T> entityType) throws RestException, ProcessingException, IllegalStateException {
     return readEntity(response, entityType, response::readEntity, Optional::ofNullable);
   }
 
@@ -174,19 +149,16 @@ public final class RestClientUtil {
    *          the type of entity
    * @return <code>Optional.empty()</code> if <code>Not Found</code>, otherwise
    *         <code>Optional.of(T)</code>
-   * @throws RestClientException
+   * @throws RestException
    *           if <code>response</code> is an error response other than
    *           <code>404 Not Found</code>
    * @throws ProcessingException
    *           see {@link Response#readEntity(Class)}
    * @throws IllegalStateException
    *           see {@link Response#readEntity(Class)}
-   * @throws RestServerException 
-   * @throws ServiceAuthException 
-   * @throws ConflictingDataException 
-   * @throws BackingStoreChangedException 
+   * @throws RestException
    */
-  public static <T> Optional<T> readEntity(Response response, Class<T> entityType) throws RestClientException, ProcessingException, IllegalStateException, BackingStoreChangedException, ConflictingDataException, ServiceAuthException, RestServerException {
+  public static <T> Optional<T> readEntity(Response response, Class<T> entityType) throws RestException, ProcessingException, IllegalStateException{
     return readEntity(response, entityType, response::readEntity, Optional::of);
   }
 
@@ -204,23 +176,20 @@ public final class RestClientUtil {
    *          the type of entity
    * @return <code>Optional.empty()</code> if <code>Not Found</code>, otherwise
    *         <code>Optional.of(T)</code>
-   * @throws RestClientException
+   * @throws RestException
    *           if <code>response</code> is an error response other than
    *           <code>404 Not Found</code>
    * @throws ProcessingException
    *           see {@link Response#readEntity(GenericType)}
    * @throws IllegalStateException
    *           see {@link Response#readEntity(GenericType)}
-   * @throws RestServerException 
-   * @throws ServiceAuthException 
-   * @throws ConflictingDataException 
-   * @throws BackingStoreChangedException 
+   * @throws RestException
    */
-  public static <T> Optional<T> readEntity(Response response, GenericType<T> entityType) throws RestClientException, ProcessingException, IllegalStateException, BackingStoreChangedException, ConflictingDataException, ServiceAuthException, RestServerException {
+  public static <T> Optional<T> readEntity(Response response, GenericType<T> entityType) throws RestException, ProcessingException, IllegalStateException{
     return readEntity(response, entityType, response::readEntity, Optional::of);
   }
 
-  private static <T, E> Optional<E> readEntity(Response response, T entityType, Function<T, E> readEntity, Function<E, Optional<E>> optionalOf) throws RestClientException, ProcessingException, IllegalStateException, BackingStoreChangedException, ConflictingDataException, ServiceAuthException, RestServerException {
+  private static <T, E> Optional<E> readEntity(Response response, T entityType, Function<T, E> readEntity, Function<E, Optional<E>> optionalOf) throws RestException, ProcessingException, IllegalStateException{
     Optional<E> result;
 
     if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
diff --git a/scim-client/src/main/java/org/apache/directory/scim/client/rest/RestClientException.java b/scim-client/src/main/java/org/apache/directory/scim/client/rest/RestException.java
similarity index 68%
rename from scim-client/src/main/java/org/apache/directory/scim/client/rest/RestClientException.java
rename to scim-client/src/main/java/org/apache/directory/scim/client/rest/RestException.java
index 9cbe5a4..8a6779c 100644
--- a/scim-client/src/main/java/org/apache/directory/scim/client/rest/RestClientException.java
+++ b/scim-client/src/main/java/org/apache/directory/scim/client/rest/RestException.java
@@ -35,40 +35,48 @@ package org.apache.directory.scim.client.rest;
 
 import jakarta.ws.rs.ProcessingException;
 import jakarta.ws.rs.core.Response;
+import org.apache.directory.scim.spec.protocol.data.ErrorResponse;
 
-public class RestClientException extends Exception {
+public class RestException extends Exception {
   private static final long serialVersionUID = 7360783673606191577L;
 
-  private int statusCode;
-  private ErrorMessage errorMessage;
+  private final int statusCode;
+  private final Response.Status status;
+  private ErrorResponse errorResponse;
 
-  public RestClientException(Response response) {
+  public RestException(Response response) {
     statusCode = response.getStatus();
+    status = response.getStatusInfo().toEnum();
     try {
-      errorMessage = response.readEntity(ErrorMessage.class);
+      errorResponse = response.readEntity(ErrorResponse.class);
     } catch (ProcessingException e) {
-      errorMessage = null;
+      errorResponse = null;
     }
   }
 
-  public RestClientException(int statusCode, ErrorMessage errorMessage) {
+  public RestException(int statusCode, ErrorResponse errorResponse) {
     this.statusCode = statusCode;
-    this.errorMessage = errorMessage;
+    this.status = Response.Status.fromStatusCode(statusCode);
+    this.errorResponse = errorResponse;
   }
 
   public int getStatusCode() {
     return statusCode;
   }
 
-  public ErrorMessage getErrorMessage() {
-    return errorMessage;
+  public Response.Status getStatus() {
+    return status;
+  }
+
+  public ErrorResponse getError() {
+    return errorResponse;
   }
 
   @Override
   public String getMessage() {
     String message = "Rest Client Exception: Status Code: " + statusCode + " ";
-    if (errorMessage != null) {
-      message += "Error Messages: " + errorMessage.getErrorMessageList();
+    if (errorResponse != null) {
+      message += "Error Message: " + errorResponse.getDetail();
     }
 
     return message;
diff --git a/scim-client/src/main/java/org/apache/directory/scim/client/rest/RestServerException.java b/scim-client/src/main/java/org/apache/directory/scim/client/rest/RestServerException.java
deleted file mode 100644
index 347b29c..0000000
--- a/scim-client/src/main/java/org/apache/directory/scim/client/rest/RestServerException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * The Pennsylvania State University © 2016
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.directory.scim.client.rest;
-
-import jakarta.ws.rs.core.Response;
-
-public class RestServerException extends RuntimeException {
-  private static final long serialVersionUID = 7360783673606191577L;
-  
-  RestClientException rce;
-
-  public RestServerException(Response response) {
-    rce = new RestClientException(response);
-  }
-
-  public RestServerException(int statusCode, ErrorMessage errorMessage) {
-    rce = new RestClientException(statusCode, errorMessage);
-  }
-
-  public int getStatusCode() {
-    return rce.getStatusCode();
-  }
-
-  public ErrorMessage getErrorMessage() {
-    return rce.getErrorMessage();
-  }
-
-  @Override
-  public String getMessage() {
-    return rce.getMessage();
-  }
-}
diff --git a/scim-client/src/main/java/org/apache/directory/scim/client/rest/ScimSelfClient.java b/scim-client/src/main/java/org/apache/directory/scim/client/rest/ScimSelfClient.java
index 318acce..8580f12 100644
--- a/scim-client/src/main/java/org/apache/directory/scim/client/rest/ScimSelfClient.java
+++ b/scim-client/src/main/java/org/apache/directory/scim/client/rest/ScimSelfClient.java
@@ -119,8 +119,8 @@ public class ScimSelfClient implements AutoCloseable {
 
       try {
         response = ScimSelfClient.this.invoke.apply(request);
-      } catch (RestClientException restClientException) {
-        throw BaseScimClient.toScimException(restClientException);
+      } catch (RestException restException) {
+        throw BaseScimClient.toScimException(restException);
       }
       return response;
     }
@@ -136,8 +136,8 @@ public class ScimSelfClient implements AutoCloseable {
 
       try {
         response = ScimSelfClient.this.invoke.apply(request);
-      } catch (RestClientException restClientException) {
-        throw BaseScimClient.toScimException(restClientException);
+      } catch (RestException restException) {
+        throw BaseScimClient.toScimException(restException);
       }
       return response;
     }
@@ -153,8 +153,8 @@ public class ScimSelfClient implements AutoCloseable {
 
       try {
         response = ScimSelfClient.this.invoke.apply(request);
-      } catch (RestClientException restClientException) {
-        throw BaseScimClient.toScimException(restClientException);
+      } catch (RestException restException) {
+        throw BaseScimClient.toScimException(restException);
       }
       return response;
     }
@@ -168,8 +168,8 @@ public class ScimSelfClient implements AutoCloseable {
 
       try {
         response = ScimSelfClient.this.invoke.apply(request);
-      } catch (RestClientException restClientException) {
-        throw BaseScimClient.toScimException(restClientException);
+      } catch (RestException restException) {
+        throw BaseScimClient.toScimException(restException);
       }
       return response;
     }
diff --git a/scim-client/src/main/java/org/apache/directory/scim/client/rest/ServiceAuthException.java b/scim-client/src/main/java/org/apache/directory/scim/client/rest/ServiceAuthException.java
deleted file mode 100644
index 14afd5c..0000000
--- a/scim-client/src/main/java/org/apache/directory/scim/client/rest/ServiceAuthException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * The Pennsylvania State University © 2016
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.directory.scim.client.rest;
-
-import jakarta.ws.rs.core.Response;
-
-public class ServiceAuthException extends Exception {
-  private static final long serialVersionUID = 7360783673606191577L;
-  
-  RestClientException rce;
-
-  public ServiceAuthException(Response response) {
-    rce = new RestClientException(response);
-  }
-
-  public ServiceAuthException(int statusCode, ErrorMessage errorMessage) {
-    rce = new RestClientException(statusCode, errorMessage);
-  }
-
-  public int getStatusCode() {
-    return rce.getStatusCode();
-  }
-
-  public ErrorMessage getErrorMessage() {
-    return rce.getErrorMessage();
-  }
-
-  @Override
-  public String getMessage() {
-    return rce.getMessage();
-  }
-}
diff --git a/scim-client/src/main/java/org/apache/directory/scim/client/rest/XmlStatusAdapter.java b/scim-client/src/main/java/org/apache/directory/scim/client/rest/XmlStatusAdapter.java
deleted file mode 100644
index 5c163bc..0000000
--- a/scim-client/src/main/java/org/apache/directory/scim/client/rest/XmlStatusAdapter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * The Pennsylvania State University © 2016
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.directory.scim.client.rest;
-
-import jakarta.ws.rs.core.Response.Status;
-import jakarta.xml.bind.annotation.adapters.XmlAdapter;
-
-public final class XmlStatusAdapter extends XmlAdapter<JaxRsStatusAdapterType, Status>
-{
-
-  @Override
-  public JaxRsStatusAdapterType marshal(Status status) throws Exception
-  {
-    return new JaxRsStatusAdapterType(status);
-  }
-
-  @Override
-  public Status unmarshal(JaxRsStatusAdapterType adapterType) throws Exception
-  {
-    return Status.fromStatusCode(adapterType.getCode());
-  }
-
-}