summaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-chef-adapter
diff options
context:
space:
mode:
authorMichal Kabaj <michal.kabaj@nokia.com>2018-02-16 11:37:35 +0100
committerPatrick Brady <pb071s@att.com>2018-02-23 03:10:53 +0000
commit0df5aa1d2f10f0c20d80dfaf0311891e6d1b5974 (patch)
tree46efaec92b7e4cc29027f98a36024beabc9b7179 /appc-adapters/appc-chef-adapter
parent5a99e9824824b2fa5f22945cd58cd5e3ee0df1ef (diff)
ChefApiClient Package Reorganization and cleanup
-Reorganize ChefApiClient classes according to their usage, construction and implementation. -Introduce api and impl packages. -Extract interface from ChefApiClient impl -Remove unused old chefapi.* classes Change-Id: Ic1ddbdcfd0e1bbc0830b923da5aac5b68ac44a2f Issue-ID: APPC-437 Signed-off-by: Michal Kabaj <michal.kabaj@nokia.com>
Diffstat (limited to 'appc-adapters/appc-chef-adapter')
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/ApiMethod.java167
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Delete.java36
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Post.java46
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Put.java46
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefApiClientFactory.java5
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/api/ChefApiClient.java (renamed from appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Get.java)26
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/api/ChefResponse.java (renamed from appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefResponse.java)2
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/ChefApiClientImpl.java (renamed from appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefApiClient.java)14
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/ChefApiHeaderFactory.java (renamed from appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefApiHeaderFactory.java)6
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/ChefRequestBuilder.java (renamed from appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefRequestBuilder.java)8
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/FormattedTimestamp.java (renamed from appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/FormattedTimestamp.java)2
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/Utils.java (renamed from appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/Utils.java)2
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java5
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/impl/ChefApiClientImplTest.java (renamed from appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/ChefApiClientTest.java)7
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/impl/ChefApiHeaderFactoryTest.java (renamed from appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/ChefApiHeaderFactoryTest.java)2
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/impl/FormattedTimestampTest.java (renamed from appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/FormattedTimestampTest.java)2
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/resources/test.properties26
17 files changed, 44 insertions, 358 deletions
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/ApiMethod.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/ApiMethod.java
deleted file mode 100644
index 8edee5709..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/ApiMethod.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.adapter.chef.chefapi;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.Header;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.util.EntityUtils;
-import org.onap.appc.adapter.chef.chefclient.Utils;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.impl.client.HttpClients;
-
-public class ApiMethod {
- private HttpClient client = null;
- protected HttpRequestBase method = null;
- protected HttpResponse response = null;
- protected String reqBody = "";
- protected String userId = "";
- protected String pemPath = "";
- protected String chefPath = "";
- protected String organizations = "";
- protected int resCode=0;
- protected String responseBody="";
- private String methodName = "GET";
- public String test = "";
- private int returnCode;
- final String KEY_STORE_PATH = "/etc/chef/trusted_certs/mykeystore.jks";
- final String KEY_STORE_PASSWORD = "adminadmin";
- static
- {
- System.setProperty("javax.net.ssl.trustStore", "/opt/onap/appc/chef/chefServerSSL.jks");
- System.setProperty("javax.net.ssl.trustStorePassword", "adminadmin");
- }
-
- public ApiMethod(String methodName) {
- client=HttpClients.createDefault();
- this.methodName = methodName;
- }
-
-
-
- public ApiMethod execute() {
- String hashedPath = Utils.sha1AndBase64("/organizations/"+organizations+chefPath);
- String hashedBody = Utils.sha1AndBase64(reqBody);
-
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
- String timeStamp = sdf.format(new Date());
- timeStamp = timeStamp.replace(" ", "T");
- timeStamp = timeStamp + "Z";
-
- StringBuilder sb = new StringBuilder();
- sb.append("Method:").append(methodName).append("\n");
- sb.append("Hashed Path:").append(hashedPath).append("\n");
- sb.append("X-Ops-Content-Hash:").append(hashedBody).append("\n");
- sb.append("X-Ops-Timestamp:").append(timeStamp).append("\n");
- sb.append("X-Ops-UserId:").append(userId);
- test = test + "sb " + sb + "\n";
-
- String auth_String = Utils.signWithRSA(sb.toString(), pemPath);
- String[] auth_headers = Utils.splitAs60(auth_String);
-
- method.addHeader("Content-type", "application/json");
- method.addHeader("X-Ops-Timestamp", timeStamp);
- method.addHeader("X-Ops-Userid", userId);
- method.addHeader("X-Chef-Version", "12.4.1");
- method.addHeader("Accept", "application/json");
- method.addHeader("X-Ops-Content-Hash", hashedBody);
- method.addHeader("X-Ops-Sign", "version=1.0");
-
- for (int i = 0; i < auth_headers.length; i++) {
- method.addHeader("X-Ops-Authorization-" + (i + 1), auth_headers[i]);
- }
- try{
- response = client.execute(method);
- resCode = response.getStatusLine().getStatusCode();
- HttpEntity entity1 = response.getEntity();
- responseBody = EntityUtils.toString(entity1);}
- catch(Exception ex){
- resCode=500;
- responseBody=ex.getMessage();
- }
- return this;
- }
-
- public void setHeaders(Header[] headers) {
- for (Header header : headers) {
- this.method.addHeader(header);
- }
- }
-
- public String getResponseBodyAsString() {
- return responseBody;
- }
-
- public int getReturnCode() {
- return resCode;
- }
-
- public String getReqBody() {
- return reqBody;
- }
-
- public void setReqBody(String body) {
- this.reqBody = body;
- }
-
- public String getUserId() {
- return userId;
- }
-
- public void setUserId(String userId) {
- this.userId = userId;
- }
-
- public String getPemPath() {
- return pemPath;
- }
-
- public void setPemPath(String pemPath) {
- this.pemPath = pemPath;
- }
-
- public String getChefPath() {
- return chefPath;
- }
-
- public void setChefPath(String chefPath) {
- this.chefPath = chefPath;
- }
-
- public String getOrganizations() {
- return organizations;
- }
-
- public void setOrganizations(String organizations) {
- this.organizations = organizations;
- }
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Delete.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Delete.java
deleted file mode 100644
index 5fa8a3fae..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Delete.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.adapter.chef.chefapi;
-
-import org.apache.http.client.methods.HttpDelete;
-
-public class Delete extends ApiMethod{
-
- public Delete(HttpDelete method) {
- super("DELETE");
- this.method = method;
- }
-
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Post.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Post.java
deleted file mode 100644
index 3234eeefa..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Post.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.adapter.chef.chefapi;
-
-import org.apache.http.client.methods.*;
-import org.apache.http.entity.StringEntity;
-
-public class Post extends ApiMethod{
-
- public Post(HttpRequestBase method) {
- super("POST");
- this.method = method;
- }
-
- public ApiMethod body(String body){
- this.reqBody = body;
- StringEntity params =new StringEntity (body,"UTF-8");
- params.setContentType("application/json");
- HttpPost post = (HttpPost) method;
- post.setEntity(params);
- return this;
- }
-
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Put.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Put.java
deleted file mode 100644
index c96fc64d1..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Put.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.adapter.chef.chefapi;
-
-import org.apache.http.client.methods.*;
-import org.apache.http.entity.StringEntity;
-
-public class Put extends ApiMethod{
-
- public Put(HttpRequestBase method) {
- super("PUT");
- this.method = method;
- }
-
- public ApiMethod body(String body){
- this.reqBody = body;
- StringEntity params =new StringEntity (body,"UTF-8");
- params.setContentType("application/json");
- HttpPut put = (HttpPut) method;
- put.setEntity(params);
- return this;
- }
-
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefApiClientFactory.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefApiClientFactory.java
index b3c4272c1..a69ccf1b2 100644
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefApiClientFactory.java
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefApiClientFactory.java
@@ -21,6 +21,9 @@ package org.onap.appc.adapter.chef.chefclient;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.HttpClients;
+import org.onap.appc.adapter.chef.chefclient.api.ChefApiClient;
+import org.onap.appc.adapter.chef.chefclient.impl.ChefApiClientImpl;
+import org.onap.appc.adapter.chef.chefclient.impl.ChefApiHeaderFactory;
public final class ChefApiClientFactory {
@@ -28,7 +31,7 @@ public final class ChefApiClientFactory {
private ChefApiHeaderFactory chefApiHeaderFactory = new ChefApiHeaderFactory();
public ChefApiClient create(String endPoint, String organizations, String userId, String pemPath) {
- return new ChefApiClient(httpClient,
+ return new ChefApiClientImpl(httpClient,
chefApiHeaderFactory,
endPoint,
organizations,
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Get.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/api/ChefApiClient.java
index da37236a7..058795b69 100644
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Get.java
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/api/ChefApiClient.java
@@ -1,35 +1,31 @@
-/*-
+/*
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
+ * Copyright (C) 2018 Nokia. All rights reserved.
* =============================================================================
* 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
+package org.onap.appc.adapter.chef.chefclient.api;
+
+public interface ChefApiClient {
-package org.onap.appc.adapter.chef.chefapi;
+ ChefResponse get(String path);
-import org.apache.http.client.methods.HttpGet;
+ ChefResponse delete(String path);
-public class Get extends ApiMethod{
+ ChefResponse post(String path, String body);
- public Get(HttpGet method) {
- super("GET");
- this.method = method;
- }
+ ChefResponse put(String path, String body);
}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefResponse.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/api/ChefResponse.java
index e83711a44..5f8ec1f8f 100644
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefResponse.java
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/api/ChefResponse.java
@@ -17,7 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.appc.adapter.chef.chefclient;
+package org.onap.appc.adapter.chef.chefclient.api;
public final class ChefResponse {
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefApiClient.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/ChefApiClientImpl.java
index 33d463bde..b26f69a9e 100644
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefApiClient.java
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/ChefApiClientImpl.java
@@ -22,7 +22,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.appc.adapter.chef.chefclient;
+package org.onap.appc.adapter.chef.chefclient.impl;
import java.io.IOException;
import java.net.URISyntaxException;
@@ -31,9 +31,11 @@ import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.util.EntityUtils;
-import org.onap.appc.adapter.chef.chefclient.ChefRequestBuilder.OngoingRequestBuilder;
+import org.onap.appc.adapter.chef.chefclient.api.ChefApiClient;
+import org.onap.appc.adapter.chef.chefclient.api.ChefResponse;
+import org.onap.appc.adapter.chef.chefclient.impl.ChefRequestBuilder.OngoingRequestBuilder;
-public class ChefApiClient {
+public class ChefApiClientImpl implements ChefApiClient {
private final HttpClient httpClient;
private final ChefApiHeaderFactory chefApiHeaderFactory;
@@ -42,7 +44,7 @@ public class ChefApiClient {
private String pemPath;
private String organizations;
- ChefApiClient(HttpClient httpClient, ChefApiHeaderFactory chefApiHeaderFactory,
+ public ChefApiClientImpl(HttpClient httpClient, ChefApiHeaderFactory chefApiHeaderFactory,
String endpoint, String organizations, String userId, String pemPath) {
this.httpClient = httpClient;
this.chefApiHeaderFactory = chefApiHeaderFactory;
@@ -52,6 +54,7 @@ public class ChefApiClient {
this.pemPath = pemPath;
}
+ @Override
public ChefResponse get(String path) {
OngoingRequestBuilder requestBuilder = ChefRequestBuilder.newRequestTo(endpoint)
.httpGet()
@@ -60,6 +63,7 @@ public class ChefApiClient {
return execute(requestBuilder);
}
+ @Override
public ChefResponse delete(String path) {
OngoingRequestBuilder requestBuilder = ChefRequestBuilder.newRequestTo(endpoint)
.httpDelete()
@@ -68,6 +72,7 @@ public class ChefApiClient {
return execute(requestBuilder);
}
+ @Override
public ChefResponse post(String path, String body) {
OngoingRequestBuilder requestBuilder = ChefRequestBuilder.newRequestTo(endpoint)
.httpPost(body)
@@ -76,6 +81,7 @@ public class ChefApiClient {
return execute(requestBuilder);
}
+ @Override
public ChefResponse put(String path, String body) {
OngoingRequestBuilder requestBuilder = ChefRequestBuilder.newRequestTo(endpoint)
.httpPut(body)
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefApiHeaderFactory.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/ChefApiHeaderFactory.java
index 94abd06dd..d045135c4 100644
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefApiHeaderFactory.java
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/ChefApiHeaderFactory.java
@@ -17,13 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.appc.adapter.chef.chefclient;
+package org.onap.appc.adapter.chef.chefclient.impl;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import java.util.Date;
-class ChefApiHeaderFactory {
+public class ChefApiHeaderFactory {
private FormattedTimestamp formattedTimestamp = new FormattedTimestamp();
@@ -32,7 +32,7 @@ class ChefApiHeaderFactory {
System.setProperty("javax.net.ssl.trustStorePassword", "adminadmin");
}
- ImmutableMap<String, String> create(String methodName, String path, String body, String userId,
+ public ImmutableMap<String, String> create(String methodName, String path, String body, String userId,
String organizations, String pemPath) {
String hashedBody = Utils.sha1AndBase64(body);
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefRequestBuilder.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/ChefRequestBuilder.java
index acf0a489d..a2248438a 100644
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefRequestBuilder.java
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/ChefRequestBuilder.java
@@ -17,7 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.appc.adapter.chef.chefclient;
+package org.onap.appc.adapter.chef.chefclient.impl;
import com.google.common.collect.ImmutableMap;
import java.net.URI;
@@ -31,16 +31,16 @@ import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
-public final class ChefRequestBuilder {
+final class ChefRequestBuilder {
private ChefRequestBuilder() {
}
- public static OngoingRequestBuilder newRequestTo(String endPoint) {
+ static OngoingRequestBuilder newRequestTo(String endPoint) {
return new OngoingRequestBuilder(endPoint);
}
- public static class OngoingRequestBuilder {
+ static class OngoingRequestBuilder {
private HttpRequestBase httpRequestBase;
private String endPoint;
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/FormattedTimestamp.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/FormattedTimestamp.java
index 15ad87389..f9adee5d6 100644
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/FormattedTimestamp.java
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/FormattedTimestamp.java
@@ -17,7 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.appc.adapter.chef.chefclient;
+package org.onap.appc.adapter.chef.chefclient.impl;
import java.text.SimpleDateFormat;
import java.util.Date;
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/Utils.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/Utils.java
index 3f7f203b7..ede5ed3d9 100644
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/Utils.java
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/Utils.java
@@ -22,7 +22,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.appc.adapter.chef.chefclient;
+package org.onap.appc.adapter.chef.chefclient.impl;
import java.io.BufferedReader;
import java.io.FileReader;
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java
index 65e64f839..eb5ee7bde 100644
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java
@@ -38,10 +38,9 @@ import org.apache.http.util.EntityUtils;
import org.json.JSONException;
import org.json.JSONObject;
import org.onap.appc.adapter.chef.ChefAdapter;
-import org.onap.appc.adapter.chef.chefapi.ApiMethod;
-import org.onap.appc.adapter.chef.chefclient.ChefApiClient;
+import org.onap.appc.adapter.chef.chefclient.api.ChefApiClient;
import org.onap.appc.adapter.chef.chefclient.ChefApiClientFactory;
-import org.onap.appc.adapter.chef.chefclient.ChefResponse;
+import org.onap.appc.adapter.chef.chefclient.api.ChefResponse;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import com.att.eelf.configuration.EELFLogger;
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/ChefApiClientTest.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/impl/ChefApiClientImplTest.java
index 58b55854a..21e607de7 100644
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/ChefApiClientTest.java
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/impl/ChefApiClientImplTest.java
@@ -17,7 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.appc.adapter.chef.chefclient;
+package org.onap.appc.adapter.chef.chefclient.impl;
import static junit.framework.TestCase.assertEquals;
import static org.mockito.BDDMockito.given;
@@ -43,9 +43,12 @@ import org.mockito.ArgumentMatcher;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.appc.adapter.chef.chefclient.ChefApiClientFactory;
+import org.onap.appc.adapter.chef.chefclient.api.ChefApiClient;
+import org.onap.appc.adapter.chef.chefclient.api.ChefResponse;
@RunWith(MockitoJUnitRunner.class)
-public class ChefApiClientTest {
+public class ChefApiClientImplTest {
private static final String END_POINT = "https://chefServer";
private static final String ORGANIZATIONS_PATH = "onap";
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/ChefApiHeaderFactoryTest.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/impl/ChefApiHeaderFactoryTest.java
index cc309811d..4aece53a0 100644
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/ChefApiHeaderFactoryTest.java
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/impl/ChefApiHeaderFactoryTest.java
@@ -17,7 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.appc.adapter.chef.chefclient;
+package org.onap.appc.adapter.chef.chefclient.impl;
import static junit.framework.TestCase.assertEquals;
import static org.mockito.BDDMockito.given;
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/FormattedTimestampTest.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/impl/FormattedTimestampTest.java
index 47d2f6c2c..faaca6284 100644
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/FormattedTimestampTest.java
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/impl/FormattedTimestampTest.java
@@ -17,7 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.appc.adapter.chef.chefclient;
+package org.onap.appc.adapter.chef.chefclient.impl;
import static org.junit.Assert.assertEquals;
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/resources/test.properties b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/resources/test.properties
deleted file mode 100644
index 09d42083a..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/resources/test.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-# ============LICENSE_START==========================================
-# ONAP : APPC
-# ===================================================================
-# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
-# ===================================================================
-#
-# Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the License);
-# you may not use this software 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.
-#
-# ECOMP is a trademark and service mark of AT&T Intellectual Property.
-# ============LICENSE_END============================================
-org.onap.appc.adapter.chef.chefclient.userId=test
-org.onap.appc.adapter.chef.chefclient.pemPath=/src/test/resources/testclient.pem
-org.onap.appc.adapter.chef.chefclient.endPoint=http://127.0.0.1
-org.onap.appc.adapter.chef.chefclient.organizations=onap
-org.onap.appc.adapter.chef.chefclient.path=/test/path