Update of
/var/cvs/contributions/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms
In directory
james.mmbase.org:/tmp/cvs-serv25435/java/com/finalist/cmsc/repository/forms
Modified Files:
ImageUploadAction.java
Log Message:
CMSC-681 Asset Maintenance code refacted
See also:
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms
See also: http://www.mmbase.org/jira/browse/CMSC-681
Index: ImageUploadAction.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/forms/ImageUploadAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- ImageUploadAction.java 9 Dec 2008 06:04:04 -0000 1.2
+++ ImageUploadAction.java 25 Dec 2008 03:28:36 -0000 1.3
@@ -1,10 +1,3 @@
-/*
- *
- * This software is OSI Certified Open Source Software. OSI Certified is a
certification mark of the Open Source
- * Initiative.
- *
- * The license (Mozilla version 1.0) can be read at the MMBase site. See
http://www.MMBase.org/license
- */
package com.finalist.cmsc.repository.forms;
import java.io.IOException;
@@ -31,6 +24,7 @@
import org.mmbase.util.transformers.ByteToCharTransformer;
import org.mmbase.util.transformers.ChecksumFactory;
+import com.finalist.cmsc.mmbase.PropertiesUtil;
import com.finalist.cmsc.services.versioning.Versioning;
import com.finalist.cmsc.services.workflow.Workflow;
import com.finalist.cmsc.struts.MMBaseAction;
@@ -38,6 +32,12 @@
public class ImageUploadAction extends MMBaseAction {
+ public static final String UPLOADED_FILE_MAX_SIZE =
"uploaded.file.max.size";
+ public static final String CONFIGURATION_RESOURCE_NAME =
"/com/finalist/util/http/util.properties";
+ protected static Set<String> supportedImages;
+
+ private static final Log log = LogFactory.getLog(BulkUploadUtil.class);
+
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response, Cloud cloud) throws Exception {
@@ -47,12 +47,22 @@
FormFile file = imageUploadForm.getFile();
int nodeId = 0;
String exist = "0";
+ String exceed = "no";
+
NodeManager manager = cloud.getNodeManager("images");
List<Integer> nodes = null;
if (file.getFileSize() != 0 && file.getFileName() != null) {
if (isImage(file.getFileName())) {
+ int maxFileSize = 16 * 1024 * 1024; // Default value of 16MB
+ try {
+ maxFileSize =
Integer.parseInt(PropertiesUtil.getProperty(UPLOADED_FILE_MAX_SIZE)) * 1024 *
1024;
+ } catch (NumberFormatException e) {
+ log.warn("System property '" + UPLOADED_FILE_MAX_SIZE + "' is
not set. Please add it (units = MB).");
+ }
+ int fileSize = file.getFileSize();
+ if (fileSize < maxFileSize) {
ChecksumFactory checksumFactory = new ChecksumFactory();
ByteToCharTransformer transformer = (ByteToCharTransformer)
checksumFactory
.createTransformer(checksumFactory.createParameters());
@@ -68,6 +78,9 @@
} else {
exist = "1";
}
+ } else {
+ exceed = "yes";
+ }
}
if (nodes != null && nodes.size() > 0) {
@@ -84,13 +97,9 @@
}
}
return new ActionForward(mapping.findForward(SUCCESS).getPath() +
"?uploadAction=select&exist=" + exist
- + "&channelid=" + parentchannel + "&uploadedNodes=" + nodeId,
true);
+ + "&exceed=" + exceed + "&channelid=" + parentchannel +
"&uploadedNodes=" + nodeId, true);
}
- private static Set<String> supportedImages;
- private static final String CONFIGURATION_RESOURCE_NAME =
"/com/finalist/util/http/util.properties";
- private static final Log log = LogFactory.getLog(BulkUploadUtil.class);
-
private static void initSupportedImages() {
supportedImages = new HashSet<String>();
Properties properties = new Properties();
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs