protected void checkFieldPresent(String fieldName, String fieldValue) { if(StringUtils.isBlank(fieldValue)) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, fieldName + " can not be empty"); } }
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); } } }
<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); } }
<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); } }
<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); } }
public static void validate(Workflow workflow) { Set<Step> check = Sets.newHashSet(); for (Step step : workflow.getSteps()) { if (!check.add(step)) { throw RaptureExceptionFactory.create(HttpStatus.SC_BAD_REQUEST, String.format("duplicateStep name '%s' not allowed", step.getName())); } } validateArgs(workflow.getExpectedArguments()); }
/** * decode external name (format is <code>@authority:path/to/series</code>) */ public static LoadHose make(String in) { String parts[] = in.split(":"); if (parts.length < 2) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_BAD_REQUEST, "Illegal syntax in path description"); } RaptureURI seriesURI = RaptureURI.builder(Scheme.SERIES, parts[0].substring(1)).docPath(parts[1]).build(); return new LoadHose(seriesURI); }
@Override public void createProcedureCallUsingSql(CallingContext context, String procUri, String rawSql) { RaptureURI uri = new RaptureURI(procUri); StructuredRepo repo = getRepoOrFail(uri.getAuthority()); registerWithTxManager(context, repo); try { repo.createProcedureCallUsingSql(context, rawSql); } catch (Exception e) { TransactionManager.transactionFailed(getTxId(context)); throw RaptureExceptionFactory.create(e.getMessage(), e.getCause()); } }
@Override public BlobRepoConfig getBlobRepoConfig(CallingContext context, String blobRepoUri) { RaptureURI uri = new RaptureURI(blobRepoUri, BLOB); if (uri.hasDocPath()) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_BAD_REQUEST, apiMessageCatalog.getMessage("NoDocPath", blobRepoUri)); //$NON-NLS-1$ } return BlobRepoConfigStorage.readByAddress(uri); }
private void installItem(CallingContext ctx, PluginTransportItem item) { RaptureURI uri = new RaptureURI(item.getUri(), null); if (isRepository(uri)) return; log.info("Installing plugin item: " + uri.toShortString()); RaptureInstaller installer = isRaw(uri) ? scheme2rawInstaller.get(uri.getScheme()) : scheme2installer.get(uri.getScheme()); if (installer == null) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_BAD_REQUEST, "Unknown install type: " + uri.getScheme()); } installer.install(ctx, uri, item); log.info("Done installing plugin item: " + uri.toString()); }
@Override public void dropTable(CallingContext context, String tableUri) { RaptureURI uri = new RaptureURI(tableUri, Scheme.STRUCTURED); StructuredRepo repo = getRepoOrFail(uri.getAuthority()); registerWithTxManager(context, repo); try { repo.dropTable(uri.getDocPath()); } catch (Exception e) { TransactionManager.transactionFailed(getTxId(context)); throw RaptureExceptionFactory.create(e.getMessage(), e.getCause()); } }
private void registerWithTxManager(CallingContext context, StructuredRepo repo) { String txId = getTxId(context); if (TransactionManager.isTransactionFailed(txId)) { throw RaptureExceptionFactory.create("Transaction " + txId + " already failed, abort now"); } if (TransactionManager.isTransactionActive(txId)) { TransactionManager.registerThread(txId); TransactionManager.registerRepo(txId, repo); } }
@Override public void deleteStructuredRepo(CallingContext context, String repoURI) { RaptureURI uri = new RaptureURI(repoURI, Scheme.STRUCTURED); if (uri.hasDocPath()) { throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_BAD_REQUEST, apiMessageCatalog.getMessage("NoDocPath", repoURI)); //$NON-NLS-1$ } getRepoOrFail(uri.getAuthority()).drop(); removeRepoFromCache(uri.getAuthority()); StructuredRepoConfigStorage.deleteByAddress(uri, context.getUser(), "Delete structured repo"); }