Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 626DD200B88 for ; Thu, 22 Sep 2016 21:32:18 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 61127160AAD; Thu, 22 Sep 2016 19:32:18 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 73D9A160AA9 for ; Thu, 22 Sep 2016 21:32:17 +0200 (CEST) Received: (qmail 4822 invoked by uid 500); 22 Sep 2016 19:32:16 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Received: (qmail 4811 invoked by uid 99); 22 Sep 2016 19:32:16 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Sep 2016 19:32:16 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id DF8891A5C93 for ; Thu, 22 Sep 2016 19:32:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.121 X-Spam-Level: X-Spam-Status: No, score=-0.121 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id ZCn-A7VjYMv6 for ; Thu, 22 Sep 2016 19:32:14 +0000 (UTC) Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 5A8D75FC7E for ; Thu, 22 Sep 2016 19:32:14 +0000 (UTC) Received: by mail-wm0-f45.google.com with SMTP id l132so166118198wmf.1 for ; Thu, 22 Sep 2016 12:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=C5BC8bBamcwA5QJzmQpDvbHbNQkHc9VeaOX4Xn8WDYY=; b=RfxYN6H3QHhsn799Fup9O6hEL6PAa5Ee0sICG4wq3j5y+L65riUWOWOX1tY91SpF7g uJ9V3DJSV6CEBI/wX5S4wMfSaarZe6U1bzO7XdFG4HpLdO1/V/m8XqagCg9IZsFrh7UC nZpMom6EYzcFQMc7jjWlDxy+BRMaL5pJcnHHNmrNsXz1gViMAPHDSY2S5+VpdpI8HD2c +zGpsMuKhC+hQNPHIrlIZyVBzexASaYIngi9yLF8kpIMVHwDIEXd1M56fAmABYBztLmo TNtNvLqXwjJhHGI1EPs9Kk66ZAaqLv7Vvh0KrJ/4vlmuFuISDdVB9ereYUj4E/Fvmol5 v2LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=C5BC8bBamcwA5QJzmQpDvbHbNQkHc9VeaOX4Xn8WDYY=; b=kLfhUd4wf0QJH5RodS4c6rwFzfMvB2HQze8YpK0cMZdNegrTMa2cM5s00tRIKLbuum Cej6WOCvqSSphiCAsiZ762xO/kUuyYKXfu5e/6KUkdrl6kBM2eWjhWtKHWQ6mIauBrwY oYXyH/5pkk3izvDsMzaPhjGUjMnkBBqgZDwAWDrBtafgSdEAqDfRrhhhw2907DOXh/ym ALk8WoMPhIFsbfYEAwPqji5C+xRrRZOPq/1aO2oeP14WWR/jbqAc7HIQAjuiwUmvam+p HFIM2+V6PkzzTVTKH7vACAR1BpWL6H2PDQbd6yISRumbbQh4RK23nwcgkqtaFKUimSSV 64dg== X-Gm-Message-State: AE9vXwOHtgHTzSk0/oJ/whmKjEGWG465ZRIQXc+6b/Kjdb3pmXpm2dCLN11XJhsm07D5Gg== X-Received: by 10.194.228.3 with SMTP id se3mr3911736wjc.132.1474572733051; Thu, 22 Sep 2016 12:32:13 -0700 (PDT) Received: from [172.20.10.3] ([80.12.42.180]) by smtp.googlemail.com with ESMTPSA id pm1sm3520143wjb.40.2016.09.22.12.32.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Sep 2016 12:32:12 -0700 (PDT) Subject: Re: Queston on Interceptor To: Apache Directory Developers List References: <070d1cf9-b433-45de-a09e-1ec58be7dba2@gmail.com> From: =?UTF-8?Q?Emmanuel_L=c3=a9charny?= Message-ID: Date: Thu, 22 Sep 2016 21:32:09 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit archived-at: Thu, 22 Sep 2016 19:32:18 -0000 Le 22/09/16 à 20:55, Sathyanarayan, Harish a écrit : > Hi Emmanuel, > > The custom interceptor I wrote looks like: > > public class ProxyInterceptor extends BaseInterceptor { > > @Override > public EntryFilteringCursor search(final SearchOperationContext searchContext) throws LdapException { > > // call connector > } > > @Override > public void add(final AddOperationContext addContext) throws LdapException { > try { logger.info("addContext.getEntry() "); > proxyConnector.add(addContext.getEntry()); > } catch (CursorException e) { > logger.info(e.getMessage()); > } > next(addContext); > } > > @Override > public void modify(final ModifyOperationContext modifyContext) throws LdapException { > > } > > } > > > I am calling this interceptor from my resource class. For example the rest call for modify does not work: > > Modification mod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, "o", > "test123456" ); > ModifyRequest modifyRequest = new ModifyRequestImpl(); > modifyRequest.setName(new Dn("dc=example,dc=com")); > modifyRequest.addModification(mod); > > getConnection().modify(modifyRequest); > // connection.modify("test", ); > logger.info("after modify"); > releaseConnection(connection); > > > Hope this helps, let me know if anything else...thanks! Ok, makes sense. The interceptors are weird little beasts... The way they are called is a bit complex. Basically, each interceptor can implement as many method as needed, from the interface they implement. Each of those method is going to be called by the previous interceptor. Up to this point, you get it right. Now, the tricky part is how the interceptors get called, and how ne interceptor know which is the next one. Each operation is associated with an ordered list of interceptor As you may not want to implement some operation, these lists may be longer or shorter. For instance, the search operation is handled by pretty much all the interceptor, but ChangeLogInterceptor or JournalInterceptor (because we don't log searches, and a search is not an change). This is true for every interceptor. This list may change, depending on which interceptor is loaded and enabled. If you add your own interceptor, then the lists are going to be longer. All in all we use a map> to store this information. the tricky part is to have this map created. Actually, you need to modify the server's configuration, insterting your intercerceptor are the place you want, and this is the moment the map is fed. Let's do that : can you check the content of this map? You can get each operation list by calling DirectoryService.getInterceptors( OperationEnum ) where OperationEnum is one of : ADD BIND COMPARE DELETE GET_ROOT_DSE HAS_ENTRY LIST LOOKUP MODIFY MOVE MOVE_AND_RENAME RENAME SEARCH UNBIND Typically, try with SEARH, and see what list you have, and try with ADD to see what you have. Your interceptor must be listed in both case. > > > -----Original Message----- > From: Emmanuel Lécharny [mailto:elecharny@gmail.com] > Sent: Thursday, September 22, 2016 2:48 PM > To: Apache Directory Developers List > Subject: Re: Queston on Interceptor > > Le 22/09/16 à 20:32, Sathyanarayan, Harish a écrit : >> Hi: >> >> I have written a proxy interceptor that implements BaseInterceptor operations like Search, add, modify etc. I have tried inserting both next to the normalizationinterceptor and at the very end of the chain. I run the ApacheDS as embedded service under dropwizard. > You probably want to insert your interceptor after the normalizerInterceptor : That wuld be the natural position >> I have a REST API performing CRUD operations. My question is: when I >> call the Resource to perform add and search it calls the interceptor > Hmm. Not sure I understand this sentence : do you call the interceptor directly, or is the interceptor called by the uer layer ? > >> that talks to the connector to perform the proxy operation. This works as intended. But if I try modify and delete, it does not even hit the interceptor and there is no response. Wondering what could be the root cause of this issue? > Can you show the signature for these operations ? > > The information contained in this electronic mail transmission may be privileged and confidential, and therefore, protected from disclosure. If you have received this communication in error, please notify us immediately by replying to this message and deleting the email and its attachments from all computers without copying or disclosing it.