1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: BuildID.java,v $
10 * $Revision: 1.1.2.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 import helper
.OSHelper
;
38 public static String
getBuildID(String _sApp
)
40 String sOfficePath
= "";
41 // TODO: StringHelper.removeQuote?
42 if (_sApp
.startsWith("\""))
44 int nIdx
= _sApp
.indexOf("\"", 1);
47 // leave double qoute out.
48 sOfficePath
= _sApp
.substring(1, nIdx
);
53 // check if a space exist, so we get all until space
54 int nIdx
= _sApp
.indexOf(" ", 1);
61 sOfficePath
= _sApp
.substring(0, nIdx
);
64 GlobalLogWriter
.get().println("Office path: " + sOfficePath
);
66 // String fs = System.getProperty("file.separator");
68 File aSOfficeFile
= new File(sOfficePath
);
69 if (aSOfficeFile
.exists())
71 sOfficePath
= FileHelper
.getPath(sOfficePath
);
72 // ok. System.out.println("directory: " + sOfficePath);
73 sBuildID
= getBuildIDFromBootstrap(sOfficePath
);
74 if (sBuildID
.length() == 0)
76 sBuildID
= getBuildIDFromVersion(sOfficePath
);
81 GlobalLogWriter
.get().println("soffice executable not found.");
88 private static String
getBuildIDFromBootstrap(String _sOfficePath
)
92 if (OSHelper
.isWindows())
94 sOfficePath
= FileHelper
.appendPath(_sOfficePath
, "bootstrap.ini");
98 sOfficePath
= FileHelper
.appendPath(_sOfficePath
, "bootstraprc");
100 IniFile aIniFile
= new IniFile(sOfficePath
);
103 sBuildID
= aIniFile
.getValue("Bootstrap", "buildid");
107 GlobalLogWriter
.get().println("Property Build, can't open file '" + sOfficePath
+ "', please check.");
112 private static String
getBuildIDFromVersion(String _sOfficePath
)
114 // String fs = System.getProperty("file.separator");
115 String sBuildID
= "";
117 if (OSHelper
.isWindows())
119 sOfficePath
= FileHelper
.appendPath(_sOfficePath
, "version.ini");
123 sOfficePath
= FileHelper
.appendPath(_sOfficePath
, "versionrc");
125 IniFile aIniFile
= new IniFile(sOfficePath
);
128 sBuildID
= aIniFile
.getValue("Version", "buildid");
132 GlobalLogWriter
.get().println("Property Build, can't open file '" + sOfficePath
+ "', please check.");
137 // public static void main(String[] args)
140 // sApp = "/opt/staroffice8_m116/program/soffice -headless -accept=socket,host=localhost,port=8100;urp;";
142 // sBuildID = getBuildID(sApp);
143 // System.out.println("BuildID is: " + sBuildID);
145 // Date aDate = new Date();
146 // long nStart = aDate.getTime();
147 // System.out.println("Time:" + nStart);
148 // // LLA: Just some more tests for getBuildID
149 // // sApp = "/opt/staroffice8_net/program/soffice";
150 // // sBuildID = getBuildID(sApp);
151 // // System.out.println("BuildID is: " + sBuildID);
153 // // sApp = "\"/opt/staroffice8_net/program/soffice\" test blah";
154 // // sBuildID = getBuildID(sApp);
156 // // System.out.println("BuildID is: " + sBuildID);