mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged BRANCHES/DEV/V4.0-BUG-FIX to HEAD:
33863: ConfigSource for XMLConfigService which uses a ResourceFinder for wildcard-compatible lookups (UrlConfigSource does not support them) 33864: ALF-10736 Make it easier to supply custom mimetypes, by automatically importing all files matching alfresco/extension/mimetype/*-map.xml, rather than having to override a bean to list them git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@33865 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -145,13 +145,17 @@
|
|||||||
|
|
||||||
<bean id="mimetypeConfigService" class="org.springframework.extensions.config.xml.XMLConfigService" init-method="init">
|
<bean id="mimetypeConfigService" class="org.springframework.extensions.config.xml.XMLConfigService" init-method="init">
|
||||||
<constructor-arg>
|
<constructor-arg>
|
||||||
<bean class="org.springframework.extensions.config.source.UrlConfigSource">
|
<bean class="org.alfresco.util.ResourceFinderConfigSource">
|
||||||
<constructor-arg>
|
<property name="resourceFinder">
|
||||||
|
<ref bean="resourceFinder" />
|
||||||
|
</property>
|
||||||
|
<property name="locations">
|
||||||
<list>
|
<list>
|
||||||
<value>classpath:alfresco/mimetype/mimetype-map.xml</value>
|
<value>classpath:alfresco/mimetype/mimetype-map.xml</value>
|
||||||
<value>classpath:alfresco/mimetype/mimetype-map-openoffice.xml</value>
|
<value>classpath:alfresco/mimetype/mimetype-map-openoffice.xml</value>
|
||||||
|
<value>classpath*:alfresco/extension/mimetype/*-map.xml</value>
|
||||||
</list>
|
</list>
|
||||||
</constructor-arg>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
</constructor-arg>
|
</constructor-arg>
|
||||||
</bean>
|
</bean>
|
||||||
|
@@ -1,21 +0,0 @@
|
|||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
|
||||||
|
|
||||||
<beans>
|
|
||||||
|
|
||||||
<bean id="mimetypeConfigService" class="org.springframework.extensions.config.xml.XMLConfigService" init-method="init">
|
|
||||||
<constructor-arg>
|
|
||||||
<bean class="org.springframework.extensions.config.source.UrlConfigSource">
|
|
||||||
<constructor-arg>
|
|
||||||
<list>
|
|
||||||
<value>classpath:alfresco/mimetype/mimetype-map.xml</value>
|
|
||||||
<value>classpath:alfresco/mimetype/mimetype-map-openoffice.xml</value>
|
|
||||||
<value>classpath:alfresco/extension/mimetypes-extension.xml</value>
|
|
||||||
</list>
|
|
||||||
</constructor-arg>
|
|
||||||
</bean>
|
|
||||||
</constructor-arg>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
|
|
||||||
</beans>
|
|
@@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.util;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.extensions.config.ConfigDeployment;
|
||||||
|
import org.springframework.extensions.config.ConfigSource;
|
||||||
|
import org.springframework.extensions.config.source.UrlConfigSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Spring {@link ConfigSource} that is powered by a {@link ResourceFinder}.
|
||||||
|
* This allows for the loading of resources with wildcards, which
|
||||||
|
* {@link UrlConfigSource} does not.
|
||||||
|
*
|
||||||
|
* @author Nick Burch
|
||||||
|
* @since 4.0.1
|
||||||
|
*/
|
||||||
|
public class ResourceFinderConfigSource implements ConfigSource
|
||||||
|
{
|
||||||
|
private static Log logger = LogFactory.getLog(ResourceFinderConfigSource.class);
|
||||||
|
|
||||||
|
/** The ResourceFinder to look up with */
|
||||||
|
private ResourceFinder resourceFinder;
|
||||||
|
/** The Resource Paths to search */
|
||||||
|
private List<String> locations;
|
||||||
|
|
||||||
|
public void setResourceFinder(ResourceFinder resourceFinder)
|
||||||
|
{
|
||||||
|
this.resourceFinder = resourceFinder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the locations, of the form classpath*:/some/path.xml
|
||||||
|
*/
|
||||||
|
public void setLocations(List<String> locations)
|
||||||
|
{
|
||||||
|
this.locations = locations;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ConfigDeployment> getConfigDeployments()
|
||||||
|
{
|
||||||
|
List<ConfigDeployment> configs = new ArrayList<ConfigDeployment>();
|
||||||
|
|
||||||
|
String[] locs = locations.toArray(new String[locations.size()]);
|
||||||
|
|
||||||
|
Resource[] resources;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
resources = resourceFinder.getResources(locs);
|
||||||
|
}
|
||||||
|
catch(IOException e)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Unable to find resources", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Resource resource : resources)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
configs.add(new ConfigDeployment(resource.getDescription(), resource.getInputStream()));
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Loaded resource " + resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(IOException e)
|
||||||
|
{
|
||||||
|
logger.warn("Skipping unreadable resource " + resource, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return configs;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user