Improved missing property check label.

This commit is contained in:
Christian P. MOMON 2020-10-30 01:29:55 +01:00
parent 4f7c1f4ee8
commit 907fd57c5d
3 changed files with 49 additions and 6 deletions

View file

@ -79,7 +79,7 @@ public class PropertyChecker
this.federationRules.add("federation.logo", URL, PropertyMode.WISHED); this.federationRules.add("federation.logo", URL, PropertyMode.WISHED);
this.federationRules.add("federation.contact.url", URL, PropertyMode.WISHED); this.federationRules.add("federation.contact.url", URL, PropertyMode.WISHED);
this.federationRules.add("federation.contact.email", EMAIL, PropertyMode.WISHED); this.federationRules.add("federation.contact.email", EMAIL, PropertyMode.WISHED);
this.federationRules.add("^federation\\.socialnetworks\\.\\S+$", URL, PropertyMode.WISHED); this.federationRules.add("federation.socialnetworks.…", "^federation\\.socialnetworks\\.\\S+$", URL, PropertyMode.WISHED);
this.federationRules.add("federation.legal.url", URL, PropertyMode.WISHED); this.federationRules.add("federation.legal.url", URL, PropertyMode.WISHED);
this.federationRules.add("federation.legal", URL, PropertyMode.WISHED); this.federationRules.add("federation.legal", URL, PropertyMode.WISHED);
this.federationRules.add("federation.guide.user", URL, PropertyMode.WISHED); this.federationRules.add("federation.guide.user", URL, PropertyMode.WISHED);
@ -111,13 +111,13 @@ public class PropertyChecker
this.organizationRules.add("organization.status.description", STRING, PropertyMode.OPTIONAL); this.organizationRules.add("organization.status.description", STRING, PropertyMode.OPTIONAL);
this.organizationRules.add("organization.website", URL, PropertyMode.WISHED); this.organizationRules.add("organization.website", URL, PropertyMode.WISHED);
this.organizationRules.add("organization.logo", URL, PropertyMode.WISHED); this.organizationRules.add("organization.logo", URL, PropertyMode.WISHED);
this.organizationRules.add("^organization\\.socialnetworks\\.\\S+$", URL, PropertyMode.WISHED); this.organizationRules.add("organization.socialnetworks.…", "^organization\\.socialnetworks\\.\\S+$", URL, PropertyMode.WISHED);
this.organizationRules.add("organization.owner.name", STRING, PropertyMode.OPTIONAL); this.organizationRules.add("organization.owner.name", STRING, PropertyMode.OPTIONAL);
this.organizationRules.add("organization.owner.website", URL, PropertyMode.OPTIONAL); this.organizationRules.add("organization.owner.website", URL, PropertyMode.OPTIONAL);
this.organizationRules.add("organization.owner.logo", URL, PropertyMode.OPTIONAL); this.organizationRules.add("organization.owner.logo", URL, PropertyMode.OPTIONAL);
this.organizationRules.add("organization.contact.url", URL, PropertyMode.WISHED); this.organizationRules.add("organization.contact.url", URL, PropertyMode.WISHED);
this.organizationRules.add("organization.contact.email", EMAIL, PropertyMode.WISHED); this.organizationRules.add("organization.contact.email", EMAIL, PropertyMode.WISHED);
this.organizationRules.add("^organization\\.legal(\\.url)?$", URL, PropertyMode.WISHED); this.organizationRules.add("organization.legal.url", "^organization\\.legal(\\.url)?$", URL, PropertyMode.WISHED);
this.organizationRules.add("organization.guide.user", URL, PropertyMode.WISHED); this.organizationRules.add("organization.guide.user", URL, PropertyMode.WISHED);
this.organizationRules.add("organization.guide.technical", URL, PropertyMode.WISHED); this.organizationRules.add("organization.guide.technical", URL, PropertyMode.WISHED);
this.organizationRules.add("organization.startdate", DATE, PropertyMode.WISHED); this.organizationRules.add("organization.startdate", DATE, PropertyMode.WISHED);
@ -147,7 +147,7 @@ public class PropertyChecker
this.serviceRules.add("service.logo", URL, PropertyMode.WISHED); this.serviceRules.add("service.logo", URL, PropertyMode.WISHED);
this.serviceRules.add("service.contact.url", URL, PropertyMode.WISHED); this.serviceRules.add("service.contact.url", URL, PropertyMode.WISHED);
this.serviceRules.add("service.contact.email", EMAIL, PropertyMode.WISHED); this.serviceRules.add("service.contact.email", EMAIL, PropertyMode.WISHED);
this.serviceRules.add("^service\\.socialnetworks\\.\\S+$", URL, PropertyMode.OPTIONAL); this.serviceRules.add("service.socialnetworks.…", "^service\\.socialnetworks\\.\\S+$", URL, PropertyMode.OPTIONAL);
this.serviceRules.add("service.legal.url", URL, PropertyMode.WISHED); this.serviceRules.add("service.legal.url", URL, PropertyMode.WISHED);
this.serviceRules.add("service.guide.user", URL, PropertyMode.WISHED); this.serviceRules.add("service.guide.user", URL, PropertyMode.WISHED);
this.serviceRules.add("service.guide.technical", URL, PropertyMode.WISHED); this.serviceRules.add("service.guide.technical", URL, PropertyMode.WISHED);
@ -226,7 +226,7 @@ public class PropertyChecker
status = Status.WARNING; status = Status.WARNING;
break; break;
} }
PropertyCheck check = new PropertyCheck(0, rule.getPathPattern().replaceAll("\\\\.", "."), status, "Propriété manquante"); PropertyCheck check = new PropertyCheck(0, rule.getLabel(), status, "Propriété manquante");
result.add(check); result.add(check);
} }
} }

