You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2015/04/01 03:01:43 UTC
svn commit: r1670531 [11/14] - in
/directory/studio/trunk/plugins/openldap.config.editor: ./ resources/icons/
src/main/java/org/apache/directory/studio/openldap/config/
src/main/java/org/apache/directory/studio/openldap/config/actions/
src/main/java/or...
Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcOverlayConfig.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcOverlayConfig.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcOverlayConfig.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcOverlayConfig.java Wed Apr 1 01:01:42 2015
@@ -22,6 +22,8 @@ package org.apache.directory.studio.open
/**
* Java bean for the 'olcOverlayConfig' object class.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OlcOverlayConfig extends OlcConfig
{
@@ -29,7 +31,26 @@ public class OlcOverlayConfig extends Ol
* Field for the 'olcOverlay' attribute.
*/
@ConfigurationElement(attributeType = "olcOverlay", isOptional = false, isRdn = true)
- private String olcOverlay;
+ protected String olcOverlay;
+
+
+ /**
+ * Creates a new instance of OlcOverlayConfig.
+ */
+ public OlcOverlayConfig()
+ {
+ }
+
+
+ /**
+ * Creates a copy instance of OlcOverlayConfig.
+ *
+ * @param o the initial object
+ */
+ public OlcOverlayConfig( OlcOverlayConfig o )
+ {
+ olcOverlay = o.olcOverlay;
+ }
/**
@@ -48,4 +69,15 @@ public class OlcOverlayConfig extends Ol
{
this.olcOverlay = olcOverlay;
}
+
+
+ /**
+ * Gets a copy of this object.
+ *
+ * @return a copy of this object
+ */
+ public OlcOverlayConfig copy()
+ {
+ return new OlcOverlayConfig( this );
+ }
}
Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcPBindConfig.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcPBindConfig.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcPBindConfig.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcPBindConfig.java Wed Apr 1 01:01:42 2015
@@ -22,6 +22,8 @@ package org.apache.directory.studio.open
/**
* Java bean for the 'olcPBindConfig' object class.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OlcPBindConfig extends OlcOverlayConfig
{
@@ -51,6 +53,30 @@ public class OlcPBindConfig extends OlcO
/**
+ * Creates a new instance of OlcPBindConfig.
+ */
+ public OlcPBindConfig()
+ {
+ super();
+ }
+
+
+ /**
+ * Creates a copy instance of OlcPBindConfig.
+ *
+ * @param o the initial object
+ */
+ public OlcPBindConfig( OlcPBindConfig o )
+ {
+ super( o );
+ olcDbURI = o.olcDbURI;
+ olcDbNetworkTimeout = o.olcDbNetworkTimeout;
+ olcDbQuarantine = o.olcDbQuarantine;
+ olcStartTLS = o.olcStartTLS;
+ }
+
+
+ /**
* @return the olcDbNetworkTimeout
*/
public String getOlcDbNetworkTimeout()
@@ -120,4 +146,13 @@ public class OlcPBindConfig extends OlcO
{
this.olcStartTLS = olcStartTLS;
}
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public OlcPBindConfig copy()
+ {
+ return new OlcPBindConfig( this );
+ }
}
Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcPPolicyConfig.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcPPolicyConfig.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcPPolicyConfig.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcPPolicyConfig.java Wed Apr 1 01:01:42 2015
@@ -19,11 +19,14 @@
*/
package org.apache.directory.studio.openldap.config.model;
+
import org.apache.directory.api.ldap.model.name.Dn;
/**
* Java bean for the 'olcPPolicyConfig' object class.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OlcPPolicyConfig extends OlcOverlayConfig
{
@@ -37,19 +40,44 @@ public class OlcPPolicyConfig extends Ol
* Field for the 'olcPPolicyForwardUpdates' attribute.
*/
@ConfigurationElement(attributeType = "olcPPolicyForwardUpdates")
- private boolean olcPPolicyForwardUpdates;
+ private Boolean olcPPolicyForwardUpdates;
/**
* Field for the 'olcPPolicyHashCleartext' attribute.
*/
@ConfigurationElement(attributeType = "olcPPolicyHashCleartext")
- private boolean olcPPolicyHashCleartext;
+ private Boolean olcPPolicyHashCleartext;
/**
* Field for the 'olcPPolicyUseLockout' attribute.
*/
@ConfigurationElement(attributeType = "olcPPolicyUseLockout")
- private boolean olcPPolicyUseLockout;
+ private Boolean olcPPolicyUseLockout;
+
+
+ /**
+ * Creates a new instance of OlcPPolicyConfig.
+ */
+ public OlcPPolicyConfig()
+ {
+ super();
+ olcOverlay = "ppolicy";
+ }
+
+
+ /**
+ * Creates a copy instance of OlcPPolicyConfig.
+ *
+ * @param o the initial object
+ */
+ public OlcPPolicyConfig( OlcPPolicyConfig o )
+ {
+ super( o );
+ olcPPolicyDefault = o.olcPPolicyDefault;
+ olcPPolicyForwardUpdates = o.olcPPolicyForwardUpdates;
+ olcPPolicyHashCleartext = o.olcPPolicyHashCleartext;
+ olcPPolicyUseLockout = o.olcPPolicyUseLockout;
+ }
/**
@@ -64,7 +92,7 @@ public class OlcPPolicyConfig extends Ol
/**
* @return the olcPPolicyForwardUpdates
*/
- public boolean getOlcPPolicyForwardUpdates()
+ public Boolean getOlcPPolicyForwardUpdates()
{
return olcPPolicyForwardUpdates;
}
@@ -73,7 +101,7 @@ public class OlcPPolicyConfig extends Ol
/**
* @return the olcPPolicyHashCleartext
*/
- public boolean getOlcPPolicyHashCleartext()
+ public Boolean getOlcPPolicyHashCleartext()
{
return olcPPolicyHashCleartext;
}
@@ -82,7 +110,7 @@ public class OlcPPolicyConfig extends Ol
/**
* @return the olcPPolicyUseLockout
*/
- public boolean getOlcPPolicyUseLockout()
+ public Boolean getOlcPPolicyUseLockout()
{
return olcPPolicyUseLockout;
}
@@ -100,7 +128,7 @@ public class OlcPPolicyConfig extends Ol
/**
* @param olcPPolicyForwardUpdates the olcPPolicyForwardUpdates to set
*/
- public void setOlcPPolicyForwardUpdates( boolean olcPPolicyForwardUpdates )
+ public void setOlcPPolicyForwardUpdates( Boolean olcPPolicyForwardUpdates )
{
this.olcPPolicyForwardUpdates = olcPPolicyForwardUpdates;
}
@@ -109,7 +137,7 @@ public class OlcPPolicyConfig extends Ol
/**
* @param olcPPolicyHashCleartext the olcPPolicyHashCleartext to set
*/
- public void setOlcPPolicyHashCleartext( boolean olcPPolicyHashCleartext )
+ public void setOlcPPolicyHashCleartext( Boolean olcPPolicyHashCleartext )
{
this.olcPPolicyHashCleartext = olcPPolicyHashCleartext;
}
@@ -118,8 +146,17 @@ public class OlcPPolicyConfig extends Ol
/**
* @param olcPPolicyUseLockout the olcPPolicyUseLockout to set
*/
- public void setOlcPPolicyUseLockout( boolean olcPPolicyUseLockout )
+ public void setOlcPPolicyUseLockout( Boolean olcPPolicyUseLockout )
{
this.olcPPolicyUseLockout = olcPPolicyUseLockout;
}
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public OlcPPolicyConfig copy()
+ {
+ return new OlcPPolicyConfig( this );
+ }
}
Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRefintConfig.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRefintConfig.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRefintConfig.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRefintConfig.java Wed Apr 1 01:01:42 2015
@@ -0,0 +1,152 @@
+/*
+ * 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.studio.openldap.config.model;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.api.ldap.model.name.Dn;
+
+
+/**
+ * Java bean for the 'olcRefintConfig' object class.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class OlcRefintConfig extends OlcOverlayConfig
+{
+ /**
+ * Field for the 'olcRefintAttribute' attribute.
+ */
+ @ConfigurationElement(attributeType = "olcRefintAttribute")
+ private List<String> olcRefintAttribute = new ArrayList<String>();
+
+ /**
+ * Field for the 'olcRefintNothing' attribute.
+ */
+ @ConfigurationElement(attributeType = "olcRefintNothing")
+ private Dn olcRefintNothing;
+
+ /**
+ * Field for the 'olcRefintModifiersName' attribute.
+ */
+ @ConfigurationElement(attributeType = "olcRefintModifiersName")
+ private Dn olcRefintModifiersName;
+
+
+ /**
+ * Creates a new instance of OlcRefintConfig.
+ */
+ public OlcRefintConfig()
+ {
+ super();
+ olcOverlay = "refint";
+ }
+
+
+ /**
+ * Creates a copy instance of OlcRefintConfig.
+ *
+ * @param o the initial object
+ */
+ public OlcRefintConfig( OlcRefintConfig o )
+ {
+ super();
+ olcRefintAttribute = o.olcRefintAttribute;
+ olcRefintNothing = o.olcRefintNothing;
+ olcRefintModifiersName = o.olcRefintModifiersName;
+ }
+
+
+ /**
+ * @param strings
+ */
+ public void addOlcRefintAttribute( String... strings )
+ {
+ for ( String string : strings )
+ {
+ olcRefintAttribute.add( string );
+ }
+ }
+
+
+ /**
+ * @return
+ */
+ public List<String> getOlcRefintAttribute()
+ {
+ return olcRefintAttribute;
+ }
+
+
+ /**
+ * @return
+ */
+ public Dn getOlcRefintNothing()
+ {
+ return olcRefintNothing;
+ }
+
+
+ /**
+ * @return
+ */
+ public Dn getOlcRefintModifiersName()
+ {
+ return olcRefintModifiersName;
+ }
+
+
+ /**
+ * @param olcRefintAttribute
+ */
+ public void setOlcRefintAttribute( List<String> olcRefintAttribute )
+ {
+ this.olcRefintAttribute = olcRefintAttribute;
+ }
+
+
+ /**
+ * @param olcRefintNothing
+ */
+ public void setOlcRefintNothing( Dn olcRefintNothing )
+ {
+ this.olcRefintNothing = olcRefintNothing;
+ }
+
+
+ /**
+ * @param olcRefintModifiersName
+ */
+ public void setOlcRefintModifiersName( Dn olcRefintModifiersName )
+ {
+ this.olcRefintModifiersName = olcRefintModifiersName;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public OlcRefintConfig copy()
+ {
+ return new OlcRefintConfig( this );
+ }
+}
Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRelayConfig.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRelayConfig.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRelayConfig.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRelayConfig.java Wed Apr 1 01:01:42 2015
@@ -19,11 +19,14 @@
*/
package org.apache.directory.studio.openldap.config.model;
+
import org.apache.directory.api.ldap.model.name.Dn;
/**
* Java bean for the 'olcRelayConfig' object class.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OlcRelayConfig extends OlcDatabaseConfig
{
@@ -50,4 +53,13 @@ public class OlcRelayConfig extends OlcD
{
this.olcRelay = olcRelay;
}
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getOlcDatabaseType()
+ {
+ return "relay";
+ };
}
Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRwmConfig.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRwmConfig.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRwmConfig.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRwmConfig.java Wed Apr 1 01:01:42 2015
@@ -0,0 +1,204 @@
+/*
+ * 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.studio.openldap.config.model;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Java bean for the 'olcPPolicyConfig' object class.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class OlcRwmConfig extends OlcOverlayConfig
+{
+ /**
+ * Field for the 'olcRwmMap' attribute.
+ */
+ @ConfigurationElement(attributeType = "olcRwmMap")
+ private List<String> olcRwmMap = new ArrayList<String>();
+
+ /**
+ * Field for the 'olcRwmNormalizeMapped' attribute.
+ */
+ @ConfigurationElement(attributeType = "olcRwmNormalizeMapped")
+ private Boolean olcRwmNormalizeMapped;
+
+ /**
+ * Field for the 'olcRwmRewrite' attribute.
+ */
+ @ConfigurationElement(attributeType = "olcRwmRewrite")
+ private List<String> olcRwmRewrite = new ArrayList<String>();
+
+ /**
+ * Field for the 'olcRwmTFSupport' attribute.
+ */
+ @ConfigurationElement(attributeType = "olcRwmTFSupport")
+ private String olcRwmTFSupport;
+
+
+ /**
+ * Creates a new instance of OlcPPolicyConfig.
+ */
+ public OlcRwmConfig()
+ {
+ super();
+ olcOverlay = "rwm";
+ }
+
+
+ /**
+ * Creates a copy instance of OlcPPolicyConfig.
+ *
+ * @param o the initial object
+ */
+ public OlcRwmConfig( OlcRwmConfig o )
+ {
+ super( o );
+ olcRwmMap = o.olcRwmMap;
+ olcRwmNormalizeMapped = o.olcRwmNormalizeMapped;
+ olcRwmRewrite = o.olcRwmRewrite;
+ olcRwmTFSupport = o.olcRwmTFSupport;
+ }
+
+
+ /**
+ * @param strings
+ */
+ public void addOlcRwmMap( String... strings )
+ {
+
+ for ( String string : strings )
+ {
+ olcRwmMap.add( string );
+ }
+ }
+
+
+ /**
+ * @param strings
+ */
+ public void addOlcRwmRewrite( String... strings )
+ {
+ for ( String string : strings )
+ {
+ olcRwmRewrite.add( string );
+ }
+ }
+
+
+ /**
+ */
+ public void clearOlcRwmMap()
+ {
+ olcRwmMap.clear();
+ }
+
+
+ /**
+ */
+ public void clearOlcRwmRewrite()
+ {
+ olcRwmRewrite.clear();
+ }
+
+
+ /**
+ * @return
+ */
+ public List<String> getOlcRwmMap()
+ {
+ return olcRwmMap;
+ }
+
+
+ /**
+ * @return
+ */
+ public Boolean getOlcRwmNormalizeMapped()
+ {
+ return olcRwmNormalizeMapped;
+ }
+
+
+ /**
+ * @return
+ */
+ public List<String> getOlcRwmRewrite()
+ {
+ return olcRwmRewrite;
+ }
+
+
+ /**
+ * @return
+ */
+ public String getOlcRwmTFSupport()
+ {
+ return olcRwmTFSupport;
+ }
+
+
+ /**
+ * @param olcRwmMap
+ */
+ public void setOlcRwmMap( List<String> olcRwmMap )
+ {
+ this.olcRwmMap = olcRwmMap;
+ }
+
+
+ /**
+ * @param olcRwmNormalizeMapped
+ */
+ public void setOlcRwmNormalizeMapped( Boolean olcRwmNormalizeMapped )
+ {
+ this.olcRwmNormalizeMapped = olcRwmNormalizeMapped;
+ }
+
+
+ /**
+ * @param olcRwmRewrite
+ */
+ public void setOlcRwmRewrite( List<String> olcRwmRewrite )
+ {
+ this.olcRwmRewrite = olcRwmRewrite;
+ }
+
+
+ /**
+ * @param olcRwmTFSupport
+ */
+ public void setOlcRwmTFSupport( String olcRwmTFSupport )
+ {
+ this.olcRwmTFSupport = olcRwmTFSupport;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public OlcRwmConfig copy()
+ {
+ return new OlcRwmConfig( this );
+ }
+}
Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRwmMapValue.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRwmMapValue.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRwmMapValue.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRwmMapValue.java Wed Apr 1 01:01:42 2015
@@ -0,0 +1,377 @@
+/*
+ * 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.studio.openldap.config.model;
+
+
+import java.text.ParseException;
+
+import org.apache.directory.api.util.Position;
+import org.apache.directory.api.util.Strings;
+
+
+/**
+ * This class represents 'olcRwmMap' value.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class OlcRwmMapValue
+{
+ /** The constant string for '*' */
+ private static final String STAR_STRING = "*";
+
+ /** The type */
+ private OlcRwmMapValueTypeEnum type;
+
+ /** The local name */
+ private String localName;
+
+ /** The foreign name */
+ private String foreignName;
+
+
+ /**
+ * Gets the type.
+ *
+ * @return the type
+ */
+ public OlcRwmMapValueTypeEnum getType()
+ {
+ return type;
+ }
+
+
+ /**
+ * Gets the local name.
+ *
+ * @return the local name
+ */
+ public String getLocalName()
+ {
+ return localName;
+ }
+
+
+ /**
+ * Gets the foreign name.
+ *
+ * @return the foreign name
+ */
+ public String getForeignName()
+ {
+ return foreignName;
+ }
+
+
+ /**
+ * Indicates if the local name is the '*' constant.
+ *
+ * @return <code>true</code> if the local name is the '*' constant,
+ * <code>false</code> if not.
+ */
+ public boolean isLocalNameStart()
+ {
+ return STAR_STRING.equals( localName );
+ }
+
+
+ /**
+ * Indicates if the foreign name is the '*' constant.
+ *
+ * @return <code>true</code> if the foreign name is the '*' constant,
+ * <code>false</code> if not.
+ */
+ public boolean isLocalForeignStart()
+ {
+ return STAR_STRING.equals( foreignName );
+ }
+
+
+ /**
+ * Sets the type.
+ *
+ * @param type the type
+ */
+ public void setType( OlcRwmMapValueTypeEnum type )
+ {
+ this.type = type;
+ }
+
+
+ /**
+ * Sets the local name.
+ *
+ * @param localName the local name
+ */
+ public void setLocalName( String localName )
+ {
+ this.localName = localName;
+ }
+
+
+ /**
+ * Sets the foreign name.
+ *
+ * @param foreignName the foreign name
+ */
+ public void setForeignName( String foreignName )
+ {
+ this.foreignName = foreignName;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ // Type
+ sb.append( type );
+
+ // Local Name
+ if ( ( localName != null ) && ( localName.length() > 0 ) )
+ {
+ sb.append( ' ' );
+ sb.append( localName );
+ }
+
+ // Foreign Name
+ if ( ( foreignName != null ) && ( foreignName.length() > 0 ) )
+ {
+ sb.append( ' ' );
+ sb.append( foreignName );
+ }
+
+ return sb.toString();
+ }
+
+
+ /**
+ * Parses a OlcValSortValue value.
+ *
+ * @param s
+ * the string to be parsed
+ * @return the associated OlcValSortValue object
+ * @throws ParseException
+ * if there are any recognition errors (bad syntax)
+ */
+ public static synchronized OlcRwmMapValue parse( String s ) throws ParseException
+ {
+ if ( s == null )
+ {
+ return null;
+ }
+
+ // Trimming the value
+ s = Strings.trim( s );
+
+ // Getting the chars of the string
+ char[] chars = new char[s.length()];
+ s.getChars( 0, s.length(), chars, 0 );
+
+ // Creating the position
+ Position pos = new Position();
+ pos.start = 0;
+ pos.end = 0;
+ pos.length = chars.length;
+
+ return parseInternal( chars, pos );
+ }
+
+
+ /**
+ * Parses the given string.
+ *
+ * @param chars the characters
+ * @param pos the position
+ * @return the associated OlcValSortValue object
+ * @throws ParseException
+ */
+ private static OlcRwmMapValue parseInternal( char[] chars, Position pos ) throws ParseException
+ {
+ OlcRwmMapValue value = new OlcRwmMapValue();
+
+ // Empty (trimmed) string?
+ if ( chars.length == 0 )
+ {
+ return null;
+ }
+
+ do
+ {
+ // Type
+ String typeString = getQuotedOrNotQuotedOptionValue( chars, pos );
+
+ if ( ( typeString != null ) && ( !typeString.isEmpty() ) )
+ {
+ OlcRwmMapValueTypeEnum type = OlcRwmMapValueTypeEnum.fromString( typeString );
+
+ if ( type != null )
+ {
+ value.setType( type );
+ }
+ else
+ {
+ throw new ParseException( "Could not identify keyword '" + typeString
+ + "' as a valid type.", pos.start );
+ }
+ }
+ else
+ {
+ throw new ParseException( "Could not find the 'type' value", pos.start );
+ }
+
+ // First Name
+ String firstName = getQuotedOrNotQuotedOptionValue( chars, pos );
+
+ if ( ( firstName == null ) || ( firstName.isEmpty() ) )
+ {
+ throw new ParseException( "Could not find any 'localName' or 'foreignName' value", pos.start );
+ }
+
+ // Second Name
+ String secondName = getQuotedOrNotQuotedOptionValue( chars, pos );
+
+ if ( ( secondName == null ) || ( secondName.isEmpty() ) )
+ {
+ // Local Name is optional
+ // If we got only one name, it's the foreign name
+ value.setForeignName( firstName );
+ }
+ else
+ {
+ value.setLocalName( firstName );
+ value.setForeignName( secondName );
+ }
+ }
+ while ( ( pos.start != pos.length ) && ( ( Strings.charAt( chars, pos.start ) ) != '\0' ) );
+
+ return value;
+ }
+
+
+ private static String getQuotedOrNotQuotedOptionValue( char[] chars, Position pos ) throws ParseException
+ {
+ if ( pos.start != pos.length )
+ {
+ char quoteChar = '\0';
+ boolean isInQuotes = false;
+ char c = Strings.charAt( chars, pos.start );
+ char[] v = new char[chars.length - pos.start];
+ int current = 0;
+
+ do
+ {
+ if ( ( current == 0 ) && !isInQuotes )
+ {
+ // Whitespace
+ if ( Character.isWhitespace( c ) )
+ {
+ // We ignore all whitespaces until we find the start of the value
+ pos.start++;
+ continue;
+ }
+ // Double quotes (") or single quotes (')
+ else if ( ( c == '"' ) || ( c == '\'' ) )
+ {
+ isInQuotes = true;
+ quoteChar = c;
+ pos.start++;
+ continue;
+ }
+ // Any other char is part of a value
+ else
+ {
+ v[current++] = c;
+ pos.start++;
+ }
+ }
+ else
+ {
+ if ( isInQuotes )
+ {
+ // Double quotes (") or single quotes (')
+ if ( quoteChar == c )
+ {
+ isInQuotes = false;
+ pos.start++;
+ continue;
+ }
+ // Checking for escaped quotes
+ else if ( c == '\\' )
+ {
+ // Double quotes (")
+ if ( ( quoteChar == '"' ) && ( Strings.areEquals( chars, pos.start, "\\\"" ) >= 0 ) )
+ {
+ v[current++] = '"';
+ pos.start += 2;
+ continue;
+ }
+ // Single quotes (')
+ else if ( ( quoteChar == '\'' ) && ( Strings.areEquals( chars, pos.start, "\\'" ) >= 0 ) )
+ {
+ v[current++] = '\'';
+ pos.start += 2;
+ continue;
+ }
+ }
+ // Any other char is part of a value
+ else
+ {
+ v[current++] = c;
+ pos.start++;
+ }
+ }
+ else
+ {
+ // Whitespace
+ if ( Character.isWhitespace( c ) )
+ {
+ // Once we have found the start of the value, the first whitespace is the exit
+ break;
+ }
+ // Any other char is part of a value
+ else
+ {
+ v[current++] = c;
+ pos.start++;
+ }
+ }
+ }
+ }
+ while ( ( c = Strings.charAt( chars, pos.start ) ) != '\0' );
+
+ // Checking the resulting value
+ if ( current == 0 )
+ {
+ throw new ParseException( "Couldn't find a value.", pos.start );
+ }
+
+ char[] value = new char[current];
+ System.arraycopy( v, 0, value, 0, current );
+
+ // Getting the value as a String
+ return new String( value );
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRwmMapValueTypeEnum.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRwmMapValueTypeEnum.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRwmMapValueTypeEnum.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcRwmMapValueTypeEnum.java Wed Apr 1 01:01:42 2015
@@ -0,0 +1,79 @@
+/*
+ * 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.studio.openldap.config.model;
+
+
+/**
+ * This enum represents the various values of part of a 'olcRwmMap' attribute.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public enum OlcRwmMapValueTypeEnum
+{
+ /** Enum value for 'attribute' */
+ ATTRIBUTE,
+
+ /** Enum value for 'objectclass' */
+ OBJECTCLASS;
+
+ /** The constant string for 'attribute' */
+ private static final String ATTRIBUTE_STRING = "attribute";
+
+ /** The constant string for 'objectclass' */
+ private static final String OBJECTCLASS_STRING = "objectclass";
+
+
+ /**
+ * Gets the associated enum element.
+ *
+ * @param s the string
+ * @return the associated enum element
+ */
+ public static OlcRwmMapValueTypeEnum fromString( String s )
+ {
+ if ( ATTRIBUTE_STRING.equalsIgnoreCase( s ) )
+ {
+ return ATTRIBUTE;
+ }
+ else if ( OBJECTCLASS_STRING.equalsIgnoreCase( s ) )
+ {
+ return OBJECTCLASS;
+ }
+
+ return null;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ switch ( this )
+ {
+ case ATTRIBUTE:
+ return ATTRIBUTE_STRING;
+ case OBJECTCLASS:
+ return OBJECTCLASS_STRING;
+ }
+
+ return super.toString();
+ }
+}
Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcSchemaConfig.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcSchemaConfig.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcSchemaConfig.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcSchemaConfig.java Wed Apr 1 01:01:42 2015
@@ -26,6 +26,8 @@ import java.util.List;
/**
* Java bean for the 'OlcSchemaConfig' object class.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OlcSchemaConfig extends OlcConfig
{
Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcSyncProvConfig.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcSyncProvConfig.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcSyncProvConfig.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcSyncProvConfig.java Wed Apr 1 01:01:42 2015
@@ -22,6 +22,8 @@ package org.apache.directory.studio.open
/**
* Java bean for the 'olcSyncProvConfig' object class.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OlcSyncProvConfig extends OlcOverlayConfig
{
@@ -34,14 +36,14 @@ public class OlcSyncProvConfig extends O
/**
* Field for the 'olcSpNoPresent' attribute.
*/
- @ConfigurationElement(attributeType = "olcSpNoPresent")
- private Boolean olcSpNoPresent;
+ @ConfigurationElement(attributeType = "olcSpNoPresent", defaultValue = "FALSE")
+ private Boolean olcSpNoPresent = false;
/**
* Field for the 'olcSpReloadHint' attribute.
*/
- @ConfigurationElement(attributeType = "olcSpReloadHint")
- private Boolean olcSpReloadHint;
+ @ConfigurationElement(attributeType = "olcSpReloadHint", defaultValue = "FALSE")
+ private Boolean olcSpReloadHint = false;
/**
* Field for the 'olcSpSessionlog' attribute.
@@ -51,6 +53,31 @@ public class OlcSyncProvConfig extends O
/**
+ * Creates a new instance of OlcSyncProvConfig.
+ */
+ public OlcSyncProvConfig()
+ {
+ super();
+ olcOverlay = "syncprov";
+ }
+
+
+ /**
+ * Creates a copy instance of OlcSyncProvConfig.
+ *
+ * @param o the initial object
+ */
+ public OlcSyncProvConfig( OlcSyncProvConfig o )
+ {
+ super();
+ olcSpCheckpoint = o.olcSpCheckpoint;
+ olcSpNoPresent = o.olcSpNoPresent;
+ olcSpReloadHint = o.olcSpReloadHint;
+ olcSpSessionlog = o.olcSpSessionlog;
+ }
+
+
+ /**
* @return the olcSpCheckpoint
*/
public String getOlcSpCheckpoint()
@@ -120,4 +147,13 @@ public class OlcSyncProvConfig extends O
{
this.olcSpSessionlog = olcSpSessionlog;
}
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public OlcSyncProvConfig copy()
+ {
+ return new OlcSyncProvConfig( this );
+ }
}
Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcValSortConfig.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcValSortConfig.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcValSortConfig.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcValSortConfig.java Wed Apr 1 01:01:42 2015
@@ -0,0 +1,108 @@
+/*
+ * 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.studio.openldap.config.model;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Java bean for the 'olcRefintConfig' object class.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class OlcValSortConfig extends OlcOverlayConfig
+{
+ /**
+ * Field for the 'olcValSortAttr' attribute.
+ */
+ @ConfigurationElement(attributeType = "olcValSortAttr", isOptional = false)
+ private List<String> olcValSortAttr = new ArrayList<String>();
+
+
+ /**
+ * Creates a new instance of OlcValSortConfig.
+ */
+ public OlcValSortConfig()
+ {
+ super();
+ olcOverlay = "valsort";
+ }
+
+
+ /**
+ * Creates a copy instance of OlcValSortConfig.
+ *
+ * @param o the initial object
+ */
+ public OlcValSortConfig( OlcValSortConfig o )
+ {
+ super();
+ olcValSortAttr = o.olcValSortAttr;
+ }
+
+
+ /**
+ * @param strings
+ */
+ public void addOlcValSortAttr( String... strings )
+ {
+ for ( String string : strings )
+ {
+ olcValSortAttr.add( string );
+ }
+ }
+
+
+ /**
+ */
+ public void clearOlcValSortAttr()
+ {
+ olcValSortAttr.clear();
+ }
+
+
+ /**
+ * @return
+ */
+ public List<String> getOlcValSortAttr()
+ {
+ return olcValSortAttr;
+ }
+
+
+ /**
+ * @param olcValSortAttr
+ */
+ public void setOlcValSortAttr( List<String> olcValSortAttr )
+ {
+ this.olcValSortAttr = olcValSortAttr;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public OlcValSortConfig copy()
+ {
+ return new OlcValSortConfig( this );
+ }
+}
Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcValSortMethodEnum.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcValSortMethodEnum.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcValSortMethodEnum.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcValSortMethodEnum.java Wed Apr 1 01:01:42 2015
@@ -0,0 +1,103 @@
+/*
+ * 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.studio.openldap.config.model;
+
+
+/**
+ * This enum represents the various values for the 'OlcValSortOverlay' sort method.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public enum OlcValSortMethodEnum
+{
+ /** Enum value for 'alpha-ascend' */
+ ALPHA_ASCEND,
+
+ /** Enum value for 'alpha-descend' */
+ ALPHA_DESCEND,
+
+ /** Enum value for 'numeric-ascend' */
+ NUMERIC_ASCEND,
+
+ /** Enum value for 'numeric-descend' */
+ NUMERIC_DESCEND;
+
+ /** The constant string for 'alpha-ascend' */
+ private static final String ALPHA_ASCEND_STRING = "alpha-ascend";
+
+ /** The constant string for 'alpha-descend' */
+ private static final String ALPHA_DESCEND_STRING = "alpha-descend";
+
+ /** The constant string for 'numeric-ascend' */
+ private static final String NUMERIC_ASCEND_STRING = "numeric-ascend";
+
+ /** The constant string for 'numeric-descend' */
+ private static final String NUMERIC_DESCEND_STRING = "numeric-descend";
+
+
+ /**
+ * Gets the associated enum element.
+ *
+ * @param s the string
+ * @return the associated enum element
+ */
+ public static OlcValSortMethodEnum fromString( String s )
+ {
+ if ( ALPHA_ASCEND_STRING.equalsIgnoreCase( s ) )
+ {
+ return ALPHA_ASCEND;
+ }
+ else if ( ALPHA_DESCEND_STRING.equalsIgnoreCase( s ) )
+ {
+ return ALPHA_DESCEND;
+ }
+ else if ( NUMERIC_ASCEND_STRING.equalsIgnoreCase( s ) )
+ {
+ return NUMERIC_ASCEND;
+ }
+ else if ( NUMERIC_DESCEND_STRING.equalsIgnoreCase( s ) )
+ {
+ return NUMERIC_DESCEND;
+ }
+
+ return null;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ switch ( this )
+ {
+ case ALPHA_ASCEND:
+ return ALPHA_ASCEND_STRING;
+ case ALPHA_DESCEND:
+ return ALPHA_DESCEND_STRING;
+ case NUMERIC_ASCEND:
+ return NUMERIC_ASCEND_STRING;
+ case NUMERIC_DESCEND:
+ return NUMERIC_DESCEND_STRING;
+ }
+
+ return super.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcValSortValue.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcValSortValue.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcValSortValue.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OlcValSortValue.java Wed Apr 1 01:01:42 2015
@@ -0,0 +1,484 @@
+/*
+ * 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.studio.openldap.config.model;
+
+
+import java.text.ParseException;
+
+import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.util.Position;
+import org.apache.directory.api.util.Strings;
+
+
+/**
+ * This class represents 'OlcValSortOverlay' value.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class OlcValSortValue
+{
+ /** The 'weighted' constant string */
+ private static final String WEIGHTED_STRING = "weighted";
+
+ /** The attribute */
+ private String attribute;
+
+ /** The base DN */
+ private Dn baseDn;
+
+ /** The sort method */
+ private OlcValSortMethodEnum sortMethod;
+
+ private boolean isWeighted = false;
+
+
+ /**
+ * Gets the attribute.
+ *
+ * @return the attribute
+ */
+ public String getAttribute()
+ {
+ return attribute;
+ }
+
+
+ /**
+ * Gets the base DN.
+ *
+ * @return the base DN
+ */
+ public Dn getBaseDn()
+ {
+ return baseDn;
+ }
+
+
+ /**
+ * Gets the sort method.
+ *
+ * @return the sort method
+ */
+ public OlcValSortMethodEnum getSortMethod()
+ {
+ return sortMethod;
+ }
+
+
+ /**
+ * Return whether or the selected sort method is weighted.
+ *
+ * @return <code>true</code> if the sort method is weighted,
+ * <code>false</code> if not
+ */
+ public boolean isWeighted()
+ {
+ return isWeighted;
+ }
+
+
+ /**
+ * Sets the attribute.
+ *
+ * @param attribute the attribute
+ */
+ public void setAttribute( String attribute )
+ {
+ this.attribute = attribute;
+ }
+
+
+ /**
+ * Sets the base DN.
+ *
+ * @param baseDn the base DN
+ */
+ public void setBaseDn( Dn baseDn )
+ {
+ this.baseDn = baseDn;
+ }
+
+
+ /**
+ * Sets the sort method.
+ *
+ * @param sortMethod the sort method
+ */
+ public void setSortMethod( OlcValSortMethodEnum sortMethod )
+ {
+ this.sortMethod = sortMethod;
+ }
+
+
+ /**
+ * Sets whether or the selected sort method is weighted..
+ *
+ * @param isWeighted the value
+ */
+ public void setWeighted( boolean isWeighted )
+ {
+ this.isWeighted = isWeighted;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ // Attribute
+ sb.append( attribute );
+ sb.append( ' ' );
+
+ // Base DN
+ boolean baseDnNeedsEscaping = false;
+
+ if ( baseDn != null )
+ {
+ baseDnNeedsEscaping = needsEscaping( baseDn.toString() );
+ }
+
+ if ( baseDnNeedsEscaping )
+ {
+ sb.append( '"' );
+ }
+
+ sb.append( baseDn );
+
+ if ( baseDnNeedsEscaping )
+ {
+ sb.append( '"' );
+ }
+
+ sb.append( ' ' );
+
+ // Weighted
+ if ( isWeighted )
+ {
+ sb.append( WEIGHTED_STRING );
+
+ // Sort method
+ if ( sortMethod != null )
+ {
+ // Sort method
+ sb.append( ' ' );
+ sb.append( sortMethod );
+ }
+ }
+ else
+ {
+ // Sort method
+ sb.append( sortMethod );
+ }
+
+ return sb.toString();
+ }
+
+
+ /**
+ * Indicates if the given string needs escaping.
+ *
+ * @param s the string
+ * @return <code>true</code> if the given string needs escaping
+ * <code>false</code> if not.
+ */
+ private boolean needsEscaping( String s )
+ {
+ if ( s != null )
+ {
+ return s.contains( " " );
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Parses a OlcValSortValue value.
+ *
+ * @param s the string to be parsed
+ * @return the associated OlcValSortValue object
+ * @throws ParseException if there are any recognition errors (bad syntax)
+ */
+ public static synchronized OlcValSortValue parse( String s ) throws ParseException
+ {
+ if ( s == null )
+ {
+ return null;
+ }
+
+ // Trimming the value
+ s = Strings.trim( s );
+
+ // Getting the chars of the string
+ char[] chars = s.toCharArray();
+
+ // Creating the position
+ Position pos = new Position();
+ pos.start = 0;
+ pos.end = 0;
+ pos.length = chars.length;
+
+ return parseInternal( chars, pos );
+ }
+
+
+ /**
+ * Parses the given string.
+ *
+ * @param chars the characters
+ * @param pos the position
+ * @return the associated OlcValSortValue object
+ * @throws ParseException
+ */
+ private static OlcValSortValue parseInternal( char[] chars, Position pos ) throws ParseException
+ {
+ OlcValSortValue olcValSortValue = new OlcValSortValue();
+
+ // Empty (trimmed) string?
+ if ( chars.length == 0 )
+ {
+ return null;
+ }
+
+ do
+ {
+ // Attribute
+ String attribute = getQuotedOrNotQuotedOptionValue( chars, pos );
+
+ if ( ( attribute != null ) && ( !attribute.isEmpty() ) )
+ {
+ olcValSortValue.setAttribute( attribute );
+ }
+ else
+ {
+ throw new ParseException( "Could not find the 'Attribute' value", pos.start );
+ }
+
+ // Base DN
+ String baseDn = getQuotedOrNotQuotedOptionValue( chars, pos );
+
+ if ( ( baseDn != null ) && ( !baseDn.isEmpty() ) )
+ {
+ try
+ {
+ olcValSortValue.setBaseDn( new Dn( baseDn ) );
+ }
+ catch ( LdapInvalidDnException e )
+ {
+ throw new ParseException( "Could not convert '" + baseDn + "' to a valid DN.", pos.start );
+ }
+ }
+ else
+ {
+ throw new ParseException( "Could not find the 'Base DN value", pos.start );
+ }
+
+ // Getting the next item
+ // It can either "weighted" or a sort method
+ String weightedOrSortMethod = getQuotedOrNotQuotedOptionValue( chars, pos );
+
+ if ( ( weightedOrSortMethod != null ) && ( !weightedOrSortMethod.isEmpty() ) )
+ {
+ // Weighted
+ if ( isWeighted( weightedOrSortMethod ) )
+ {
+ olcValSortValue.setWeighted( true );
+ }
+ // Sort Method
+ else if ( isSortMethod( weightedOrSortMethod ) )
+ {
+ olcValSortValue.setSortMethod( OlcValSortMethodEnum.fromString( weightedOrSortMethod ) );
+ }
+ else
+ {
+ throw new ParseException( "Could not identify keyword '" + weightedOrSortMethod
+ + "' as a valid sort method.", pos.start );
+ }
+ }
+
+ // Getting the next item
+ // It should not exist if the previous item was "weighted" and
+ // must a sort method it the previous item was "weighted"
+ String sortMethod = getQuotedOrNotQuotedOptionValue( chars, pos );
+
+ if ( ( sortMethod != null ) && ( !sortMethod.isEmpty() ) )
+ {
+ if ( olcValSortValue.isWeighted() )
+ {
+ if ( isSortMethod( sortMethod ) )
+ {
+ olcValSortValue.setSortMethod( OlcValSortMethodEnum.fromString( sortMethod ) );
+ }
+ else
+ {
+ throw new ParseException( "Could not identify keyword '" + sortMethod
+ + "' as a valid sort method.", pos.start );
+ }
+ }
+ else
+ {
+ throw new ParseException( "Keyword '" + sortMethod + "' is not allowed after sort method.",
+ pos.start );
+ }
+ }
+ }
+ while ( ( pos.start != pos.length ) && ( ( Strings.charAt( chars, pos.start ) ) != '\0' ) );
+
+ return olcValSortValue;
+ }
+
+
+ /**
+ * Indicates if the given string is "weighted".
+ *
+ * @param s the string to test
+ * @return <code>true</code> if the given string is "weighted",
+ * <code>false</code> if not.
+ */
+ private static boolean isWeighted( String s )
+ {
+ return WEIGHTED_STRING.equalsIgnoreCase( s );
+ }
+
+
+ /**
+ * Indicates if the given string is one of the sort methods.
+ *
+ * @param s the string to test
+ * @return <code>true</code> if the given string is one of the sort methods,
+ * <code>false</code> if not.
+ */
+ private static boolean isSortMethod( String s )
+ {
+ return ( OlcValSortMethodEnum.fromString( s ) != null );
+ }
+
+
+ private static String getQuotedOrNotQuotedOptionValue( char[] chars, Position pos ) throws ParseException
+ {
+ if ( pos.start != pos.length )
+ {
+ char quoteChar = '\0';
+ boolean isInQuotes = false;
+ char c = Strings.charAt( chars, pos.start );
+ char[] v = new char[chars.length - pos.start];
+ int current = 0;
+
+ do
+ {
+ if ( ( current == 0 ) && !isInQuotes )
+ {
+ // Whitespace
+ if ( Character.isWhitespace( c ) )
+ {
+ // We ignore all whitespaces until we find the start of the value
+ pos.start++;
+ continue;
+ }
+ // Double quotes (") or single quotes (')
+ else if ( ( c == '"' ) || ( c == '\'' ) )
+ {
+ isInQuotes = true;
+ quoteChar = c;
+ pos.start++;
+ continue;
+ }
+ // Any other char is part of a value
+ else
+ {
+ v[current++] = c;
+ pos.start++;
+ }
+ }
+ else
+ {
+ if ( isInQuotes )
+ {
+ // Double quotes (") or single quotes (')
+ if ( quoteChar == c )
+ {
+ isInQuotes = false;
+ pos.start++;
+ continue;
+ }
+ // Checking for escaped quotes
+ else if ( c == '\\' )
+ {
+ // Double quotes (")
+ if ( ( quoteChar == '"' ) && ( Strings.areEquals( chars, pos.start, "\\\"" ) >= 0 ) )
+ {
+ v[current++] = '"';
+ pos.start += 2;
+ continue;
+ }
+ // Single quotes (')
+ else if ( ( quoteChar == '\'' ) && ( Strings.areEquals( chars, pos.start, "\\'" ) >= 0 ) )
+ {
+ v[current++] = '\'';
+ pos.start += 2;
+ continue;
+ }
+ }
+ // Any other char is part of a value
+ else
+ {
+ v[current++] = c;
+ pos.start++;
+ }
+ }
+ else
+ {
+ // Whitespace
+ if ( Character.isWhitespace( c ) )
+ {
+ // Once we have found the start of the value, the first whitespace is the exit
+ break;
+ }
+ // Any other char is part of a value
+ else
+ {
+ v[current++] = c;
+ pos.start++;
+ }
+ }
+ }
+ }
+ while ( ( c = Strings.charAt( chars, pos.start ) ) != '\0' );
+
+ // Checking the resulting value
+ if ( current == 0 )
+ {
+ throw new ParseException( "Couldn't find a value.", pos.start );
+ }
+
+ char[] value = new char[current];
+ System.arraycopy( v, 0, value, 0, current );
+
+ // Getting the value as a String
+ return new String( value );
+ }
+
+ return null;
+ }
+}
Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OpenLdapConfiguration.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OpenLdapConfiguration.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OpenLdapConfiguration.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/OpenLdapConfiguration.java Wed Apr 1 01:01:42 2015
@@ -23,63 +23,103 @@ package org.apache.directory.studio.open
import java.util.ArrayList;
import java.util.List;
+import org.apache.directory.studio.connection.core.Connection;
+
/**
* This class implements the basic class for an OpenLDAP configuration.
* <p>
- * It contains all the configuration objects found under the "cn=config" branch.
+ * It contains all the configuration objects found under the "cn=config" branch.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OpenLdapConfiguration
{
+ /** The connection */
+ private Connection connection;
+
+ /** The global configuration */
+ private OlcGlobal global;
+
+ /** The databases list */
+ private List<OlcDatabaseConfig> databases = new ArrayList<OlcDatabaseConfig>();
+
+ /** The other configuration elements list*/
private List<OlcConfig> configurationElements = new ArrayList<OlcConfig>();
- /**
- * @return the configurationElements
- */
- public List<OlcConfig> getConfigurationElements()
+ public boolean add( OlcConfig o )
{
- return configurationElements;
+ return configurationElements.add( o );
}
- /**
- * @param e
- * @return
- * @see java.util.List#add(java.lang.Object)
- */
- public boolean add( OlcConfig o )
+ public boolean addDatabase( OlcDatabaseConfig o )
{
- return configurationElements.add( o );
+ return databases.add( o );
+ }
+
+
+ public void clearDatabases()
+ {
+ databases.clear();
}
- /**
- * @param o
- * @return
- * @see java.util.List#contains(java.lang.Object)
- */
public boolean contains( OlcConfig o )
{
return configurationElements.contains( o );
}
- /**
- * @param o
- * @return
- * @see java.util.List#remove(java.lang.Object)
- */
+ public List<OlcConfig> getConfigurationElements()
+ {
+ return configurationElements;
+ }
+
+
+ public Connection getConnection()
+ {
+ return connection;
+ }
+
+
+ public List<OlcDatabaseConfig> getDatabases()
+ {
+ return databases;
+ }
+
+
+ public OlcGlobal getGlobal()
+ {
+ return global;
+ }
+
+
public boolean remove( OlcConfig o )
{
return configurationElements.remove( o );
}
- /**
- * @return
- * @see java.util.List#size()
- */
+ public boolean removeDatabase( OlcDatabaseConfig o )
+ {
+ return databases.remove( o );
+ }
+
+
+ public void setConnection( Connection connection )
+ {
+ this.connection = connection;
+ }
+
+
+ public void setGlobal( OlcGlobal global )
+ {
+ this.global = global;
+ }
+
+
public int size()
{
return configurationElements.size();
Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/io/ConfigurationException.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/io/ConfigurationException.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/io/ConfigurationException.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/io/ConfigurationException.java Wed Apr 1 01:01:42 2015
@@ -25,7 +25,9 @@ import org.apache.directory.api.ldap.mod
/**
* An exception used when we cannot read the configuration, or when an error
- * occured while reading it from the DIT.
+ * occurred while reading it from the DIT.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ConfigurationException extends LdapException
{
Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/io/ConfigurationReader.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/io/ConfigurationReader.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/io/ConfigurationReader.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/io/ConfigurationReader.java Wed Apr 1 01:01:42 2015
@@ -20,6 +20,7 @@
package org.apache.directory.studio.openldap.config.model.io;
+import java.io.File;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
@@ -28,8 +29,11 @@ import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import javax.naming.directory.SearchResult;
@@ -46,53 +50,112 @@ import org.apache.directory.api.ldap.mod
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.model.schema.ObjectClass;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
+import org.apache.directory.api.ldap.util.tree.DnNode;
import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
+import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.connection.core.io.StudioNamingEnumeration;
import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
import org.apache.directory.studio.ldapbrowser.core.jobs.SearchRunnable;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.apache.directory.studio.ldapbrowser.core.model.SearchParameter;
-import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.osgi.util.NLS;
+import org.apache.directory.studio.openldap.config.ExpandedLdifUtils;
+import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin;
import org.apache.directory.studio.openldap.config.editor.ConnectionServerConfigurationInput;
+import org.apache.directory.studio.openldap.config.editor.DirectoryServerConfigurationInput;
import org.apache.directory.studio.openldap.config.editor.ServerConfigurationEditorUtils;
import org.apache.directory.studio.openldap.config.jobs.EntryBasedConfigurationPartition;
import org.apache.directory.studio.openldap.config.model.AuxiliaryObjectClass;
import org.apache.directory.studio.openldap.config.model.ConfigurationElement;
import org.apache.directory.studio.openldap.config.model.OlcConfig;
+import org.apache.directory.studio.openldap.config.model.OlcDatabaseConfig;
+import org.apache.directory.studio.openldap.config.model.OlcGlobal;
+import org.apache.directory.studio.openldap.config.model.OlcOverlayConfig;
import org.apache.directory.studio.openldap.config.model.OpenLdapConfiguration;
/**
* This class implements a configuration reader for OpenLDAP.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ConfigurationReader
{
+ /** The package name where the model classes are stored */
private static final String MODEL_PACKAGE_NAME = "org.apache.directory.studio.openldap.config.model";
+ /**
+ * Reads the configuration.
+ *
+ * @param input the input
+ * @return the OpenLDAP configuration
+ * @throws Exception
+ */
public static OpenLdapConfiguration readConfiguration( ConnectionServerConfigurationInput input ) throws Exception
{
// Creating a new OpenLDAP configuration
OpenLdapConfiguration configuration = new OpenLdapConfiguration();
+ // Saving the connection to the configuration
+ configuration.setConnection( input.getConnection() );
+
// Getting the browser connection associated with the connection in the input
IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
.getBrowserConnection( input.getConnection() );
+ // Find the location of the configuration
+ Dn configurationDn = ConfigurationUtils.getConfigurationDn( browserConnection );
+
// Reading the configuration entries on the server
- List<Entry> configurationEntries = readEntries( input, browserConnection );
+ List<Entry> configurationEntries = readEntries( configurationDn, input, browserConnection );
+
+ // Creating a map to store object created based on their DN
+ Map<Dn, OlcConfig> dnToConfigObjectMap = new HashMap<Dn, OlcConfig>();
// For each configuration entries we create an associated configuration
// object and store it in the OpenLDAP configuration
for ( Entry entry : configurationEntries )
{
- OlcConfig configurationObject = createConfigurationObject( entry, browserConnection.getSchema() );
+ // Converting the entry into a configuration object
+ OlcConfig configurationObject = createConfigurationObject( entry );
if ( configurationObject != null )
{
- configuration.add( configurationObject );
+ // Storing the object in the configuration objects map
+ dnToConfigObjectMap.put( entry.getDn(), configurationObject );
+
+ if ( configurationObject instanceof OlcDatabaseConfig )
+ {
+ OlcDatabaseConfig databaseConfig = ( OlcDatabaseConfig ) configurationObject;
+ configuration.addDatabase( databaseConfig );
+ }
+ else if ( configurationObject instanceof OlcOverlayConfig )
+ {
+ OlcOverlayConfig overlayConfig = ( OlcOverlayConfig ) configurationObject;
+
+ OlcDatabaseConfig databaseConfig = ( OlcDatabaseConfig ) dnToConfigObjectMap.get( entry.getDn()
+ .getParent() );
+
+ if ( databaseConfig != null )
+ {
+ databaseConfig.addOverlay( overlayConfig );
+ }
+ else
+ {
+ configuration.add( overlayConfig );
+ }
+ }
+ else if ( configurationObject instanceof OlcGlobal )
+ {
+ configuration.setGlobal( ( OlcGlobal ) configurationObject );
+ }
+ else
+ {
+ configuration.add( configurationObject );
+ }
}
}
@@ -101,42 +164,210 @@ public class ConfigurationReader
/**
+ * Reads the configuration.
+ *
+ * @param input the input
+ * @return the OpenLDAP configuration
+ * @throws Exception
+ */
+ public static OpenLdapConfiguration readConfiguration( DirectoryServerConfigurationInput input ) throws Exception
+ {
+ return readConfiguration( input.getDirectory() );
+ }
+
+
+ /**
+ * Reads the configuration.
+ *
+ * @param directory the directory
+ * @return the OpenLDAP configuration
+ * @throws Exception
+ */
+ public static OpenLdapConfiguration readConfiguration( File directory ) throws Exception
+ {
+ // Creating a new OpenLDAP configuration
+ OpenLdapConfiguration configuration = new OpenLdapConfiguration();
+
+ // Reading the configuration entries disk
+ DnNode<Entry> tree = readEntries( directory );
+
+ // Creating configuration objects
+ createConfigurationObjects( tree, configuration );
+
+ return configuration;
+ }
+
+
+ /**
+ * Creates the configuration objects.
+ *
+ * @param configuration the configuration
+ * @param dnToConfigObjectMap the maps to store
+ */
+ /**
+ * Creates the configuration objects.
+ *
+ * @param tree the tree
+ * @param configuration the configuration
+ * @throws ConfigurationException
+ */
+ private static void createConfigurationObjects( DnNode<Entry> tree, OpenLdapConfiguration configuration )
+ throws ConfigurationException
+ {
+ // Creating a map to store object created based on their DN
+ Map<Dn, OlcConfig> dnToConfigObjectMap = new HashMap<Dn, OlcConfig>();
+
+ createConfigurationObjects( tree, configuration, dnToConfigObjectMap );
+ }
+
+
+ /**
+ * Creates the configuration objects.
+ *
+ * @param node the node
+ * @param configuration the configuration
+ * @param dnToConfigObjectMap the maps to associate DNs to configuration objects
+ * @throws ConfigurationException
+ */
+ private static void createConfigurationObjects( DnNode<Entry> node, OpenLdapConfiguration configuration,
+ Map<Dn, OlcConfig> dnToConfigObjectMap ) throws ConfigurationException
+ {
+ if ( node != null )
+ {
+ // Checking if the node as an element
+ if ( node.hasElement() )
+ {
+ // Getting the entry for the node
+ Entry entry = node.getElement();
+
+ // Converting the entry into a configuration object
+ OlcConfig configurationObject = createConfigurationObject( entry );
+
+ if ( configurationObject != null )
+ {
+ // Storing the object in the configuration objects map
+ dnToConfigObjectMap.put( entry.getDn(), configurationObject );
+
+ // Checking if it's a database
+ if ( configurationObject instanceof OlcDatabaseConfig )
+ {
+ OlcDatabaseConfig databaseConfig = ( OlcDatabaseConfig ) configurationObject;
+ configuration.addDatabase( databaseConfig );
+ }
+ // Checking if it's an overlay
+ else if ( configurationObject instanceof OlcOverlayConfig )
+ {
+ OlcOverlayConfig overlayConfig = ( OlcOverlayConfig ) configurationObject;
+
+ // Getting the associated database configuration object
+ OlcDatabaseConfig databaseConfig = ( OlcDatabaseConfig ) dnToConfigObjectMap.get( entry.getDn()
+ .getParent() );
+
+ if ( databaseConfig != null )
+ {
+ databaseConfig.addOverlay( overlayConfig );
+ }
+ else
+ {
+ configuration.add( overlayConfig );
+ }
+ }
+ // Checking if it's the "global' configuration object
+ else if ( configurationObject instanceof OlcGlobal )
+ {
+ configuration.setGlobal( ( OlcGlobal ) configurationObject );
+ }
+ // Any other object type
+ else
+ {
+ configuration.add( configurationObject );
+ }
+ }
+ }
+
+ // Checking the node has some children
+ if ( node.hasChildren() )
+ {
+ Collection<DnNode<Entry>> children = node.getChildren().values();
+
+ for ( DnNode<Entry> child : children )
+ {
+ createConfigurationObjects( child, configuration, dnToConfigObjectMap );
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Reads the configuration entries from the input.
+ *
+ * @param directory the directory
+ * @return the tree of configuration entries found
+ * @throws Exception if an error occurred
+ */
+ private static DnNode<Entry> readEntries( File directory )
+ throws Exception
+ {
+ // Reading the entries tree
+ DnNode<Entry> tree = ExpandedLdifUtils.read( directory );
+
+ // Checking the read tree
+ if ( ( tree != null ) && ( tree.size() != 0 ) )
+ {
+ return tree;
+ }
+ else
+ {
+ throw new Exception( "No entries found" );
+ }
+ }
+
+
+ /**
* Gets the highest structural object class found in the attribute.
*
* @param objectClassAttribute the 'objectClass' attribute
- * @param schema the schema associated with the connection
* @return the highest structural object class found in the attribute.
*/
- public static ObjectClass getHighestStructuralObjectClass( Attribute objectClassAttribute, Schema schema )
+ public static ObjectClass getHighestStructuralObjectClass( Attribute objectClassAttribute )
+ throws ConfigurationException
{
Set<ObjectClass> candidates = new HashSet<ObjectClass>();
- if ( ( objectClassAttribute != null ) && ( schema != null ) )
+ try
{
- // Create the set of candidates
- for ( Value<?> objectClassValue : objectClassAttribute )
+ SchemaManager schemaManager = OpenLdapConfigurationPlugin.getDefault().getSchemaManager();
+
+ if ( ( objectClassAttribute != null ) && ( schemaManager != null ) )
{
- ObjectClass oc = schema.getObjectClassDescription( objectClassValue.getString() );
- if ( oc.isStructural() )
+ // Create the set of candidates
+ for ( Value<?> objectClassValue : objectClassAttribute )
{
- candidates.add( oc );
- }
- }
+ ObjectClass oc = ServerConfigurationEditorUtils.getObjectClass( schemaManager,
+ objectClassValue.getString() );
- // Now find the parent OC
- for ( Value<?> objectClassValue : objectClassAttribute )
- {
- String ocName = objectClassValue.getString();
- ObjectClass oc = schema.getObjectClassDescription( ocName );
+ if ( ( oc != null ) && ( oc.isStructural() ) )
+ {
+ candidates.add( oc );
+ }
+ }
- for ( String superiorName : oc.getSuperiorOids() )
+ // Now find the parent OC
+ for ( Value<?> objectClassValue : objectClassAttribute )
{
- ObjectClass superior = schema.getObjectClassDescription( superiorName );
- if ( superior != null )
+ ObjectClass oc = ServerConfigurationEditorUtils.getObjectClass( schemaManager,
+ objectClassValue.getString() );
+
+ if ( oc != null )
{
- if ( oc.isStructural() )
+ for ( String superiorName : oc.getSuperiorOids() )
{
- if ( candidates.contains( superior ) )
+ ObjectClass superior = ServerConfigurationEditorUtils.getObjectClass( schemaManager,
+ superiorName );
+
+ if ( ( superior != null ) && ( superior.isStructural() )
+ && ( candidates.contains( superior ) ) )
{
candidates.remove( superior );
}
@@ -145,6 +376,10 @@ public class ConfigurationReader
}
}
}
+ catch ( Exception e )
+ {
+ throw new ConfigurationException( e );
+ }
// The remaining OC in the candidates set is the one we are looking for
return candidates.toArray( new ObjectClass[]
@@ -153,53 +388,76 @@ public class ConfigurationReader
/**
- * Gets the highest object class found in the attribute.
+ * Gets the auxiliary object classes found in the attribute.
*
* @param objectClassAttribute the 'objectClass' attribute
- * @param schema the schema associated with the connection
- * @return the highest object class found in the attribute.
+ * @return the auxiliary object classes found in the attribute.
*/
- public static ObjectClass[] getAuxiliaryObjectClasses( Attribute objectClassAttribute, Schema schema )
+ public static ObjectClass[] getAuxiliaryObjectClasses( Attribute objectClassAttribute )
+ throws ConfigurationException
{
List<ObjectClass> auxiliaryObjectClasses = new ArrayList<ObjectClass>();
- if ( ( objectClassAttribute != null ) && ( schema != null ) )
+ try
{
- for ( Value<?> objectClassValue : objectClassAttribute )
+ SchemaManager schemaManager = OpenLdapConfigurationPlugin.getDefault().getSchemaManager();
+
+ if ( ( objectClassAttribute != null ) && ( schemaManager != null ) )
{
- ObjectClass oc = schema.getObjectClassDescription( objectClassValue.getString() );
- if ( oc.isAuxiliary() )
+ for ( Value<?> objectClassValue : objectClassAttribute )
{
- auxiliaryObjectClasses.add( oc );
+ ObjectClass oc = ServerConfigurationEditorUtils.getObjectClass( schemaManager,
+ objectClassValue.getString() );
+
+ if ( ( oc != null ) && ( oc.isAuxiliary() ) )
+ {
+ auxiliaryObjectClasses.add( oc );
+ }
}
}
}
+ catch ( Exception e )
+ {
+ throw new ConfigurationException( e );
+ }
return auxiliaryObjectClasses.toArray( new ObjectClass[0] );
}
- public static List<Entry> readEntries( ConnectionServerConfigurationInput input,
+ /**
+ * Reads the configuration entries from the input.
+ *
+ * @param configurationDn the configuration DN
+ * @param input the editor input
+ * @param browserConnection the connection
+ * @return the list of configuration entries found
+ * @throws Exception if an error occurred
+ */
+ public static List<Entry> readEntries( Dn configurationDn, ConnectionServerConfigurationInput input,
IBrowserConnection browserConnection ) throws Exception
{
List<Entry> foundEntries = new ArrayList<Entry>();
IProgressMonitor progressMonitor = new NullProgressMonitor();
StudioProgressMonitor monitor = new StudioProgressMonitor( progressMonitor );
+ Connection connection = input.getConnection();
// Creating the schema manager
- SchemaManager schemaManager = ServerConfigurationEditorUtils.createSchemaManager( input.getConnection() );
+ SchemaManager schemaManager = OpenLdapConfigurationPlugin.getDefault().getSchemaManager();
// The DN corresponding to the configuration base
- Dn configBaseDn = new Dn( "cn=config" ); // TODO Change this
// Creating the configuration partition
EntryBasedConfigurationPartition configurationPartition = ServerConfigurationEditorUtils
- .createConfigurationPartition( schemaManager, configBaseDn );
+ .createConfigurationPartition( schemaManager, configurationDn );
+
+ // Opening the connection (if needed)
+ ConfigurationUtils.openConnection( connection, monitor );
// Creating the search parameter
SearchParameter configSearchParameter = new SearchParameter();
- configSearchParameter.setSearchBase( configBaseDn );
+ configSearchParameter.setSearchBase( configurationDn );
configSearchParameter.setFilter( "(objectClass=*)" );
configSearchParameter.setScope( SearchScope.OBJECT );
configSearchParameter.setReturningAttributes( SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
@@ -218,17 +476,17 @@ public class ConfigurationReader
// Getting the entry
if ( enumeration.hasMore() )
{
- // Creating the 'ou=config' base entry
+ // Creating the base entry
SearchResult searchResult = ( SearchResult ) enumeration.next();
configEntry = new DefaultEntry( schemaManager, AttributeUtils.toEntry( searchResult.getAttributes(),
new Dn( searchResult.getNameInNamespace() ) ) );
}
enumeration.close();
- // Verifying we found the 'ou=config' base entry
+ // Verifying we found the base entry
if ( configEntry == null )
{
- throw new LdapNoSuchObjectException( "Unable to find the 'ou=config' base entry." );
+ throw new LdapNoSuchObjectException( NLS.bind( "Unable to find the ''{0}'' base entry.", configurationDn ) );
}
// Creating a list to hold the entries that needs to be checked
@@ -283,7 +541,7 @@ public class ConfigurationReader
}
- private static OlcConfig createConfigurationObject( Entry entry, Schema schema )
+ private static OlcConfig createConfigurationObject( Entry entry )
throws ConfigurationException
{
// Getting the 'objectClass' attribute
@@ -291,7 +549,7 @@ public class ConfigurationReader
if ( objectClassAttribute != null )
{
// Getting the highest structural object class based on schema
- ObjectClass highestStructuralObjectClass = getHighestStructuralObjectClass( objectClassAttribute, schema );
+ ObjectClass highestStructuralObjectClass = getHighestStructuralObjectClass( objectClassAttribute );
// Computing the class name for the bean corresponding to the structural object class
String highestObjectClassName = highestStructuralObjectClass.getName();
@@ -319,7 +577,7 @@ public class ConfigurationReader
}
// Checking auxiliary object classes
- ObjectClass[] auxiliaryObjectClasses = getAuxiliaryObjectClasses( objectClassAttribute, schema );
+ ObjectClass[] auxiliaryObjectClasses = getAuxiliaryObjectClasses( objectClassAttribute );
if ( ( auxiliaryObjectClasses != null ) && ( auxiliaryObjectClasses.length > 0 ) )
{
for ( ObjectClass auxiliaryObjectClass : auxiliaryObjectClasses )