directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 10444 - incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile
Date Fri, 30 Apr 2004 05:34:05 GMT
Author: akarasulu
Date: Thu Apr 29 22:34:04 2004
New Revision: 10444

Added:
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/JeLinkAppNameKeyCreator.java
  (contents, props changed)
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/JeLinkRoleNameKeyCreator.java
  (contents, props changed)
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/JeLinkUserNameKeyCreator.java
  (contents, props changed)
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/JeProfileRoleLinkBinding.java
  (contents, props changed)
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/ProfileRoleLinkDAOMonitor.java
  (contents, props changed)
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/ProfileRoleLinkDAOMonitorAdapter.java
  (contents, props changed)
Log:
Commit changes ...
 
 o completed key creators for profile to role link database secondary databases
     - appName key creator for the appName:link secondary
     - userName key creator for the userName:link secondary
     - roleName key creator for the roleName:link secondary
 o completed tuple binding for profile to role link entries
 o added monitor interface and adapter stubs



Added: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/JeLinkAppNameKeyCreator.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/JeLinkAppNameKeyCreator.java
Thu Apr 29 22:34:04 2004
@@ -0,0 +1,71 @@
+/*
+ *   Copyright 2004 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 permission and
+ *   limitations under the License.
+ *
+ */
+package org.apache.rms.je.profile ;
+
+
+import com.sleepycat.je.DatabaseEntry ;
+import com.sleepycat.je.SecondaryDatabase ;
+import com.sleepycat.je.DatabaseException ;
+import com.sleepycat.je.SecondaryKeyCreator ;
+
+import java.io.IOException;
+
+
+/**
+ * A appName key creator for the Profile database's secondary database.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class JeLinkAppNameKeyCreator implements SecondaryKeyCreator
+{
+    /** the binding used to manipulate a serialized profile */
+    private final JeProfileRoleLinkBinding BINDING =
+            new JeProfileRoleLinkBinding() ;
+
+
+    /**
+     * Sets the profile appName bytes for the result entry by extracting it
+     * from the dataEntry.
+     *
+     * @param secondaryDatabase the secondary database the new key is for
+     * @param keyEntry the key in the primary
+     * @param dataEntry the data in the primary
+     * @param resultEntry the new key for the secondary
+     * @return true if a key is created, false otherwise.
+     */
+    public boolean createSecondaryKey( SecondaryDatabase secondaryDatabase,
+                                       DatabaseEntry keyEntry,
+                                       DatabaseEntry dataEntry,
+                                       DatabaseEntry resultEntry )
+        throws DatabaseException
+    {
+        String name = null ;
+
+        try
+        {
+            name = BINDING.getApplicationName( dataEntry ) ;
+            resultEntry.setData( name.getBytes( "UTF-8" ) ) ;
+        }
+        catch ( IOException e )
+        {
+            throw new DatabaseException( e ) ;
+        }
+
+        return true ;
+    }
+}

Added: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/JeLinkRoleNameKeyCreator.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/JeLinkRoleNameKeyCreator.java
Thu Apr 29 22:34:04 2004
@@ -0,0 +1,70 @@
+/*
+ *   Copyright 2004 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 permission and
+ *   limitations under the License.
+ *
+ */
+package org.apache.rms.je.profile ;
+
+
+import com.sleepycat.je.DatabaseEntry ;
+import com.sleepycat.je.SecondaryDatabase ;
+import com.sleepycat.je.DatabaseException ;
+import com.sleepycat.je.SecondaryKeyCreator ;
+
+import java.io.IOException;
+
+
+/**
+ * A roleName key creator for the Profile database's secondary database.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class JeLinkRoleNameKeyCreator implements SecondaryKeyCreator
+{
+    /** the binding used to manipulate a serialized profile */
+    private final JeProfileRoleLinkBinding BINDING = new JeProfileRoleLinkBinding() ;
+
+
+    /**
+     * Sets the profile roleName bytes for the result entry by extracting it
+     * from the dataEntry.
+     *
+     * @param secondaryDatabase the secondary database the new key is for
+     * @param keyEntry the key in the primary
+     * @param dataEntry the data in the primary
+     * @param resultEntry the new key for the secondary
+     * @return true if a key is created, false otherwise.
+     */
+    public boolean createSecondaryKey( SecondaryDatabase secondaryDatabase,
+                                       DatabaseEntry keyEntry,
+                                       DatabaseEntry dataEntry,
+                                       DatabaseEntry resultEntry )
+        throws DatabaseException
+    {
+        String name = null ;
+
+        try
+        {
+            name = BINDING.getRoleName( dataEntry ) ;
+            resultEntry.setData( name.getBytes( "UTF-8" ) ) ;
+        }
+        catch ( IOException e )
+        {
+            throw new DatabaseException( e ) ;
+        }
+
+        return true ;
+    }
+}