View file

@ -35,6 +35,7 @@ public class PropertyRule
OPTIONAL OPTIONAL
} }
private String label;
private Pattern pathPattern; private Pattern pathPattern;
private Pattern valuePattern; private Pattern valuePattern;
private PropertyMode mode; private PropertyMode mode;
@ -50,10 +51,28 @@ public class PropertyRule
* the mode * the mode
*/ */
public PropertyRule(final String pathRegex, final String valueRegex, final PropertyMode mode) public PropertyRule(final String pathRegex, final String valueRegex, final PropertyMode mode)
{
this(pathRegex, pathRegex, valueRegex, mode);
}
/**
* Instantiates a new property rule.
*
* @param label
* the label
* @param pathRegex
* the path regex
* @param valueRegex
* the value regex
* @param mode
* the mode
*/
public PropertyRule(final String label, final String pathRegex, final String valueRegex, final PropertyMode mode)
{ {
this.pathPattern = Pattern.compile(pathRegex); this.pathPattern = Pattern.compile(pathRegex);
this.valuePattern = Pattern.compile(valueRegex); this.valuePattern = Pattern.compile(valueRegex);
this.mode = mode; this.mode = mode;
this.label = label;
} }
/** /**
@ -89,6 +108,11 @@ public class PropertyRule
return result; return result;
} }
public String getLabel()
{
return this.label;
}
public PropertyMode getMode() public PropertyMode getMode()
{ {
return this.mode; return this.mode;

View file

@ -60,7 +60,26 @@ public class PropertyRules extends ArrayList<PropertyRule>
targetPath = path.replace(".", "\\."); targetPath = path.replace(".", "\\.");
} }
PropertyRule rule = new PropertyRule(targetPath, pattern, mode); PropertyRule rule = new PropertyRule(path, targetPath, pattern, mode);
this.add(rule);
}
/**
* Adds the.
*
* @param label
* the label
* @param path
* the path
* @param pattern
* the pattern
* @param mode
* the mode
*/
public void add(final String label, final String path, final String pattern, final PropertyMode mode)
{
PropertyRule rule = new PropertyRule(label, path, pattern, mode);
this.add(rule); this.add(rule);
} }