xref: /AOO41X/main/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Dumper.java (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 package org.openoffice.setup.Util;
29 
30 import org.openoffice.setup.InstallData;
31 import org.openoffice.setup.SetupData.PackageDescription;
32 import java.util.Enumeration;
33 import java.util.Iterator;
34 import java.util.Map;
35 import java.util.Properties;
36 import java.util.Vector;
37 
38 
39 public class Dumper {
40 
41     private Dumper() {
42     }
43 
44     static public void dumpPackageSettings(PackageDescription packageData) {
45 
46         if ( packageData.isLeaf() ) {
47             System.out.println("Name: " + packageData.getName() +
48                                " State: " + packageData.getSelectionState()  +
49                                " " + packageData.getPackageName());
50         } else {
51             System.out.println("Nod-Name: " + packageData.getName() +
52                                " State: " + packageData.getSelectionState());
53         }
54 
55         for (Enumeration e = packageData.children(); e.hasMoreElements(); ) {
56             PackageDescription child = (PackageDescription) e.nextElement();
57             dumpPackageSettings(child);
58         }
59 
60     }
61 
62     static public void dumpModuleStates(PackageDescription packageData) {
63 
64         System.err.println("Name: " + packageData.getName() +
65                            " State: " + packageData.getSelectionState() +
66                            " " + packageData.getPackageName());
67 
68         for (Enumeration e = packageData.children(); e.hasMoreElements(); ) {
69             PackageDescription child = (PackageDescription) e.nextElement();
70             dumpModuleStates(child);
71         }
72     }
73 
74     static private String getStateString(int state) {
75         String stateString = null;
76 
77         if ( state == 0 ) {
78             stateString = "DONT_INSTALL";
79         } else if ( state == 1 ) {
80             stateString = "INSTALL";
81         } else if ( state == 2 ) {
82             stateString = "INSTALL_SOME";
83         } else if ( state == 3 ) {
84             stateString = "REMOVE";
85         } else if ( state == 4 ) {
86             stateString = "DONT_REMOVE";
87         } else if ( state == 5 ) {
88             stateString = "REMOVE_SOME";
89         } else if ( state == 6 ) {
90             stateString = "IGNORE";
91         } else if ( state == 7 ) {
92             stateString = "DONT_KNOW";
93         } else {
94             stateString = null;
95         }
96 
97         return stateString;
98     }
99 
100     static private void logModuleStatesHelper(PackageDescription packageData) {
101         int state = packageData.getSelectionState();
102         String stateStr = getStateString(state);
103 
104         LogManager.addModulesLogfileComment("Name: " + packageData.getName() +
105                            " State: " + stateStr +
106                            " " + packageData.getPackageName());
107 
108         // System.err.println("Name: " + packageData.getName() +
109         //                    " State: " + stateStr +
110         //                    " " + packageData.getPackageName());
111 
112         for (Enumeration e = packageData.children(); e.hasMoreElements(); ) {
113             PackageDescription child = (PackageDescription) e.nextElement();
114             logModuleStatesHelper(child);
115         }
116     }
117 
118     static public void logModuleStates(PackageDescription packageData, String text) {
119         LogManager.setModulesLogFileHeaderLine(text);
120         logModuleStatesHelper(packageData);
121     }
122 
123     static public void logPackagesToInstall(Vector packages, String text) {
124         PackageDescription packageData = null;
125         LogManager.setModulesLogFileHeaderLine(text);
126         for (int i = 0; i < packages.size(); i++) {
127             packageData = (PackageDescription)packages.get(i);
128             LogManager.addModulesLogfileComment("Name: " + packageData.getName() +
129                                                 " " + packageData.getPackageName());
130         }
131     }
132 
133     static public void dumpInstallPackages(PackageDescription packageData) {
134 
135         if (( packageData.isLeaf() ) && ( packageData.getSelectionState() == packageData.INSTALL )) {
136             System.out.println("Now installing: " + packageData.getPackageName());
137         }
138 
139         for (Enumeration e = packageData.children(); e.hasMoreElements(); ) {
140             PackageDescription child = (PackageDescription) e.nextElement();
141             dumpInstallPackages(child);
142         }
143     }
144 
145     static public void dumpUninstallPackages(PackageDescription packageData) {
146 
147         if (( packageData.isLeaf() ) && ( packageData.getSelectionState() == packageData.REMOVE )) {
148             System.out.println("Now uninstalling: " + packageData.getPackageName());
149         }
150 
151         for (Enumeration e = packageData.children(); e.hasMoreElements(); ) {
152             PackageDescription child = (PackageDescription) e.nextElement();
153             dumpUninstallPackages(child);
154         }
155     }
156 
157     static public void dumpAllRpmInfo(PackageDescription packageData) {
158 
159         if (( packageData.getPackageName() != null ) && ( ! packageData.getPackageName().equals(""))) {
160             if ( packageData.pkgExists() ) {
161                 System.err.println("RPM data: " + packageData.getPkgRealName() + " : " +
162                                                   packageData.getPkgVersion() + " : " +
163                                                   packageData.getPkgRelease() + " : " +
164                                                   packageData.getPackageName() );
165             }
166         }
167 
168         for (Enumeration e = packageData.children(); e.hasMoreElements(); ) {
169             PackageDescription child = (PackageDescription) e.nextElement();
170             dumpAllRpmInfo(child);
171         }
172 
173     }
174 
175     static public void dumpNewInstallData() {
176         InstallData data = InstallData.getInstance();
177         System.err.println("PackagePath: " + data.getPackagePath());
178         System.err.println("AdminFileReloc: " + data.getAdminFileNameReloc());
179         System.err.println("AdminFileRelocNoDepends: " + data.getAdminFileNameRelocNoDepends());
180         System.err.println("AdminFileNoReloc: " + data.getAdminFileNameNoReloc());
181         System.err.println("AdminFileNoRelocNoDepends: " + data.getAdminFileNameNoRelocNoDepends());
182         System.err.println("DatabasePath: " + data.getDatabasePath());
183         System.err.println("InstallDir: " + data.getInstallDir());
184         System.err.println("Original privileges: " + data.getStoredInstallationPrivileges());
185         System.err.println("getuid.so File: " + data.getGetUidPath());
186     }
187 
188     static public void dumpAllProperties() {
189         Properties properties = System.getProperties();
190 
191         int size = properties.size();
192         Iterator m = properties.entrySet().iterator();
193         int counter = 0;
194 
195         while ( m.hasNext() ) {
196             Map.Entry entry = (Map.Entry) m.next();
197             String env = entry.getKey() + "=" + entry.getValue();
198             System.err.println(env);
199         }
200     }
201 
202 }
203