Remove Code from cadi, it is now in authz
[aaf/cadi.git] / client / src / main / java / org / onap / aaf / cadi / dme2 / DEClient.java
diff --git a/client/src/main/java/org/onap/aaf/cadi/dme2/DEClient.java b/client/src/main/java/org/onap/aaf/cadi/dme2/DEClient.java
deleted file mode 100644 (file)
index 7bbdc25..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- *  *      http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- *  * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cadi.dme2;\r
-\r
-import java.io.ByteArrayOutputStream;\r
-import java.io.IOException;\r
-import java.net.URI;\r
-\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.SecuritySetter;\r
-import org.onap.aaf.cadi.client.EClient;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-\r
-import com.att.aft.dme2.api.DME2Client;\r
-import com.att.aft.dme2.api.DME2Exception;\r
-import com.att.aft.dme2.api.DME2Manager;\r
-import com.att.aft.dme2.handler.DME2RestfulHandler;\r
-import com.att.aft.dme2.handler.DME2RestfulHandler.ResponseInfo;\r
-import org.onap.aaf.inno.env.APIException;\r
-import org.onap.aaf.inno.env.Data;\r
-import org.onap.aaf.rosetta.env.RosettaDF;\r
-\r
-public class DEClient implements EClient<DME2Client> {\r
-       private DME2Client client;\r
-       private DME2RestfulHandler replyHandler;\r
-       private EClient.Transfer payload;\r
-       private boolean isProxy;\r
-       private SecuritySetter<DME2Client> ss;\r
-       \r
-       public DEClient(DME2Manager manager, SecuritySetter<DME2Client> ss, URI uri, long timeout) throws DME2Exception, CadiException {\r
-               client = new DME2Client(manager,uri,timeout);\r
-               client.setAllowAllHttpReturnCodes(true);\r
-               this.ss = ss;\r
-               ss.setSecurity(client);\r
-               replyHandler = new DME2RestfulHandler(Rcli.BLANK);\r
-               client.setReplyHandler(replyHandler);\r
-       }\r
-\r
-       @Override\r
-       public void setMethod(String meth) {\r
-               client.setMethod(meth);\r
-       }\r
-\r
-       /**\r
-        * DME2 can't handle having QueryParams on the URL line, but it is the most natural way, so...\r
-        * \r
-        * Also, DME2 can't handle "/proxy" as part of Context in the main URI line, so we add it when we see authz-gw to "isProxy"\r
-        */\r
-       public void setPathInfo(String pathinfo) {\r
-               int qp = pathinfo.indexOf('?');\r
-               if(qp<0) {\r
-                       client.setContext(isProxy?("/proxy"+pathinfo):pathinfo);\r
-               } else {\r
-                       client.setContext(isProxy?("/proxy"+pathinfo.substring(0,qp)):pathinfo.substring(0,qp));\r
-                       client.setQueryParams(pathinfo.substring(qp+1));\r
-               }\r
-       }\r
-\r
-       @Override\r
-       public void setPayload(EClient.Transfer transfer) {\r
-               payload = transfer;\r
-       }\r
-\r
-       @Override\r
-       public void addHeader(String tag, String value) {\r
-               client.addHeader(tag, value);\r
-       }\r
-\r
-\r
-       @Override\r
-       public void setQueryParams(String q) {\r
-               client.setQueryParams(q);\r
-       }\r
-\r
-       @Override\r
-       public void setFragment(String f) {\r
-               // DME2 does not implement this\r
-       }\r
-\r
-       @Override\r
-       public void send() throws APIException {\r
-               try {\r
-                       if(payload!=null) {\r
-                               ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-                               payload.transfer(baos);\r
-                               client.setPayload(new String(baos.toByteArray()));\r
-                       } else {\r
-                               client.setPayload("");\r
-                       }\r
-                       client.send();\r
-               } catch (DME2Exception e) {\r
-                       throw new APIException(e);\r
-               } catch (IOException e) {\r
-                       throw new APIException(e);\r
-               }\r
-       }\r
-\r
-       \r
-       public class DFuture<T> extends Future<T> {\r
-               protected final DME2RestfulHandler reply;\r
-               protected ResponseInfo info;\r
-               \r
-               public DFuture(DME2RestfulHandler reply) {\r
-                       this.reply = reply;\r
-               }\r
-               \r
-               protected boolean evalInfo() throws APIException{\r
-                       //return info.getCode()==200;\r
-                       return true;\r
-               };\r
-               \r
-               public final boolean get(int timeout) throws CadiException {\r
-                       try {\r
-                               info = reply.getResponse(timeout);\r
-                               ss.setLastResponse(info.getCode());\r
-                               return evalInfo();\r
-                       } catch (Exception e) {\r
-                               throw new CadiException(e);\r
-                       }\r
-               }\r
-\r
-               @Override\r
-               public int code() {\r
-                       return info.getCode();\r
-               }\r
-\r
-               @Override\r
-               public String body() {\r
-                       return info.getBody();\r
-               }\r
-\r
-               @Override\r
-               public String header(String tag) {\r
-                       return info.header(tag);\r
-               }\r
-\r
-       }\r
-\r
-       @Override\r
-       public <T> Future<T> futureCreate(Class<T> t) {\r
-               return new DFuture<T>(replyHandler) {\r
-                       public boolean evalInfo() throws APIException {\r
-                               \r
-                               return info.getCode()==201;\r
-                       }\r
-               };\r
-       }\r
-       \r
-\r
-       @Override\r
-       public Future<String> futureReadString() {\r
-               return new DFuture<String>(replyHandler) {\r
-                       public boolean evalInfo() throws APIException {\r
-                               if(info.getCode()==200) {\r
-                                       value = info.getBody();\r
-                                       return true;\r
-                               }\r
-                               return false;\r
-                       }\r
-               };\r
-       }\r
-       \r
-       @Override\r
-       public<T> Future<T> futureRead(final RosettaDF<T> df, final Data.TYPE type) {\r
-               return new DFuture<T>(replyHandler) {\r
-                       public boolean evalInfo() throws APIException {\r
-                               if(info.getCode()==200) {\r
-                                       value = df.newData().in(type).load(info.getBody()).asObject();\r
-                                       return true;\r
-                               }\r
-                               return false;\r
-                       }\r
-               };\r
-       }\r
-\r
-       @Override\r
-       public <T> Future<T> future(final T t) {\r
-               return new DFuture<T>(replyHandler) {\r
-                       public boolean evalInfo() {\r
-                               if(info.getCode()==200) {\r
-                                       value = t;\r
-                                       return true;\r
-                               }\r
-                               return false;\r
-                       }\r
-               };\r
-       }\r
-\r
-       @Override\r
-       public Future<Void> future(HttpServletResponse resp,int expected) throws APIException {\r
-               // TODO Auto-generated method stub\r
-               return null;\r
-       }\r
-\r
-       public void setProxy(boolean isProxy) {\r
-               this.isProxy=isProxy;\r
-       }\r
-\r
-       \r
-}\r