johnament commented on a change in pull request #359: Adding an implementation 
of the MicroProfile Rest Client v1.0
URL: https://github.com/apache/cxf/pull/359#discussion_r157662913
 
 

 ##########
 File path: 
rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/proxy/MicroProfileClientProxyImpl.java
 ##########
 @@ -0,0 +1,65 @@
+/**
+ * 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.cxf.microprofile.client.proxy;
+
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.util.List;
+import javax.ws.rs.core.Response;
+import org.apache.cxf.jaxrs.client.ClientProxyImpl;
+import org.apache.cxf.jaxrs.client.ClientState;
+import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.microprofile.client.MicroProfileClientProviderFactory;
+import org.eclipse.microprofile.rest.client.ext.ResponseExceptionMapper;
+
+public class MicroProfileClientProxyImpl extends ClientProxyImpl {
+    public MicroProfileClientProxyImpl(URI baseURI, ClassLoader loader, 
ClassResourceInfo cri,
+                                       boolean isRoot, boolean inheritHeaders, 
Object... varValues) {
+        super(baseURI, loader, cri, isRoot, inheritHeaders, varValues);
+    }
+
+    public MicroProfileClientProxyImpl(ClientState initialState, ClassLoader 
loader, ClassResourceInfo cri,
+                                       boolean isRoot, boolean inheritHeaders, 
Object... varValues) {
+        super(initialState, loader, cri, isRoot, inheritHeaders, varValues);
+    }
+
+    @Override
+    protected void checkResponse(Method m, Response r, Message inMessage) 
throws Throwable {
+        MicroProfileClientProviderFactory factory = 
MicroProfileClientProviderFactory.getInstance(inMessage);
+        List<ResponseExceptionMapper<?>> mappers = 
factory.createResponseExceptionMapper(inMessage,
+                Throwable.class);
+        for (ResponseExceptionMapper<?> mapper : mappers) {
+            if (mapper.handles(r.getStatus(), r.getHeaders())) {
+                Throwable t = mapper.toThrowable(r);
+                if (t instanceof RuntimeException) {
+                    throw t;
+                } else if (t != null && m.getExceptionTypes() != null) {
+                    // its a checked exception, make sure its declared
+                    for (Class c : m.getExceptionTypes()) {
+                        if (t.getClass().isAssignableFrom(c)) {
+                            throw t;
+                        }
+                    }
+                    // TODO Log the unhandled declarable
 
 Review comment:
   Still have this pending TODO.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to