use of com.fathomdb.cli.CliException in project platformlayer by platformlayer.
the class ListJobs method formatRaw.
@Override
public void formatRaw(Object o, PrintWriter writer) {
JobDataList jobs = (JobDataList) o;
switch(getFormat()) {
case JSON:
JsonHelper<JobDataList> jsonHelper = JsonHelper.build(JobDataList.class);
boolean formatted = true;
try {
String json = jsonHelper.marshal(jobs, formatted);
writer.println(json);
return;
} catch (IOException e) {
throw new CliException("Error formatting for output", e);
}
}
Ansi ansi = new Ansi(writer);
for (JobData job : jobs.getJobs()) {
// JobState state = job.state;
// if (state != null) {
// ansi.setColorBlue();
// switch (job.state) {
// case FAILED:
// ansi.setColorRed();
// break;
//
// case SUCCESS:
// ansi.setColorGreen();
// break;
//
// case RUNNING:
// ansi.setColorBlue();
// break;
//
// default:
// ansi.setColorBlue();
// break;
// }
// }
writer.println(job.key);
}
ansi.reset();
}
use of com.fathomdb.cli.CliException in project platformlayer by platformlayer.
the class CreateUser method runCommand.
@Override
public Object runCommand() throws RepositoryException, GeneralSecurityException, IOException, OpsException {
if (password == null && keystore == null && certPath == null) {
throw new CliException("Either key or password or cert is required");
}
UserDatabase userRepository = getContext().getUserRepository();
Certificate[] certificateChain = null;
if (keystore != null) {
certificateChain = getContext().getCertificateChain(keystore, keystoreSecret, keyAlias);
} else if (certPath != null) {
certificateChain = getContext().loadCertificateChain(certPath);
}
OpsUser user = userRepository.createUser(username, password, certificateChain);
return user;
}
Aggregations