Update of 
/var/cvs/contributions/CMSContainer_Modules/openofficeintegration/src/java/com/finalist/cmsc/openoffice/service
In directory 
james.mmbase.org:/tmp/cvs-serv15291/openofficeintegration/src/java/com/finalist/cmsc/openoffice/service

Modified Files:
        OODocUploadUtil.java 
Log Message:
CMSC-1029 Move some sources from net.sf.mmapps.mmcommons to cmsc cvs


See also: 
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Modules/openofficeintegration/src/java/com/finalist/cmsc/openoffice/service
See also: http://www.mmbase.org/jira/browse/CMSC-1029


Index: OODocUploadUtil.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Modules/openofficeintegration/src/java/com/finalist/cmsc/openoffice/service/OODocUploadUtil.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- OODocUploadUtil.java        28 Jan 2008 09:11:25 -0000      1.3
+++ OODocUploadUtil.java        25 Jul 2008 15:54:55 -0000      1.4
@@ -1,24 +1,11 @@
 package com.finalist.cmsc.openoffice.service;
 
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+import java.io.*;
+import java.util.*;
 
 import javax.servlet.http.HttpServletRequest;
 
-import net.sf.mmapps.commons.util.UploadUtil;
-import net.sf.mmapps.commons.util.UploadUtil.BinaryData;
-
-import org.apache.commons.fileupload.FileItem;
-import org.apache.commons.fileupload.FileItemFactory;
-import org.apache.commons.fileupload.FileUploadException;
+import org.apache.commons.fileupload.*;
 import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
 import org.apache.commons.lang.StringUtils;
@@ -26,6 +13,8 @@
 import org.apache.commons.logging.LogFactory;
 
 import com.finalist.cmsc.openoffice.model.OdtDocument;
+import com.finalist.cmsc.util.UploadUtil;
+import com.finalist.cmsc.util.UploadUtil.BinaryData;
 
 /**
  * openoffice one odt document or more ,persist
@@ -88,19 +77,23 @@
                        log.error("openoffice file error :" + e.getMessage());
                }
                String realPath = "";
-               if (request.getAttribute("dir") != null)
+               if (request.getAttribute("dir") != null) {
                        realPath = (String) request.getAttribute("dir");
-               if (StringUtils.isBlank(realPath))
+      }
+               if (StringUtils.isBlank(realPath)) {
                        realPath = dir;
+      }
 
                realPath += File.separator + channel;
-               if (realPath.endsWith("null"))
+               if (realPath.endsWith("null")) {
                        realPath = realPath.substring(0, realPath.length() - 5);
+      }
 
                if (request.getAttribute("root") != null) {
-                       if (!realPath.endsWith(TEMP_PATH))
+                       if (!realPath.endsWith(TEMP_PATH)) {
                                realPath = realPath.substring(0, 
realPath.indexOf(TEMP_PATH)
                                                + TEMP_PATH.length());
+         }
                        realPath += File.separator + SINGLE_FILE_PATH;
                }
 
@@ -110,8 +103,9 @@
                                log.debug("contentType: " + 
binary.getContentType());
                        }
 
-                       if (!isOdtFile(binary))
+                       if (!isOdtFile(binary)) {
                                return false;
+         }
                        persistOdtDoc(binary, realPath);
                }
                return true;
@@ -148,8 +142,9 @@
                byte[] writeBuffer = new byte[bufferSize];
                BufferedOutputStream bos = new BufferedOutputStream(outs, 
bufferSize);
                int bufferRead;
-               while ((bufferRead = ins.read(writeBuffer)) != -1)
+               while ((bufferRead = ins.read(writeBuffer)) != -1) {
                        bos.write(writeBuffer, 0, bufferRead);
+      }
                bos.flush();
                bos.close();
                outs.flush();
@@ -207,8 +202,9 @@
                        }
                }
                if (binary.getOriginalFilePath() != null
-                               && 
binary.getOriginalFilePath().toLowerCase().endsWith("odt"))
+                               && 
binary.getOriginalFilePath().toLowerCase().endsWith("odt")) {
                        return true;
+      }
                return false;
        }
 
@@ -239,7 +235,7 @@
                                        binary.setData(item.get());
                                        
binary.setOriginalFilePath(fullFileName);
                                        
binary.setContentType(item.getContentType());
-                                       if (log.isDebugEnabled())
+                                       if (log.isDebugEnabled()) {
                                                log.debug((new 
StringBuilder()).append(
                                                                "Setting binary 
").append(binary.getLength())
                                                                .append(" bytes 
in type ").append(
@@ -247,6 +243,7 @@
                                                                                
" with ").append(
                                                                                
binary.getOriginalFilePath()).append(
                                                                                
" name").toString());
+               }
 
                                }
                        }
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to