}
private void entityCommand(CommandLine commandLine)
throws IvoryCLIException, IOException {
String ivoryUrl = getIvoryEndpoint(commandLine);
IvoryClient client = new IvoryClient(ivoryUrl);
Set<String> optionsList = new HashSet<String>();
for (Option option : commandLine.getOptions()) {
optionsList.add(option.getOpt());
}
String result = null;
String entityType = commandLine.getOptionValue(ENTITY_TYPE_OPT);
String entityName = commandLine.getOptionValue(ENTITY_NAME_OPT);
String filePath = commandLine.getOptionValue(FILE_PATH_OPT);
String colo = commandLine.getOptionValue(COLO_OPT);
validateEntityType(optionsList, entityType);
if (optionsList.contains(SUBMIT_OPT)) {
validateFilePath(optionsList, filePath);
validateColo(optionsList);
result = client.submit(entityType, filePath);
} else if (optionsList.contains(UPDATE_OPT)) {
validateFilePath(optionsList, filePath);
validateColo(optionsList);
validateEntityName(optionsList, entityName);
result = client.update(entityType, entityName, filePath);
} else if (optionsList.contains(SUBMIT_AND_SCHEDULE_OPT)) {
validateFilePath(optionsList, filePath);
validateColo(optionsList);
result = client.submitAndSchedule(entityType, filePath);
} else if (optionsList.contains(VALIDATE_OPT)) {
validateFilePath(optionsList, filePath);
validateColo(optionsList);
result = client.validate(entityType, filePath);
} else if (optionsList.contains(SCHEDULE_OPT)) {
validateEntityName(optionsList, entityName);
colo = getColo(colo);
result = client.schedule(entityType, entityName, colo);
} else if (optionsList.contains(SUSPEND_OPT)) {
validateEntityName(optionsList, entityName);
colo = getColo(colo);
result = client.suspend(entityType, entityName, colo);
} else if (optionsList.contains(RESUME_OPT)) {
validateEntityName(optionsList, entityName);
colo = getColo(colo);
result = client.resume(entityType, entityName, colo);
} else if (optionsList.contains(DELETE_OPT)) {
validateColo(optionsList);
validateEntityName(optionsList, entityName);
result = client.delete(entityType, entityName);
} else if (optionsList.contains(STATUS_OPT)) {
validateEntityName(optionsList, entityName);
colo = getColo(colo);
result = client.getStatus(entityType, entityName, colo);
} else if (optionsList.contains(DEFINITION_OPT)) {
validateColo(optionsList);
validateEntityName(optionsList, entityName);
result = client.getDefinition(entityType, entityName);
} else if (optionsList.contains(DEPENDENCY_OPT)) {
validateColo(optionsList);
validateEntityName(optionsList, entityName);
result = client.getDependency(entityType, entityName);
} else if (optionsList.contains(LIST_OPT)) {
validateColo(optionsList);
result = client.getEntityList(entityType);
} else if (optionsList.contains(HELP_CMD)) {
OUT_STREAM.println("Ivory Help");
} else {
throw new IvoryCLIException("Invalid command");
}