use of org.apache.commons.lang3.StringUtils.isBlank in project nifi-registry by apache.
the class RegistryService method getFlows.
public List<VersionedFlow> getFlows(final String bucketId) {
if (StringUtils.isBlank(bucketId)) {
throw new IllegalArgumentException("Bucket identifier cannot be null");
}
readLock.lock();
try {
final BucketEntity existingBucket = metadataService.getBucketById(bucketId);
if (existingBucket == null) {
LOGGER.warn("The specified bucket id [{}] does not exist.", bucketId);
throw new ResourceNotFoundException("The specified bucket ID does not exist in this registry.");
}
// return non-verbose set of flows for the given bucket
final List<FlowEntity> flows = metadataService.getFlowsByBucket(existingBucket.getId());
return flows.stream().map(f -> DataModelMapper.map(existingBucket, f)).collect(Collectors.toList());
} finally {
readLock.unlock();
}
}
use of org.apache.commons.lang3.StringUtils.isBlank in project sponge by softelnet.
the class StandaloneEngineBuilder method build.
/**
* Returns a new StandaloneEngine or {@code null} if help or version option is specified so the application should exit.
*/
@Override
public StandaloneSpongeEngine build() {
try {
if (commandLineArgs == null) {
return super.build();
}
CommandLineParser parser = new DefaultParser();
CommandLine commandLine = parser.parse(options, commandLineArgs);
if (commandLine.hasOption(OPTION_HELP)) {
printHelp();
return null;
}
if (commandLine.hasOption(OPTION_VERSION)) {
System.out.println(getDescription());
return null;
}
if (commandLine.hasOption(OPTION_CONFIG)) {
config(commandLine.getOptionValue(OPTION_CONFIG));
}
if (Stream.of(commandLine.getOptions()).filter(option -> option.getOpt().equals(OPTION_CONFIG)).count() > 1) {
throw new StandaloneInitializationException("Only one Sponge XML configuration file may be provided.");
}
Stream.of(commandLine.getOptions()).filter(option -> option.getOpt().equals(OPTION_KNOWLEDGE_BASE)).forEachOrdered(option -> {
String value = option.getValue();
if (value == null || StringUtils.isBlank(value)) {
throw new StandaloneInitializationException("Empty knowledge base specification.");
}
String[] values = StringUtils.split(value, ARGUMENT_VALUE_SEPARATOR);
String kbName = values.length == 2 ? values[0] : DEFAULT_KNOWLEDGE_BASE_NAME;
String kbFilesString = values.length == 2 ? values[1] : values[0];
if (StringUtils.isBlank(kbName)) {
throw new StandaloneInitializationException("Empty knowledge base name.");
}
List<String> kbFiles = SpongeUtils.split(kbFilesString, KB_FILES_SEPARATOR);
knowledgeBase(kbName, kbFiles.toArray(new String[kbFiles.size()]));
});
if (!commandLine.hasOption(OPTION_CONFIG) && !commandLine.hasOption(OPTION_KNOWLEDGE_BASE)) {
throw new StandaloneInitializationException("An Sponge XML configuration file or a knowledge base file(s) should be provided.");
}
// Apply standard parameters.
super.build();
applyDefaultParameters();
if (commandLine.hasOption(OPTION_INTERACTIVE)) {
InteractiveMode interactiveMode = new DefaultInteractiveMode(engine, commandLine.getOptionValue(OPTION_INTERACTIVE), interactiveModeConsoleSupplier);
ExceptionHandler interactiveExceptionHandler = new SystemErrExceptionHandler();
interactiveMode.setExceptionHandler(interactiveExceptionHandler);
engine.setInteractiveMode(interactiveMode);
if (commandLine.hasOption(OPTION_PRINT_ALL_EXCEPTIONS)) {
engine.setExceptionHandler(new CombinedExceptionHandler(interactiveExceptionHandler, new LoggingExceptionHandler()));
} else {
LoggingUtils.logToConsole(false);
}
} else {
if (commandLine.hasOption(OPTION_PRINT_ALL_EXCEPTIONS)) {
throw new StandaloneInitializationException("'" + OPTION_PRINT_ALL_EXCEPTIONS + "' option may be used only if '" + OPTION_INTERACTIVE + "' is also used.");
}
}
StandaloneEngineListener standaloneListener = new StandaloneEngineListener(engine);
List<String> springConfigurationFiles = Stream.of(commandLine.getOptions()).filter(option -> option.getOpt().equals(OPTION_SPRING)).map(option -> {
String[] values = option.getValues();
if (values == null || values.length == 0) {
throw new StandaloneInitializationException("No Spring configuration file provided.");
}
return option.getValue(0);
}).collect(Collectors.toList());
if (!springConfigurationFiles.isEmpty()) {
standaloneListener.setSpringConfigurations(springConfigurationFiles);
}
if (commandLine.hasOption(OPTION_CAMEL)) {
standaloneListener.setCamel(true);
}
engine.addOnStartupListener(standaloneListener);
engine.addOnShutdownListener(standaloneListener);
} catch (ParseException e) {
throw new StandaloneInitializationException(e.getMessage(), e);
}
return engine;
}
use of org.apache.commons.lang3.StringUtils.isBlank in project timbuctoo by HuygensING.
the class RdfUpload method upload.
@Consumes(MediaType.MULTIPART_FORM_DATA)
@POST
public Response upload(@FormDataParam("file") final InputStream rdfInputStream, @FormDataParam("file") final FormDataBodyPart body, @FormDataParam("fileMimeTypeOverride") final MediaType mimeTypeOverride, @FormDataParam("encoding") final String encoding, @FormDataParam("baseUri") final URI baseUri, @FormDataParam("defaultGraph") final URI defaultGraph, @HeaderParam("authorization") final String authHeader, @PathParam("userId") final String userId, @PathParam("dataSet") final String dataSetId, @QueryParam("forceCreation") boolean forceCreation, @QueryParam("async") final boolean async) throws ExecutionException, InterruptedException, LogStorageFailedException, DataStoreCreationException {
final Either<Response, Response> result = authCheck.getOrCreate(authHeader, userId, dataSetId, forceCreation).flatMap(userAndDs -> authCheck.hasAdminAccess(userAndDs.getLeft(), userAndDs.getRight())).map((Tuple<User, DataSet> userDataSetTuple) -> {
final MediaType mediaType = mimeTypeOverride == null ? body.getMediaType() : mimeTypeOverride;
final DataSet dataSet = userDataSetTuple.getRight();
ImportManager importManager = dataSet.getImportManager();
if (mediaType == null || !importManager.isRdfTypeSupported(mediaType)) {
return Response.status(Response.Status.BAD_REQUEST).type(MediaType.APPLICATION_JSON_TYPE).entity("{\"error\": \"We do not support the mediatype '" + mediaType + "'. Make sure to add the correct " + "mediatype to the file parameter. In curl you'd use `-F \"file=@<filename>;type=<mediatype>\"`. In a " + "webbrowser you probably have no way of setting the correct mimetype. So you can use a special " + "parameter " + "to override it: `formData.append(\"fileMimeTypeOverride\", \"<mimetype>\");`\"}").build();
}
if (StringUtils.isBlank(encoding)) {
return Response.status(Response.Status.BAD_REQUEST).entity("Please provide an 'encoding' parameter").build();
}
if (StringUtils.isBlank(body.getContentDisposition().getFileName())) {
return Response.status(400).entity("filename cannot be empty.").build();
}
Future<ImportStatus> promise = null;
try {
promise = importManager.addLog(baseUri == null ? dataSet.getMetadata().getBaseUri() : baseUri.toString(), defaultGraph == null ? dataSet.getMetadata().getBaseUri() : defaultGraph.toString(), body.getContentDisposition().getFileName(), rdfInputStream, Optional.of(Charset.forName(encoding)), mediaType);
} catch (LogStorageFailedException e) {
return Response.serverError().build();
}
if (!async) {
return handleImportManagerResult(promise);
}
return Response.accepted().build();
});
if (result.isLeft()) {
return result.getLeft();
} else {
return result.get();
}
}
use of org.apache.commons.lang3.StringUtils.isBlank in project dwoss by gg-net.
the class GenerateOnePriceAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
Ui.exec(() -> {
Ui.build().title("Bitte SopoNr eingeben :").dialog().eval(() -> {
TextInputDialog dialog = new TextInputDialog();
dialog.setContentText("Bitte SopoNr eingeben :");
return dialog;
}).opt().filter(s -> !StringUtils.isBlank(s)).map(r -> ReplyUtil.wrap(() -> Dl.remote().lookup(Exporter.class).onePrice(r))).filter(Ui.failure()::handle).map(Reply::getPayload).ifPresent(p -> Ui.build().modality(WINDOW_MODAL).title("SopoNr").fx().show(() -> Css.toHtml5WithStyle(PriceEngineResultFormater.toSimpleHtml(p)), () -> new HtmlPane()));
});
}
use of org.apache.commons.lang3.StringUtils.isBlank in project dwoss by gg-net.
the class ScrapUnitAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
Ui.exec(() -> {
Ui.build().title("SopoNr die verschrottet werden soll").dialog().eval(() -> {
TextInputDialog dialog = new TextInputDialog();
dialog.setContentText("SopoNr die verschrottet werden soll:");
return dialog;
}).opt().filter(s -> !StringUtils.isBlank(s)).ifPresent(r -> {
Ui.build().dialog().eval(() -> new Alert(CONFIRMATION, "SopoNr " + r + " wirklich verschrotten ?")).opt().filter(b -> b == OK).map(u -> ReplyUtil.wrap(() -> Dl.remote().lookup(UnitDestroyer.class).verifyScarpOrDeleteAble(r))).filter(Ui.failure()::handle).map(Reply::getPayload).ifPresent(u -> {
Ui.build().title("Bitte Grund angeben").dialog().eval(() -> {
TextInputDialog dialog = new TextInputDialog();
dialog.setContentText("Bitte Grund angeben");
dialog.getDialogPane().lookupButton(OK).disableProperty().bind(Bindings.createBooleanBinding(() -> dialog.getEditor().getText().trim().isEmpty(), dialog.getEditor().textProperty()));
return dialog;
}).opt().filter(s -> !StringUtils.isBlank(s)).ifPresent(c -> {
Dl.remote().lookup(UnitDestroyer.class).scrap(u, c, Dl.local().lookup(Guardian.class).getUsername());
Ui.build().alert().message("SopoNr " + r + " ist verschrottet.").show(AlertType.INFO);
});
});
});
});
}
Aggregations