@Override public boolean isAvailable() { CommandLineExecutorService cles = Framework.getService(CommandLineExecutorService.class); CommandAvailability commandAvailability = cles.getCommandAvailability("identify"); return commandAvailability.isAvailable(); }
public boolean isToolAvailable(String toolName) { String commandLine; try { VideoTool tool = (VideoTool) videoTools.get(toolName).newInstance(); commandLine = tool.getCommandLineName(); } catch (InstantiationException e) { throw new NuxeoException("The video tool is not available.", e); } catch (IllegalAccessException e) { throw new NuxeoException("The video tool is not available.", e); } CommandAvailability ca = Framework.getService(CommandLineExecutorService.class) .getCommandAvailability(commandLine); return ca.isAvailable(); }
public Blob call(Blob blob, String targetExt, String commandName) { CommandLineExecutorService cles = Framework.getService(CommandLineExecutorService.class); CommandAvailability availability = cles.getCommandAvailability(commandName); if (!availability.isAvailable()) { return null; } try { makeFiles(blob, targetExt); callImageMagick(); Blob targetBlob = Blobs.createBlob(targetFile); targetBlob.setFilename(getFilename(blob, targetExt)); Framework.trackFile(targetFile, targetBlob); return targetBlob; } catch (CommandNotAvailable | CommandException | IOException e) { log.error("ImageMagick failed on command: " + commandName, e); return null; } finally { if (tmpFile != null) { try { Files.delete(tmpFile.toPath()); } catch (IOException e) { log.error("Unable to delete temporary file when calling ImageMagick command: " + commandName, e); } } } }
if (!availability.isAvailable()) { return null;
protected Map<String, Object> readMetadata(String command, Blob blob, List<String> metadata, boolean ignorePrefix) { CommandAvailability ca = commandLineService.getCommandAvailability(command); if (!ca.isAvailable()) { throw new BinaryMetadataException("Command '" + command + "' is not available."); } if (blob == null) { throw new BinaryMetadataException("The following command " + ca + " cannot be executed with a null blob"); } try { ExecResult er; try (CloseableFile source = getTemporaryFile(blob)) { CmdParameters params = commandLineService.getDefaultCmdParameters(); params.addNamedParameter("inFilePath", source.getFile()); if (metadata != null) { params.addNamedParameter("tagList", getCommandTags(metadata)); } er = commandLineService.execCommand(command, params); } return returnResultMap(er); } catch (CommandNotAvailable commandNotAvailable) { throw new RuntimeException("Command '" + command + "' is not available.", commandNotAvailable); } catch (IOException ioException) { throw new BinaryMetadataException(ioException); } }
if (!commandAvailability.isAvailable()) { return null;
: BinaryMetadataConstants.EXIFTOOL_WRITE; CommandAvailability ca = commandLineService.getCommandAvailability(command); if (!ca.isAvailable()) { throw new BinaryMetadataException("Command '" + command + "' is not available.");