diff options
Diffstat (limited to 'src/main/java/com/wipro/www/sonhms/restclient')
10 files changed, 0 insertions, 754 deletions
diff --git a/src/main/java/com/wipro/www/sonhms/restclient/AsyncResponseBody.java b/src/main/java/com/wipro/www/sonhms/restclient/AsyncResponseBody.java deleted file mode 100644 index 94e6919..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/AsyncResponseBody.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 Wipro Limited. - * ============================================================================== - * 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. - * ============LICENSE_END========================================================= - ******************************************************************************/ - -package com.wipro.www.sonhms.restclient; - -import java.util.List; - -public class AsyncResponseBody { - - String transactionId = null; - String requestId = null; - String requestStatus = null; - String statusMessage = null; - List<Solution> solutions; - - public String getTransactionId() { - return transactionId; - } - - public void setTransactionId(String transactionId) { - this.transactionId = transactionId; - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getRequestStatus() { - return requestStatus; - } - - @Override - public String toString() { - return "AsyncResponseBody [transactionId=" + transactionId + ", requestId=" + requestId + ", requestStatus=" - + requestStatus + ", statusMessage=" + statusMessage + ", solutions=" + solutions + "]"; - } - - public void setRequestStatus(String requestStatus) { - this.requestStatus = requestStatus; - } - - public String getStatusMessage() { - return statusMessage; - } - - public void setStatusMessage(String statusMessage) { - this.statusMessage = statusMessage; - } - - public List<Solution> getSolutions() { - return solutions; - } - - public void setSolutions(List<Solution> solutions) { - this.solutions = solutions; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/CellInfo.java b/src/main/java/com/wipro/www/sonhms/restclient/CellInfo.java deleted file mode 100644 index 77d4003..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/CellInfo.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 Wipro Limited. - * ============================================================================== - * 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. - * ============LICENSE_END========================================================= - ******************************************************************************/ - -package com.wipro.www.sonhms.restclient; - -import java.util.ArrayList; -import java.util.List; - -public class CellInfo { - String networkId = null; - List<String> cellIdList = new ArrayList<>(); - - public String getNetworkId() { - return networkId; - } - - public void setNetworkId(String networkId) { - this.networkId = networkId; - } - - public List<String> getCellIdList() { - return cellIdList; - } - - public void setCellIdList(List<String> cellIdList) { - this.cellIdList = cellIdList; - } - - - -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/OofRequestBody.java b/src/main/java/com/wipro/www/sonhms/restclient/OofRequestBody.java deleted file mode 100644 index edee572..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/OofRequestBody.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 Wipro Limited. - * ============================================================================== - * 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. - * ============LICENSE_END========================================================= - ******************************************************************************/ - -package com.wipro.www.sonhms.restclient; - -public class OofRequestBody { - - protected RequestInfo requestInfo = new RequestInfo(); - protected CellInfo cellInfo = new CellInfo(); - - public RequestInfo getRequestInfo() { - return requestInfo; - } - - public void setRequestInfo(RequestInfo requestInfo) { - this.requestInfo = requestInfo; - } - - public CellInfo getCellInfo() { - return cellInfo; - } - - public void setCellInfo(CellInfo cellInfo) { - this.cellInfo = cellInfo; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/OofRestClient.java b/src/main/java/com/wipro/www/sonhms/restclient/OofRestClient.java deleted file mode 100644 index 7b95d90..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/OofRestClient.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 Wipro Limited. - * ============================================================================== - * 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. - * ============LICENSE_END========================================================= - ******************************************************************************/ - -package com.wipro.www.sonhms.restclient; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.wipro.www.sonhms.ConfigPolicy; -import com.wipro.www.sonhms.Configuration; -import com.wipro.www.sonhms.exceptions.OofNotFoundException; -import com.wipro.www.sonhms.utils.HttpRequester; - -import java.util.List; -import java.util.UUID; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class OofRestClient { - private static Logger log = LoggerFactory.getLogger(OofRestClient.class); - - private OofRestClient() { - - } - - /** - * rest client that pci uses to query the OOF for pci solutions. - * @throws OofNotFoundException when request to oof fails - */ - - public static String queryOof(int numSolutions, String transactionId, String requestType, - List<String> cellIdList, String networkId, List<String> optimizers) throws OofNotFoundException { - log.debug("inside queryoof"); - - String response = ""; - Configuration configuration = Configuration.getInstance(); - try { - UUID requestUuid = UUID.randomUUID(); - String requestId = requestUuid.toString(); - String callbackUrl = configuration.getCallbackUrl(); - RequestInfo requestInfo = new RequestInfo(); - requestInfo.setTransactionId(transactionId); - requestInfo.setRequestId(requestId); - requestInfo.setCallbackUrl(callbackUrl); - String sourceId = configuration.getSourceId(); - requestInfo.setSourceId(sourceId); - requestInfo.setRequestType(requestType); - requestInfo.setNumSolutions(numSolutions); - requestInfo.setOptimizers(optimizers); - ConfigPolicy config = ConfigPolicy.getInstance(); - int timeout = 60; - try { - timeout = (int) config.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS"); - } catch (NullPointerException e) { - log.debug("No config policy available. Using default timeout 60 sec"); - } - requestInfo.setTimeout(timeout); - CellInfo cellInfo = new CellInfo(); - cellInfo.setCellIdList(cellIdList); - cellInfo.setNetworkId(networkId); - OofRequestBody oofRequestBody = new OofRequestBody(); - oofRequestBody.setRequestInfo(requestInfo); - oofRequestBody.setCellInfo(cellInfo); - - ObjectMapper mapper = new ObjectMapper(); - String requestBody = mapper.writeValueAsString(oofRequestBody); - log.debug("requestBody{}", requestBody); - - String requestUrl = configuration.getOofService() + "/api/oof/v1/pci"; - log.debug("requestUrl {}", requestUrl); - - response = HttpRequester.sendPostRequestToOof(requestUrl, requestBody); - if (response == null) { - throw new OofNotFoundException("Request to oof failed"); - } - log.debug("response {}", response); - - return response; - } catch (JsonProcessingException e) { - log.debug("exception{}", e); - - } - return response; - } -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/PolicyRequestBody.java b/src/main/java/com/wipro/www/sonhms/restclient/PolicyRequestBody.java deleted file mode 100644 index e9e7b0d..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/PolicyRequestBody.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 Wipro Limited. - * ============================================================================== - * 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. - * ============LICENSE_END========================================================= - ******************************************************************************/ - -package com.wipro.www.sonhms.restclient; - -public class PolicyRequestBody { - - String configName = null; - String policyName = null; - String requestId = null; - - public String getConfigName() { - return configName; - } - - public void setConfigName(String configName) { - this.configName = configName; - } - - public String getPolicyName() { - return policyName; - } - - public void setPolicyName(String policyName) { - this.policyName = policyName; - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/PolicyRestClient.java b/src/main/java/com/wipro/www/sonhms/restclient/PolicyRestClient.java deleted file mode 100644 index 7c286af..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/PolicyRestClient.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 Wipro Limited. - * ============================================================================== - * 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. - * ============LICENSE_END========================================================= - ******************************************************************************/ - -package com.wipro.www.sonhms.restclient; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.wipro.www.sonhms.Configuration; -import com.wipro.www.sonhms.utils.HttpRequester; - -import java.util.UUID; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class PolicyRestClient { - private static Logger log = LoggerFactory.getLogger(PolicyRestClient.class); - - private PolicyRestClient() { - - } - - /** - * Fetches configuration from policy. - */ - public static String fetchConfigFromPolicy() { - log.debug("inside fetconfig from policy"); - - Configuration configuration = Configuration.getInstance(); - String response = ""; - String configName = configuration.getConfigName(); - String policyName = configuration.getPolicyName(); - - try { - PolicyRequestBody policyRequestBody = new PolicyRequestBody(); - policyRequestBody.setConfigName(configName); - policyRequestBody.setPolicyName(policyName); - UUID requestUuid = UUID.randomUUID(); - String requestId = requestUuid.toString(); - policyRequestBody.setRequestId(requestId); - ObjectMapper mapper = new ObjectMapper(); - String requestBody; - requestBody = mapper.writeValueAsString(policyRequestBody); - - log.debug("policyRequestBody{}", requestBody); - String requestUrl = configuration.getPolicyService() + "/pdp/api/getConfig"; - response = HttpRequester.sendPostToPolicy(requestUrl, requestBody); - log.debug("policy response{}", response); - - return response; - } catch (JsonProcessingException e) { - log.debug("exception", e); - } - return response; - - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/RequestInfo.java b/src/main/java/com/wipro/www/sonhms/restclient/RequestInfo.java deleted file mode 100644 index 6dcbf63..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/RequestInfo.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 Wipro Limited. - * ============================================================================== - * 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. - * ============LICENSE_END========================================================= - ******************************************************************************/ - -package com.wipro.www.sonhms.restclient; - -import java.util.List; - -public class RequestInfo { - String transactionId = null; - String requestId = null; - String callbackUrl = null; - String sourceId = null; - String requestType = null; - int numSolutions; - List<String> optimizers = null; - - public void setOptimizers(List<String> optimizers) { - this.optimizers = optimizers; - } - - public List<String> getOptimizers() { - return optimizers; - } - - int timeout; - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getCallbackUrl() { - return callbackUrl; - } - - public void setCallbackUrl(String callbackUrl) { - this.callbackUrl = callbackUrl; - } - - public String getSourceId() { - return sourceId; - } - - public void setSourceId(String sourceId) { - this.sourceId = sourceId; - } - - public String getRequestType() { - return requestType; - } - - public void setRequestType(String requestType) { - this.requestType = requestType; - } - - public int getNumSolutions() { - return numSolutions; - } - - public void setNumSolutions(int numSolutions) { - this.numSolutions = numSolutions; - } - - public int getTimeout() { - return timeout; - } - - public void setTimeout(int timeout) { - this.timeout = timeout; - } - - public String getTransactionId() { - return transactionId; - } - - public void setTransactionId(String transactionId) { - this.transactionId = transactionId; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/SdnrRestClient.java b/src/main/java/com/wipro/www/sonhms/restclient/SdnrRestClient.java deleted file mode 100644 index c37791f..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/SdnrRestClient.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 Wipro Limited. - * ============================================================================== - * 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. - * ============LICENSE_END========================================================= - ******************************************************************************/ - -package com.wipro.www.sonhms.restclient; - -import com.wipro.www.sonhms.Configuration; -import com.wipro.www.sonhms.exceptions.ConfigDbNotFoundException; -import com.wipro.www.sonhms.model.CellPciPair; -import com.wipro.www.sonhms.utils.HttpRequester; - -import java.sql.Time; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; - -import org.json.JSONArray; -import org.json.JSONObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - - -public class SdnrRestClient { - - private static final String DATETIMEFORMAT = "yyyy-MM-dd HH:mm:ss"; - private static Logger log = LoggerFactory.getLogger(SdnrRestClient.class); - - private SdnrRestClient() { - - } - - /** - * Method to get cell list from SDNR. - * - * @throws ConfigDbNotFoundException - * when request to configDB fails - */ - public static String getCellList(String networkId) throws ConfigDbNotFoundException { - Configuration configuration = Configuration.getInstance(); - String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis())); - String requestUrl = configuration.getSdnrService() + "/SDNCConfigDBAPI/getCellList" + "/" + networkId + "/" - + encode(ts); - return sendRequest(requestUrl); - } - - /** - * Method to get neibhbour list from SDNR. - * - * @throws ConfigDbNotFoundException - * when request to configDB fails - */ - public static List<CellPciPair> getNbrList(String cellId) throws ConfigDbNotFoundException { - Configuration configuration = Configuration.getInstance(); - String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis())); - String requestUrl = configuration.getSdnrService() + "/SDNCConfigDBAPI/getNbrList" + "/" + cellId + "/" - + encode(ts); - log.debug("request url: {}", requestUrl); - String response = sendRequest(requestUrl); - List<CellPciPair> nbrList = new ArrayList<>(); - JSONArray nbrListObj = new JSONArray(response); - for (int i = 0; i < nbrListObj.length(); i++) { - JSONObject cellObj = nbrListObj.getJSONObject(i); - CellPciPair cell = new CellPciPair(cellObj.getString("cellId"), cellObj.getInt("pciValue")); - nbrList.add(cell); - } - - return nbrList; - } - - /** - * Method to get PCI from SDNR. - * - * @throws ConfigDbNotFoundException - * when request to configDB fails - */ - public static int getPci(String cellId) throws ConfigDbNotFoundException { - Configuration configuration = Configuration.getInstance(); - String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis())); - String requestUrl = configuration.getSdnrService() + "/SDNCConfigDBAPI/getPCI" + "/" + cellId + "/" - + encode(ts); - String response = sendRequest(requestUrl); - JSONObject respObj = new JSONObject(response); - return respObj.getInt("value"); - } - - /** - * Method to get PNF name from SDNR. - * - * @throws ConfigDbNotFoundException - * when request to configDB fails - */ - public static String getPnfName(String cellId) throws ConfigDbNotFoundException { - Configuration configuration = Configuration.getInstance(); - String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis())); - String requestUrl = configuration.getSdnrService() + "/SDNCConfigDBAPI/getPnfName" + "/" + cellId + "/" - + encode(ts); - String response = sendRequest(requestUrl); - JSONObject responseObject = new JSONObject(response); - return responseObject.getString("value"); - } - - /** - * Method to encode url. - */ - private static String encode(String url) { - return url.replace(" ", "%20"); - } - - /** - * Method to send request. - */ - private static String sendRequest(String url) throws ConfigDbNotFoundException { - String response = HttpRequester.sendGetRequest(url); - if (response.equals("")) { - throw new ConfigDbNotFoundException("Cannot reach Config DB"); - } - return response; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/Solution.java b/src/main/java/com/wipro/www/sonhms/restclient/Solution.java deleted file mode 100644 index 765501a..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/Solution.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 Wipro Limited. - * ============================================================================== - * 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. - * ============LICENSE_END========================================================= - ******************************************************************************/ - -package com.wipro.www.sonhms.restclient; - -import java.util.ArrayList; -import java.util.List; - -public class Solution { - String startTime = null; - String finishTime = null; - String networkId = null; - List<SonSolution> pciSolutions = new ArrayList<>(); - - public String getStartTime() { - return startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getFinishTime() { - return finishTime; - } - - public void setFinishTime(String finishTime) { - this.finishTime = finishTime; - } - - public String getNetworkId() { - return networkId; - } - - public void setNetworkId(String networkId) { - this.networkId = networkId; - } - - public List<SonSolution> getPciSolutions() { - return pciSolutions; - } - - /** - * Sets PciSolutions. - */ - public void setPciSolutions(List<SonSolution> pciSolutions) { - - this.pciSolutions = pciSolutions; - - } - - @Override - public String toString() { - return "Solutions [startTime=" + startTime + ", finishTime=" + finishTime + ", networkId=" + networkId - + ", pciSolutions=" + pciSolutions + "]"; - } -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/SonSolution.java b/src/main/java/com/wipro/www/sonhms/restclient/SonSolution.java deleted file mode 100644 index 4872fc7..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/SonSolution.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 Wipro Limited. - * ============================================================================== - * 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. - * ============LICENSE_END========================================================= - ******************************************************************************/ - -package com.wipro.www.sonhms.restclient; - -public class SonSolution { - - String cellId = null; - int pci; - - public String getCellId() { - return cellId; - } - - public void setCellId(String cellId) { - this.cellId = cellId; - } - - public int getPci() { - return pci; - } - - public void setPci(int pci) { - this.pci = pci; - } - -} |