public void updateAction()

in src/main/java/org/apache/openwhisk/intellij/explorer/dialog/action/ui/ActionManagerDialogForm.java [312:359]


    public void updateAction() {
        try {
            // parameters
            Optional<String> params = getParameter();
            if (!params.isPresent()) {
                NOTIFIER.notify(project, "The json format of the parameter is incorrect.", NotificationType.ERROR);
                return;
            }
            List<Map<String, Object>> validParams = ParameterUtils.mapToListMap(JsonParserUtils.parseMap(params.get()));
            // timeout
            int timeout = (Integer) timeoutJSpinner.getValue();
            // memory
            int memory = (Integer) memoryJSpinner.getValue();
            Limits limits = action.getLimits();
            limits.setTimeout(timeout);
            limits.setMemory(memory);
            // runtime
            Runtime runtime = (Runtime) runtimeJComboBox.getSelectedItem();
            CodeExec exec = createExec(action, runtime);
            // web action
            boolean web = webactionJCheckBox.isSelected();
            boolean rawHttp = rawHttpJCheckBox.isSelected();
            boolean customOption = customOptionHeaderJCheckBox.isSelected();
            boolean finalDefaultParameter = finalOptionJCheckBox.isSelected();
            // code type
            Optional<String> codeType = getCodeType(runtime);
            // annotations
            List<Map<String, Object>> annotations = annotationToCollection(action, web, rawHttp, customOption, finalDefaultParameter, codeType);

            // payload
            Map<String, Object> payload = new LinkedHashMap<>();
            payload.put("namespace", action.getNamespacePath());
            payload.put("name", action.getWhiskPackage().map(pkg -> pkg + "/" + action.getName()).orElse(action.getName()));
            payload.put("parameters", validParams);
            payload.put("annotations", annotations);
            payload.put("limits", limits);
            payload.put("exec", exec);
            whiskActionService.updateWhiskAction(whiskAuth, action, payload).ifPresent(updated -> {
                NOTIFIER.notify(project, "Action update succeeded: " + updated.getFullyQualifiedName(), NotificationType.INFORMATION);
                EventUtils.publish(project, RefreshActionOrTriggerListener.TOPIC, RefreshActionOrTriggerListener::fetchActionMetadata);
                EventUtils.publish(project, RefreshWhiskTreeListener.TOPIC, RefreshWhiskTreeListener::refreshWhiskTree);
            });
        } catch (IOException e) {
            String msg = "Failed to update action: " + action.getFullyQualifiedName();
            LOG.error(msg, e);
            NOTIFIER.notify(project, msg, NotificationType.ERROR);
        }
    }