diff options
author | 2022-09-08 09:45:06 +0200 | |
---|---|---|
committer | 2022-09-08 09:46:47 +0200 | |
commit | a2b6dd34d73bf432846dc59c6f57dd59a03aff9b (patch) | |
tree | 35658e382769bc7575f87d0e9580d6ee98230eb2 /sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts | |
parent | 6f9c3d2cea04a2af7a73d8df1de87d584b277552 (diff) |
update odlux sources
update basic odlux functionality for kohn
Issue-ID: CCSDK-3765
Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com>
Change-Id: I3723c9c2f35b9012ba537920b294a54bb556cbc6
Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts')
-rw-r--r-- | sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts b/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts index 0dd42e3b7..2846dba06 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts +++ b/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts @@ -1,21 +1,3 @@ -/** - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt odlux - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. 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. - * ============LICENSE_END========================================================================== - */ - import { Action } from '../../../../framework/src/flux/action'; import { Dispatch } from '../../../../framework/src/flux/store'; import { IApplicationStoreState } from "../../../../framework/src/store/applicationStore"; @@ -65,6 +47,22 @@ export class UpdatOutputData extends Action { } } +type HttpResult = { + status: number; + message?: string | undefined; + data: { + [key: string]: any; + } | null | undefined; +}; + +const checkResponseCode = (restResult: HttpResult) =>{ + + //403 gets handled by the framework from now on + + return restResult.status !== 403 && ( restResult.status < 200 || restResult.status > 299); + +} + export const updateNodeIdAsyncActionCreator = (nodeId: string) => async (dispatch: Dispatch, getState: () => IApplicationStoreState ) => { dispatch(new UpdateDeviceDescription("", {}, [])); @@ -81,8 +79,8 @@ export const updateNodeIdAsyncActionCreator = (nodeId: string) => async (dispatc })); throw new Error(`NetworkElement : [${nodeId}] has no capabilities.`); } - - const parser = new YangParser(unavailableCapabilities || undefined, importOnlyModules || undefined); + + const parser = new YangParser(unavailableCapabilities || undefined, importOnlyModules || undefined, nodeId); for (let i = 0; i < availableCapabilities.length; ++i){ const capRaw = availableCapabilities[i]; @@ -146,7 +144,7 @@ const getReferencedDataList = async (refPath: string, dataPath: string, modules: for (let j = 0; j < dataUrls.length; ++j) { const dataUrl = dataUrls[j]; const restResult = (await restService.getConfigData(dataUrl)); - if (restResult.data == null || restResult.status < 200 || restResult.status > 299) { + if (restResult.data == null || checkResponseCode(restResult)) { const message = restResult.data && restResult.data.errors && restResult.data.errors.error && restResult.data.errors.error[0] && restResult.data.errors.error[0]["error-message"] || ""; throw new Error(`Server Error. Status: [${restResult.status}]\n${message || restResult.message || ''}`); } @@ -178,7 +176,7 @@ const getReferencedDataList = async (refPath: string, dataPath: string, modules: for (let j = 0; j < dataUrls.length; ++j) { const dataUrl = dataUrls[j]; const restResult = (await restService.getConfigData(dataUrl)); - if (restResult.data == null || restResult.status < 200 || restResult.status > 299) { + if (restResult.data == null || checkResponseCode(restResult)) { const message = restResult.data && restResult.data.errors && restResult.data.errors.error && restResult.data.errors.error[0] && restResult.data.errors.error[0]["error-message"] || ""; throw new Error(`Server Error. Status: [${restResult.status}]\n${message || restResult.message || ''}`); } @@ -426,7 +424,7 @@ export const updateViewActionAsyncCreator = (vPath: string) => async (dispatch: return dispatch(new UpdatViewDescription(vPath, [], ds)); } throw new Error(`Did not get response from Server. Status: [${restResult.status}]`); - } else if (restResult.status < 200 || restResult.status > 299) { + } else if (checkResponseCode(restResult)) { const message = restResult.data.errors && restResult.data.errors.error && restResult.data.errors.error[0] && restResult.data.errors.error[0]["error-message"] || ""; throw new Error(`Server Error. Status: [${restResult.status}]\n${message}`); } else { @@ -581,7 +579,7 @@ export const updateDataActionAsyncCreator = (vPath: string, data: any) => async // do not extract root member (0) if (viewSpecification && viewSpecification.id !== "0") { const updateResult = await restService.setConfigData(dataPath, { [`${currentNS}:${dataMember!}`]: data }); // addDataMember using currentNS - if (updateResult.status < 200 || updateResult.status > 299) { + if (checkResponseCode(updateResult)) { const message = updateResult.data && updateResult.data.errors && updateResult.data.errors.error && updateResult.data.errors.error[0] && updateResult.data.errors.error[0]["error-message"] || ""; throw new Error(`Server Error. Status: [${updateResult.status}]\n${message || updateResult.message || ''}`); } @@ -653,7 +651,7 @@ export const removeElementActionAsyncCreator = (vPath: string) => async (dispatc } const updateResult = await restService.removeConfigElement(dataPath); - if (updateResult.status < 200 || updateResult.status > 299) { + if (checkResponseCode(updateResult)) { const message = updateResult.data && updateResult.data.errors && updateResult.data.errors.error && updateResult.data.errors.error[0] && updateResult.data.errors.error[0]["error-message"] || ""; throw new Error(`Server Error. Status: [${updateResult.status}]\n${message || updateResult.message || ''}`); } @@ -747,7 +745,7 @@ export const executeRpcActionAsyncCreator = (vPath: string, data: any) => async // do not post root member (0) if ((viewSpecification && viewSpecification.id !== "0") || (dataMember! && !data)) { const updateResult = await restService.executeRpc(dataPath, { [`${defaultNS}:input`]: data || {} }); - if (updateResult.status < 200 || updateResult.status > 299) { + if (checkResponseCode(updateResult)) { const message = updateResult.data && updateResult.data.errors && updateResult.data.errors.error && updateResult.data.errors.error[0] && updateResult.data.errors.error[0]["error-message"] || ""; throw new Error(`Server Error. Status: [${updateResult.status}]\n${message || updateResult.message || ''}`); } |