+++ /dev/null
-/*******************************************************************************\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.net.MalformedURLException;\r
-import java.net.URI;\r
-import java.net.URISyntaxException;\r
-import java.util.ArrayList;\r
-import java.util.List;\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.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.manager.registry.DME2Endpoint;\r
-import com.att.aft.dme2.request.DmeUniformResource;\r
-import org.onap.aaf.inno.env.APIException;\r
-import org.onap.aaf.inno.env.Data.TYPE;\r
-\r
-/**\r
- * DME2 Rosetta Client\r
- * \r
- * JAXB defined JSON or XML over DME2 middleware\r
- * \r
- *\r
- * @param <T>\r
- */\r
-public class DRcli extends Rcli<DME2Client> {\r
- // Can be more efficient if tied to manager, apparently. Can pass in null.\r
- DME2Manager manager=null;\r
- private SecuritySetter<DME2Client> ss;\r
- private boolean isProxy;\r
- \r
- public DRcli(URI uri, SecuritySetter<DME2Client> secSet) {\r
- this.uri = uri;\r
- type = TYPE.JSON;\r
- apiVersion = null;\r
- ss=secSet;\r
- }\r
- \r
- @Override\r
- protected DRcli clone(URI uri, SecuritySetter<DME2Client> ss) {\r
- return new DRcli(uri,ss);\r
- }\r
-\r
-\r
-\r
- /**\r
- * Note from Thaniga on 11/5. DME2Client is not expected to be reused... need a fresh one\r
- * on each transaction, which is expected to cover the Async aspects.\r
- * \r
- * @return\r
- * @throws APIException \r
- * @throws DME2Exception \r
- */\r
- protected EClient<DME2Client> client() throws CadiException {\r
- try {\r
- DEClient dc = new DEClient(manager,getSecuritySetter(),uri,readTimeout);\r
- dc.setProxy(isProxy);\r
- return dc;\r
- } catch (DME2Exception e) {\r
- throw new CadiException(e);\r
- }\r
- }\r
-\r
- public DRcli setManager(DME2Manager dme2Manager) {\r
- manager = dme2Manager;\r
- return this;\r
- }\r
-\r
- public List<DRcli> all() throws DME2Exception, APIException {\r
- ArrayList<DRcli> al = new ArrayList<DRcli>();\r
- \r
- if(manager == null) {\r
- manager = DME2Manager.getDefaultInstance();\r
- }\r
- try {\r
- DME2Endpoint[] endp = manager.getEndpoints(new DmeUniformResource(manager.getConfig(),uri));\r
- // Convert Searchable Endpoints to Direct Endpoints\r
- for(DME2Endpoint de : endp) {\r
- al.add(new DRcli(\r
- new URI(uri.getScheme(),null,de.getHost(),de.getPort(),null,null,null),ss)\r
-// new URI(uri.getScheme(),null,de.getHost(),de.getPort(),uri.getPath(),null,null),ss)\r
- .setManager(manager)\r
- );\r
- }\r
- } catch (MalformedURLException e) {\r
- throw new APIException("Invalid URL",e);\r
- } catch (URISyntaxException e) {\r
- throw new APIException("Invalid URI",e);\r
- }\r
- return al;\r
- }\r
-\r
- @Override\r
- public void invalidate() throws CadiException {\r
- try {\r
- manager.refresh();\r
- } catch (Exception e) {\r
- throw new CadiException(e);\r
- }\r
- }\r
-\r
- @Override\r
- public void setSecuritySetter(SecuritySetter<DME2Client> ss) {\r
- this.ss = ss;\r
- }\r
-\r
- @Override\r
- public SecuritySetter<DME2Client> getSecuritySetter() {\r
- return ss;\r
- }\r
-\r
- public void setProxy(boolean isProxy) {\r
- this.isProxy = isProxy;\r
- }\r
-\r
-}\r