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 base.Query;
 
 
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
 
 import static base.jee.Constants.MAX_IP_ADDRESS_LENGTH;
 import static base.jee.api.cassandra.util.Log.log;

Lookup a small set of information about the person associated this token and reset the expriry time of the token. This is the minimal set of data that a user facing client (web page, or iPhone) might need to render the user interface, such as the menu bar.
 
 public class GetSession extends Query<User> {
 
 	private CassandraAPI api;
 	private String token;
 	private String ip;
 
 	public GetSession(CassandraAPI apiString tokenString ip) {
 
 		if(api == null) {
 			throw new IllegalArgumentException("Invalid parameter: api");
 		}
 		if(ip != null && ip.length() > ) {
 			throw new IllegalArgumentException("Invalid IP address.");
 		}
 
 		this. = api;
 		this. = ip;
 		this. = token == null?null:token.trim();
 	}
 
 	public GetSession() {
 	}
 
 	public Query<UsernewWithParameters(Map<StringObjectparameters) {
 		return new GetSession(
 				(CassandraAPI)parameters.get("api"),
 				(String)parameters.get("token"),
 				(String)parameters.get("ip")
 				);
 	}
 
 	public List<Userexecute() throws IOException {
 		List<Userresults = new LinkedList<>();
 
 		if( == null || .length() == 0) {
 			results.add(u);
 			return results;
 		}
 
 		Settings settings = .getSettingsCache();
 
 				"select person_uuid, first_name, last_name, roles " +
 				"from session_token " +
 				"where uid = ?");
 		for(Row r : s.execute(q.bind())) {
 			User u = new User(r.getUUID(0),
 					r.getString(1),
 					r.getString(2),
 					User.roleSet(r.getString(3)),
 					);
 			results.add(u);
 
 			q = s.prepare(
 					"update session_token " +
 					"set expiry = ? " +
 					"where uid = ?");
 			s.execute(q.bind((new Date()).getTime()/1000 + Long.parseLong(settings.get("session.expiry")), ));
 
			log(s"DEBUG"u"Fetched session details.");
			return results;
		}
		User u = User.userWithIp();
		results.add(u);
		return results;
	}
		return "{" +
			"\"token\":\"" +  + "\"," +
			"\"ip\":" + ( == null?"null":"\"" +  + "\"") +
			"}";
	}
New to GrepCode? Check out our FAQ X