Search in sources :

Example 1 with SharedResourceReference

use of org.apache.wicket.request.resource.SharedResourceReference in project midpoint by Evolveum.

the class MidPointApplication method mountFiles.

private void mountFiles(String path, Class<?> clazz) {
    try {
        List<Resource> list = new ArrayList<>();
        String packagePath = clazz.getPackage().getName().replace('.', '/');
        PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
        Resource[] res = resolver.getResources("classpath:" + packagePath + "/*.png");
        if (res != null) {
            list.addAll(Arrays.asList(res));
        }
        res = resolver.getResources("classpath:" + packagePath + "/*.gif");
        if (res != null) {
            list.addAll(Arrays.asList(res));
        }
        for (Resource resource : list) {
            URI uri = resource.getURI();
            File file = new File(uri.toString());
            mountResource(path + "/" + file.getName(), new SharedResourceReference(clazz, file.getName()));
        }
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't mount files", ex);
    }
}
Also used : SharedResourceReference(org.apache.wicket.request.resource.SharedResourceReference) ArrayList(java.util.ArrayList) Resource(org.springframework.core.io.Resource) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) URI(java.net.URI) File(java.io.File) SchemaException(com.evolveum.midpoint.util.exception.SchemaException)

Aggregations

SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 File (java.io.File)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 SharedResourceReference (org.apache.wicket.request.resource.SharedResourceReference)1 Resource (org.springframework.core.io.Resource)1 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)1