cancel
Showing results for 
Search instead for 
Did you mean: 

export api

Former Member
0 Kudos

Hi all,

in the Help provided by Hybris there is a code where you can export using API

ExportConfiguration config = new ExportConfiguration( impexscript, ImpExManager.getExportOnlyMode() );

I do know that impexscript is an ImpExMedia but how to create it..

Can any one help to write the statement with which this impexscript is created..

Best

Accepted Solutions (1)

Accepted Solutions (1)

bhavirisetty
Active Participant
0 Kudos

Hi,

 InputStream stream =new FileInputStream("abc.impex"); // read your impex
  ImpexMediaModel mediaModel = new StreamBasedImpExResource(stream, "UTF-8").getMedia();
 ImpexMedia media=modelservice.getSource(mediaModel );

Hope this is what you are looking for.

Thanks

Former Member
0 Kudos

Thanks Phani, ya, this is exactly what I meant!

Answers (1)

Answers (1)

Former Member
0 Kudos

I have used the following code to Export items and its finished success but its giving a NullPointerException at setTargetFile method, can you help .. @Override public PerformResult perform(final CronJobModel cronJob) { FileInputStream stream = null;

     try
     {
         stream = new FileInputStream("C:/export.impex");
         int content;
         while ((content = stream.read()) != -1)
         {
             // convert to char and display it
             System.out.println((char) content);
         }
     }
     catch (final FileNotFoundException e2)
     {
         // YTODO Auto-generated catch block

         e2.getMessage();
     } // read your impex
     catch (final IOException e)
     {
         // YTODO Auto-generated catch block
         e.printStackTrace();
     }

     try

     {
         final ImpExMediaModel mediaModel = new StreamBasedImpExResource(stream, "UTF-8").getMedia();
         final ImpExMedia media = modelService.getSource(mediaModel);
         final ExportConfiguration config = new ExportConfiguration(media, ImpExManager.getExportOnlyMode());
         final Exporter exporter = new Exporter(config);
         exporter.setTargetFile("C:/result.csv", true);
         exporter.exportItems("Buch", true);
     }
     catch (final Exception e1)
     { // YTODO Auto-generated catch block System.out.println("Exception is here::::::::" + stream);
         System.out.println("heeeeeeeeeeeeeeeeeHere man::::::::");
         e1.printStackTrace();
     }

     return new PerformResult(CronJobResult.SUCCESS, CronJobStatus.FINISHED);
 }


}

Former Member
0 Kudos

Yes, above code will give Success as even after exception we are setting perform result to sucess which is why its success. Even i am facing same problem of setTargetFile. Could you please help ?