directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1068723 [3/3] - in /directory/shared/branches/m1: asn1-ber/src/main/java/org/apache/directory/shared/asn1/ber/grammar/ ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/ ldap-codec/src/main/java/org/apache/directory/shared/ld...
Date Wed, 09 Feb 2011 01:34:33 GMT
Added: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/AllowGrammarEnd.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/AllowGrammarEnd.java?rev=1068723&view=auto
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/AllowGrammarEnd.java
(added)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/AllowGrammarEnd.java
Wed Feb  9 01:34:33 2011
@@ -0,0 +1,53 @@
+/*
+ *  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.shared.ldap.codec.actions;
+
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.decorators.MessageDecorator;
+import org.apache.directory.shared.ldap.model.message.Message;
+
+
+/**
+ * The action used to indicate that the grammar can terminate after this action
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AllowGrammarEnd extends GrammarAction<LdapMessageContainer<MessageDecorator<?
extends Message>>>
+{
+    /**
+     * Instantiates a new value action.
+     */
+    public AllowGrammarEnd()
+    {
+        super( "Allow a grammar end" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( LdapMessageContainer<MessageDecorator<? extends Message>>
container ) throws DecoderException
+    {
+        container.setGrammarEndAllowed( true );
+    }
+}

Added: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchResultEntry/InitSearchResultEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchResultEntry/InitSearchResultEntry.java?rev=1068723&view=auto
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchResultEntry/InitSearchResultEntry.java
(added)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchResultEntry/InitSearchResultEntry.java
Wed Feb  9 01:34:33 2011
@@ -0,0 +1,58 @@
+/*
+ *  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.shared.ldap.codec.actions.searchResultEntry;
+
+
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.decorators.SearchResultEntryDecorator;
+import org.apache.directory.shared.ldap.model.message.SearchResultEntryImpl;
+
+
+/**
+ * The action used to initialize the SearchResultEntry response
+ * <pre>
+ * LdapMessage ::= ... SearchResultEntry ...
+ * SearchResultEntry ::= [APPLICATION 4] SEQUENCE { ...
+ * </pre>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class InitSearchResultEntry extends GrammarAction<LdapMessageContainer<SearchResultEntryDecorator>>
+{
+    /**
+     * Instantiates a new action.
+     */
+    public InitSearchResultEntry()
+    {
+        super( "Init SearchResultEntry" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( LdapMessageContainer<SearchResultEntryDecorator> container
)
+    {
+        // Now, we can allocate the SearchResultEntry Object
+        SearchResultEntryDecorator searchResultEntry = new SearchResultEntryDecorator(
+            container.getLdapCodecService(), new SearchResultEntryImpl( container.getMessageId()
) );
+        container.setMessage( searchResultEntry );
+    }
+}

Added: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchResultEntry/StoreObjectName.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchResultEntry/StoreObjectName.java?rev=1068723&view=auto
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchResultEntry/StoreObjectName.java
(added)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchResultEntry/StoreObjectName.java
Wed Feb  9 01:34:33 2011
@@ -0,0 +1,102 @@
+/*
+ *  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.shared.ldap.codec.actions.searchResultEntry;
+
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.decorators.SearchResultEntryDecorator;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.util.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to initialize the SearchResultEntry response
+ * <pre>
+ * LdapMessage ::= ... SearchResultEntry ...
+ * SearchResultEntry ::= [APPLICATION 4] SEQUENCE { ...
+ * </pre>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreObjectName extends GrammarAction<LdapMessageContainer<SearchResultEntryDecorator>>
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreObjectName.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+    /**
+     * Instantiates a new action.
+     */
+    public StoreObjectName()
+    {
+        super( "Init SearchResultEntry" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( LdapMessageContainer<SearchResultEntryDecorator> container
) throws DecoderException
+    {
+        SearchResultEntryDecorator searchResultEntry = container.getMessage();
+
+        TLV tlv = container.getCurrentTLV();
+
+        Dn objectName = Dn.EMPTY_DN;
+
+        // Store the value.
+        if ( tlv.getLength() == 0 )
+        {
+            searchResultEntry.setObjectName( objectName );
+        }
+        else
+        {
+            byte[] dnBytes = tlv.getValue().getData();
+            String dnStr = Strings.utf8ToString(dnBytes);
+
+            try
+            {
+                objectName = new Dn( dnStr );
+            }
+            catch ( LdapInvalidDnException ine )
+            {
+                // This is for the client side. We will never decode LdapResult on the server
+                String msg = "The Dn " + Strings.dumpBytes(dnBytes) + "is invalid : "
+                    + ine.getMessage();
+                LOG.error( "{} : {}", msg, ine.getMessage() );
+                throw new DecoderException( msg, ine );
+            }
+
+            searchResultEntry.setObjectName( objectName );
+        }
+
+        if ( IS_DEBUG )
+        {
+            LOG.debug( "Search Result Entry Dn found : {}", searchResultEntry.getObjectName()
);
+        }
+    }
+}



Mime
View raw message