Revision 41278 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/java/org/gvsig/installer/lib/impl/info/InstallerInfoFileWriter.java
InstallerInfoFileWriter.java | ||
---|---|---|
83 | 83 |
} |
84 | 84 |
} |
85 | 85 |
|
86 |
/** |
|
87 |
* Writes the install.info file |
|
88 |
* |
|
89 |
* @param os |
|
90 |
* The file to write the installation information |
|
91 |
* @param installInfo |
|
92 |
* The installation information |
|
93 |
* @throws InstallerInfoFileException |
|
94 |
*/ |
|
95 |
public void write(PackageInfo installInfo, OutputStream os) |
|
96 |
throws InstallerInfoFileException { |
|
97 |
try { |
|
98 |
// Fill the properties |
|
99 |
Properties properties = new Properties(); |
|
100 |
properties.setProperty(InstallerInfoTags.CODE, installInfo |
|
101 |
.getCode()); |
|
102 |
properties.setProperty(InstallerInfoTags.NAME, installInfo |
|
103 |
.getName()); |
|
104 |
properties.setProperty(InstallerInfoTags.DESCRIPTION, installInfo |
|
105 |
.getDescription()); |
|
106 |
properties.setProperty(InstallerInfoTags.VERSION, installInfo |
|
107 |
.getVersion().toString()); |
|
108 |
properties.setProperty(InstallerInfoTags.BUILD, Integer |
|
109 |
.toString(installInfo.getBuild())); |
|
110 |
properties.setProperty(InstallerInfoTags.STATE, installInfo |
|
111 |
.getState()); |
|
112 |
properties.setProperty(InstallerInfoTags.OFFICIAL, Boolean |
|
113 |
.toString(installInfo.isOfficial())); |
|
114 |
properties.setProperty(InstallerInfoTags.TYPE, installInfo |
|
115 |
.getType()); |
|
116 |
properties.setProperty(InstallerInfoTags.OS, installInfo |
|
117 |
.getOperatingSystem()); |
|
118 |
properties.setProperty(InstallerInfoTags.ARCHITECTURE, installInfo |
|
119 |
.getArchitecture()); |
|
120 |
properties.setProperty(InstallerInfoTags.JVM, installInfo |
|
121 |
.getJavaVM()); |
|
122 |
properties.setProperty(InstallerInfoTags.GVSIG_VERSION, installInfo |
|
123 |
.getGvSIGVersion()); |
|
124 |
String owner = installInfo.getOwner(); |
|
125 |
properties.setProperty(InstallerInfoTags.OWNER, owner == null ? "" |
|
126 |
: owner); |
|
127 |
String categories = installInfo.getCategoriesAsString(); |
|
128 |
properties.setProperty(InstallerInfoTags.CATEGORIES, |
|
129 |
categories == null ? "" : categories); |
|
130 |
if (installInfo.getDependencies() == null) { |
|
131 |
properties.setProperty(InstallerInfoTags.DEPENDENCIES, ""); |
|
132 |
} else { |
|
133 |
properties.setProperty(InstallerInfoTags.DEPENDENCIES, |
|
134 |
installInfo.getDependencies().toString()); |
|
135 |
} |
|
136 |
|
|
137 |
URL sourcesURL = installInfo.getSourcesURL(); |
|
138 |
if (sourcesURL != null) { |
|
139 |
properties.setProperty(InstallerInfoTags.SOURCES_URL, |
|
140 |
sourcesURL.toString()); |
|
141 |
} else { |
|
142 |
properties.setProperty(InstallerInfoTags.SOURCES_URL, ""); |
|
143 |
} |
|
144 |
|
|
145 |
URL webURL = installInfo.getWebURL(); |
|
146 |
if (webURL != null) { |
|
147 |
properties.setProperty(InstallerInfoTags.WEB_URL, webURL |
|
148 |
.toString()); |
|
149 |
} else { |
|
150 |
properties.setProperty(InstallerInfoTags.WEB_URL, ""); |
|
151 |
} |
|
152 |
|
|
153 |
String downloadURL = installInfo.getDownloadURLAsString(); |
|
154 |
if (downloadURL != null) { |
|
155 |
properties.setProperty(InstallerInfoTags.DOWNLOAD_URL, |
|
156 |
downloadURL); |
|
157 |
} |
|
158 |
URL ownerURL = installInfo.getOwnerURL(); |
|
159 |
if (ownerURL != null) { |
|
160 |
properties.setProperty(InstallerInfoTags.OWNER_URL, ownerURL |
|
161 |
.toString()); |
|
162 |
} |
|
163 |
properties.setProperty(InstallerInfoTags.MODEL_VERSION, installInfo |
|
164 |
.getModelVersion()); |
|
165 |
properties.store(os, ""); |
|
166 |
os.close(); |
|
167 |
} catch (IOException e) { |
|
168 |
throw new InstallerInfoFileException( |
|
169 |
"install_infofile_writing_error", e); |
|
170 |
} |
|
171 |
} |
|
86 |
/** |
|
87 |
* Writes the install.info file |
|
88 |
* |
|
89 |
* @param os |
|
90 |
* The file to write the installation information |
|
91 |
* @param installInfo |
|
92 |
* The installation information |
|
93 |
* @throws InstallerInfoFileException |
|
94 |
*/ |
|
95 |
public void write(PackageInfo installInfo, OutputStream os) |
|
96 |
throws InstallerInfoFileException { |
|
97 |
try { |
|
98 |
// Fill the properties |
|
99 |
Properties properties = new Properties(); |
|
100 |
properties.setProperty(InstallerInfoTags.CODE, toStr(installInfo.getCode())); |
|
101 |
properties.setProperty(InstallerInfoTags.NAME, toStr(installInfo.getName())); |
|
102 |
properties.setProperty(InstallerInfoTags.DESCRIPTION, toStr(installInfo.getDescription())); |
|
103 |
properties.setProperty(InstallerInfoTags.VERSION, installInfo.getVersion().toString()); |
|
104 |
properties.setProperty(InstallerInfoTags.BUILD, Integer.toString(installInfo.getBuild())); |
|
105 |
properties.setProperty(InstallerInfoTags.STATE, toStr(installInfo.getState())); |
|
106 |
properties.setProperty(InstallerInfoTags.OFFICIAL, Boolean.toString(installInfo.isOfficial())); |
|
107 |
properties.setProperty(InstallerInfoTags.TYPE, toStr(installInfo.getType())); |
|
108 |
properties.setProperty(InstallerInfoTags.OS, toStr(installInfo.getOperatingSystem())); |
|
109 |
properties.setProperty(InstallerInfoTags.ARCHITECTURE, toStr(installInfo.getArchitecture())); |
|
110 |
properties.setProperty(InstallerInfoTags.JVM, toStr(installInfo.getJavaVM())); |
|
111 |
properties.setProperty(InstallerInfoTags.GVSIG_VERSION, toStr(installInfo.getGvSIGVersion())); |
|
112 |
properties.setProperty(InstallerInfoTags.OWNER, toStr(installInfo.getOwner())); |
|
113 |
properties.setProperty(InstallerInfoTags.CATEGORIES, toStr(installInfo.getCategoriesAsString())); |
|
114 |
properties.setProperty(InstallerInfoTags.DEPENDENCIES, toStr(installInfo.getDependencies())); |
|
115 |
properties.setProperty(InstallerInfoTags.SOURCES_URL, toStr(installInfo.getSourcesURL())); |
|
116 |
properties.setProperty(InstallerInfoTags.WEB_URL, toStr(installInfo.getWebURL())); |
|
117 |
properties.setProperty(InstallerInfoTags.DOWNLOAD_URL, toStr(installInfo.getDownloadURLAsString())); |
|
118 |
properties.setProperty(InstallerInfoTags.OWNER_URL, toStr(installInfo.getOwnerURL())); |
|
119 |
properties.setProperty(InstallerInfoTags.MODEL_VERSION, toStr(installInfo.getModelVersion())); |
|
120 |
|
|
121 |
properties.store(os, ""); |
|
122 |
os.close(); |
|
123 |
} catch (IOException e) { |
|
124 |
throw new InstallerInfoFileException( |
|
125 |
"install_infofile_writing_error", e); |
|
126 |
} |
|
127 |
} |
|
128 |
|
|
129 |
private String toStr(Object s) { |
|
130 |
return s == null ? "" : s.toString(); |
|
131 |
} |
|
172 | 132 |
} |
Also available in: Unified diff