You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2009/03/22 13:14:10 UTC
svn commit: r757176 - in /lenya/branches/BRANCH_2_0_X/src:
impl/java/org/apache/lenya/cms/publication/ResourceTypeImpl.java
java/org/apache/lenya/cms/publication/ResourceType.java
modules/resource/config/cocoon-xconf/module.xconf
Author: andreas
Date: Sun Mar 22 12:14:10 2009
New Revision: 757176
URL: http://svn.apache.org/viewvc?rev=757176&view=rev
Log:
Allow to configure the accepted mime-types of a resource type.
Modified:
lenya/branches/BRANCH_2_0_X/src/impl/java/org/apache/lenya/cms/publication/ResourceTypeImpl.java
lenya/branches/BRANCH_2_0_X/src/java/org/apache/lenya/cms/publication/ResourceType.java
lenya/branches/BRANCH_2_0_X/src/modules/resource/config/cocoon-xconf/module.xconf
Modified: lenya/branches/BRANCH_2_0_X/src/impl/java/org/apache/lenya/cms/publication/ResourceTypeImpl.java
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_0_X/src/impl/java/org/apache/lenya/cms/publication/ResourceTypeImpl.java?rev=757176&r1=757175&r2=757176&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_0_X/src/impl/java/org/apache/lenya/cms/publication/ResourceTypeImpl.java (original)
+++ lenya/branches/BRANCH_2_0_X/src/impl/java/org/apache/lenya/cms/publication/ResourceTypeImpl.java Sun Mar 22 12:14:10 2009
@@ -24,6 +24,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.StringTokenizer;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
@@ -64,6 +65,8 @@
protected static final String ELEMENT_FORMAT = "format";
protected static final String ELEMENT_EXPIRES = "expires";
protected static final String ATTRIBUTE_SECONDS = "seconds";
+ protected static final String ELEMENT_SUPPORTS = "supports";
+ protected static final String ELEMENT_MIME_TYPE = "mime-type";
private Schema schema = null;
private String[] linkAttributeXPaths;
@@ -73,6 +76,7 @@
private long expires = 0;
private String name;
private ServiceManager manager;
+ private String[] mimeTypes;
/**
* A format.
@@ -140,6 +144,16 @@
this.expires = expiresConf.getAttributeAsLong(ATTRIBUTE_SECONDS);
}
+ Configuration supportsConf = config.getChild(ELEMENT_SUPPORTS, false);
+ if (supportsConf != null) {
+ Configuration[] mimeTypeConfigs = supportsConf.getChildren(ELEMENT_MIME_TYPE);
+ this.mimeTypes = new String[mimeTypeConfigs.length];
+ List types = new ArrayList();
+ for (int i = 0; i < mimeTypeConfigs.length; i++) {
+ this.mimeTypes[i] = mimeTypeConfigs[i].getValue();
+ }
+ }
+
} catch (Exception e) {
throw new ConfigurationException("Configuring resource type failed: ", e);
}
@@ -255,5 +269,9 @@
public String toString() {
return getName();
}
+
+ public String[] getMimeTypes() {
+ return this.mimeTypes;
+ }
}
Modified: lenya/branches/BRANCH_2_0_X/src/java/org/apache/lenya/cms/publication/ResourceType.java
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_0_X/src/java/org/apache/lenya/cms/publication/ResourceType.java?rev=757176&r1=757175&r2=757176&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_0_X/src/java/org/apache/lenya/cms/publication/ResourceType.java (original)
+++ lenya/branches/BRANCH_2_0_X/src/java/org/apache/lenya/cms/publication/ResourceType.java Sun Mar 22 12:14:10 2009
@@ -107,6 +107,11 @@
* @return The URI to get the formatted content at.
*/
String getFormatURI(String format);
+
+ /**
+ * @return An array of all MIME types which are accepted by this resource type.
+ */
+ String[] getMimeTypes();
/**
* A resource type sample.
Modified: lenya/branches/BRANCH_2_0_X/src/modules/resource/config/cocoon-xconf/module.xconf
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_0_X/src/modules/resource/config/cocoon-xconf/module.xconf?rev=757176&r1=757175&r2=757176&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_0_X/src/modules/resource/config/cocoon-xconf/module.xconf (original)
+++ lenya/branches/BRANCH_2_0_X/src/modules/resource/config/cocoon-xconf/module.xconf Sun Mar 22 12:14:10 2009
@@ -35,6 +35,12 @@
<format name="downloadLink" uri="cocoon://modules/resource/downloadLink.xml"/>
<format name="icon" uri="cocoon://modules/resource/icon"/>
<format name="luceneIndex" uri="cocoon://modules/resource/lucene-index"/>
+ <supports>
+ <mime-type>application/pdf</mime-type>
+ <mime-type>image/gif</mime-type>
+ <mime-type>image/jpeg</mime-type>
+ <mime-type>image/png</mime-type>
+ </supports>
</component-instance>
</xconf>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org