Skip to Content.
Sympa Menu

notify-dpml - svn commit: r1541 - in development/main/magic/core/src/main/net/dpml/magic: . builder

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT netcompartner.com
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r1541 - in development/main/magic/core/src/main/net/dpml/magic: . builder
  • Date: Thu, 20 Jan 2005 14:32:53 +0100

Author: mcconnell
Date: Thu Jan 20 14:32:53 2005
New Revision: 1541

Modified:
development/main/magic/core/src/main/net/dpml/magic/Index.java

development/main/magic/core/src/main/net/dpml/magic/builder/IndexBuilder.java

development/main/magic/core/src/main/net/dpml/magic/builder/XMLDefinitionBuilder.java
Log:
fix bug related to element selection

Modified: development/main/magic/core/src/main/net/dpml/magic/Index.java
==============================================================================
--- development/main/magic/core/src/main/net/dpml/magic/Index.java
(original)
+++ development/main/magic/core/src/main/net/dpml/magic/Index.java Thu
Jan 20 14:32:53 2005
@@ -156,7 +156,6 @@
buildList( m_index );
int n = m_resources.size();
log( "Resources: " + n, Project.MSG_VERBOSE );
-
}

private void processModuleProperties( Project project, File base )
@@ -455,6 +454,10 @@
// internal
//-------------------------------------------------------------

+ /**
+ * Populate the index from the contents of the supplied XML source.
+ * @param source the index source file
+ */
private void buildList( final File source )
{
buildList( source, null );
@@ -598,7 +601,7 @@
else
{
final String error =
- "Source index or module [" + source + "] declartes the key
[" + key + "] that is already bound.";
+ "Source index or module [" + source + "] declares the key
[" + key + "] that is already bound.";
throw new BuildException( error );
}
}
@@ -614,7 +617,7 @@
}

final Element resources = ElementHelper.getChild( root, "resources"
);
- final Element[] elements = ElementHelper.getChildren( resources );
+ final Element[] elements = ElementHelper.getChildren( resources,
"resource" );
final File anchor = source.getParentFile();
final ResourceRef[] children = new ResourceRef[ elements.length ];
for( int i=0; i < elements.length; i++ )
@@ -633,8 +636,6 @@
log( "resource: " + module, Project.MSG_VERBOSE );

return module;
-
- //buildLocalList( anchor, elements, uri );
}

private File resolveIndex( File file )
@@ -659,12 +660,10 @@
if( "import".equals( element.getTagName() ) )
{
final String filename = element.getAttribute( "index" );
- final String path = element.getAttribute( "href" );
final String urn = element.getAttribute( "uri" );
if(( null != filename ) && ( !"".equals( filename )))
{
final File index = IndexBuilder.getFile( anchor,
filename );
- //buildList( index, urn );
buildList( index, uri );
}
else if(( null != urn ) && ( !"".equals( urn )))
@@ -690,19 +689,10 @@
}
}
}
- else if(( null != path ) && ( !"".equals( path )))
- {
- // switch to remote
- if( !m_includes.contains( path ) )
- {
- m_includes.add( path );
- buildRemoteList( path );
- }
- }
else
{
final String error =
- "Invalid import statement. No uri, href or index
attribute.";
+ "Invalid import statement. No uri, index attribute.";
throw new BuildException( error );
}
}
@@ -744,167 +734,6 @@
}
}

