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/03/30 12:06:45 UTC
svn commit: r524022 - in
/directory/ldapstudio/trunk/ldapstudio-schemas-plugin: ./ META-INF/
ressources/icons/ src/main/java/org/apache/directory/ldapstudio/schemas/
src/main/java/org/apache/directory/ldapstudio/schemas/controller/
src/main/java/org/ap...
Author: pamarcelot
Date: Fri Mar 30 03:06:36 2007
New Revision: 524022
URL: http://svn.apache.org/viewvc?view=rev&rev=524022
Log:
Added a new action to generate from a schema the necessary LDIF file to include the schema in the new Apache DS 1.5 system.
Added:
directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ressources/icons/export_schema_for_ads.png (with props)
directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/ExportSchemaForADSAction.java
Modified:
directory/ldapstudio/trunk/ldapstudio-schemas-plugin/.classpath
directory/ldapstudio/trunk/ldapstudio-schemas-plugin/META-INF/MANIFEST.MF
directory/ldapstudio/trunk/ldapstudio-schemas-plugin/build.properties
directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ivy.xml
directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/PluginConstants.java
directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/SchemasViewController.java
directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/io/SchemaWriter.java
directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/ViewUtils.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=524022&r1=524021&r2=524022
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/.classpath (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/.classpath Fri Mar 30 03:06:36 2007
@@ -6,15 +6,20 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<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"/>
+ <classpathentry kind="lib" path="lib/xercesImpl-2.0.2.jar"/>
+ <classpathentry kind="lib" path="lib/apacheds-core-plugin-1.5.0-SNAPSHOT.jar"/>
+ <classpathentry kind="lib" path="lib/apacheds-core-shared-1.5.0-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="lib/commons-configuration-1.2.jar"/>
<classpathentry kind="lib" path="lib/commons-lang-2.1.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.1.jar"/>
- <classpathentry kind="lib" path="lib/apacheds-core-plugin-1.5.0-SNAPSHOT.jar"/>
- <classpathentry kind="lib" path="lib/apacheds-core-shared-1.5.0-SNAPSHOT.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/nlog4j-1.2.24.jar"/>
<classpathentry kind="lib" path="lib/commons-collections-3.2.jar"/>
- <classpathentry kind="lib" path="lib/shared-asn1-0.9.6-SNAPSHOT.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/META-INF/MANIFEST.MF?view=diff&rev=524022&r1=524021&r2=524022
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/META-INF/MANIFEST.MF (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/META-INF/MANIFEST.MF Fri Mar 30 03:06:36 2007
@@ -17,10 +17,14 @@
lib/commons-configuration-1.2.jar,
lib/commons-lang-2.1.jar,
lib/commons-logging-1.1.jar,
- lib/nlog4j-1.2.24.jar,
lib/shared-ldap-0.9.6-SNAPSHOT.jar,
lib/velocity-dep-1.4.jar,
lib/apacheds-core-plugin-1.5.0-SNAPSHOT.jar,
lib/apacheds-core-shared-1.5.0-SNAPSHOT.jar,
lib/shared-asn1-0.9.6-SNAPSHOT.jar,
- lib/commons-collections-3.2.jar
+ lib/commons-collections-3.2.jar,
+ lib/antlr-2.7.6.jar,
+ lib/checkstyle-2.2.jar,
+ lib/nlog4j-1.2.25.jar,
+ lib/shared-converter-0.9.6-SNAPSHOT.jar,
+ lib/xercesImpl-2.0.2.jar
Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/build.properties
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/build.properties?view=diff&rev=524022&r1=524021&r2=524022
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/build.properties (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/build.properties Fri Mar 30 03:06:36 2007
@@ -11,7 +11,6 @@
lib/commons-configuration-1.2.jar,\
lib/commons-lang-2.1.jar,\
lib/commons-logging-1.1.jar,\
- lib/nlog4j-1.2.24.jar,\
lib/shared-ldap-0.9.6-SNAPSHOT.jar,\
lib/velocity-dep-1.4.jar,\
src/main/resources/,\
@@ -19,4 +18,8 @@
lib/apacheds-core-shared-1.5.0-SNAPSHOT.jar,\
lib/shared-asn1-0.9.6-SNAPSHOT.jar,\
lib/antlr-2.7.6.jar,\
- lib/commons-collections-3.2.jar
+ lib/commons-collections-3.2.jar,\
+ lib/checkstyle-2.2.jar,\
+ lib/nlog4j-1.2.25.jar,\
+ lib/shared-converter-0.9.6-SNAPSHOT.jar,\
+ lib/xercesImpl-2.0.2.jar
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=524022&r1=524021&r2=524022
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ivy.xml (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ivy.xml Fri Mar 30 03:06:36 2007
@@ -24,8 +24,9 @@
<dependency org="commons-lang" name="commons-lang" rev="2.1"/>
<dependency org="commons-logging" name="commons-logging" rev="1.1"/>
<dependency org="org.apache.directory.server" name="apacheds-core-plugin" rev="1.5.0-SNAPSHOT"/>
- <dependency org="org.apache.directory.server" name="apacheds-core-shared" rev="1.5.0-SNAPSHOT"/>
- <dependency org="org.apache.directory.shared" name="shared-ldap" rev="0.9.6-SNAPSHOT"/>
+ <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"/>
</dependencies>
Added: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ressources/icons/export_schema_for_ads.png
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ressources/icons/export_schema_for_ads.png?view=auto&rev=524022
==============================================================================
Binary file - no diff available.
Propchange: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ressources/icons/export_schema_for_ads.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/PluginConstants.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/PluginConstants.java?view=diff&rev=524022&r1=524021&r2=524022
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/PluginConstants.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/PluginConstants.java Fri Mar 30 03:06:36 2007
@@ -227,6 +227,7 @@
public static final String IMG_CREATE_A_NEW_SCHEMA = "ressources/icons/schema_new.png"; //$NON-NLS-1$
public static final String IMG_DELETE = "ressources/icons/delete.gif"; //$NON-NLS-1$
public static final String IMG_ERASE_SEARCH = "ressources/icons/erase_search.gif"; //$NON-NLS-1$
+ public static final String IMG_EXPORT_SCHEMA_FOR_ADS = "ressources/icons/export_schema_for_ads.png"; //$NON-NLS-1$
public static final String IMG_HIDE_OBJECT_CLASSES = "ressources/icons/hide_object_classes.png"; //$NON-NLS-1$
public static final String IMG_HIDE_ATTRIBUTE_TYPES = "ressources/icons/hide_attribute_types.png"; //$NON-NLS-1$
public static final String IMG_LINK_WITH_EDITOR = "ressources/icons/link_with_editor.gif"; //$NON-NLS-1$
@@ -268,6 +269,7 @@
public static final String CMD_CREATE_A_NEW_SCHEMA = Activator.PLUGIN_ID + ".cmd.CreateANewSchema"; //$NON-NLS-1$
public static final String CMD_DELETE = Activator.PLUGIN_ID + ".cmd.Delete"; //$NON-NLS-1$
public static final String CMD_ERASE_SEARCH = Activator.PLUGIN_ID + ".cmd.EraseSearch"; //$NON-NLS-1$
+ public static final String CMD_EXPORT_FOR_ADS = Activator.PLUGIN_ID + ".cmd.ExportForADS"; //$NON-NLS-1$
public static final String CMD_HIDE_ATTRIBUTE_TYPES = Activator.PLUGIN_ID + ".cmd.HideAttributesTypes"; //$NON-NLS-1$
public static final String CMD_HIDE_OBJECT_CLASSES = Activator.PLUGIN_ID + ".cmd.HideObjectClasses"; //$NON-NLS-1$
public static final String CMD_LINK_WITH_EDITOR_SCHEMA_ELEMENTS_VIEW = Activator.PLUGIN_ID
Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/SchemasViewController.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/SchemasViewController.java?view=diff&rev=524022&r1=524021&r2=524022
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/SchemasViewController.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/SchemasViewController.java Fri Mar 30 03:06:36 2007
@@ -32,6 +32,7 @@
import org.apache.directory.ldapstudio.schemas.controller.actions.CreateANewObjectClassAction;
import org.apache.directory.ldapstudio.schemas.controller.actions.CreateANewSchemaAction;
import org.apache.directory.ldapstudio.schemas.controller.actions.DeleteAction;
+import org.apache.directory.ldapstudio.schemas.controller.actions.ExportSchemaForADSAction;
import org.apache.directory.ldapstudio.schemas.controller.actions.LinkWithEditorSchemasView;
import org.apache.directory.ldapstudio.schemas.controller.actions.OpenLocalFileAction;
import org.apache.directory.ldapstudio.schemas.controller.actions.OpenSchemaSourceCode;
@@ -125,6 +126,7 @@
private Action openSortDialog;
private Action openPreferencePage;
private Action openTypeHierarchy;
+ private Action exportSchemaForADS;
/**
@@ -183,6 +185,7 @@
openSortDialog = new OpenSchemasViewSortDialogAction();
openPreferencePage = new OpenSchemasViewPreferencesAction();
openTypeHierarchy = new OpenTypeHierarchyAction();
+ exportSchemaForADS = new ExportSchemaForADSAction( view );
}
@@ -244,6 +247,8 @@
{
manager.add( saveAs );
manager.add( new Separator() );
+ manager.add( exportSchemaForADS);
+ manager.add( new Separator() );
manager.add( openSchemaSourceCode );
}
else if ( schema.type == SchemaType.userSchema )
@@ -254,6 +259,8 @@
manager.add( save );
manager.add( saveAs );
manager.add( removeSchema );
+ manager.add( new Separator() );
+ manager.add( exportSchemaForADS);
manager.add( new Separator() );
manager.add( openSchemaSourceCode );
}
Added: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/ExportSchemaForADSAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/ExportSchemaForADSAction.java?view=auto&rev=524022
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/ExportSchemaForADSAction.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/ExportSchemaForADSAction.java Fri Mar 30 03:06:36 2007
@@ -0,0 +1,307 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.schemas.controller.actions;
+
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.ldapstudio.schemas.Activator;
+import org.apache.directory.ldapstudio.schemas.PluginConstants;
+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.directory.ldapstudio.schemas.view.ViewUtils;
+import org.apache.directory.ldapstudio.schemas.view.views.SchemasView;
+import org.apache.directory.ldapstudio.schemas.view.views.wrappers.SchemaWrapper;
+import org.apache.directory.shared.converter.schema.AttributeTypeHolder;
+import org.apache.directory.shared.converter.schema.ObjectClassHolder;
+import org.apache.log4j.Logger;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class implements the Action for Exporting a schema For ADS.
+ */
+public class ExportSchemaForADSAction extends Action
+{
+ private static Logger logger = Logger.getLogger( ExportSchemaForADSAction.class );
+
+ /** The associated view */
+ private SchemasView view;
+
+
+ /**
+ * Creates a new instance of ExportSchemaForADSAction.
+ *
+ * @param view
+ * the associated view
+ */
+ public ExportSchemaForADSAction( SchemasView view )
+ {
+ super( "Export For Apache DS..." );
+ this.view = view;
+ setToolTipText( getText() );
+ setId( PluginConstants.CMD_EXPORT_FOR_ADS );
+ setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+ PluginConstants.IMG_EXPORT_SCHEMA_FOR_ADS ) );
+ setEnabled( true );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run()
+ {
+ Object selection = ( ( TreeSelection ) view.getViewer().getSelection() ).getFirstElement();
+
+ if ( selection != null )
+ {
+ if ( selection instanceof SchemaWrapper )
+ {
+ Schema schema = ( ( SchemaWrapper ) selection ).getMySchema();
+
+ // Opening the FileDialog to let the user choose the destination file
+ FileDialog fd = new FileDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ SWT.SAVE );
+ fd.setText( "Select a file" );
+ fd.setFilterPath( System.getProperty( "user.home" ) ); //$NON-NLS-1$
+ fd.setFileName( schema.getName() + ".ldif" ); //$NON-NLS-1$
+ fd.setFilterExtensions( new String[]
+ { "*.ldif", "*.*" } ); //$NON-NLS-1$ //$NON-NLS-2$
+ fd.setFilterNames( new String[]
+ { "LDIF files", "All_files" } );
+ String savePath = fd.open();
+ if ( savePath != null )
+ {
+ File selectedFile = new File( savePath );
+ if ( selectedFile.exists() )
+ {
+ int response = ViewUtils.displayQuestionMessageBox( SWT.OK | SWT.CANCEL,
+ "Overwrite existing file ?",
+ "The file you have choosen already exists. Do you want to overwrite it?" );
+ if ( response == SWT.CANCEL )
+ {
+ return;
+ }
+ }
+
+ StringBuffer sb = new StringBuffer();
+ sb.append( "# " + schema.getName() + "\n" );
+ DateFormat format = DateFormat.getDateTimeInstance( DateFormat.LONG, DateFormat.MEDIUM );
+ Date date = new Date();
+ sb.append( "# Generated by LDAP Studio on " + format.format( date ) + "\n" );
+ sb.append( "\n" );
+
+ // Generation the Schema Node
+ sb.append( "dn: cn=" + schema.getName() + ", ou=schema\n" );
+ sb.append( "objectclass: metaSchema\n" );
+ sb.append( "objectclass: top\n" );
+ sb.append( "cn: " + schema.getName() + "\n" );
+ sb.append( "\n" );
+
+ try
+ {
+ // Generation the Attribute Types Node
+ sb.append( "dn: ou=attributeTypes, cn=" + schema.getName() + ", ou=schema\n" );
+ sb.append( "objectclass: organizationalUnit\n" );
+ sb.append( "objectclass: top\n" );
+ sb.append( "ou: attributetypes\n" );
+ sb.append( "\n" );
+
+ // Generating LDIF for Attributes Types
+ for ( AttributeType at : schema.getAttributeTypesAsArray() )
+ {
+ AttributeTypeHolder holder = new AttributeTypeHolder( at.getOid() );
+ holder.setCollective( at.isCollective() );
+ holder.setDescription( at.getDescription() );
+ holder.setEquality( at.getEquality() );
+ List<String> names = new ArrayList<String>();
+ for ( String name : at.getNames() )
+ {
+ names.add( name );
+ }
+ holder.setNames( names );
+ holder.setNoUserModification( at.isNoUserModification() );
+ holder.setObsolete( at.isObsolete() );
+ holder.setOrdering( at.getOrdering() );
+ holder.setSingleValue( at.isSingleValue() );
+ holder.setSubstr( at.getSubstr() );
+ holder.setSuperior( at.getSuperior() );
+ holder.setSyntax( at.getSyntax() );
+ holder.setOidLen( at.getLength() );
+ holder.setUsage( at.getUsage() );
+
+ sb.append( holder.toLdif( schema.getName() ) + "\n" );
+ }
+
+ // Generation the Comparators Node
+ sb.append( "dn: ou=comparators, cn=" + schema.getName() + ", ou=schema\n" );
+ sb.append( "objectclass: organizationalUnit\n" );
+ sb.append( "objectclass: top\n" );
+ sb.append( "ou: comparators\n" );
+ sb.append( "\n" );
+
+ // Generation the DIT Content Rules Node
+ sb.append( "dn: ou=ditContentRules, cn=" + schema.getName() + ", ou=schema\n" );
+ sb.append( "objectclass: organizationalUnit\n" );
+ sb.append( "objectclass: top\n" );
+ sb.append( "ou: ditcontentrules\n" );
+ sb.append( "\n" );
+
+ // Generation the DIT Structure RulesNode
+ sb.append( "dn: ou=ditStructureRules, cn=" + schema.getName() + ", ou=schema\n" );
+ sb.append( "objectclass: organizationalUnit\n" );
+ sb.append( "objectclass: top\n" );
+ sb.append( "ou: ditstructurerules\n" );
+ sb.append( "\n" );
+
+ // Generation the Matching Rules Node
+ sb.append( "dn: ou=macthingRules, cn=" + schema.getName() + ", ou=schema\n" );
+ sb.append( "objectclass: organizationalUnit\n" );
+ sb.append( "objectclass: top\n" );
+ sb.append( "ou: matchingrules\n" );
+ sb.append( "\n" );
+
+ // Generation the Matching Rule Use Node
+ sb.append( "dn: ou=matchingRuleUse, cn=" + schema.getName() + ", ou=schema\n" );
+ sb.append( "objectclass: organizationalUnit\n" );
+ sb.append( "objectclass: top\n" );
+ sb.append( "ou: matchingruleuse\n" );
+ sb.append( "\n" );
+
+ // Generation the Name Forms Node
+ sb.append( "dn: ou=nameForms, cn=" + schema.getName() + ", ou=schema\n" );
+ sb.append( "objectclass: organizationalUnit\n" );
+ sb.append( "objectclass: top\n" );
+ sb.append( "ou: nameforms\n" );
+ sb.append( "\n" );
+
+ // Generation the Normalizers Node
+ sb.append( "dn: ou=normalizers, cn=" + schema.getName() + ", ou=schema\n" );
+ sb.append( "objectclass: organizationalUnit\n" );
+ sb.append( "objectclass: top\n" );
+ sb.append( "ou: normalizers\n" );
+ sb.append( "\n" );
+
+ // Generation the Object Classes Node
+ sb.append( "dn: ou=objectClasses, cn=" + schema.getName() + ", ou=schema\n" );
+ sb.append( "objectclass: organizationalUnit\n" );
+ sb.append( "objectclass: top\n" );
+ sb.append( "ou: objectClasses\n" );
+ sb.append( "\n" );
+
+ // Generating LDIF for Object Classes
+ for ( ObjectClass oc : schema.getObjectClassesAsArray() )
+ {
+ ObjectClassHolder holder = new ObjectClassHolder( oc.getOid() );
+ holder.setClassType( oc.getClassType() );
+ holder.setDescription( oc.getDescription() );
+ List<String> mayList = new ArrayList<String>();
+ for ( String may : oc.getMay() )
+ {
+ mayList.add( may );
+ }
+ holder.setMay( mayList );
+ List<String> mustList = new ArrayList<String>();
+ for ( String must : oc.getMust() )
+ {
+ mustList.add( must );
+ }
+ holder.setMust( mustList );
+ List<String> names = new ArrayList<String>();
+ for ( String name : oc.getNames() )
+ {
+ names.add( name );
+ }
+ holder.setNames( names );
+ List<String> superiorList = new ArrayList<String>();
+ for ( String superior : oc.getSuperiors() )
+ {
+ superiorList.add( superior );
+ }
+ holder.setSuperiors( superiorList );
+ holder.setObsolete( oc.isObsolete() );
+
+ sb.append( holder.toLdif( schema.getName() ) + "\n" );
+ }
+
+ // Generation the Syntax Checkers Node
+ sb.append( "dn: ou=syntaxCheckers, cn=" + schema.getName() + ", ou=schema\n" );
+ sb.append( "objectclass: organizationalUnit\n" );
+ sb.append( "objectclass: top\n" );
+ sb.append( "ou: syntaxcheckers\n" );
+ sb.append( "\n" );
+
+ // Generation the Syntaxes Node
+ sb.append( "dn: ou=syntaxes, cn=" + schema.getName() + ", ou=schema\n" );
+ sb.append( "objectclass: organizationalUnit\n" );
+ sb.append( "objectclass: top\n" );
+ sb.append( "ou: syntaxes\n" );
+ sb.append( "\n" );
+ }
+ catch ( NamingException e )
+ {
+ logger.error( "An error occurred when generating the LDIF associated to the schema.", e );
+ ViewUtils
+ .displayErrorMessageBox( "Export Failed!",
+ "The file couldn't be saved. An error occurred when generating the LDIF associated to the schema." );
+ return;
+ }
+
+ // Writing generated LDIF to the specified file
+ BufferedWriter bufferedWriter;
+ try
+ {
+ bufferedWriter = new BufferedWriter( new FileWriter( savePath ) );
+ bufferedWriter.write( sb.toString() );
+ bufferedWriter.close();
+ }
+ catch ( IOException e )
+ {
+ logger.error( "The file couldn't be saved. An error occurred when writing file to disk.", e );
+ ViewUtils.displayErrorMessageBox( "Export Failed!",
+ "The file couldn't be saved. An error occurred when writing file to disk." );
+ return;
+ }
+
+ // Export Successful
+ ViewUtils.displayInformationMessageBox( "Export Successful",
+ "The schema has been sucessfully exported." );
+ }
+ }
+ }
+ }
+}
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=524022&r1=524021&r2=524022
==============================================================================
--- 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 Fri Mar 30 03:06:36 2007
@@ -28,6 +28,7 @@
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;
@@ -58,7 +59,6 @@
* @param src the file-path where it will be generated
* @throws Exception if an exception during the generation of the schema
*/
- @SuppressWarnings("deprecation")//$NON-NLS-1$
public void write( Schema schema, String src ) throws Exception
{
// VelocityEngine initialization
@@ -67,8 +67,9 @@
// VelocityContext initialization and variables setup
VelocityContext context = new VelocityContext();
context.put( "schemaName", schema.getName() ); //$NON-NLS-1$
+ DateFormat format = DateFormat.getDateTimeInstance( DateFormat.LONG, DateFormat.MEDIUM );
Date date = new Date();
- context.put( "date", date.toLocaleString() ); //$NON-NLS-1$
+ 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$
Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/ViewUtils.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/ViewUtils.java?view=diff&rev=524022&r1=524021&r2=524022
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/ViewUtils.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/ViewUtils.java Fri Mar 30 03:06:36 2007
@@ -22,6 +22,7 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.ui.PlatformUI;
@@ -80,4 +81,97 @@
{
return name.matches( "[a-zA-Z]+[a-zA-Z0-9;-]*" ); //$NON-NLS-1$
}
+
+
+ /**
+ * Displays an Error Message Box with the given title and message.
+ *
+ * @param title
+ * the title of the window
+ * @param message
+ * the message to display
+ * @return
+ * the ID of the button that was selected to dismiss
+ * the message box (e.g. SWT.OK, SWT.CANCEL, etc...)
+ */
+ public static int displayErrorMessageBox( String title, String message )
+ {
+ return displayMessageBox( SWT.OK | SWT.ICON_ERROR, title, message );
+ }
+
+
+ /**
+ * Displays a Information Message Box with the given title and message.
+ *
+ * @param title
+ * the title of the window
+ * @param message
+ * the message to display
+ * @return
+ * the ID of the button that was selected to dismiss
+ * the message box (e.g. SWT.OK, SWT.CANCEL, etc...)
+ */
+ public static int displayWarningMessageBox( String title, String message )
+ {
+ return displayMessageBox( SWT.OK | SWT.ICON_WARNING, title, message );
+ }
+
+
+ /**
+ * Displays a Information Message Box with the given title and message.
+ *
+ * @param title
+ * the title of the window
+ * @param message
+ * the message to display
+ * @return
+ * the ID of the button that was selected to dismiss
+ * the message box (e.g. SWT.OK, SWT.CANCEL, etc...)
+ */
+ public static int displayInformationMessageBox( String title, String message )
+ {
+ return displayMessageBox( SWT.OK | SWT.ICON_INFORMATION, title, message );
+ }
+
+
+ /**
+ * Displays a Information Question Box with the given title and message.
+ *
+ * @param buttonStyle
+ * the style of the buttons of the dialog (e.g. SWT.OK, SWT.CANCEL, etc...)
+ * @param title
+ * the title of the window
+ * @param message
+ * the message to display
+ * @return
+ * the ID of the button that was selected to dismiss
+ * the message box (e.g. SWT.OK, SWT.CANCEL, etc...)
+ */
+ public static int displayQuestionMessageBox( int buttonStyle, String title, String message )
+ {
+ return displayMessageBox( SWT.ICON_QUESTION | buttonStyle, title, message );
+ }
+
+
+ /**
+ * Displays a Message Box with the given style, title and message.
+ *
+ * @param style
+ * the style of dialog
+ * @param title
+ * the title of the window
+ * @param message
+ * the message to display
+ * @return
+ * the ID of the button that was selected to dismiss
+ * the message box (e.g. SWT.OK, SWT.CANCEL, etc...)
+ */
+ private static int displayMessageBox( int style, String title, String message )
+ {
+ MessageBox messageBox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), style );
+ messageBox.setText( title );
+ messageBox.setMessage( message );
+ return messageBox.open();
+ }
+
}