AnsweredAssumed Answered

adding binary content

Question asked by rcortesr on Nov 20, 2006
Latest reply on Nov 21, 2006 by rcortesr
I need to add binary content to my customized type.
I do it like in the example of wikiExample but the execution does not finish!!
This is my code:
[size=75]
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:org/alfresco/sample/jcr/facturaModel-context.xml");
          
           // Retrieve Repository
           Repository repository = (Repository)context.getBean("JCR.Repository");

           // Login to workspace
           // Note: Default workspace is the one used by Alfresco Web Client which contains all the Spaces
           //       and their documents
           Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
          
           // Retrieve a node
            Node myNode = (Node) session.getItem("app:company_home");
            System.out.println("Company home node: path=" + myNode.getPath() + ", type=" + myNode.getPrimaryNodeType().getName());
           

            Node facturas = myNode.addNode("fac:facturas", "cm:folder");
         facturas.setProperty("cm:name", "Facturas");
            facturas.setProperty("cm:description", "");
           
            do
         {
            line = buffer.readLine(); //leo la primera linea
            if(line == null) break;
            x.parsear(line); //parseo la siguiente linea
            Node fac1 = facturas.addNode("fac:entry" + cnt, "fac:factura");
               for(int i=0;i<4;i++)
               {
                  if(i == 3) //añado el contenido, la imagen escaneada
                  {
                     //fac1.setProperty("cm:content", resource.getInputStream());
                  }
                  else
                  {
                     fac1.setProperty(campos[i], x.lista[i]); //Add a property
                  }
               }
               session.save(); //Persist the changes mySession.save();
               cnt++;
         }while(true);
            session.logout();
            System.out.println("¡¡¡Transferencia Completada!!!");
            System.exit(0);
[/size]

I have another question, why when I execute wikiExample appears the following error?
[size=75]Exception in thread "main" java.io.FileNotFoundException: class path resource [org/alfresco/jcr/example/wikiImage.gif] cannot be opened because it does not exist
   at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:137)
   at org.alfresco.sample.jcr.WIKIExample.main(WIKIExample.java:145)
[/size]

Outcomes