Added: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/JeLinkUserNameKeyCreator.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/JeLinkUserNameKeyCreator.java
Thu Apr 29 22:34:04 2004
@@ -0,0 +1,71 @@
+/*
+ *   Copyright 2004 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 permission and
+ *   limitations under the License.
+ *
+ */
+package org.apache.rms.je.profile ;
+
+
+import com.sleepycat.je.DatabaseEntry ;
+import com.sleepycat.je.SecondaryDatabase ;
+import com.sleepycat.je.DatabaseException ;
+import com.sleepycat.je.SecondaryKeyCreator ;
+
+import java.io.IOException;
+
+
+/**
+ * A userName key creator for the Profile database's secondary database.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class JeLinkUserNameKeyCreator implements SecondaryKeyCreator
+{
+    /** the binding used to manipulate a serialized profile */
+    private final JeProfileRoleLinkBinding BINDING =
+            new JeProfileRoleLinkBinding() ;
+
+
+    /**
+     * Sets the profile userName bytes for the result entry by extracting it
+     * from the dataEntry.
+     *
+     * @param secondaryDatabase the secondary database the new key is for
+     * @param keyEntry the key in the primary
+     * @param dataEntry the data in the primary
+     * @param resultEntry the new key for the secondary
+     * @return true if a key is created, false otherwise.
+     */
+    public boolean createSecondaryKey( SecondaryDatabase secondaryDatabase,
+                                       DatabaseEntry keyEntry,
+                                       DatabaseEntry dataEntry,
+                                       DatabaseEntry resultEntry )
+        throws DatabaseException
+    {
+        String name = null ;
+
+        try
+        {
+            name = BINDING.getUserName( dataEntry ) ;
+            resultEntry.setData( name.getBytes( "UTF-8" ) ) ;
+        }
+        catch ( IOException e )
+        {
+            throw new DatabaseException( e ) ;
+        }
+
+        return true ;
+    }
+}