- private void buildRemoteList( String path )
- {
- log( "import: " + path, Project.MSG_VERBOSE );
- final URL url = createURL( path );
- buildRemoteList( url );
- }
-
- private void buildRemoteList( URL url )
- {
- log( "import: " + url, Project.MSG_VERBOSE );
- InputStream input = null;
- try
- {
- input = url.openStream();
- final Element root = ElementHelper.getRootElement( input );
- final Element[] elements = ElementHelper.getChildren( root );
- buildRemoteList( url, elements );
- }
- catch( SAXParseException e )
- {
- int line = e.getLineNumber();
- int column = e.getColumnNumber();
- throw new BuildException( e, new Location( url.toString(), line,
column ) );
- }
- catch( SAXException e )
- {
- if( e.getException() != null)
- {
- throw new BuildException(
- e.getException(), new Location( url.toString() ) );
- }
- throw new BuildException( e, new Location( url.toString() ) );
- }
- catch( Throwable e )
- {
- throw new BuildException( e, new Location( url.toString() ) );
- }
- finally
- {
- if( null != input )
- {
- try
- {
- input.close();
- }
- catch( IOException ioe )
- {
- // ignore
- }
- }
- }
- }
-
- private void buildRemoteList( final URL source, final Element[] children
)
- {
- log( "entries: " + children.length, Project.MSG_VERBOSE );
- for( int i=0; i<children.length; i++ )
- {
- final Element element = children[i];
- final String tag = element.getTagName();
- if( isaResource( tag ) )
- {
- final Resource resource = createResource( element );
- final String key = resource.getKey();
- m_resources.put( key, resource );
- log(
- "resource: " + resource + " key=" + key,
- Project.MSG_VERBOSE );
- }
- else if( "import".equals( element.getTagName() ) )
- {
- final String path = element.getAttribute( "href" );
- final String urn = element.getAttribute( "uri" );
- final String index = element.getAttribute( "index" );
- if(( null != urn ) && ( !"".equals( urn )))
- {
- // switch to artifact
- if( !m_includes.contains( urn ) )
- {
- m_includes.add( urn );
- try
- {
- URL artifact = new URL( null, urn, new Handler()
);
- File local = (File) artifact.getContent( new
Class[]{ File.class } );
- buildList( local, urn );
- }
- catch( IOException ioe )
- {
- final String error =
- "Failed to load module ["
- + urn
- + "]."
- + ioe.toString();
- throw new BuildException( error, ioe );
- }
- }
- }
- else if(( null != path ) && ( !"".equals( path )))
- {
- if( !m_includes.contains( path ) )
- {
- m_includes.add( path );
- buildRemoteList( path );
- }
- }
- else if(( null != index ) && ( !"".equals( index )))
- {
- URL href = resolveURL( source, index );
- if( !m_includes.contains( href.toString() ) )
- {
- m_includes.add( href.toString() );
- buildRemoteList( href );
- }
- }
- else
- {
- final String error =
- "Import statement in remote index does not contain a
'uri' or 'href' or 'index' attribute.";
- throw new BuildException( error, new Location(
source.toString() ) );
- }
- }
- else
- {
- final String error =
- "Unrecognized element type \"" + tag + "\" found in remote
index.";
- throw new BuildException( error, new Location(
source.toString() ) );
- }
- }
- }
-
- private URL createURL( String path )
- {
- try
- {
- if( path.startsWith( "artifact:" ) )
- {
- return new URL( null, path, new Handler() );
- }
- else
- {
- return new URL( path );
- }
- }
- catch( IOException ioe )
- {
- throw new BuildException( ioe );
- }
- }
-
- private URL resolveURL( URL base, String path )
- {
- try
- {
- return new URL( base, path );
- }
- catch( IOException ioe )
- {
- throw new BuildException( ioe );
- }
- }
-
private Resource createResource(
final Element element, final File anchor, String uri )
{
@@ -927,7 +756,6 @@
final Project project, final File file ) throws BuildException
{
final Property props = (Property) project.createTask( "property" );
- //props.setTaskName( "project" );
props.init();
props.setFile( file );
props.execute();

Modified:
development/main/magic/core/src/main/net/dpml/magic/builder/IndexBuilder.java
==============================================================================
---
development/main/magic/core/src/main/net/dpml/magic/builder/IndexBuilder.java
(original)
+++
development/main/magic/core/src/main/net/dpml/magic/builder/IndexBuilder.java
Thu Jan 20 14:32:53 2005
@@ -189,14 +189,6 @@
return null;
}

-/* Niclas: Never used.
- private static String getTemplatePath( File system )
- {
- File templates = new File( system, "templates" );
- return getCanonicalPath( templates );
- }
-*/
-
/**
* Return a file using a supplied root and path. If the path is absolute
* an absolute file is retured relative to the supplied path otherwise the

Modified:
development/main/magic/core/src/main/net/dpml/magic/builder/XMLDefinitionBuilder.java
==============================================================================
---
development/main/magic/core/src/main/net/dpml/magic/builder/XMLDefinitionBuilder.java
(original)
+++
development/main/magic/core/src/main/net/dpml/magic/builder/XMLDefinitionBuilder.java
Thu Jan 20 14:32:53 2005
@@ -111,7 +111,9 @@
else
{
final String error =
- "Unrecognized project type \"" + tag + "\".";
+ "Unrecognized element name \""
+ + tag
+ + "\" (recognized types include 'resource', 'project' and
'import').";
throw new BuildException( error );
}
}



  • svn commit: r1541 - in development/main/magic/core/src/main/net/dpml/magic: . builder, mcconnell, 01/20/2005

Archive powered by MHonArc 2.6.24.

Top of Page