Search in sources :

Example 1 with JspPropertyGroupMetaData

use of org.jboss.metadata.web.spec.JspPropertyGroupMetaData in project wildfly by wildfly.

the class UndertowDeploymentInfoService method createJspConfig.

private static HashMap<String, JspPropertyGroup> createJspConfig(JBossWebMetaData metaData) {
    final HashMap<String, JspPropertyGroup> result = new HashMap<>();
    // JSP Config
    JspConfigMetaData config = metaData.getJspConfig();
    if (config != null) {
        // JSP Property groups
        List<JspPropertyGroupMetaData> groups = config.getPropertyGroups();
        if (groups != null) {
            for (JspPropertyGroupMetaData group : groups) {
                org.apache.jasper.deploy.JspPropertyGroup jspPropertyGroup = new org.apache.jasper.deploy.JspPropertyGroup();
                for (String pattern : group.getUrlPatterns()) {
                    jspPropertyGroup.addUrlPattern(pattern);
                }
                jspPropertyGroup.setElIgnored(group.getElIgnored());
                jspPropertyGroup.setPageEncoding(group.getPageEncoding());
                jspPropertyGroup.setScriptingInvalid(group.getScriptingInvalid());
                jspPropertyGroup.setIsXml(group.getIsXml());
                if (group.getIncludePreludes() != null) {
                    for (String includePrelude : group.getIncludePreludes()) {
                        jspPropertyGroup.addIncludePrelude(includePrelude);
                    }
                }
                if (group.getIncludeCodas() != null) {
                    for (String includeCoda : group.getIncludeCodas()) {
                        jspPropertyGroup.addIncludeCoda(includeCoda);
                    }
                }
                jspPropertyGroup.setDeferredSyntaxAllowedAsLiteral(group.getDeferredSyntaxAllowedAsLiteral());
                jspPropertyGroup.setTrimDirectiveWhitespaces(group.getTrimDirectiveWhitespaces());
                jspPropertyGroup.setDefaultContentType(group.getDefaultContentType());
                jspPropertyGroup.setBuffer(group.getBuffer());
                jspPropertyGroup.setErrorOnUndeclaredNamespace(group.getErrorOnUndeclaredNamespace());
                for (String pattern : jspPropertyGroup.getUrlPatterns()) {
                    // Split off the groups to individual mappings
                    result.put(pattern, jspPropertyGroup);
                }
            }
        }
    }
    //it looks like jasper needs these in order of least specified to most specific
    final LinkedHashMap<String, JspPropertyGroup> ret = new LinkedHashMap<>();
    final ArrayList<String> paths = new ArrayList<>(result.keySet());
    Collections.sort(paths, new Comparator<String>() {

        @Override
        public int compare(final String o1, final String o2) {
            return o1.length() - o2.length();
        }
    });
    for (String path : paths) {
        ret.put(path, result.get(path));
    }
    return ret;
}
Also used : JspPropertyGroup(org.apache.jasper.deploy.JspPropertyGroup) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) JspConfigMetaData(org.jboss.metadata.web.spec.JspConfigMetaData) ArrayList(java.util.ArrayList) JspPropertyGroupMetaData(org.jboss.metadata.web.spec.JspPropertyGroupMetaData) JspPropertyGroup(org.apache.jasper.deploy.JspPropertyGroup) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 JspPropertyGroup (org.apache.jasper.deploy.JspPropertyGroup)1 JspConfigMetaData (org.jboss.metadata.web.spec.JspConfigMetaData)1 JspPropertyGroupMetaData (org.jboss.metadata.web.spec.JspPropertyGroupMetaData)1