use of org.fagu.fmv.soft.Soft in project fmv by f-agu.
the class XpdfExceptionKnowAnalyzeTestCase method extract.
// *************************************
/**
* @param srcResource
* @throws IOException
*/
private void extract(String srcResource, String expectedMessage) throws IOException {
File folder = new File(System.getProperty("java.io.tmpdir"), "xpdf-info-test");
try {
FileUtils.deleteDirectory(folder);
folder.mkdirs();
File srcFile = srcResource != null ? extractResource(folder, srcResource) : folder;
try {
Soft pdfInfoSoft = PdfInfo.search();
pdfInfoSoft.withParameters(srcFile.getAbsolutePath()).workingDirectory(srcFile.getParentFile()).execute();
fail();
} catch (FMVExecuteException e) {
if (e.isKnown()) {
assertEquals(expectedMessage, e.getExceptionKnown().toString());
} else {
throw e;
}
}
} finally {
FileUtils.deleteDirectory(folder);
}
}
use of org.fagu.fmv.soft.Soft in project fmv by f-agu.
the class SoftFoundHealthIndicator method doHealthCheck.
/**
* @see org.springframework.boot.actuate.health.AbstractHealthIndicator#doHealthCheck(org.springframework.boot.actuate.health.Health.Builder)
*/
@Override
protected void doHealthCheck(Builder builder) throws Exception {
Collection<Soft> softs = Softs.getHealthIndicators();
if (softs.isEmpty()) {
builder.unknown();
return;
}
builder.up();
for (Soft soft : softs) {
String msg = soft.toString();
SoftFound softFound = soft.getFounds().getFirstFound();
if (soft.isFound()) {
// recheck soft
softFound = soft.reFind();
}
if (softFound != null && !softFound.isFound()) {
builder.down();
StringJoiner joiner = new StringJoiner(", ");
soft.getFounds().forEach(f -> {
String reason = f.getReason();
if (StringUtils.isNotBlank(reason)) {
joiner.add(reason);
}
});
if (joiner.length() > 0) {
msg += ": " + joiner.toString();
}
} else if (softFound == null) {
builder.down();
}
builder.withDetail(soft.getName(), msg);
}
}
use of org.fagu.fmv.soft.Soft in project fmv by f-agu.
the class SoftInfoContributor method content.
// *********************************************
/**
* @return
*/
private Map<String, String> content() {
Map<String, String> map = new HashMap<>();
for (Soft soft : Softs.getInfoContributors()) {
String msg = null;
if (soft.isFound()) {
StringBuilder buf = new StringBuilder(100);
SoftInfo softInfo = soft.getFirstInfo();
if (softInfo instanceof VersionSoftInfo) {
((VersionSoftInfo) softInfo).getVersion().ifPresent(v -> buf.append(v).append(", "));
}
if (softInfo instanceof VersionDateSoftInfo) {
((VersionDateSoftInfo) softInfo).getDate().ifPresent(d -> {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
buf.append(dateFormat.format(d)).append(", ");
});
}
buf.append(soft.getFile().getAbsolutePath());
msg = buf.toString();
} else {
StringJoiner joiner = new StringJoiner(" ; ");
for (SoftFound softFound : soft.getFounds()) {
StringBuilder buf = new StringBuilder();
FoundReason foundReason = softFound != null ? softFound.getFoundReason() : FoundReasons.NOT_FOUND;
buf.append(foundReason.name());
String reason = softFound.getReason();
if (reason != null) {
buf.append(": ").append(reason);
}
joiner.add(buf.toString());
}
msg = joiner.toString();
}
map.put(soft.getName(), msg);
}
return map;
}
use of org.fagu.fmv.soft.Soft in project fmv by f-agu.
the class IMReducer method reduceMedia.
/**
* @see org.fagu.fmv.mymedia.reduce.Reducer#reduceMedia(java.io.File, String, Logger)
*/
@Override
public Reduced reduceMedia(File srcFile, String consolePrefixMessage, Logger logger) throws IOException {
File destFile = getTempFile(srcFile, format);
IMOperation op = new IMOperation();
op.image(srcFile, "[0]").autoOrient().quality(quality).image(destFile);
Soft convertSoft = Convert.search();
convertSoft.withParameters(op.toList()).logCommandLine(line -> logger.log("Exec: " + line)).execute();
return new Reduced(destFile, false);
}
use of org.fagu.fmv.soft.Soft in project fmv by f-agu.
the class GSExceptionKnowAnalyzeTestCase method testMerge.
/**
* @throws IOException
*/
@Test
public // @Ignore
void testMerge() throws IOException {
File folder = new File(System.getProperty("java.io.tmpdir"), "gs-merge-test");
FileUtils.deleteDirectory(folder);
folder.mkdirs();
try {
try {
Soft gsSoft = GS.search();
File viewJpegPSFile = new File(new File(gsSoft.getFile().getParentFile().getParentFile(), "lib"), "viewjpeg.ps");
File srcFile = Resource.extract(folder, "cheese.zip");
File outFile = new File(srcFile.getPath() + ".pdf");
List<String> parameters = new ArrayList<>();
parameters.add("-sDEVICE=pdfwrite");
parameters.add("-dPDFSETTINGS=/prepress");
parameters.add("-o");
parameters.add(outFile.getAbsolutePath());
parameters.add(viewJpegPSFile.getAbsolutePath());
parameters.add("-c");
parameters.add("(" + srcFile.getName() + ") viewJPEG showpage");
gsSoft.withParameters(parameters).workingDirectory(srcFile.getParentFile()).execute();
} catch (FMVExecuteException e) {
if (e.isKnown()) {
assertEquals("ddd", e.getExceptionKnown().toString());
} else {
throw e;
}
}
} finally {
FileUtils.deleteDirectory(folder);
}
}
Aggregations