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 base.json.Json;
 
 import static base.jee.api.cassandra.util.Log.log;

Return the personal details associated with a particular person. A user may only lookup the details associated with their own account unless they have the Types.PERSON_MANAGE permission.
 
 public class GetPersonByEmail extends Query<Person> {
 
 	private CassandraAPI api;
 	private User user;
 	private String email;
 
 	public GetPersonByEmail(CassandraAPI apiUser userString emailthrows PermissionException {
 
 		if(api == null) {
 			throw new IllegalArgumentException("Invalid parameter: api");
 		}
 		if(user == null || !user.isAuthenticated()) {
 			throw new PermissionException(getClass().getSimpleName(), user"Authenticate before invoking this command."null);
 		}
 
 		this. = api;
 		this. = user;
 		this. = email;
 	}
 
 	public GetPersonByEmail() {
 	}
 
 	public Query<PersonnewWithParameters(Map<StringObjectparametersthrows PermissionException {
 		return new GetPersonByEmail(
 				(CassandraAPI)parameters.get("api"),
 				(User)parameters.get("user"),
 				(String)parameters.get("email"));
 	}
 
 	public List<Personexecute() throws IOException {
 		List<Personresults = new LinkedList<>();
 
 			log(s"WARN""Permission denied invoking: " + GetPersonByEmail.class.getSimpleName() + " " + getJsonParameters());
 			throw new PermissionException(this.getClass().getSimpleName(), "You do not have permission to view this persons account details.".);
 		}
 
 				"select uuid, first_name, last_name, email, username, last_auth, last_auth_ip, created, updated, expiry "+
 				"from  person "+
 						"where email = ?");
 		for(Row r : s.execute(q.bind())) {
 			Person p = new Person();
 			p.setUuid(r.getUUID(0));
 			p.setEmail(r.getString(3));
 			if(r.getLong(5) != 0) {
 				p.setLastAuth(new Date(r.getLong(5)));
 			}
 			p.setCreated(new Date(r.getLong(7)));
 			p.setUpdated(new Date(r.getLong(8)));
 			if(r.getLong(9) > 0) {
 				p.setExpiry(new Date(r.getLong(9)));
 			}
 			results.add(p);
 		}
 
 		return results;
 	}
 
		return "{" +
				"\"person\":" + .getPersonUuid() + "," +
				"\"email\":\"" + Json.escape() + "\"" +
				"}";
	}
New to GrepCode? Check out our FAQ X