Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
Stuart McCulloch | c792b37 | 2008-02-17 16:12:24 +0000 | [diff] [blame] | 19 | package org.apache.felix.obrplugin; |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 20 | |
| 21 | |
| 22 | import java.io.File; |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 23 | import java.io.FileInputStream; |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 24 | import java.io.FileOutputStream; |
| 25 | import java.io.IOException; |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 26 | import java.io.InputStream; |
| 27 | import java.io.OutputStreamWriter; |
| 28 | import java.io.Writer; |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 29 | import java.net.URI; |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 30 | |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 31 | import org.apache.felix.bundlerepository.Resource; |
| 32 | import org.apache.felix.bundlerepository.impl.DataModelHelperImpl; |
| 33 | import org.apache.felix.bundlerepository.impl.PullParser; |
| 34 | import org.apache.felix.bundlerepository.impl.RepositoryImpl; |
| 35 | import org.apache.felix.bundlerepository.impl.RepositoryParser; |
| 36 | import org.apache.felix.bundlerepository.impl.ResourceImpl; |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 37 | import org.apache.maven.plugin.MojoExecutionException; |
| 38 | import org.apache.maven.plugin.logging.Log; |
| 39 | import org.apache.maven.project.MavenProject; |
Stuart McCulloch | 8812902 | 2009-09-03 02:52:58 +0000 | [diff] [blame] | 40 | import org.codehaus.plexus.util.FileUtils; |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 41 | import org.kxml2.io.KXmlParser; |
| 42 | import org.xmlpull.v1.XmlPullParser; |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 43 | |
| 44 | |
| 45 | /** |
| 46 | * this class parse the old repository.xml file build the bundle resource description and update the repository. |
| 47 | * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a> |
| 48 | */ |
| 49 | public class ObrUpdate |
| 50 | { |
| 51 | /** |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 52 | * logger for this plugin. |
| 53 | */ |
| 54 | private Log m_logger; |
| 55 | |
| 56 | /** |
| 57 | * name and path to the repository descriptor file. |
| 58 | */ |
| 59 | private URI m_repositoryXml; |
| 60 | |
| 61 | /** |
| 62 | * name and path to the obr.xml file. |
| 63 | */ |
| 64 | private URI m_obrXml; |
| 65 | |
| 66 | /** |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 67 | * maven project description. |
| 68 | */ |
| 69 | private MavenProject m_project; |
| 70 | |
| 71 | /** |
| 72 | * user configuration information. |
| 73 | */ |
| 74 | private Config m_userConfig; |
| 75 | |
| 76 | /** |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 77 | * root on parent document. |
| 78 | */ |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 79 | private RepositoryImpl m_repository; |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 80 | |
| 81 | /** |
| 82 | * used to store bundle information. |
| 83 | */ |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 84 | private ResourceImpl m_resourceBundle; |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 85 | |
| 86 | /** |
| 87 | * base URI used to relativize bundle URIs. |
| 88 | */ |
| 89 | private URI m_baseURI; |
| 90 | |
| 91 | |
| 92 | /** |
| 93 | * initialize information. |
| 94 | * @param repositoryXml path to the repository descriptor file |
| 95 | * @param obrXml path and filename to the obr.xml file |
| 96 | * @param project maven project description |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 97 | * @param mavenRepositoryPath path to the local maven repository |
| 98 | * @param userConfig user information |
| 99 | * @param logger plugin logger |
| 100 | */ |
Stuart McCulloch | 0ae86ab | 2008-02-19 06:24:30 +0000 | [diff] [blame] | 101 | public ObrUpdate( URI repositoryXml, URI obrXml, MavenProject project, String mavenRepositoryPath, |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 102 | Config userConfig, Log logger ) |
| 103 | { |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 104 | m_repositoryXml = repositoryXml; |
| 105 | m_obrXml = obrXml; |
| 106 | m_project = project; |
| 107 | m_logger = logger; |
| 108 | |
| 109 | m_userConfig = userConfig; |
| 110 | |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 111 | if ( userConfig.isRemoteFile() ) |
| 112 | { |
| 113 | m_baseURI = ObrUtils.toFileURI( mavenRepositoryPath ); |
| 114 | } |
| 115 | else |
| 116 | { |
| 117 | m_baseURI = m_repositoryXml; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | |
| 122 | /** |
Stuart McCulloch | 0ae86ab | 2008-02-19 06:24:30 +0000 | [diff] [blame] | 123 | * update the repository descriptor file. parse the old repository descriptor file, |
| 124 | * get the old reference of the bundle or determine the id for a new bundle, extract |
| 125 | * information from bindex set the new information in descriptor file and save it. |
| 126 | * |
| 127 | * @param bundleJar path to the bundle jar file |
| 128 | * @param sourceJar path to the source jar file |
Stuart McCulloch | a1d3a29 | 2008-02-20 00:53:52 +0000 | [diff] [blame] | 129 | * @param docJar path to the docs jar file |
Stuart McCulloch | 0ae86ab | 2008-02-19 06:24:30 +0000 | [diff] [blame] | 130 | * |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 131 | * @throws MojoExecutionException if the plugin failed |
| 132 | */ |
Stuart McCulloch | a1d3a29 | 2008-02-20 00:53:52 +0000 | [diff] [blame] | 133 | public void updateRepository( URI bundleJar, URI sourceJar, URI docJar ) throws MojoExecutionException |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 134 | { |
| 135 | m_logger.debug( " (f) repositoryXml = " + m_repositoryXml ); |
Stuart McCulloch | 0ae86ab | 2008-02-19 06:24:30 +0000 | [diff] [blame] | 136 | m_logger.debug( " (f) bundleJar = " + bundleJar ); |
| 137 | m_logger.debug( " (f) sourceJar = " + sourceJar ); |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 138 | m_logger.debug( " (f) obrXml = " + m_obrXml ); |
| 139 | |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 140 | if ( m_repository == null ) |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 141 | { |
| 142 | return; |
| 143 | } |
| 144 | |
| 145 | // get the file size |
Stuart McCulloch | 0ae86ab | 2008-02-19 06:24:30 +0000 | [diff] [blame] | 146 | File bundleFile = new File( bundleJar ); |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 147 | if ( bundleFile.exists() ) |
| 148 | { |
| 149 | URI resourceURI = m_userConfig.getRemoteBundle(); |
| 150 | if ( null == resourceURI ) |
| 151 | { |
Stuart McCulloch | 0ae86ab | 2008-02-19 06:24:30 +0000 | [diff] [blame] | 152 | resourceURI = bundleJar; |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 153 | if ( m_userConfig.isPathRelative() ) |
| 154 | { |
| 155 | resourceURI = ObrUtils.getRelativeURI( m_baseURI, resourceURI ); |
| 156 | } |
| 157 | } |
| 158 | |
Stuart McCulloch | 7b6f591 | 2008-02-18 17:30:36 +0000 | [diff] [blame] | 159 | if ( m_userConfig.isRemoteFile() ) |
| 160 | { |
| 161 | m_logger.info( "Deploying " + resourceURI ); |
| 162 | } |
| 163 | else |
| 164 | { |
| 165 | m_logger.info( "Installing " + resourceURI ); |
| 166 | } |
| 167 | |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 168 | try |
| 169 | { |
| 170 | m_resourceBundle = (ResourceImpl) new DataModelHelperImpl().createResource( bundleJar.toURL() ); |
Guillaume Nodet | 127d557 | 2010-03-19 18:24:02 +0000 | [diff] [blame] | 171 | if (m_resourceBundle == null) |
| 172 | { |
| 173 | return; |
| 174 | } |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 175 | } |
| 176 | catch (IOException e) |
| 177 | { |
| 178 | throw new MojoExecutionException("Unable to load resource information", e); |
| 179 | } |
| 180 | |
| 181 | m_resourceBundle.put( Resource.SIZE, String.valueOf( bundleFile.length() ) ); |
| 182 | m_resourceBundle.put( Resource.URI, resourceURI.toASCIIString() ); |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 183 | } |
| 184 | else |
| 185 | { |
Stuart McCulloch | 0ae86ab | 2008-02-19 06:24:30 +0000 | [diff] [blame] | 186 | m_logger.error( "file doesn't exist: " + bundleJar ); |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 187 | return; |
| 188 | } |
| 189 | |
| 190 | // parse the obr.xml file |
| 191 | if ( m_obrXml != null ) |
| 192 | { |
| 193 | m_logger.info( "Adding " + m_obrXml ); |
| 194 | |
| 195 | // URL url = getClass().getResource("/SchemaObr.xsd"); |
| 196 | // TODO validate obr.xml file |
| 197 | |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 198 | // add contents to resource bundle |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 199 | parseObrXml(); |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 200 | } |
| 201 | |
Stuart McCulloch | a1d3a29 | 2008-02-20 00:53:52 +0000 | [diff] [blame] | 202 | String sourcePath = relativisePath( sourceJar ); |
| 203 | String docPath = relativisePath( docJar ); |
Stuart McCulloch | 0ae86ab | 2008-02-19 06:24:30 +0000 | [diff] [blame] | 204 | |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 205 | // m_resourceBundle.construct( m_project, bindexExtractor, sourcePath, docPath ); |
| 206 | // TODO: rebuild wrt m_project |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 207 | |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 208 | m_repository.addResource( m_resourceBundle ); |
| 209 | m_repository.setLastModified(System.currentTimeMillis()); |
Stuart McCulloch | 0ae86ab | 2008-02-19 06:24:30 +0000 | [diff] [blame] | 210 | } |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 211 | |
Stuart McCulloch | 0ae86ab | 2008-02-19 06:24:30 +0000 | [diff] [blame] | 212 | |
Stuart McCulloch | a1d3a29 | 2008-02-20 00:53:52 +0000 | [diff] [blame] | 213 | private String relativisePath( URI uri ) |
| 214 | { |
| 215 | if ( null != uri ) |
| 216 | { |
| 217 | if ( m_userConfig.isPathRelative() ) |
| 218 | { |
| 219 | return ObrUtils.getRelativeURI( m_baseURI, uri ).toASCIIString(); |
| 220 | } |
| 221 | |
| 222 | return uri.toASCIIString(); |
| 223 | } |
| 224 | |
| 225 | return null; |
| 226 | } |
| 227 | |
| 228 | |
Stuart McCulloch | 0ae86ab | 2008-02-19 06:24:30 +0000 | [diff] [blame] | 229 | public void writeRepositoryXml() throws MojoExecutionException |
| 230 | { |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 231 | m_logger.info( "Writing OBR metadata" ); |
Stuart McCulloch | 0ae86ab | 2008-02-19 06:24:30 +0000 | [diff] [blame] | 232 | |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 233 | File file = null; |
| 234 | Writer writer; |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 235 | try |
| 236 | { |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 237 | file = File.createTempFile( "repository", ".xml" ); |
| 238 | writer = new OutputStreamWriter( new FileOutputStream( file ) ); |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 239 | } |
| 240 | catch ( IOException e ) |
| 241 | { |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 242 | m_logger.error( "Unable to write to file: " + file.getName() ); |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 243 | e.printStackTrace(); |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 244 | throw new MojoExecutionException( "Unable to write to file: " + file.getName() + " : " + e.getMessage() ); |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 245 | } |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 246 | |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 247 | try |
| 248 | { |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 249 | new DataModelHelperImpl().writeRepository(m_repository, writer); |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 250 | } |
Stuart McCulloch | 8812902 | 2009-09-03 02:52:58 +0000 | [diff] [blame] | 251 | catch ( IOException e ) |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 252 | { |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 253 | throw new MojoExecutionException( "Unable to write repository xml", e ); |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | try |
| 257 | { |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 258 | writer.flush(); |
| 259 | writer.close(); |
Stuart McCulloch | 8812902 | 2009-09-03 02:52:58 +0000 | [diff] [blame] | 260 | |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 261 | File outputFile = new File( m_repositoryXml ); |
Stuart McCulloch | 8812902 | 2009-09-03 02:52:58 +0000 | [diff] [blame] | 262 | outputFile.getParentFile().mkdirs(); |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 263 | FileUtils.rename( file, outputFile ); |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 264 | } |
| 265 | catch ( IOException e ) |
| 266 | { |
| 267 | e.printStackTrace(); |
| 268 | throw new MojoExecutionException( "IOException" ); |
| 269 | } |
| 270 | |
| 271 | } |
| 272 | |
| 273 | |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 274 | /** |
| 275 | * Parse the repository descriptor file. |
| 276 | * |
| 277 | * @throws MojoExecutionException if the plugin failed |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 278 | */ |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 279 | public void parseRepositoryXml() throws MojoExecutionException |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 280 | { |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 281 | File fout = new File( m_repositoryXml ); |
| 282 | if ( !fout.exists() ) |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 283 | { |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 284 | m_repository = new RepositoryImpl(); |
| 285 | writeRepositoryXml(); |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 286 | } |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 287 | else |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 288 | { |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 289 | try |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 290 | { |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 291 | m_repository = (RepositoryImpl) new DataModelHelperImpl().repository( m_repositoryXml.toURL() ); |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 292 | } |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 293 | catch ( Exception e ) |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 294 | { |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 295 | throw new MojoExecutionException( "Unable to read repository xml: " + m_repositoryXml, e ); |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 296 | } |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | |
| 301 | /** |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 302 | * put the information from obr.xml into ressourceBundle object. |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 303 | */ |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 304 | private void parseObrXml() throws MojoExecutionException { |
| 305 | try |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 306 | { |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 307 | InputStream is = new FileInputStream(new File(m_obrXml)); |
| 308 | try |
| 309 | { |
| 310 | KXmlParser kxp = new KXmlParser(); |
| 311 | kxp.setInput(is, null); |
Guillaume Nodet | bdc1375 | 2010-03-25 08:21:15 +0000 | [diff] [blame^] | 312 | kxp.nextTag(); // skip top level element |
| 313 | kxp.nextTag(); // go to first child element |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 314 | parseObrXml(kxp); |
| 315 | } |
| 316 | finally |
| 317 | { |
| 318 | is.close(); |
| 319 | } |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 320 | } |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 321 | catch (Exception e) |
| 322 | { |
| 323 | throw new MojoExecutionException("Unable to parse obr xml: " + m_obrXml, e); |
| 324 | } |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 325 | } |
Guillaume Nodet | 8d5faf6 | 2010-03-19 15:32:17 +0000 | [diff] [blame] | 326 | |
| 327 | private void parseObrXml(KXmlParser kxp) throws Exception |
| 328 | { |
| 329 | PullParser parser = new PullParser(); |
| 330 | while (kxp.getEventType() == XmlPullParser.START_TAG) |
| 331 | { |
| 332 | if (RepositoryParser.CATEGORY.equals(kxp.getName())) |
| 333 | { |
| 334 | m_resourceBundle.addCategory(parser.parseCategory(kxp)); |
| 335 | } |
| 336 | else if (RepositoryParser.REQUIRE.equals(kxp.getName())) |
| 337 | { |
| 338 | m_resourceBundle.addRequire(parser.parseRequire(kxp)); |
| 339 | } |
| 340 | else if (RepositoryParser.CAPABILITY.equals(kxp.getName())) |
| 341 | { |
| 342 | m_resourceBundle.addCapability(parser.parseCapability(kxp)); |
| 343 | } |
| 344 | else |
| 345 | { |
| 346 | kxp.nextTag(); |
| 347 | parseObrXml(kxp); |
| 348 | } |
| 349 | kxp.nextTag(); |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | |
Stuart McCulloch | bb8b9fa | 2008-02-17 16:07:14 +0000 | [diff] [blame] | 354 | } |