use of org.apache.sling.servlets.post.impl.helper.DateParser in project sling by apache.
the class SlingPostServlet method configure.
@Modified
private void configure(final Config configuration) {
this.baseVersioningConfiguration = createBaseVersioningConfiguration(configuration);
final DateParser dateParser = new DateParser();
final String[] dateFormats = configuration.servlet_post_dateFormats();
for (String dateFormat : dateFormats) {
try {
dateParser.register(dateFormat);
} catch (Throwable t) {
log.warn("configure: Ignoring DateParser format {} because it is invalid: {}", dateFormat, t);
}
}
final String[] nameHints = configuration.servlet_post_nodeNameHints();
final int nameMax = configuration.servlet_post_nodeNameMaxLength();
final NodeNameGenerator nodeNameGenerator = new DefaultNodeNameGenerator(nameHints, nameMax);
final String paramMatch = configuration.servlet_post_ignorePattern();
final Pattern paramMatchPattern = Pattern.compile(paramMatch);
this.modifyOperation.setDateParser(dateParser);
this.modifyOperation.setDefaultNodeNameGenerator(nodeNameGenerator);
this.modifyOperation.setIgnoredParameterNamePattern(paramMatchPattern);
if (this.importOperation != null) {
this.importOperation.setDefaultNodeNameGenerator(nodeNameGenerator);
this.importOperation.setIgnoredParameterNamePattern(paramMatchPattern);
}
}
use of org.apache.sling.servlets.post.impl.helper.DateParser in project sling by apache.
the class AbstractAuthorizablePostServlet method activate.
// ---------- SCR Integration ----------------------------------------------
protected void activate(Map<String, Object> props) {
dateParser = new DateParser();
String[] dateFormats = OsgiUtil.toStringArray(props.get(PROP_DATE_FORMAT));
for (String dateFormat : dateFormats) {
dateParser.register(dateFormat);
}
}
Aggregations