add file problem,chinese file name

Former SVN Browser
zhhigh
Posts: 1
Joined: Wed May 10, 2006 9:35 am

add file problem,chinese file name

Postby zhhigh » Wed May 10, 2006 9:51 am

add a file ,path=C:\Documents and Settings\Administrator\桌面\CVS\关键里程.doc,add succsessed,
add another file,path=C:\Documents and Settings\Administrator\桌面\CVS\关键里程碑.doc,add failed.

erro message:
org.polarion.svnwebclient.data.DataProviderException: 关键里程�?.doc could not be found
at org.polarion.svnwebclient.data.javasvn.DataProvider.addFile(DataProvider.java:684)
at org.polarion.svnwebclient.web.servlet.FileAddActionServlet.executeSVNOperation(FileAddActionServlet.java:123)
at org.polarion.svnwebclient.web.servlet.AbstractServlet.execute(AbstractServlet.java:53)
at org.polarion.svnwebclient.web.servlet.FileAddActionServlet.doPost(FileAddActionServlet.java:66)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.polarion.svnwebclient.authorization.impl.BindSessionsFilter.doFilter(BindSessionsFilter.java:48)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.polarion.svnwebclient.web.CharsetFilter.doFilter(CharsetFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)

evan
Posts: 1
Joined: Sun May 14, 2006 11:37 am
Contact:

using latest fileupload to fix this problem

Postby evan » Sun May 14, 2006 12:23 pm

You can fix this problem as follows:

1. Download the latest FileUpload and IO from Jarkata website;
2. Replace DiskFileUpload with ServletFileUoload and modify the Uploader.java as follows, redeploy and enjoy it.

Code: Select all

    public static Map doPost(HttpServletRequest request, HttpServletResponse responce, String destinationDirectory, String tempDirectory) {
        Map parameters = new HashMap();

        File tempDir = new File(tempDirectory);
        if (!tempDir.exists()) {
            tempDir.mkdirs();
        }

        File destDir = new File(destinationDirectory);
        if (!destDir.exists()) {
            destDir.mkdirs();
        }

        ServletFileUpload fu = new ServletFileUpload(new DiskFileItemFactory(4096, new java.io.File(tempDirectory)));
        List fileItems = null;
        try {
            fileItems = fu.parseRequest(request);
        } catch (FileUploadException e) {
            Logger.getInstance(Uploader.class).error(e, e);
        }

        for (Iterator i = fileItems.iterator(); i.hasNext();) {
            FileItem fi = (FileItem) i.next();
            if (fi.isFormField()) {
                try {
                    parameters.put(fi.getFieldName(), fi.getString("UTF8"));
                } catch (UnsupportedEncodingException e) {
                    Logger.getInstance(Uploader.class).error(e, e);
                }
            } else {
                // filename on the client
                String fileName = fi.getName();
                // write the file
                try {
                    File uploadFile = new File(destinationDirectory + "/" + FileUtil.getLastPathElement(fileName));
                    fi.write(uploadFile);
                    // fi.delete();
                } catch (Exception e) {
                    Logger.getInstance(Uploader.class).error(e, e);
                }
                parameters.put(FormParameters.FILE_NAME, FileUtil.getLastPathElement(fileName));
            }
        }

        return parameters;
    }

kevinwei
Posts: 2
Joined: Thu Aug 27, 2009 3:25 am

Re: add file problem,chinese file name

Postby kevinwei » Thu Aug 27, 2009 3:31 am

I did as Even's instruction but a new defect appeared. The comment including Chinese characters turned into wrong characters while submitted. It's weired only uploader.java modified but comment is infected. And sometime Chinese file name is still in wrong characters.

kevinwei
Posts: 2
Joined: Thu Aug 27, 2009 3:25 am

Re: add file problem,chinese file name

Postby kevinwei » Fri Aug 28, 2009 3:23 am

I got what mistake I've made while modify the source code. I forgot to modify the rest code below the line of "ServletFileUpload fu = new ServletFileUpload(new DiskFileItemFactory(4096, new java.io.File(tempDirectory)));". Evan's method does work!


Return to “Polarion SVN Web Client”

Who is online

Users browsing this forum: No registered users and 3 guests