use of io.hops.hopsworks.exceptions.InvalidQueryException in project hopsworks by logicalclocks.
the class AbstractFacade method getDate.
public Date getDate(String field, String value) {
String[] formats = { "yyyy-MM-dd'T'HH:mm:ss.SSSX", "yyyy-MM-dd'T'HH:mm:ss.SSSZ", "yyyy-MM-dd'T'HH:mm:ssX", "yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm:sss", "yyyy-MM-dd" };
Date date = null;
for (int i = 0; i < formats.length && date == null; i++) {
date = getDateByFormat(value, formats[i]);
}
if (date == null) {
throw new InvalidQueryException("Filter value for " + field + " needs to set valid format. Expected:yyyy-MM-dd hh:mm:ss.SSSX but found: " + value);
}
return date;
}
use of io.hops.hopsworks.exceptions.InvalidQueryException in project hopsworks by logicalclocks.
the class UserFacade method getTypeValue.
private UserAccountType getTypeValue(String field, String value) {
if (value == null || value.isEmpty()) {
throw new InvalidQueryException("Filter value for " + field + " needs to set an Integer or a valid " + field + ", but found: " + value);
}
UserAccountType val;
try {
int v = Integer.parseInt(value);
val = UserAccountType.fromValue(v);
} catch (IllegalArgumentException e) {
try {
val = UserAccountType.valueOf(value);
} catch (IllegalArgumentException ie) {
throw new InvalidQueryException("Filter value for " + field + " needs to set an Integer or a valid " + field + ", but found: " + value);
}
}
return val;
}
use of io.hops.hopsworks.exceptions.InvalidQueryException in project hopsworks by logicalclocks.
the class JobFacade method getJobStates.
private Set<JobState> getJobStates(String field, String values) {
String[] jobStatesArr = values.split(",");
Set<JobState> jobStates = new HashSet<>();
for (String jobState : jobStatesArr) {
try {
jobStates.add(JobState.valueOf(jobState.trim().toUpperCase()));
} catch (IllegalArgumentException ie) {
throw new InvalidQueryException("Filter value for " + field + " needs to set a valid " + field + ", but found: " + jobState);
}
}
if (jobStates.isEmpty()) {
throw new InvalidQueryException("Filter value for " + field + " needs to set valid job state, but found: " + values);
}
return jobStates;
}
use of io.hops.hopsworks.exceptions.InvalidQueryException in project hopsworks by logicalclocks.
the class JobFacade method getJobTypes.
public static Set<JobType> getJobTypes(String field, String values) {
String[] jobTypesArr = values.split(",");
Set<JobType> jobTypes = new HashSet<>();
for (String jobType : jobTypesArr) {
try {
jobTypes.add(JobType.valueOf(jobType.trim().toUpperCase()));
} catch (IllegalArgumentException ie) {
throw new InvalidQueryException("Filter value for " + field + " needs to set a valid " + field + ", but found: " + jobType);
}
}
if (jobTypes.isEmpty()) {
throw new InvalidQueryException("Filter value for " + field + " needs to set valid job types, but found: " + values);
}
return jobTypes;
}
use of io.hops.hopsworks.exceptions.InvalidQueryException in project hopsworks by logicalclocks.
the class UserFacade method getStatusValue.
private UserAccountStatus getStatusValue(String field, String value) {
if (value == null || value.isEmpty()) {
throw new InvalidQueryException("Filter value for " + field + " needs to set an Integer or a valid " + field + ", but found: " + value);
}
UserAccountStatus val;
try {
int v = Integer.parseInt(value);
val = UserAccountStatus.fromValue(v);
} catch (IllegalArgumentException e) {
try {
val = UserAccountStatus.valueOf(value);
} catch (IllegalArgumentException ie) {
throw new InvalidQueryException("Filter value for " + field + " needs to set an Integer or a valid " + field + ", but found: " + value);
}
}
return val;
}
Aggregations