Update of
/var/cvs/contributions/CMSContainer_Modules/openofficeintegration/src/java/com/finalist/cmsc/openoffice/service
In directory
james.mmbase.org:/tmp/cvs-serv13229/openofficeintegration/src/java/com/finalist/cmsc/openoffice/service
Modified Files:
OdtFileTranster.java OODocUploadUtil.java
Log Message:
CMSC-472.
Add enter point in content.jsp.
implement Openoffice export function ,server side function.
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-472
Index: OdtFileTranster.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer_Modules/openofficeintegration/src/java/com/finalist/cmsc/openoffice/service/OdtFileTranster.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- OdtFileTranster.java 21 Jan 2008 07:35:30 -0000 1.1
+++ OdtFileTranster.java 22 Jan 2008 10:26:11 -0000 1.2
@@ -22,10 +22,11 @@
public static String WORKINGFOLDER;
- public static OdtDocument process(File file) {
+ public static OdtDocument process(File file, String requestContext) {
String middelFileLocation = WORKINGFOLDER + File.separator +
file.getName() + ".xml";
+
ChangeContentXml ccx = new ChangeContentXml();
ChangeHtml ch = new ChangeHtml();
OutFinishHtml ofh = new OutFinishHtml(file.getPath(),
middelFileLocation);
@@ -36,9 +37,14 @@
try {
+ File workingfolder = new File(WORKINGFOLDER);
+ if (!workingfolder.exists()) {
+ workingfolder.mkdir();
+ }
+
ofh.getFirstHtml();
- Map rowAndSavedImageMap = saveAllImageToCMSC(new
FileInputStream(file));
- ch.change(middelFileLocation, styleMap,rowAndSavedImageMap);
+ Map rowAndSavedImageMap = saveAllImageToCMSC(new
FileInputStream(file), requestContext);
+ ch.change(middelFileLocation, styleMap, rowAndSavedImageMap);
BufferedReader in = new BufferedReader(new
FileReader(middelFileLocation + ".html"));
String str;
@@ -64,7 +70,7 @@
return doc;
}
- public static Map saveAllImageToCMSC(InputStream fis) throws IOException {
+ public static Map saveAllImageToCMSC(InputStream fis, String
requestContext) throws IOException {
Map<String, String> rawImgeToSavedImgeMaping = new HashMap();
@@ -74,7 +80,7 @@
String entryName = ze.getName();
if (entryName.startsWith("Pictures/")) {
String numbersOfSavedImage = saveAImage(zis, entryName);
- rawImgeToSavedImgeMaping.put(entryName, numbersOfSavedImage);
+ rawImgeToSavedImgeMaping.put(entryName, requestContext +
numbersOfSavedImage);
}
zis.closeEntry();
}
Index: OODocUploadUtil.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer_Modules/openofficeintegration/src/java/com/finalist/cmsc/openoffice/service/OODocUploadUtil.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- OODocUploadUtil.java 21 Jan 2008 07:35:30 -0000 1.1
+++ OODocUploadUtil.java 22 Jan 2008 10:26:11 -0000 1.2
@@ -2,7 +2,9 @@
import java.io.BufferedOutputStream;
import java.io.File;
+import java.io.FileFilter;
import java.io.FileOutputStream;
+import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -37,8 +39,9 @@
/* a temp directory used for saving files uploaded */
public static final String TEMP_PATH = "tempDir";
+ public static final String SINGLE_FILE_PATH = "singlePath";
// set max size allowed
- private static final int MAXSIZE = 4 * 1024 * 1024;
+ private static final int MAXSIZE = 16 * 1024 * 1024;
private static final String OPENOFFICE_ODT_MIME_TYPES[] = new String[]{
"application/vnd.oasis.opendocument.text",
@@ -57,16 +60,13 @@
private static final String CHANNELBAK_KEY = "channelbak";
public static final String NODE_NUMBER = "node.number";
- private static OODocUploadUtil docUploadUtil;
+ //private static OODocUploadUtil docUploadUtil;
private OODocUploadUtil() {
}
public static OODocUploadUtil getInstance() {
- if (docUploadUtil == null)
- docUploadUtil = new OODocUploadUtil();
-
- return docUploadUtil;
+ return new OODocUploadUtil();
}
public BinaryData getBinaryData() {
@@ -86,7 +86,7 @@
*
* @param request
*/
- public void upload(HttpServletRequest request, String dir)
+ public boolean upload(HttpServletRequest request, String dir)
throws IOException {
try {
uploadFiles(request, MAXSIZE);
@@ -95,11 +95,20 @@
}
String realPath = "";
if (request.getAttribute("dir") != null)
- if (request.getAttribute("dir") instanceof String)
realPath = (String) request.getAttribute("dir");
if (StringUtils.isBlank(realPath))
realPath = dir;
+ realPath += File.separator + getChannelId();
+ if (realPath.endsWith("null"))
+ realPath = realPath.substring(0, realPath.length() - 5);
+
+ if (request.getAttribute("root") != null) {
+ if (!realPath.endsWith(TEMP_PATH))
+ realPath = realPath.substring(0,
realPath.indexOf(TEMP_PATH)
+ + TEMP_PATH.length());
+ realPath += File.separator + SINGLE_FILE_PATH;
+ }
if (binary != null) {
if (log.isDebugEnabled()) {
@@ -107,9 +116,12 @@
log.debug("contentType: " + binary.getContentType());
}
- realPath += File.separator + getChannelId();
+
+ if (!isOdtFile(binary))
+ return false;
persistOdtDoc(binary, realPath);
}
+ return true;
}
private String getChannelId() {
@@ -168,7 +180,7 @@
String[] files = new String[]{};
File directory = new File(dir);
if (directory.exists() && directory.isDirectory()) {
- files = directory.list();
+ files = directory.list(new OdtFilter());
}
return files;
@@ -202,6 +214,9 @@
return true;
}
}
+ if (binary.getOriginalFilePath() != null
+ &&
binary.getOriginalFilePath().toLowerCase().endsWith("odt"))
+ return true;
return false;
}
@@ -262,5 +277,24 @@
}
}
}
+ public class OdtFilter implements FilenameFilter
+ {
+
+
+
+ public boolean isFile(String file)
+ {
+ if (file.toLowerCase().endsWith(".odt")){
+ return true;
+ }else{
+ return false;
+ }
+ }
+ public boolean accept(File dir,String fname){
+ return (isFile(fname));
+
+ }
+
+ }
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs