Update a script

@param model
@param scriptIdentifier
@param name
@param script
@return
@throws Exception
552277
@RequestMapping(value = "/api/scripts/{scriptIdentifier}", method = RequestMethod.POST)
    public
    @ResponseBody
    Script updateScript(Model model, @PathVariable String scriptIdentifier,
                        @RequestParam(required = false) String name,
                        @RequestParam(required = false) String script) throws Exception {
        int scriptId = Integer.parseInt(scriptIdentifier);

        if (name != null) {
            ScriptService.getInstance().updateName(scriptId, name);
        }

        if (script != null) {
            ScriptService.getInstance().updateScript(scriptId, script);
        }

        return ScriptService.getInstance().getScript(scriptId);
    }
420639
@RequestMapping(value = "/api/scripts/{scriptIdentifier}", method = RequestMethod.GET)
    public
    @ResponseBody
    Script getScript(Model model, @PathVariable String scriptIdentifier) throws Exception {
        return ScriptService.getInstance().getScript(Integer.parseInt(scriptIdentifier));
    }
346010
public void setPreInstallScript( final String script) {
        setPreInstallProgram(readProgram(script));
        if ( script != null) format.getHeader().createEntry( PREINSCRIPT, script);
	}
889887
public void eInit(SarlScript script, String name, IJvmTypeProvider context) {
		setTypeResolutionContext(context);
		if (this.sarlBehavior == null) {
			this.sarlBehavior = SarlFactory.eINSTANCE.createSarlBehavior();
			script.getXtendTypes().add(this.sarlBehavior);
			this.sarlBehavior.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendTypeDeclaration());
			if (!Strings.isEmpty(name)) {
				this.sarlBehavior.setName(name);
			}
		}
	}
357827
public void eInit(SarlScript script, String name, IJvmTypeProvider context) {
		setTypeResolutionContext(context);
		if (this.sarlAnnotationType == null) {
			this.container = script;
			this.sarlAnnotationType = SarlFactory.eINSTANCE.createSarlAnnotationType();
			script.getXtendTypes().add(this.sarlAnnotationType);
			this.sarlAnnotationType.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendTypeDeclaration());
			if (!Strings.isEmpty(name)) {
				this.sarlAnnotationType.setName(name);
			}
		}
	}
881457
public void write(Object object, Object value) {
        if(object == null) {
            String msg = "Can not update the identifier \"" + _identifier + "\" on a null value object.";
            LOGGER.error(msg);
            throw new RuntimeException(msg);
        }

        if(TRACE_ENABLED)
            LOGGER.trace("Update property named \"" + _identifier + "\" on object of type: \"" + object.getClass().getName() + "\"");

        if(object instanceof Map)
            mapUpdate((Map)object, _identifier, value);
        else if(object instanceof List) {
            int i = parseIndex(_identifier);
            listUpdate((List)object, i, value);
        }
        else if(object.getClass().isArray()) {
            int i = parseIndex(_identifier);
            arrayUpdate(object, i, value);
        }
        else beanUpdate(object, _identifier, value);
    }
189020
@Help(
    help =
        "Executes a script at runtime for a VNFR of a defined VNFD in a running NSR with specific id"
  )
  public void executeScript(final String idNsr, final String idVnfr, String script)
      throws SDKException {
    String url = idNsr + "/vnfrecords" + "/" + idVnfr + "/execute-script";
    requestPost(url, script);
  }
1203877
public ScriptedAction where(String name, Object value) {
        try {
            interpreter.set(name, value);
        }
        catch (EvalError e) {
            throw new IllegalArgumentException("invalid name binding", e);
        }
        return this;
    }
535348
private static void loadScript(ScriptEngine engine, Supplier<Reader> scriptReader) {

        try (Reader reader = scriptReader.get()) {
            engine.eval(reader);
        } catch (ScriptException | IOException e) {
            throw new RuntimeException(e);
        }

    }
1147414
public Script addScript(String name, String script) throws Exception {
        int id = -1;
        PreparedStatement statement = null;
        ResultSet results = null;

        try (Connection sqlConnection = SQLService.getInstance().getConnection()) {
            statement = sqlConnection.prepareStatement(
                "INSERT INTO " + Constants.DB_TABLE_SCRIPT
                    + "(" + Constants.SCRIPT_NAME + "," + Constants.SCRIPT_SCRIPT + "," + Constants.SCRIPT_TYPE + ")"
                    + " VALUES (?, ?, ?)", PreparedStatement.RETURN_GENERATED_KEYS
            );
            statement.setString(1, name);
            statement.setString(2, script);
            statement.setInt(3, 0);
            statement.executeUpdate();

            // execute statement and get resultSet which will have the generated path ID as the first field
            results = statement.getGeneratedKeys();

            if (results.next()) {
                id = results.getInt(1);
            } else {
                // something went wrong
                throw new Exception("Could not add script");
            }
        } catch (SQLException e) {
            throw e;
        } finally {
            try {
                if (results != null) {
                    results.close();
                }
            } catch (Exception e) {
            }
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (Exception e) {
            }
        }

        return this.getScript(id);
    }
321788
public function addScript(string $name, AbstractScript $script): self
    {
        if (!\strlen($name)) {
            throw new InvalidException('The name of a Script is required and must be a string');
        }
        $this->setParam($name, $script);

        return $this;
    }
340422
private void executeMethod(String script) {
    parent.assertConnected();
    debugger.callFunctionOnObject(script, objectId, false);
  }
1188915
@RequestMapping(value = "/api/scripts", method = RequestMethod.GET)
    public
    @ResponseBody
    HashMap<String, Object> getScripts(Model model,
                                       @RequestParam(required = false) Integer type) throws Exception {
        Script[] scripts = ScriptService.getInstance().getScripts(type);
        return Utils.getJQGridJSON(scripts, "scripts");
    }
518008
public Script getScriptSig() throws ScriptException {
        // Transactions that generate new coins don't actually have a script. Instead this
        // parameter is overloaded to be something totally different.
        Script script = scriptSig == null ? null : scriptSig.get();
        if (script == null) {
            script = new Script(scriptBytes);
            scriptSig = new WeakReference<>(script);
        }
        return script;
    }
49051
@Deprecated
    @Override
    public void addModel(String name, Object value) {
        getInvocation().addModel(name, value);
    }
258990
private void initScriptClasses(Set<Class<?>> classes)throws Exception
	{
		Set<Class<? extends S>> scriptClass=findScriptClass(classes);
		Set<Class<? extends S>> instanceAbleScript = findInstanceAbleScript(scriptClass);
		Map<String, Class<? extends S>> nameMap_ = new HashMap<String, Class<? extends S>>();
		Map<Integer, Class<? extends S>> idMap_ = new HashMap<Integer, Class<? extends S>>();
		for(Class<? extends S> clazz:instanceAbleScript)
		{
			registScript(clazz, nameMap_, idMap_);
		}
		this.idMap.clear();
		this.nameMap.clear();
		this.idMap.putAll(idMap_);
		this.nameMap.putAll(nameMap_);
		_log.info("loadScriptClass complete,id mapping size:"+idMap.size()+",name mapping size:"+nameMap.size());
	}
629883
public static CompiledScript compile(ScriptEngine engine, String script) throws ScriptException {
		if (engine instanceof Compilable) {
			Compilable compEngine = (Compilable) engine;
			return compEngine.compile(script);
		}
		return null;
	}