directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ersi...@apache.org
Subject svn commit: r463987 - in /directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo: SPDemo01.java SPDemo02.java SPDemo03.java SPMainDemo.java TriggersMainDemo.java common/BackupUtilities.java common/Greeter.java
Date Sat, 14 Oct 2006 18:52:18 GMT
Author: ersiner
Date: Sat Oct 14 11:52:15 2006
New Revision: 463987

URL: http://svn.apache.org/viewvc?view=rev&rev=463987
Log:
Updating SP-Trigger demos used at ApacheCon.

Added:
    directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/SPDemo01.java
    directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/SPDemo02.java
    directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/SPDemo03.java
    directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/common/BackupUtilities.java
Removed:
    directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/SPMainDemo.java
    directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/TriggersMainDemo.java
Modified:
    directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/common/Greeter.java

Added: directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/SPDemo01.java
URL: http://svn.apache.org/viewvc/directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/SPDemo01.java?view=auto&rev=463987
==============================================================================
--- directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/SPDemo01.java (added)
+++ directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/SPDemo01.java Sat
Oct 14 11:52:15 2006
@@ -0,0 +1,69 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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 sptriggerdemo;
+
+
+import java.util.Hashtable;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.shared.ldap.sp.JavaStoredProcedureUtils;
+
+import sptriggerdemo.common.BulkOperations;
+import sptriggerdemo.common.Greeter;
+
+
+/**
+ * SPDemo01
+ * 
+ * @author <a href="mailto:ersiner@apache.org">Ersin Er</a>
+ */
+public class SPDemo01
+{
+    private static String host = "localhost";
+    private static int port = 1024;
+
+
+    private static LdapContext connectToServer() throws NamingException
+    {
+        Hashtable env = new Hashtable();
+        env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
+        env.put( "java.naming.provider.url", "ldap://" + host + ":" + port + "/ou=system"
);
+        env.put( "java.naming.security.principal", "uid=admin,ou=system" );
+        env.put( "java.naming.security.credentials", "secret" );
+        env.put( "java.naming.security.authentication", "simple" );
+        return new InitialLdapContext( env, null );
+    }
+
+
+    public static void main( String[] args ) throws NamingException
+    {
+        LdapContext ctx = connectToServer();
+
+        LdapContext spCtx = ( LdapContext ) ctx.lookup( "ou=Stored Procedures" );
+
+        //JavaStoredProcedureUtils.loadStoredProcedureClass( spCtx, Greeter.class );
+
+        String spName = Greeter.class.getName() + ".helloWorld";
+        Object[] params = new Object[] {};
+        
+        JavaStoredProcedureUtils.callStoredProcedure( ctx, spName, params );
+    }
+}

Added: directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/SPDemo02.java
URL: http://svn.apache.org/viewvc/directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/SPDemo02.java?view=auto&rev=463987
==============================================================================
--- directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/SPDemo02.java (added)
+++ directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/SPDemo02.java Sat
Oct 14 11:52:15 2006
@@ -0,0 +1,71 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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 sptriggerdemo;
+
+
+import java.util.Hashtable;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.shared.ldap.sp.JavaStoredProcedureUtils;
+
+import sptriggerdemo.common.BulkOperations;
+import sptriggerdemo.common.Greeter;
+
+
+/**
+ * SPDemo02
+ * 
+ * @author <a href="mailto:ersiner@apache.org">Ersin Er</a>
+ */
+public class SPDemo02
+{
+    private static String host = "localhost";
+    private static int port = 1024;
+
+
+    private static LdapContext connectToServer() throws NamingException
+    {
+        Hashtable env = new Hashtable();
+        env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
+        env.put( "java.naming.provider.url", "ldap://" + host + ":" + port + "/ou=system"
);
+        env.put( "java.naming.security.principal", "uid=admin,ou=system" );
+        env.put( "java.naming.security.credentials", "secret" );
+        env.put( "java.naming.security.authentication", "simple" );
+        return new InitialLdapContext( env, null );
+    }
+
+
+    public static void main( String[] args ) throws NamingException
+    {
+        LdapContext ctx = connectToServer();
+
+        LdapContext spCtx = ( LdapContext ) ctx.lookup( "ou=Stored Procedures" );
+
+        //JavaStoredProcedureUtils.loadStoredProcedureClass( spCtx, Greeter.class );
+
+        String spName = Greeter.class.getName() + ".sayHello";
+        Object[] params = new Object[] {
+            new String ( "John" ), new Integer( 3 ) };
+        
+        Object response = JavaStoredProcedureUtils.callStoredProcedure( ctx, spName, params
);
+        System.out.println( "Response: " + response );
+    }
+}

