protected void checkFieldPresent(String fieldName, String fieldValue) { if(StringUtils.isBlank(fieldValue)) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, fieldName + " can not be empty"); } }
@Override public RaptureQueryResult runNativeQuery(String repoType, List<String> queryParams) { if (repoType.toUpperCase().equals("FILE")) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Not yet implemented"); } else { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_BAD_REQUEST, "RepoType mismatch. Repo is of type FILE, asked for " + repoType); } }
public static void register(String name, HoseFactory factory) { if (name2hose.put(name, factory) != null) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_BAD_REQUEST, "Duplicate function definition "+name); } } }
public static <T> T objectFromJson(JsonNode json, Class<T> klass) { T object; if (klass == null) { throw RaptureExceptionFactory.create("Null class given to objectFromJson"); } try { object = DEFAULT_MAPPER.convertValue(json, klass); } catch (RuntimeException e) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Error making " + klass.getName() + " object from json " + json, e); } return object; }
public static <T> T objectFromJson(String json, TypeReference<T> tr) { T object; try { object = DEFAULT_MAPPER.readValue(json, tr); } catch (IOException | RuntimeException e) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Error parsing json content from TR " + json, e); } return object; }
<T extends BaseDispatcher> DispatchScriptFunction(Class<T> klass) { try { this.dispatcher = klass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, Messages.getMessage("Api", "ErrorInitDispatch", null, null), e); } }
<T extends BaseDispatcher> DispatchSysFunction(Class<T> klass) { try { this.dispatcher = klass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, Messages.getMessage("Api", "ErrorInitDispatch", null, null), e); } }
<T extends BaseDispatcher> DispatchEnvironmentFunction(Class<T> klass) { try { this.dispatcher = klass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, Messages.getMessage("Api", "ErrorInitDispatch", null, null), e); } }
<T extends BaseDispatcher> DispatchDecisionFunction(Class<T> klass) { try { this.dispatcher = klass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, Messages.getMessage("Api", "ErrorInitDispatch", null, null), e); } }
private static SQLStore createSQLStore(int storeToken, String instanceName, Map<String, String> config) { if (sqlStoreImplementationMap.containsKey(storeToken)) { return getSQLStore(sqlStoreImplementationMap.get(storeToken), instanceName, config); } else { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Unsupported sql store type"); } }
<T extends BaseDispatcher> DispatchPipelineFunction(Class<T> klass) { try { this.dispatcher = klass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, Messages.getMessage("Api", "ErrorInitDispatch", null, null), e); } }
<T extends BaseDispatcher> DispatchSearchFunction(Class<T> klass) { try { this.dispatcher = klass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, Messages.getMessage("Api", "ErrorInitDispatch", null, null), e); } }
public static CronParser create(String cronSpec) { try { MultiCronParser result = new MultiCronParser(cronSpec); if (result.cronList.isEmpty()) { throw new Exception("all empty"); } return result; } catch (Exception ex) { throw RaptureExceptionFactory.create("Unsupported cron specification: " + cronSpec); } } /**
public static <T extends Storable> T read(JsonContent string, Class<T> storableClass, ObjectMapper mapper) { String json = string.getContent(); try { return mapper.readValue(json, storableClass); } catch (IOException e) { throw RaptureExceptionFactory .create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Error making " + storableClass.getName() + " object from json " + json, e); } }
<T extends BaseDispatcher> DispatchJarFunction(Class<T> klass) { try { this.dispatcher = klass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, Messages.getMessage("Api", "ErrorInitDispatch", null, null), e); } }
private static IStatStore createStatStore(int storeToken, Map<String, String> config) { if (implementationMap.containsKey(storeToken)) { return getStat(implementationMap.get(storeToken), config); } else { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Unsupported stat store type " + storeToken); } }
@Override public void resetIdGen(Long number) { File file = FileRepoUtils.makeGenericFile(parentDir, instanceName); try { FileUtils.writeStringToFile(file, "" + number); } catch (NumberFormatException | IOException e) { throw RaptureExceptionFactory.create("Cannot update idgen storage " + file.getName(), e); } }
<T extends BaseDispatcher> DispatchAsyncFunction(Class<T> klass) { try { this.dispatcher = klass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, Messages.getMessage("Api", "ErrorInitDispatch", null, null), e); } }
@Override public void setConfig(Map<String, String> config) { // What happens if this is called twice? if (parentDir != null) throw RaptureExceptionFactory.create("Calling setConfig twice is currently not supported"); String prefix = config.get(FileRepoUtils.PREFIX); if (StringUtils.trimToNull(prefix) == null) throw RaptureExceptionFactory.create("prefix must be specified"); parentDir = FileRepoUtils.ensureDirectory(prefix + "_series"); }
public static String decode(String encoded) { try { return URIUtil.decode(encoded, CharEncoding.UTF_8); } catch (URIException e) { throw RaptureExceptionFactory.create(String.format("Error decoding step name %s:", encoded), e); } }