use of org.fagu.fmv.soft.find.SoftFound in project fmv by f-agu.
the class JavaSoftProviderTestCase method testFind.
/**
*/
@Test
@Ignore
public void testFind() {
Soft java = Java.search();
for (SoftFound softFound : java.getFounds()) {
System.out.println(softFound);
}
System.out.println();
System.out.println(java);
}
use of org.fagu.fmv.soft.find.SoftFound in project fmv by f-agu.
the class PdfInfoSoftProviderTestCase method assertInfo.
/**
* @param parser
* @param expectedVersion
* @throws IOException
*/
private void assertInfo(Parser parser, Version expectedVersion) throws IOException {
SoftFound softFound = parser.closeAndParse("", 0);
VersionSoftInfo softInfo = (VersionSoftInfo) softFound.getSoftInfo();
assertEquals(expectedVersion, softInfo.getVersion().orElse(null));
}
use of org.fagu.fmv.soft.find.SoftFound in project fmv by f-agu.
the class SoftLogger method logDetails.
/**
* @param formatConsumer
*/
public SoftLogger logDetails(Consumer<String> formatConsumer) {
int maxLength = getNameMaxLength() + 3;
for (Soft soft : softs) {
Founds founds = soft.getFounds();
String name = soft.getName();
SoftFound firstFound = founds.getFirstFound();
SoftProvider softProvider = soft.getSoftProvider();
if (founds.isFound()) {
toLine(startLine(maxLength, name, firstFound), softProvider, firstFound, formatConsumer);
} else {
if (founds.isEmpty()) {
toLine(startLine(maxLength, name, firstFound), softProvider, SoftFound.notFound(), formatConsumer);
} else {
int index = 0;
for (SoftFound softFound : founds) {
toLine(startLine(maxLength, 0 == index++ ? name : null, softFound), softProvider, softFound, formatConsumer);
}
}
String downloadURL = softProvider.getDownloadURL();
if (downloadURL != null && !"".equals(downloadURL.trim())) {
formatConsumer.accept(" Download " + name + " at " + downloadURL + " and add the path in your system environment PATH");
}
}
}
return this;
}
use of org.fagu.fmv.soft.find.SoftFound in project fmv by f-agu.
the class SoftSearch method search.
/**
* @param softFoundFactory
* @return
*/
public Soft search(SoftFoundFactory softFoundFactory) {
checkUsed();
SoftLocator locator = getLocator();
Founds founds = locator.find((file, loc, softPol) -> {
try {
SoftFound softFound = softFoundFactory.create(file, loc, softPol);
if (softFound == null) {
return SoftFound.foundBadSoft(file);
}
return softFound;
} catch (IOException e) {
return SoftFound.foundError(file, e.getMessage()).setLocalizedBy(locator.toString());
}
});
return createAndfireEventFound(founds, locator);
}
use of org.fagu.fmv.soft.find.SoftFound 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);
}
}
Aggregations