Skip to Content.
Sympa Menu

notify-dpml - svn commit: r1334 - development/main/magic/core/src/main/net/dpml/magic

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: niclas AT netcompartner.com
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r1334 - development/main/magic/core/src/main/net/dpml/magic
  • Date: Fri, 31 Dec 2004 12:09:54 +0100

Author: niclas
Date: Fri Dec 31 12:09:54 2004
New Revision: 1334

Modified:
development/main/magic/core/src/main/net/dpml/magic/Index.java
Log:
Better error message if the module file is corrupt.

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 Fri
Dec 31 12:09:54 2004
@@ -458,48 +458,11 @@
final String rootElementName = root.getTagName();
if( "index".equals( rootElementName ) )
{
- //
- // its a native magic index
- //
-
- final Element[] elements = ElementHelper.getChildren( root );
- final File anchor = source.getParentFile();
- buildLocalList( anchor, elements, uri );
+ buildIndex( root, source, uri );
}
else if( "module".equals( rootElementName ) )
{
- //
- // its a module definition so we need to add the module as
an available
- // resources and add all of the resources defined by the
module
- //
-
- final String moduleUri = ElementHelper.getAttribute( root,
"uri" );
- Info info = Info.create( moduleUri );
- String key = info.getName();
- Resource resource = new Resource( this, key, info, new
ResourceRef[0], null );
-
- if( !m_resources.containsKey( key ) )
- {
- m_resources.put( key, resource );
- log( "resource: " + resource, Project.MSG_VERBOSE );
- }
- else
- {
- Resource r = (Resource) m_resources.get( key );
- if( !r.equals( resource ) )
- {
- final String error =
- "WARNING: Ignoring duplicate module key reference
["
- + key
- + "].";
- log( error, Project.MSG_WARN );
- }
- }
-
- final Element resources = ElementHelper.getChild( root,
"resources" );
- final Element[] elements = ElementHelper.getChildren(
resources );
- final File anchor = source.getParentFile();
- buildLocalList( anchor, elements, uri );
+ buildModule( root, source, uri );
}
else
{
@@ -513,6 +476,60 @@
throw new BuildException( e, new Location( source.toString() ) );
}
}
+
+ private void buildIndex( Element root, File source, String uri )
+ {
+ //
+ // its a native magic index
+ //
+
+ final Element[] elements = ElementHelper.getChildren( root );
+ final File anchor = source.getParentFile();
+ buildLocalList( anchor, elements, uri );
+ }
+
+ private void buildModule( Element root, File source, String uri )
+ {
+ //
+ // its a module definition so we need to add the module as an
available
+ // resources and add all of the resources defined by the module
+ //
+
+ final String moduleUri = ElementHelper.getAttribute( root, "uri" );
+ if( "".equals( moduleUri ) )
+ {
+ String mess =
+ "Modules must contain a \"uri\" attribute in the root module
element: " + source;
+ throw new BuildException( mess );
+ }
+
+ Info info = Info.create( moduleUri );
+ String key = info.getName();
+ Resource resource = new Resource( this, key, info, new
ResourceRef[0], null );
+
+ if( !m_resources.containsKey( key ) )
+ {
+ m_resources.put( key, resource );
+ log( "resource: " + resource, Project.MSG_VERBOSE );
+ }
+ else
+ {
+ Resource r = (Resource) m_resources.get( key );
+ if( ! r.equals( resource ) )
+ {
+ final String error =
+ "WARNING: Ignoring duplicate module key reference ["
+ + key
+ + "].";
+ log( error, Project.MSG_WARN );
+ }
+ }
+
+ final Element resources = ElementHelper.getChild( root, "resources"
);
+ final Element[] elements = ElementHelper.getChildren( resources );
+ final File anchor = source.getParentFile();
+ buildLocalList( anchor, elements, uri );
+ }

private File resolveIndex( File file )
{
@@ -526,8 +543,7 @@
}
}

- private void buildLocalList(
- final File anchor, final Element[] children, String uri )
+ private void buildLocalList( final File anchor, final Element[]
children, String uri )
{
log( "entries: " + children.length, Project.MSG_VERBOSE );
for( int i=0; i<children.length; i++ )



  • svn commit: r1334 - development/main/magic/core/src/main/net/dpml/magic, niclas, 12/31/2004

Archive powered by MHonArc 2.6.24.

Top of Page