Search in sources :

Example 1 with DateParser

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);
    }
}
Also used : DateParser(org.apache.sling.servlets.post.impl.helper.DateParser) DefaultNodeNameGenerator(org.apache.sling.servlets.post.impl.helper.DefaultNodeNameGenerator) Pattern(java.util.regex.Pattern) DefaultNodeNameGenerator(org.apache.sling.servlets.post.impl.helper.DefaultNodeNameGenerator) NodeNameGenerator(org.apache.sling.servlets.post.NodeNameGenerator) Modified(org.osgi.service.component.annotations.Modified)

Example 2 with DateParser

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);
    }
}
Also used : DateParser(org.apache.sling.servlets.post.impl.helper.DateParser)

Aggregations

DateParser (org.apache.sling.servlets.post.impl.helper.DateParser)2 Pattern (java.util.regex.Pattern)1 NodeNameGenerator (org.apache.sling.servlets.post.NodeNameGenerator)1 DefaultNodeNameGenerator (org.apache.sling.servlets.post.impl.helper.DefaultNodeNameGenerator)1 Modified (org.osgi.service.component.annotations.Modified)1