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

Commit 128fd59

Browse files
author
Emmanuel Hugonnet
committed
Bug #4346 : Updating code to detect Old office versions thus using a basic auth url instead of the digest.
1 parent 4d0aa88 commit 128fd59

File tree

5 files changed

+45
-69
lines changed

5 files changed

+45
-69
lines changed

src/main/java/org/silverpeas/openoffice/OfficeLauncher.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.silverpeas.openoffice.util.MsOfficeType;
3333
import org.silverpeas.openoffice.util.OsEnum;
3434
import org.silverpeas.openoffice.windows.FileWebDavAccessManager;
35+
import org.silverpeas.openoffice.windows.MsOfficeVersion;
3536

3637
/**
3738
* @author Emmanuel Hugonnet
@@ -61,7 +62,7 @@ public static int launch(MsOfficeType type, String url, AuthenticationInfo authI
6162
logger.log(Level.INFO, "Are we using Office 2007 : {0}", finder.isMicrosoftOffice());
6263
logger.log(Level.INFO, "We are on {0} OS", OsEnum.getOS());
6364
boolean modeDisconnected = ((OsEnum.isWindows() && useDeconnectedMode) || OsEnum.getOS()
64-
== OsEnum.MAC_OSX) && finder.isMicrosoftOffice();
65+
== OsEnum.MAC_OSX) && finder.isMicrosoftOffice();
6566
switch (type) {
6667
case EXCEL:
6768
return launch(finder.findSpreadsheet(), url, modeDisconnected, authInfo);
@@ -114,8 +115,12 @@ public static int launch(String path, String url, boolean modeDisconnected,
114115
}
115116
} else {
116117
// Standard mode : just open it
117-
logger.log(Level.INFO, "The exact exec line: {0} {2}", new Object[]{path, url});
118-
Process process = Runtime.getRuntime().exec(path + ' ' + url);
118+
String webdavUrl = url;
119+
if(OsEnum.isWindows() && MsOfficeVersion.isOldOffice()) {
120+
webdavUrl = webdavUrl.replace("/repository/", "/repository2000/");
121+
}
122+
logger.log(Level.INFO, "The exact exec line: {0} {2}", new Object[]{path, webdavUrl});
123+
Process process = Runtime.getRuntime().exec(path + ' ' + webdavUrl);
119124
return process.waitFor();
120125
}
121126
}

src/main/java/org/silverpeas/openoffice/OpenOfficeLauncher.java

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/main/java/org/silverpeas/openoffice/util/RegistryKeyReader.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,20 @@ public static String readKey(String regKey) {
5454
}
5555
return null;
5656
}
57+
58+
public static boolean checkRegistryKey(String baseKey, String key) {
59+
try {
60+
Process process = Runtime.getRuntime().exec(REGQUERY_UTIL + baseKey + " /f" + key);
61+
StreamReader reader = new StreamReader(process.getInputStream());
62+
reader.start();
63+
process.waitFor();
64+
reader.join();
65+
String result = reader.getResult();
66+
int p = result.indexOf(baseKey + '\\' + key);
67+
return (p != -1);
68+
} catch (Exception e) {
69+
logger.log(Level.SEVERE, MessageUtil.getMessage("error.reading.registry"), e);
70+
}
71+
return false;
72+
}
5773
}

src/main/java/org/silverpeas/openoffice/windows/MsOfficeRegistryHelper.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
/**
22
* Copyright (C) 2000 - 2009 Silverpeas
33
*
4-
* This program is free software: you can redistribute it and/or modify
5-
* it under the terms of the GNU Affero General Public License as
6-
* published by the Free Software Foundation, either version 3 of the
7-
* License, or (at your option) any later version.
4+
* This program is free software: you can redistribute it and/or modify it under the terms of the
5+
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
6+
* of the License, or (at your option) any later version.
87
*
9-
* As a special exception to the terms and conditions of version 3.0 of
10-
* the GPL, you may redistribute this Program in connection with Free/Libre
11-
* Open Source Software ("FLOSS") applications as described in Silverpeas's
12-
* FLOSS exception. You should have received a copy of the text describing
13-
* the FLOSS exception, and it is also available here:
8+
* As a special exception to the terms and conditions of version 3.0 of the GPL, you may
9+
* redistribute this Program in connection with Free/Libre Open Source Software ("FLOSS")
10+
* applications as described in Silverpeas's FLOSS exception. You should have received a copy of the
11+
* text describing the FLOSS exception, and it is also available here:
1412
* "http://repository.silverpeas.com/legal/licensing"
1513
*
16-
* This program is distributed in the hope that it will be useful,
17-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19-
* GNU Affero General Public License for more details.
14+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
15+
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
* Affero General Public License for more details.
2017
*
21-
* You should have received a copy of the GNU Affero General Public License
22-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
* You should have received a copy of the GNU Affero General Public License along with this program.
19+
* If not, see <http://www.gnu.org/licenses/>.
2320
*/
2421
package org.silverpeas.openoffice.windows;
2522

@@ -43,8 +40,10 @@ public class MsOfficeRegistryHelper implements OfficeFinder {
4340
static final String POWERPOINT = "Powerpoint.Application";
4441
static final String WORD = "Word.Application";
4542
static final String FRONTPAGE = "FrontPage.Application";
43+
static final String BASE_KEY_OFFICE = "\"HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Office\\";
4644
static final String BASE_APPLICATION_KEY = "\"HKEY_LOCAL_MACHINE\\Software\\Classes\\";
47-
static final String BASE_KEY_64_CLSID = "\"HKEY_LOCAL_MACHINE\\Software\\Wow6432Node\\Classes\\CLSID\\";
45+
static final String BASE_KEY_64_CLSID =
46+
"\"HKEY_LOCAL_MACHINE\\Software\\Wow6432Node\\Classes\\CLSID\\";
4847
static final String BASE_KEY_CLSID = "\"HKEY_LOCAL_MACHINE\\Software\\Classes\\CLSID\\";
4948
static final Pattern AUTOMATION = Pattern.compile(
5049
"\\s*/[aA][uU][tT][oO][mM][aA][tT][iI][oO][nN]\\s*");
@@ -61,7 +60,11 @@ protected String getPath(String type) {
6160
path = RegistryKeyReader.readKey(BASE_KEY_64_CLSID + clsid + "\\LocalServer32\"");
6261
}
6362
if (path != null) {
64-
return '"' + extractPath(path) + '"';
63+
String extractedPath = extractPath(path);
64+
if (!extractedPath.startsWith("\"")) {
65+
extractedPath = '"' + extractedPath + '"';
66+
}
67+
return extractedPath;
6568
}
6669
}
6770
return null;

src/main/java/org/silverpeas/openoffice/windows/WindowsLibreOfficeFinder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
public class WindowsLibreOfficeFinder extends OpenOfficeFinder {
3333

3434
static final Logger logger = Logger.getLogger(WindowsLibreOfficeFinder.class.getName());
35-
private static final String[] VERSIONS = new String[]{"3.5", "3.6"};
35+
private static final String[] VERSIONS = new String[]{"3.5", "3.6", "4.0"};
3636
private static final String GLOBAL_LIBRE_OFFICE_FOLDER =
3737
"\"HKEY_LOCAL_MACHINE\\SOFTWARE\\LibreOffice\\LibreOffice\\";
3838
private static final String GLOBAL_LIBRE_OFFICE_FOLDER_64 =

0 commit comments

Comments
 (0)