Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit f3981c1

Browse files
author
Emmanuel Hugonnet
committed
@fix:;Incorrect installation path
git-svn-id: https://www.silverpeas.org/svn/silverpeas/services/office-online/trunk@69 a8e77078-a1c7-4fa5-b8fc-53c5178a176c
1 parent 68f6078 commit f3981c1

File tree

3 files changed

+89
-5
lines changed

3 files changed

+89
-5
lines changed

src/main/java/com/silverpeas/openoffice/Launcher.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
public class Launcher {
2828

29-
static final String LAUNCHER_VERSION = "2.11";
29+
static final String LAUNCHER_VERSION = "2.12";
3030
static final MimetypesFileTypeMap mimeTypes = new MimetypesFileTypeMap();
3131
static Logger logger = Logger.getLogger(Launcher.class.getName());
3232

@@ -42,9 +42,9 @@ public static void main(String[] args) throws OfficeNotFoundException {
4242
String url = UrlExtractor.extractUrl(args[0]);
4343
logger.log(Level.INFO, MessageUtil.getMessage("info.url.decoded") + url);
4444
if (args[1] != null && !"".equals(args[1].trim())) {
45-
logger.log(Level.INFO,
46-
MessageUtil.getMessage("info.default.path") + ' ' + args[1]);
47-
MsOfficePathFinder.basePath = args[1].replace('/', File.separatorChar);
45+
logger.log(Level.INFO,MessageUtil.getMessage("info.default.path")
46+
+ ' ' + UrlExtractor.decodePath(args[1]));
47+
MsOfficePathFinder.basePath = UrlExtractor.decodePath(args[1]);
4848
}
4949
AuthenticationInfo authInfo = null;
5050
if (args.length >= 4) {

src/main/java/com/silverpeas/openoffice/util/UrlExtractor.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
package com.silverpeas.openoffice.util;
66

7-
import com.silverpeas.openoffice.Launcher;
7+
import java.io.File;
88
import java.io.IOException;
99
import java.net.URLDecoder;
1010
import java.util.logging.Level;
@@ -65,4 +65,14 @@ public static String extractUrl(String encodedUrl) {
6565
String decodedUrl = decodeUrl(encodedUrl);
6666
return escapeUrl(decodedUrl);
6767
}
68+
69+
/**
70+
* Decode the encoded path
71+
* @param encodedUrl the path encoded.
72+
* @return the path decoded.
73+
*/
74+
public static String decodePath(String encodedPath) {
75+
String path = decodeUrl(encodedPath);
76+
return path.replace('/', File.separatorChar);
77+
}
6878
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* To change this template, choose Tools | Templates
3+
* and open the template in the editor.
4+
*/
5+
package com.silverpeas.openoffice.util;
6+
7+
import junit.framework.TestCase;
8+
9+
/**
10+
*
11+
* @author ehugonnet
12+
*/
13+
public class UrlExtractorTest extends TestCase {
14+
15+
public UrlExtractorTest(String testName) {
16+
super(testName);
17+
}
18+
19+
@Override
20+
protected void setUp() throws Exception {
21+
super.setUp();
22+
}
23+
24+
@Override
25+
protected void tearDown() throws Exception {
26+
super.tearDown();
27+
}
28+
29+
/**
30+
* Test of decodeUrl method, of class UrlExtractor.
31+
*/
32+
public void testDecodeUrl() {
33+
String encodedUrl = "http%3A%2F%2Fdsr-preprod-3%2Fsilverpeas%2Frepository%2Fjackrabbit%2Fattachments%2Fkmelia34%2FAttachment%2FImages%2F44733%2FAtelier+en+classe.doc";
34+
String expResult = "http://dsr-preprod-3/silverpeas/repository/jackrabbit/attachments/kmelia34/Attachment/Images/44733/Atelier en classe.doc";
35+
String result = UrlExtractor.decodeUrl(encodedUrl);
36+
assertEquals(expResult, result);
37+
}
38+
39+
/**
40+
* Test of escapeUrl method, of class UrlExtractor.
41+
*/
42+
public void testEscapeUrl() {
43+
String url = "http://dsr-preprod-3/silverpeas/repository/jackrabbit/attachments/kmelia34/Attachment/Images/44733/Atelier en classe.doc";
44+
String expResult = "\"http://dsr-preprod-3/silverpeas/repository/jackrabbit/attachments/kmelia34/Attachment/Images/44733/Atelier en classe.doc\"";
45+
String expResultUnix = "http://dsr-preprod-3/silverpeas/repository/jackrabbit/attachments/kmelia34/Attachment/Images/44733/Atelier%20en%20classe.doc";
46+
System.setProperty("os.name", "Windows XP");
47+
String result = UrlExtractor.escapeUrl(url);
48+
assertEquals(expResult, result);
49+
System.setProperty("os.name", "Linux");
50+
result = UrlExtractor.escapeUrl(url);
51+
assertEquals(expResultUnix, result);
52+
}
53+
54+
/**
55+
* Test of extractUrl method, of class UrlExtractor.
56+
*/
57+
public void testExtractUrl() {
58+
System.setProperty("os.name", "Windows XP");
59+
String encodedUrl = "http%3A%2F%2Fdsr-preprod-3%2Fsilverpeas%2Frepository%2Fjackrabbit%2Fattachments%2Fkmelia34%2FAttachment%2FImages%2F44733%2FAtelier+en+classe.doc";
60+
String expResult = "\"http://dsr-preprod-3/silverpeas/repository/jackrabbit/attachments/kmelia34/Attachment/Images/44733/Atelier en classe.doc\"";
61+
String result = UrlExtractor.extractUrl(encodedUrl);
62+
assertEquals(expResult, result);
63+
}
64+
65+
/**
66+
* Test of decodePath method, of class UrlExtractor.
67+
*/
68+
public void testDecodePath() {
69+
String encodedPath = "C%3A%5C%5CProgram+Files%5C%5CMicrosoft+Office%5C%5COFFICE10";
70+
String expResult = "C:\\\\Program Files\\\\Microsoft Office\\\\OFFICE10";
71+
String result = UrlExtractor.decodePath(encodedPath);
72+
assertEquals(expResult, result);
73+
}
74+
}

0 commit comments

Comments
 (0)