Update of
/var/cvs/contributions/CMSContainer_Modules/fileupload/src/java/com/finalist/cmsc/fileupload
In directory
james.mmbase.org:/tmp/cvs-serv10356/fileupload/src/java/com/finalist/cmsc/fileupload
Modified Files:
Configuration.java
Log Message:
CMSC-1074 - Transfer upload module from InContext to CMSc - Made allowedmeta
types as configurable property
See also:
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Modules/fileupload/src/java/com/finalist/cmsc/fileupload
See also: http://www.mmbase.org/jira/browse/CMSC-1074
Index: Configuration.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer_Modules/fileupload/src/java/com/finalist/cmsc/fileupload/Configuration.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- Configuration.java 29 Sep 2008 14:44:30 -0000 1.1
+++ Configuration.java 1 Oct 2008 12:01:54 -0000 1.2
@@ -6,23 +6,27 @@
import com.finalist.cmsc.mmbase.PropertiesUtil;
+import java.util.List;
+
/**
* Provides access to the configuration properties. This can also trigger
- * [EMAIL PROTECTED] ConfigurationException} to be thrown if the configuration
was not
- * deemed valid.
+ * [EMAIL PROTECTED] ConfigurationException} to be thrown if the configuration
was not deemed valid.
*
* @author Auke van Leeuwen
*/
public class Configuration {
+
private static final String STORAGEPATH_PROP_NAME =
"fileupload.storepath";
+
private static final String URLPREFIX_PROP_NAME =
"fileupload.urlprefix";
+ private static final String ALLOWED_MIMETYPES_PROP_NAME =
"fileupload.allowedmimetypes";
+
/**
- * Returns the storage path that is stored as a property for this
module. If
- * the property - or the folder the property points - does not exist it
will
- * thrown an [EMAIL PROTECTED] ConfigurationException}. Since this
property should
- * denote a directory it will always be appended with a
- * [EMAIL PROTECTED] File#separatorChar} if it didn't end with one in
the first place.
+ * Returns the storage path that is stored as a property for this module.
If the property - or
+ * the folder the property points - does not exist it will thrown an
+ * [EMAIL PROTECTED] ConfigurationException}. Since this property should
denote a directory it will always
+ * be appended with a [EMAIL PROTECTED] File#separatorChar} if it didn't
end with one in the first place.
*
* @return the value stored in the property for the url prefix.
*/
@@ -50,9 +54,8 @@
}
/**
- * Returns the url prefix that is stored as a property for this module.
If
- * the property does not exist, it will thrown an
- * [EMAIL PROTECTED] ConfigurationException}.
+ * Returns the url prefix that is stored as a property for this module. If
the property does not
+ * exist, it will thrown an [EMAIL PROTECTED] ConfigurationException}.
*
* @return the value stored in the property for the url prefix.
*/
@@ -68,18 +71,37 @@
}
/**
- * Thrown when a configuration exception occurs, constructed with an
- * ActionMessage for a localized message.
+ * Returns the url prefix that is stored as a property for this module. If
the property does not
+ * exist, it will thrown an [EMAIL PROTECTED] ConfigurationException}.
+ *
+ * @return the value stored in the property for the url prefix.
+ */
+ public static List<String> getAllowedMimeTypes() {
+ String allowedMimeTypes =
PropertiesUtil.getProperty(ALLOWED_MIMETYPES_PROP_NAME);
+
+ if (allowedMimeTypes == null) {
+ ActionMessage message = new
ActionMessage("fileupload.error.config.noproperty",
ALLOWED_MIMETYPES_PROP_NAME);
+ throw new ConfigurationException(message);
+ }
+
+ String[] allowedMimeTypesArray = allowedMimeTypes.split(",");
+ java.util.List<String> allowedMimeTypesList =
java.util.Arrays.asList(allowedMimeTypesArray);
+ return allowedMimeTypesList;
+ }
+
+ /**
+ * Thrown when a configuration exception occurs, constructed with an
ActionMessage for a
+ * localized message.
*
* @author Auke van Leeuwen
*/
@SuppressWarnings("serial")
public static class ConfigurationException extends RuntimeException {
+
private ActionMessage actionMessage;
/**
- * Construct a new ConfigurationException based on the given
- * actionmessage and cause.
+ * Construct a new ConfigurationException based on the given
actionmessage and cause.
*
* @param actionMessage
* the action message
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs