Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Creative commons Attribution-NonCommercial license. http://creativecommons.org/licenses/by-nc/2.5/au/deed.en_GB NO WARRANTY IS GIVEN OR IMPLIED, USE AT YOUR OWN RISK.
 
 package base.jee.api.cassandra;
 
import static base.jee.api.cassandra.util.Log.log;
public class UpsertSetting extends Command {
	private CassandraAPI c;
	private User user;
	private String name;
	private String value;
	public UpsertSetting(CassandraAPI cUser userString nameString value) {
		this. = c;
		this. = name;
		this. = value;
		this. = user;
		if(c == null) {
			throw new IllegalArgumentException("Invalid parameter: c");
		}
		if(user != null && !user.isAuthenticated()) {
			throw new IllegalArgumentException("Requires an authenticated user.");
		}
		if(name == null || name.length() == 0) {
			throw new IllegalArgumentException("Invalid parameter: name");
		}
	}
	public UpsertSetting() {
	}
	public Command newWithParameters(Map<StringObjectparameters) {
		return new UpsertSetting(
				(CassandraAPI)parameters.get("api"),
				(User)parameters.get("user"),
				(String)parameters.get("name"),
				(String)parameters.get("value"));
	}
	protected void execute() throws IOException {
			log(s"WARN""Permission denied invoking: " + UpsertSetting.class.getSimpleName() + " " + getJsonParameters());
			throw new IllegalStateException("You do not have permission to manage settings.");
		}
		PreparedStatement p = s.prepare("delete from setting where name=?");
		p = s.prepare("insert into setting (name,value) values(?,?)");
		log(s"INFO""Updated setting " +  + "=" + );
	}
		return "{" +
				"\"name\":\"" + Json.escape() + "\"," +
				"\"value\":" + ( == null?"null":"\"" + Json.escape() + "\"") + "\"" +
				"}";
	}
New to GrepCode? Check out our FAQ X