Binding a subtree using custom State- and ObjectFactory

Hi,
first of all a very short example to illustrate my idea. I know that it would be complete rubbish to store the kind of data in the example in multiple classes and ldap entries. Currently I'm working with much larger objects that must be written according to special schema definitions. This example is really only for illustration!
LDAP-Schema:
objectclass ( 1.3.6.1.4.1... NAME 'myperson'
              SUP top STRUCTURAL
              MUST ( cn $ sn ) MAY ( email ) )
objectclass ( 1.3.6.1.4.1... NAME 'myphoto'
              SUP top STRUCTURAL
              MUST ( cn $ jpegPhoto ) )
Java-Classes:
class MyPhoto {
    byte[] photo;
class MyPerson {
    String cn;
    String sn;
    String email;
    MyPhoto photo; // This is the really relevant line :)
}Now to the question:
Is it possible to bind multiple java objects with one call to bind and to get a subtree by using custom State- and ObjectFactory-Classes?
Structure of the LDAP-Database
dn: cn=John Doe
{  cn=John Doe
   sn=Doe
   [email protected]   }
dn: cn=TheLogo, cn=John Doe    // Child of cn=John Doe
{ cn=TheLogo              // The cn is the same for all MyPhoto entries
                          // its only use is for building the dn
  jpegPhoto=[some binary data]   }I tried to solve the problem with a kind of recursion. When my StateFactory is called to bind an Object of Class MyPerson it builds the appropriate AttributeList. Before it returns, it calls bind for the Object of class MyPhoto with the dn: "cn=TheLogo,cn=John Doe".
Of course this doesn't work because the entry for cn="John Doe" doesn't exist at this time. Now I don't know what to do. A possible solution would be to create everything by hand, but then I wouldn't have to use custom StateFactories at all. But if there is a simple solution to my problem I would like to use my own StateFactory instead of having to implement a persistance manager on my own.
I hope you understand what I want to do and why it doesn't work out. If you don't please ask and I will try to clarify.

Hello,
A provisional solution is to use an external controller. For this approach to work, each class has to provide the list of objects being part of its properties. I have prepared two interfaces for this purpose:
public interface HasSubordinates {
Enumeration getSubordinates();
boolean hasSubordinates();
public interface Storable extends HasSubordinates {
String getIdentifier();
Then, you can use the controller to recursively get the object "tree" and store it in the directory (either using objects that implement the DirContext interface or using StateFactories - the last one is the one I have used)
The code for the Controller is the following:
import javax.naming.*;
import javax.naming.directory.*;
import javax.naming.spi.*;
import java.util.*;
import java.io.IOException;
public class DatabaseAccessController {
// Constants
final static String ldapServerName = "localhost";
final static String rootdn = "cn=juanluis, o=niaf";
final static String rootpass = "secret";
final static String rootContext = "o=niaf";
private DirContext initialContext;
private static Properties env = new Properties();
static {
env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
env.put( Context.STATE_FACTORIES, "database.PersonStateFactory:database.AddressStateFactory");
env.put( Context.PROVIDER_URL, "ldap://"+ ldapServerName+"/"+rootContext);
env.put( Context.SECURITY_PRINCIPAL, rootdn );
env.put( Context.SECURITY_CREDENTIALS, rootpass );
public DatabaseAccessController() {
try {
initialContext = new InitialDirContext( env );
} catch( Exception e ) {
e.printStackTrace();
public void store( Storable object ) {   
try {
store( object, initialContext );
} catch( NamingException ne ) {
ne.printStackTrace();
private void store( Storable object, DirContext ctx ) throws NamingException{
DirStateFactory.Result result = DirectoryManager.getStateToBind( object, null, null, env, null );
Attributes attributes = result.getAttributes();
DirContext new_ctx = ctx.createSubcontext( dn(object), attributes );
if( object.hasSubordinates() ) {
Enumeration subordinates = object.getSubordinates();
while( subordinates.hasMoreElements() ) {
try {
store( (Storable)subordinates.nextElement(), new_ctx );
} catch( Exception e ) {
e.printStackTrace();
private String dn( Storable object ) {
return "cn="+object.getIdentifier();
This is an example of how it should work on two objects:
public class Person implements Storable{
String name;
String surname;
Address address;
public Person(String n, String sn, Address addr) {
name = n;
surname = sn;
address = addr;
public boolean hasSubordinates() {
return true;
public Enumeration getSubordinates() {
Hashtable h = new Hashtable();
h.put("address", address );
return h.elements();
public String getIdentifier() {
return name + " "+ surname;
public class Address implements Storable {
String street;
int number;
Attributes attrs;
public Address( String s, int n) {
street = s;
number = n;
public boolean hasSubordinates() {
return false;
public Enumeration getSubordinates() {
return null;
public String getIdentifier() {
return street + number;
And here it is the program that access to the directory:
public class TestLDAP {
public TestLDAP() {
public static void main(String[] args) {
try {
System.out.println("Creating controller...");
DatabaseAccessController controller = new DatabaseAccessController();
System.out.println("Controller created");
Person person = new Person("Juan Luis", "Manas", new Address("Street in Madrid", 33 ));
System.out.println("Storing object in the directory...");
controller.store(person);
System.out.println("object stored successfully!");
} catch( Exception e ) {
e.printStackTrace();
}���
If you find a better way of performing the storage of complex objects in the directory, please, let me know.
Regards,
Juan Luis

Similar Messages

  • What is a customer statement and when do we use it?

    Hi,
    What is a customer statement and when do we use it? An example in terms of business scenario would surely help me.

    Hi,
    In business sense Customer statment is the list of  transactions that were executed over a period of time.
    When ever customer buys the material from the company bill is generated and the same is debited to his account.
    whenever customer pays the amount to the company, the amount will be credited to his account.
    So the Customer statment will have the list of DEBIT and CREDIT entries.
    There will be Reconciliation for every quarter with the customer by the company sales executive and related price, discounts, freight which might be excess or less will be settled

  • Customer Statements and Correspondence

    Hello-
    We have couple of correspondence types created for our customer statements and invoices. We use program "RFKORD10" and have some sap scripts designed to print out customer statements.
    We were on 4.7 SP 24 and recently have applied supprot packs till 31. With the applicaiton of SP's two notes were applied to this program "RFK0RD10" which are 999507 and 854148.
    Our statements now printing way different and incorrect. We looked at the sap scripts and nothing changed. Looked at the program and these are the two changes. What else would be the problem?
    Did anyone face this issue?
    Thanks in advance.
    RNarayan

    Hello,
    Check if notes 1243485 and 1100728 are applied. If not, implement them.
    They should fix this.
    Regards,

  • R12 Generate Customer Statement and email to customer automatically.

    Hi,
    Is there any standard function "Generating Customer Statement and emailing directly to customer" in R12?
    Thanks
    Dharma

    Not that I am aware of - see MOS Doc 433215.1 (Is There a Way to Email AR Statements or Dunning Letters to Customers?)
    Srini

  • Recently in the Bahamas where I helped a friend with his new iPad. We could not find Bahamas in initial setup so we used United States and could not enter Visa/MC billing address in Bahamas. iTunes rejected, billing info is not what's on file. What to do?

    Recently in the Bahamas where I helped a friend with his new iPad. We could not find Bahamas in initial setup so we used United States and could not enter Visa/MC billing address in Bahamas. iTunes rejected, billing info is not what's on file. What to do?

    Just to recap, this is a collection of ports I have collected over time for people who needed this information when setting up the HP ePrint app so that they could view their email from within the app.  I am certain other applications also need this information.  Although lengthy, I could not find a more comprehensive place to retrieve this information.  Feel free to post additional information, faulty information, or other related topics below as this is simply a collection of data and it would be practically impossible to test all of them. Thank you!
    Don't forgot to say thanks by giving "Kudos" if I helped solve your problem.
    When a solution is found please mark the post that solves your issue.
    Every problem has a solution!

  • Customer Statement and DI API Invoices

    Hi,
    We are running SAP Business One 2007A PL5.
    We have a number of invoices that have been created by the DI API used by the Radio Beacon/SAP interface.  These invoices are not appearing on the customer statement.
    The only noticable difference in the OINV table is that these invoices have a data source of 'O'.
    It seems the statement is not recognising invoices with a data source of 'O'.
    Has anyone else experienced this issue or have a fix for it?
    Also, we have some invoices that have 'A' for Auto Summary... out of interest, what is this exactly?
    Thanks,
    Michael

    Hi Michael,
    I am not sure what the issue is, however, there has been quite some changes to the ageing and reconciliation functionality from version 2005 SP01 to 2007, the main change between these 2 versions is actually the ageing and the reconciliation functionality. So there might be something missing in the Invoices. Also, PL5 is a pretty early version of 2007.
    Question 1 - are they appearing on the Customer Account Balance as it is opened from the BP Master Data?
    For the data source 'A', I think it stands for the 'Document Generation Wizard'.
    Thanks,
    Jesper

  • After upgrading to FF 7. When I change my Privacy settings to Use custom settings and check ok, the changes are not saved.

    Using Win 7 sp1
    FireFox 7.0.1
    In Privacy Settings: When I change the FireFox will: to "use custom settings for history" and check ok, the setting isn't saved. After I close, then reopen the Privacy Settings tab, the setting for FireFox will: is back to "remember history"
    Thank you

    You can try to delete the cookies.sqlite and permissions.sqlite files in the Firefox profile folder.
    You can use this button to go to the currently used Firefox profile folder:
    *Help > Troubleshooting Information > Profile Director: Show Folder (Linux: Open Director; Mac: Show in Finder)
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    You can inspect and manage the permissions for the domain in the currently selected tab via these steps:
    *Click the "Site Identity Button" (globe/padlock) on the location bar
    *Click "More Information" to open "Tools > Page Info" with the Security tab selected
    *Go to the Permissions tab (Tools > Page Info > Permissions) to check the permissions for the domain in the currently selected tab
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • How to make reference wbs custom data carried to new wbs when using custom tab and custom table

    I created a custom tab for WBS elements by using user exit CNEX0007 and custom screen and put a table control in it.
    As table control's data has to be stored in a table I could not use append structure of PRPS.
    When I used reference wbs, PRPS custom fields were carried also but I could not find any solution to fill table control data with reference table.
    I need to get correspondence between reference number's and new id's key data. Is there any exit, enh. that I can store the relationship.

    Solved...
    I've used an enhancement point in include LCNPB_MF38.  CJWB_SUBTREE_COPY exports a table called newnumbers. Here you can find correspondances between copied WBS and new WBS.
    Exported table to memory id.
    And imported it in another user-exit. You can use proper user exit for your need.  ( EXIT_SAPLCNAU_002)

  • We have always used custom excel and other PDF files how do we build an app for ipad

    apart from the "mac" what else do I need as I only want 1 license of the resulting app and as it is an inhouse app paying a developer and getting volume license is too expensive.  Or is all extras in the dev pack issued by Apple

    it is only for myself to use in the business on a day to day basis
    The app is to collect 5-6 types of data that currently we have to write down each time we do certain processes with work
    current example new page new day so 300+ sheets per year with 1-3 lines of writing on
    initials of employee - product made - added ingredients batch numbers 4-5 columns - total made
    this type of capture should be ideal for ipad with scroll or number input and each day new form saves the planet as well
    our only issue is we have all custom programs and equipment based round XP pro systems and cannot go to touchscreen windows 8 with any of our old custom software hence going to custom app as keyboards are not possible in our industry due to hygiene issues unless stainless and silicon coated at $700 each

  • JTree selection problem when using custom renderer and editor

    Hello:
    I created a JTree with custom renderer and editor.
    The customization makes JCheckBox to be the component
    responsible for editing and rendering.
    The problem is that when I click on the node with the checkbox
    the JTree selection model does not get updated.
    Without customizations of the editor and renderer the MouseEvent would be fired and BasicTreeUI$MouseHandler.mousePressed() method would call
    the selectPathForEvent() method which would be responsible for updating
    the selection model. At the same time if I attach a mouse listener to the JTree (customized) I see the events when clicking on the nodes. It seems like the MouseEvent gets lost and somehow as a result of which the selection model does not get updated.
    Am I missing something?
    Thanks
    Alexander

    You probably forgot to call super.getTreeCellRendererComponent(...) at the beginning of your getTreeCellRendererComponent(...) method in your custom renderer.
    Or maybe in the getTreeCellEditorComponent(...) of the TreeCellEditor...

  • Printing Purchase Order from ME9F using custom program and smartform

    I was able to use my custom program which calls a smartform to print purchase orders from transaction ME9F. I did this using transaction NACE.
    However, when I call "Output Message" from ME9F, the output always fails (shown by an 'X' icon after the checkbox). When I try to put back the standard program in NACE, it does not show an 'X' but a check which indicates that the printing was successful.
    Do you know why this happens? What did I miss?
    Here's my call to my smartform from my custom driver program:
        " Change Smartform ZP_MMSF_P01_PURCHASE_ORDER
        " to internal Function module name
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
            EXPORTING
                FORMNAME   = 'ZP_MMSF_P01_PURCHASE_ORDER'
            IMPORTING
                FM_NAME    = fmname
        wa_cparam-no_dialog = 'X'.
        wa_output-tddest = 'LOCL'. "or 'LP01'.  "Spool: Output device
        CALL FUNCTION fmname
            EXPORTING
                control_parameters         = wa_cparam
                output_options             = wa_output
                i_data                     = i_data
                wa_lookup                  = wa_data_lookup
                goods_amt                  = goods_amt
                discount_amt               = discount_amt
                vat                        = vat
                total_amt                  = total_amt
                total_amt_inwords          = total_amt_inwords

    Vijaya,
    I have this problem though,
    Whenever I try to provide values for CONTROL_PARAMETERS and OUTPUT_OPTIONS to the sapscript call in your code, the PO printing (even the preview) does not proceed. I do this because I wanted to suppress the printer dialog.
    here is a fragment of the code:
    " code I added
    LS_COMPOSER_PARAM-tddest = 'LOCL'. "or 'LP01'.  "Spool: Output device
    LS_COMPOSER_PARAM-bcs_langu = sy-langu.
    LS_CONTROL_PARAM-preview = 'X'.
    LS_CONTROL_PARAM-no_open = 'X'.
    LS_CONTROL_PARAM-no_close = 'X'.
    LS_CONTROL_PARAM-device = 'PRINTER'.
    LS_CONTROL_PARAM-no_dialog = 'X'.
    DO NAST_ANZAL TIMES.
    *--In case of repetition only one time archiving
    * if sy-index > 1 and nast-tdarmod = 3.
    * nast_tdarmod = nast-tdarmod.
    * nast-tdarmod = 1.
    * ls_composer_param-tdarmod = 1.
    * endif.
    IF SY-INDEX NE 1 AND REPEAT IS INITIAL.
    REPEAT = 'X'.
    ENDIF.
    CALL FUNCTION LF_FM_NAME
    EXPORTING
    ARCHIVE_INDEX = TOA_DARA
    ARCHIVE_PARAMETERS = ARC_PARAMS
    CONTROL_PARAMETERS = LS_CONTROL_PARAM
    MAIL_RECIPIENT = LS_RECIPIENT
    MAIL_SENDER = LS_SENDER
    OUTPUT_OPTIONS = LS_COMPOSER_PARAM
    USER_SETTINGS = SPACE
    IS_NAST = NAST
    IS_REPEAT = REPEAT
    I tried to trace it to the function module generated by smartform. The error propagates this way: From the function module, there is a call to function SSFCOMP_PROCESS_DOCUMENT. Then inside that function, there is a perform operation to tr_ssfcomp_process_doc
    perform tr_ssfcomp_process_doc using startpage docstruc
                                           header.
    Inside that form, it calls the macro tr_active which checks the value of ssfcstat-trlevel (tracelevel) against c_trlevel_document. In the macro, if ssfcstat-trlevel is less than c_trlevel_document, the smartform will fail. c_trlevel_document is 15 and ssfcstat-trlevel is 0, and so the smartform fails.
    (you can see the macro tr_active in include LSTXBCMAC and the form tr_ssfcomp_process_doc is in the include LSTXBCFTR)
    When I do not put values in CONTROL_PARAMETERS and OUTPUT_OPTIONS, everything is ok.
    Do you know why this happens?
    Thanks in advance!
    Edit: I have found out about transaction SFTRACE, but this is disabled.
    Kyle

  • Mass emailing of customer statements and invoices

    Hi Experts
    Is there a method within SAP B1 or using an add-on whereby we can send all of our invoices for a single days business by email without needing to send each one individually?  Ideally we would like to be able to do the same thing with out statements also in each case using the E_Mail field from the BP Master Data Form (field OCRD,E_Mail) as the recipient address for the email.
    At the moment we are able to email individually using B1 Outlook Integration, but this can be time consuming when dealing with 250+ invoices per day.
    Likewise monthly statements can be as many as 3000 and it would be great if we could mass email them using SAP B1 or appropriate add-on.  Would save huge amount of time on printing, folding, stamping etc, not to mention the price of postage.  Even if we needed to purchase a 3rd party add-on it would likely pay for itself within a few months seeing as 99% of our BPs now use email addresses.
    Thanks in advance
    Jon

    Hi Johnny,
    We use a product called formscape. [http://www.bottomline.co.uk/solutions_services/formscape.html]
    All output is printed to the formscape server and the output is is tested to see if each document needs emailing, faxing (zetafax) or printing.  Formscape then outputs all documents the our document management system (Invu). 
    Works great for us.
    Thanks,
    Mike

  • Trouble using Custom Template and Saving Resulting Document. Help!

    I created a Custom Template in Numbers '09. When I go hit "New from Template Chooser", there it is. I've tried entering info directly into the template, as well as duplicating it and entering info in the duplicated document. I can enter the info just fine, but.... Either way, when I'm done I do not have an option to Save, Save As or anything like that. I only see "Save As Template".....but it's already a perfectly good template. I don't want to Save As Template and create another template!!!. I want a named document saved, using the great template I already put together. Is this a problem? What's up? Why can't I do this???? Please help!

    I'm on an iMac running 10.7.5. (Afraid to go further  because I have FInal Cut Pro 7 and I'm very attached to it....I'm afraid to upgrade my OS and have FCP not work! I'm a pro and not so willing to go to FCP 10).  Anyway, I'm on an iMac 3.06 GHz Intel Core  4 GB, 1333 MHz RAM.
    I'm running Numbers ''09 and don't have 13, so it's an 09 template entering 09 info. It's perfect. I run webinars and it contains all of the status for media and every detail of any upcoming webinar production. My goal is to open the template, enter the info, and save it with the name of the webinar client. Then open again, enter for another client, save, etc.
    It's just 09 all the way through. It says I can Save a Version or Save as Template.
    Should I open a template and then Duplicate so it's a fresh document? I do that sometimes in hopes of seeing an option to SAVE AS. Sometimes I open and Don't Duplicate, but just use the template. Either way I see no way of saving the document with the specific information for the client. I don't want to Save As Template! Who wants hundreds of templates running around that are all virtually the same except for the info entered within it.
    Am I missing the boat here?

  • How can I use custom colors and not presets when using Smart Brush Tool Color?

    I don't see a way to use the color picker tool or change the color to custom colors. Please help.

    seodude wrote:
    I don't see a way to use the color picker tool or change the color to custom colors. Please help.
    This tool employs a gradient adjustment layer. In the layers palette, double click the layer thumbnail, not the name.
    Then, double click the gradient bar to bring up the gradient editor.

  • Invoices, Customer Statements and Order Confirmation

    If one customer wants these things sent to three different places how and where do I look to configure this. i.e. They want their invoice to arrive in an office in Indiana, and the confirmation in Michigan.
    Any help would be great.
    Thanks
    Justin

    Hi Justin
    Here is the link from SAP help on the EDI settings for invoice and order confirmation
    http://help.sap.com/saphelp_47x200/helpdata/en/f0/4228f2a97311d2897a0000e8216438/frameset.htm
    http://help.sap.com/saphelp_47x200/helpdata/en/4b/ad4ecb17fd11d28a360000e829fbbd/frameset.htm
    But all this should be setup in co-operation with the EDI consultant.
    Thanks
    Ashok
    Award points if this is useful

Maybe you are looking for