Added: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/JeProfileRoleLinkBinding.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/JeProfileRoleLinkBinding.java
Thu Apr 29 22:34:04 2004
@@ -0,0 +1,149 @@
+/*
+ *   Copyright 2004 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 permission and
+ *   limitations under the License.
+ *
+ */
+package org.apache.rms.je.profile ;
+
+import com.sleepycat.je.DatabaseEntry ;
+import com.sleepycat.bind.tuple.TupleInput ;
+import com.sleepycat.bind.tuple.TupleOutput ;
+import com.sleepycat.bind.tuple.TupleBinding ;
+
+import java.io.IOException ;
+
+
+/**
+ * A JE Profile to Role link object binding.  There really is no class for a
+ * link object so the entryToObject and objectToEntry methods simply throw an
+ * UnsupportedOperationException.  What's the point to this class you might
+ * ask?  Well we don't need to create the object but we do need to serialize
+ * on using our own binding.  There is just no better place we can put the
+ * code that manages extracting info from the db entry.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class JeProfileRoleLinkBinding extends TupleBinding
+{
+
+    // -----------------------------------------------------------------------
+    // TupleBinding implementations and overrides
+    // -----------------------------------------------------------------------
+
+
+    /**
+     * Reconstructs a Profile to Role link object (none exists) using a
+     * serialized entry.  This operation is unsupported so what's the point to
+     * this tuple binding u may ask.  Well you'll never need this but we want
+     * to keep the serialization operations here in the object that would do it
+     * if there was an object for it.  This also applies to the objectToEntry
+     * operation.
+     *
+     * @param tupleInput the tuple data
+     * @return the newly constructed Profile
+     * @throws java.io.IOException if there are any failures accessing the tuple data
+     */
+    public Object entryToObject( TupleInput tupleInput ) throws IOException
+    {
+        throw new UnsupportedOperationException(
+                "You should never have to use this method" ) ;
+    }
+
+
+    /**
+     * Marshals a Profile to Role link object into serialized Tuple data.
+     * This operation is unsupported so what's the point to this tuple binding
+     * u may ask.  Well you'll never need this but we want to keep the
+     * serialization operations here in the object that would do it
+     * if there was an object for it.
+     *
+     * @param o the profile to role link object to marshal (none exists)
+     * @param tupleOutput
+     * @throws java.io.IOException
+     */
+    public void objectToEntry( Object o, TupleOutput tupleOutput ) throws IOException
+    {
+        throw new UnsupportedOperationException(
+                "You should never have to use this method" ) ;
+    }
+
+
+    /**
+     * Marshals the members of a Profile to Role link object (if one were to
+     * exist) into a serialized Tuple rather than having to create an object.
+     *
+     * @param entry the entry to populate
+     * @param appName the appName of the application
+     * @param userName the name of the profile's user
+     * @param roleName the name of the role linked to the profile
+     * @throws java.io.IOException if there are failures writing the data
+     */
+    public void membersToEntry( DatabaseEntry entry, String appName,
+                                String userName, String roleName )
+            throws IOException
+    {
+        TupleOutput out = new TupleOutput() ;
+        out.writeString( appName ) ;
+        out.writeString( userName ) ;
+        out.writeString( roleName ) ;
+        entry.setData( out.getBufferBytes(), out.getBufferOffset(),
+                out.getBufferLength() ) ;
+    }
+
+
+    /**
+     * Gets the name of the application stored within the database entry.
+     *
+     * @param entry the database entry for the profile to role link
+     * @return the link's application name field
+     * @throws java.io.IOException if there are failures reading from the entry
+     */
+    public String getApplicationName( DatabaseEntry entry ) throws IOException
+    {
+        TupleInput in = new TupleInput( entry.getData() ) ;
+        return in.readString() ;
+    }
+
+
+    /**
+     * Gets the name of the link's user stored within the database entry.
+     *
+     * @param entry the database entry for the link
+     * @return the link's user name field
+     * @throws java.io.IOException if there are failures reading from the entry
+     */
+    public String getUserName( DatabaseEntry entry ) throws IOException
+    {
+        TupleInput in = new TupleInput( entry.getData() ) ;
+        in.readString() ;
+        return in.readString() ;
+    }
+
+
+    /**
+     * Gets the name of the link's role stored within the database entry.
+     *
+     * @param entry the database entry for the link
+     * @return the link's role name field
+     * @throws java.io.IOException if there are failures reading from the entry
+     */
+    public String getRoleName( DatabaseEntry entry ) throws IOException
+    {
+        TupleInput in = new TupleInput( entry.getData() ) ;
+        in.readString() ;
+        in.readString() ;
+        return in.readString() ;
+    }
+}

Added: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/ProfileRoleLinkDAOMonitor.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/ProfileRoleLinkDAOMonitor.java
Thu Apr 29 22:34:04 2004
@@ -0,0 +1,28 @@
+/*
+ *   Copyright 2004 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 org.apache.rms.je.profile ;
+
+
+/**
+ * A monitor interface for the Profile to Role link data access object.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface ProfileRoleLinkDAOMonitor
+{
+}

Added: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/ProfileRoleLinkDAOMonitorAdapter.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/profile/ProfileRoleLinkDAOMonitorAdapter.java
Thu Apr 29 22:34:04 2004
@@ -0,0 +1,30 @@
+/*
+ *   Copyright 2004 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 org.apache.rms.je.profile ;
+
+
+/**
+ * A no-op monitor adapter for the Profile to Role link data access object.
+ * At a bare minimum this adapter dumps faulting exceptions to stderr.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ProfileRoleLinkDAOMonitorAdapter
+        implements ProfileRoleLinkDAOMonitor
+{
+}

Mime
View raw message