org.rhq.enterprise.server.plugins.url
Class XmlIndexParser

java.lang.Object
  extended by org.rhq.enterprise.server.plugins.url.XmlIndexParser
All Implemented Interfaces:
IndexParser

public class XmlIndexParser
extends java.lang.Object
implements IndexParser

Parses the index XML file whose format follows the package details schema.

Author:
John Mazzitelli

Constructor Summary
XmlIndexParser()
           
 
Method Summary
protected static java.lang.String generateHash(java.io.File file, java.lang.String algorithm)
          Generates a hash code for the given file.
protected static void generatePackageIndex(java.io.File file, java.util.List<PackageDetailsType> list, java.io.File root, PackageDetailsKeyType packageTypeInfo)
           
protected  java.util.Map<java.lang.String,RemotePackageInfo> jaxbParse(java.io.InputStream indexStream, java.net.URL indexUrl, java.lang.String rootUrlString)
           
static void main(java.lang.String[] args)
          A utility that can build an index file that contains metadata for content found in a given directory.
 java.util.Map<java.lang.String,RemotePackageInfo> parse(java.io.InputStream indexStream, UrlProvider contentSource)
          Given an input stream containing the index data, this will parse that data and return the parsed information.
protected  java.lang.String stripLeadingSlash(java.lang.String str)
           
protected  Property translateListProperty(ListPropertyType object, java.lang.String defaultName)
           
protected  Property translateMapProperty(MapPropertyType object, java.lang.String defaultName)
           
protected  Property translateSimpleProperty(SimplePropertyType object, java.lang.String defaultName)
           
protected  ContentProviderPackageDetails translateXmlToDomain(PackageDetailsType pkg)
          Translates the details XML type to its domain object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlIndexParser

public XmlIndexParser()
Method Detail

parse

public java.util.Map<java.lang.String,RemotePackageInfo> parse(java.io.InputStream indexStream,
                                                               UrlProvider contentSource)
                                                        throws java.lang.Exception
Description copied from interface: IndexParser
Given an input stream containing the index data, this will parse that data and return the parsed information.

Specified by:
parse in interface IndexParser
Parameters:
indexStream - stream containing the index data (it is not necessary for this method to close this)
contentSource - the content source where the index file came from
Returns:
map containing the package metadata info, keyed on each package's location
Throws:
java.lang.Exception - if failed to parse the index file

jaxbParse

protected java.util.Map<java.lang.String,RemotePackageInfo> jaxbParse(java.io.InputStream indexStream,
                                                                      java.net.URL indexUrl,
                                                                      java.lang.String rootUrlString)
                                                               throws java.lang.Exception
Throws:
java.lang.Exception

translateXmlToDomain

protected ContentProviderPackageDetails translateXmlToDomain(PackageDetailsType pkg)
                                                      throws java.lang.Exception
Translates the details XML type to its domain object.

Parameters:
pkg - the XML type object
Returns:
the domain object with the same data that the XML object had
Throws:
java.lang.Exception

translateSimpleProperty

protected Property translateSimpleProperty(SimplePropertyType object,
                                           java.lang.String defaultName)

translateListProperty

protected Property translateListProperty(ListPropertyType object,
                                         java.lang.String defaultName)

translateMapProperty

protected Property translateMapProperty(MapPropertyType object,
                                        java.lang.String defaultName)

stripLeadingSlash

protected java.lang.String stripLeadingSlash(java.lang.String str)

main

public static void main(java.lang.String[] args)
A utility that can build an index file that contains metadata for content found in a given directory.
 java -cp "target\rhq-serverplugin-url-1.3.0-SNAPSHOT.jar;
           ..\..\..\..\core\client-api\target\rhq-core-client-api-1.3.0-SNAPSHOT.jar;
           ..\..\..\..\core\domain\target\rhq-core-domain-ejb3.jar;
           %HOMEPATH%\.m2\repository\commons-logging\commons-logging\1.1.0.jboss\commons-logging-1.1.0.jboss.jar"
      org.rhq.enterprise.server.plugins.url.XmlIndexParser
      C:\my\content\source\directory
      library
      noarch
      "JBossAS Server"
      JBossAS
 

Parameters:
args -

generatePackageIndex

protected static void generatePackageIndex(java.io.File file,
                                           java.util.List<PackageDetailsType> list,
                                           java.io.File root,
                                           PackageDetailsKeyType packageTypeInfo)
                                    throws java.lang.Exception
Throws:
java.lang.Exception

generateHash

protected static java.lang.String generateHash(java.io.File file,
                                               java.lang.String algorithm)
                                        throws java.lang.Exception
Generates a hash code for the given file.

Parameters:
file - the file whose contents is used to generate the hash
algorithm - "MD5" or "SHA-256"
Returns:
Throws:
java.lang.Exception


Copyright © 2008-2009 Red Hat, Inc.. All Rights Reserved.