You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2007/04/23 17:57:45 UTC
svn commit: r531514 - in
/directory/ldapstudio/trunk/ldapstudio-schemas-plugin: .classpath ivy.xml
ressources/templates/
src/main/java/org/apache/directory/ldapstudio/schemas/io/SchemaWriter.java
Author: pamarcelot
Date: Mon Apr 23 08:57:44 2007
New Revision: 531514
URL: http://svn.apache.org/viewvc?view=rev&rev=531514
Log:
Removed the dependency to Velocity.
Removed:
directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ressources/templates/
Modified:
directory/ldapstudio/trunk/ldapstudio-schemas-plugin/.classpath
directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ivy.xml
directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/io/SchemaWriter.java
Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/.classpath
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/.classpath?view=diff&rev=531514&r1=531513&r2=531514
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/.classpath (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/.classpath Mon Apr 23 08:57:44 2007
@@ -7,7 +7,6 @@
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3.8.1"/>
<classpathentry kind="lib" path="lib/antlr-2.7.6.jar"/>
- <classpathentry kind="lib" path="lib/checkstyle-2.2.jar"/>
<classpathentry kind="lib" path="lib/log4j-1.2.13.jar"/>
<classpathentry kind="lib" path="lib/nlog4j-1.2.25.jar"/>
<classpathentry kind="lib" path="lib/shared-converter-0.9.6-SNAPSHOT.jar"/>
@@ -19,7 +18,7 @@
<classpathentry kind="lib" path="lib/commons-logging-1.1.jar"/>
<classpathentry kind="lib" path="lib/shared-asn1-0.9.6-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="lib/shared-ldap-0.9.6-SNAPSHOT.jar"/>
- <classpathentry kind="lib" path="lib/velocity-dep-1.4.jar"/>
<classpathentry kind="lib" path="lib/commons-collections-3.2.jar"/>
+ <classpathentry kind="lib" path="lib/checkstyle-2.2.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ivy.xml
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ivy.xml?view=diff&rev=531514&r1=531513&r2=531514
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ivy.xml (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ivy.xml Mon Apr 23 08:57:44 2007
@@ -27,7 +27,6 @@
<dependency org="org.apache.directory.server" name="apacheds-core-shared" rev="1.5.0-SNAPSHOT"/>
<dependency org="org.apache.directory.shared" name="shared-converter" rev="0.9.6-SNAPSHOT"/>
<dependency org="org.apache.directory.shared" name="shared-ldap" rev="0.9.6-SNAPSHOT"/>
- <dependency org="org.slf4j" name="nlog4j" rev="1.2.24"/>
- <dependency org="velocity" name="velocity-dep" rev="1.4"/>
+ <dependency org="org.slf4j" name="nlog4j" rev="1.2.24"/>
</dependencies>
</ivy-module>
Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/io/SchemaWriter.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/io/SchemaWriter.java?view=diff&rev=531514&r1=531513&r2=531514
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/io/SchemaWriter.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/io/SchemaWriter.java Mon Apr 23 08:57:44 2007
@@ -21,21 +21,14 @@
package org.apache.directory.ldapstudio.schemas.io;
-import java.io.BufferedReader;
-import java.io.File;
+import java.io.BufferedWriter;
import java.io.FileWriter;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.Writer;
-import java.net.URL;
import java.text.DateFormat;
import java.util.Date;
-import org.apache.directory.ldapstudio.schemas.Activator;
+import org.apache.directory.ldapstudio.schemas.model.AttributeType;
+import org.apache.directory.ldapstudio.schemas.model.ObjectClass;
import org.apache.directory.ldapstudio.schemas.model.Schema;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.eclipse.core.runtime.Platform;
/**
@@ -44,14 +37,6 @@
*/
public class SchemaWriter
{
- private VelocityEngine ve;
-
-
- public SchemaWriter()
- {
- ve = new VelocityEngine();
- }
-
/**
* Launch schema generation
@@ -61,25 +46,29 @@
*/
public void write( Schema schema, String src ) throws Exception
{
- // VelocityEngine initialization
- ve.init( new java.util.Properties() );
-
- // VelocityContext initialization and variables setup
- VelocityContext context = new VelocityContext();
- context.put( "schemaName", schema.getName() ); //$NON-NLS-1$
+ StringBuffer sb = new StringBuffer();
+ sb.append( "# " + schema.getName() + "\n" );
DateFormat format = DateFormat.getDateTimeInstance( DateFormat.LONG, DateFormat.MEDIUM );
Date date = new Date();
- context.put( "date", format.format( date ) ); //$NON-NLS-1$
- context.put( "attributeTypes", schema.getAttributeTypesAsArray() ); //$NON-NLS-1$
- context.put( "objectClasses", schema.getObjectClassesAsArray() ); //$NON-NLS-1$
-
- // Schema generation
- URL template = Platform.getBundle( Activator.PLUGIN_ID ).getResource( "ressources/templates/Schema.template" ); //$NON-NLS-1$
- Reader fileIn = new BufferedReader( new InputStreamReader( template.openStream() ) );
- Writer writer = new FileWriter( new File( src ) );
- ve.evaluate( context, writer, "LOG", fileIn ); //$NON-NLS-1$
+ sb.append( "# Generated by LDAP Studio on " + format.format( date ) + "\n" );
+ sb.append( "\n" );
- writer.flush();
- writer.close();
+ for ( AttributeType at : schema.getAttributeTypesAsArray() )
+ {
+ sb.append( at.write() );
+ sb.append( "\n" );
+ }
+
+ for ( ObjectClass oc : schema.getObjectClassesAsArray() )
+ {
+ sb.append( oc.write() );
+ sb.append( "\n" );
+ }
+
+ // Writing schema file to the specified location.
+ BufferedWriter bufferedWriter;
+ bufferedWriter = new BufferedWriter( new FileWriter( src ) );
+ bufferedWriter.write( sb.toString() );
+ bufferedWriter.close();
}
}