in src/main/java/org/apache/sling/feature/extension/apiregions/analyser/CheckDeprecatedApi.java [92:160]
private void checkBundlesForRegion(final AnalyserTaskContext context,
final ApiRegion region,
final Map<BundleDescriptor, Set<String>> bundleRegions,
final boolean strict,
final int removalPeriod) {
final Calendar checkDate;
if ( removalPeriod > 0 ) {
checkDate = Calendar.getInstance();
checkDate.set(Calendar.HOUR_OF_DAY, 23);
checkDate.set(Calendar.MINUTE, 59);
checkDate.add(Calendar.DAY_OF_YEAR, removalPeriod);
} else {
checkDate = null;
}
final Set<ApiExport> exports = this.calculateDeprecatedPackages(region, bundleRegions);
final Set<String> allowedNames = getAllowedRegions(region);
for(final BundleDescriptor bd : context.getFeatureDescriptor().getBundleDescriptors()) {
if ( isInAllowedRegion(bundleRegions.get(bd), region.getName(), allowedNames) ) {
for(final PackageInfo pi : bd.getImportedPackages()) {
final VersionRange importRange = pi.getPackageVersionRange();
DeprecationInfo deprecationInfo = null;
for(final ApiExport exp : exports) {
if ( pi.getName().equals(exp.getName()) ) {
String version = exp.getProperties().get(PROP_VERSION);
if ( version == null || importRange == null || importRange.includes(new Version(version)) ) {
deprecationInfo = exp.getDeprecation().getPackageInfo();
break;
}
}
}
if ( deprecationInfo != null ) {
String msg = "Usage of deprecated package found : ".concat(pi.getName()).concat(" : ").concat(deprecationInfo.getMessage());
if ( deprecationInfo.getSince() != null ) {
msg = msg.concat(" Deprecated since ").concat(deprecationInfo.getSince());
}
boolean isError;
if ( deprecationInfo.getMode() != null ) {
isError = deprecationInfo.getMode() == DeprecationValidationMode.STRICT;
} else {
isError = strict;
}
if ( deprecationInfo.isForRemoval() ) {
boolean printRemoval = true;
if ( checkDate != null ) {
final Calendar c = deprecationInfo.getForRemovalBy();
if ( c != null && c.before(checkDate)) {
isError = true;
printRemoval = false;
msg = msg.concat(" The package is scheduled to be removed in less than ").concat(String.valueOf(removalPeriod)).concat(" days by ").concat(deprecationInfo.getForRemoval());
}
}
if ( printRemoval ) {
msg = msg.concat(" For removal : ").concat(deprecationInfo.getForRemoval());
}
}
if ( isError ) {
context.reportArtifactError(bd.getArtifact().getId(), msg);
} else {
context.reportArtifactWarning(bd.getArtifact().getId(), msg);
}
}
}
}
}
}