#1 2009-01-28 12:02:04

kzone
Member
Company: Synotis
Registered: 2008-07-06
Posts: 909
Website

creation of a simple component SMB

hi,

Sure i'm missing something important !
but it seems that Talend 's  never gone in "my code" :

just a few ligne of code in main part :

Code:

<% 
    CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
    INode node = (INode)codeGenArgument.getArgument();
    String cid = node.getUniqueName();    
%>

<%

        // recuperer les parametres du GUI
        //String filename = ElementParameterParser.getValue(node, "__FILENAME__");
        String username = ElementParameterParser.getValue(node, "__USER__");
        String password = ElementParameterParser.getValue(node, "__PASS__");
        String server = ElementParameterParser.getValue(node, "__SERVER__");
        String srcURL = ElementParameterParser.getValue(node,"__SRCURL__");
        String destURL = ElementParameterParser.getValue(node,"__DESTURL__");
   
%>


//jcifs.smb.NtlmPasswordAuthentication theAuth = null;
    

try{
        jcifs.Config.setProperty("jcifs.netbios.wins", <%=server %>);
        //if(theAuth == null)
        jcifs.smb.NtlmPasswordAuthentication theAuth = new jcifs.smb.NtlmPasswordAuthentication(<%=server %>, <%=username %>, <%=password %>);
            
        jcifs.smb.SmbFile sf = new jcifs.smb.SmbFile(<%=server %> + <%=srcURL %>, theAuth);
        jcifs.smb.SmbFileInputStream in = new jcifs.smb.SmbFileInputStream(sf);
        
        
        java.io.File file = new java.io.File(<%=destURL %>);
        java.io.OutputStream out = new java.io.FileOutputStream(file);
        
        if(sf.exists()){
        System.out.println("entree boucle if");
        //byte[] buff = new byte[1024];
        int len;
        while((len = in.read()) != -1)
            out.write(len);
        }
        else 
            System.out.println("fichier smb n'existe pas" );
        in.close();
        out.close();
    }

    catch(jcifs.smb.SmbException e){
        System.out.println(e.getMessage());
    }

I've add some out.println method to see where run is ... but nothing appear in the console !!

And any data is read/write from a "smb" file to a local file ...but have any compilation or generated errors ..

I can find the reason why and where to look for .. so i need your help .. again smile


Ps: perhaps you nedd more informatio about properties componenet


do Svg your graphical language !!!

Offline

#2 2009-01-28 12:31:06

mhirt
Talend team
Registered: 2006-09-19
Posts: 1633

Re: creation of a simple component SMB

Offline

#3 2009-01-28 13:22:30

kzone
Member
Company: Synotis
Registered: 2008-07-06
Posts: 909
Website

Re: creation of a simple component SMB

hi, mhirt

good news ... !!!

i'm going to have a look at the source code (in my ' trunk ' ) , and find why my code doesn't work !!
but source code poined in the second link are similar with mine ... except that mine doesn't work of course (lol) ..where is the coma less !?

PS: I had choiced "Smb protocole" for training on "creation of new componenent" for the  fisrt one  ... i was thought a simple one !!

thank !
I gonna keep on searching ...


do Svg your graphical language !!!

Offline

#4 2009-01-28 17:05:14

mhirt
Talend team
Registered: 2006-09-19
Posts: 1633

Re: creation of a simple component SMB

Hello,

I think it's a very good first example.
The code is simpler enough to easily understand the first keys of component development.
Nevertheless, don't hesitate to ask if yoiu don't find your answer.

Regards,
Mike.

Offline

Board footer

Powered by FluxBB