Added: directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/SPDemo03.java
URL: http://svn.apache.org/viewvc/directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/SPDemo03.java?view=auto&rev=463987
==============================================================================
--- directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/SPDemo03.java (added)
+++ directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/SPDemo03.java Sat
Oct 14 11:52:15 2006
@@ -0,0 +1,71 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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 sptriggerdemo;
+
+
+import java.util.Hashtable;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.sp.JavaStoredProcedureUtils;
+import org.apache.directory.shared.ldap.sp.LdapContextParameter;
+
+import sptriggerdemo.common.BulkOperations;
+
+
+/**
+ * SPDemo03
+ * 
+ * @author <a href="mailto:ersiner@apache.org">Ersin Er</a>
+ */
+public class SPDemo03
+{
+    private static String host = "localhost";
+    private static int port = 1024;
+
+
+    private static LdapContext connectToServer() throws NamingException
+    {
+        Hashtable env = new Hashtable();
+        env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
+        env.put( "java.naming.provider.url", "ldap://" + host + ":" + port + "/ou=system"
);
+        env.put( "java.naming.security.principal", "uid=admin,ou=system" );
+        env.put( "java.naming.security.credentials", "secret" );
+        env.put( "java.naming.security.authentication", "simple" );
+        return new InitialLdapContext( env, null );
+    }
+
+
+    public static void main( String[] args ) throws NamingException
+    {
+        LdapContext ctx = connectToServer();
+
+        LdapContext spCtx = ( LdapContext ) ctx.lookup( "ou=Stored Procedures" );
+
+        JavaStoredProcedureUtils.loadStoredProcedureClass( spCtx, BulkOperations.class );
+
+        String spName = BulkOperations.class.getName() + ".deleteSubtree";
+        Object[] params = new Object[] { new LdapContextParameter( "ou=system" ),
+                                         new LdapDN( "ou=Mailing Lists") };
+        
+        JavaStoredProcedureUtils.callStoredProcedure( ctx, spName, params );
+    }
+}

Added: directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/common/BackupUtilities.java
URL: http://svn.apache.org/viewvc/directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/common/BackupUtilities.java?view=auto&rev=463987
==============================================================================
--- directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/common/BackupUtilities.java
(added)
+++ directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/common/BackupUtilities.java
Sat Oct 14 11:52:15 2006
@@ -0,0 +1,24 @@
+package sptriggerdemo.common;
+
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.ldap.LdapContext;
+
+/**
+ * BackupUtilities
+ * 
+ * @author <a href="mailto:ersiner@apache.org">Ersin Er</a>
+ */
+public class BackupUtilities
+{
+    public static void backupDeleted( LdapContext ctx, Name deletedEntryName, Name operationPrincipal,
Attributes deletedEntry ) throws NamingException
+    {
+        System.out.println( "User \"" + operationPrincipal + "\" has deleted entry \"" +
deletedEntryName + "\"" );
+        System.out.println( "Entry content was: " + deletedEntry );
+        LdapContext backupCtx = ( LdapContext ) ctx.lookup( "ou=Backups,ou=system" );
+        String deletedEntryRdn = deletedEntryName.get( deletedEntryName.size() - 1 );
+        backupCtx.createSubcontext( deletedEntryRdn, deletedEntry );
+        System.out.println( "Backed up deleted entry to \"" + ( ( LdapContext ) backupCtx.lookup(
deletedEntryRdn ) ).getNameInNamespace() + "\"" );
+    }
+}

Modified: directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/common/Greeter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/common/Greeter.java?view=diff&rev=463987&r1=463986&r2=463987
==============================================================================
--- directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/common/Greeter.java
(original)
+++ directory/sandbox/ersiner/sptriggerdemo/src/main/java/sptriggerdemo/common/Greeter.java
Sat Oct 14 11:52:15 2006
@@ -3,13 +3,19 @@
 import javax.naming.NamingException;
 
 /**
- * LDAP Stored Procedure Unit that does not really make much sense.
- * Just has a "Hello World" type procedure.
+ * LDAP Stored Procedure Unit that can be used for demostration purposes.
  * 
  * @author <a href="mailto:ersiner@apache.org">Ersin Er</a>
  */
 public class Greeter
 {
+    
+    public static void helloWorld() throws NamingException
+    {
+        System.out.println( "Hello World!" );
+    }
+    
+    
     public static String sayHello( String who, Integer times ) throws NamingException
     {
         StringBuffer buffer = new StringBuffer();



Mime
View raw message