Advertisement
Guest User

Untitled

a guest
Aug 24th, 2011
968
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.50 KB | None | 0 0
  1. // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
  2. // Jad home page: http://www.kpdus.com/jad.html
  3. // Decompiler options: packimports(3)
  4. // Source File Name:   Autoingestion.java
  5.  
  6. import java.io.*;
  7. import java.net.URL;
  8. import java.net.URLEncoder;
  9. import java.text.SimpleDateFormat;
  10. import java.util.Calendar;
  11. import javax.net.ssl.HttpsURLConnection;
  12.  
  13. public class Autoingestion
  14. {
  15.  
  16.     public Autoingestion()
  17.     {
  18.     }
  19.  
  20.     public static void main(String args[])
  21.         throws Throwable
  22.     {
  23.         HttpsURLConnection httpsurlconnection;
  24.         String s1;
  25.         if(args.length < 6 || args.length > 7)
  26.         {
  27.             System.out.println("Please enter all the required parameters.  For help, please download the latest User Guide from the Sales and Trends module in iTunes Connect.");
  28.             return;
  29.         }
  30.         String s = null;
  31.         if(args.length == 7 && null != args[6])
  32.         {
  33.             s = args[6];
  34.         } else
  35.         {
  36.             Calendar calendar = Calendar.getInstance();
  37.             SimpleDateFormat simpledateformat = new SimpleDateFormat("yyyyMMdd");
  38.             calendar.add(5, -1);
  39.             s = simpledateformat.format(calendar.getTime()).toString();
  40.         }
  41.         httpsurlconnection = null;
  42.         Object obj = null;
  43.         s1 = (new StringBuilder()).append("USERNAME=").append(URLEncoder.encode(args[0], "UTF-8")).toString();
  44.         s1 = (new StringBuilder()).append(s1).append("&PASSWORD=").append(URLEncoder.encode(args[1], "UTF-8")).toString();
  45.         s1 = (new StringBuilder()).append(s1).append("&VNDNUMBER=").append(URLEncoder.encode(args[2], "UTF-8")).toString();
  46.         s1 = (new StringBuilder()).append(s1).append("&TYPEOFREPORT=").append(URLEncoder.encode(args[3], "UTF-8")).toString();
  47.         s1 = (new StringBuilder()).append(s1).append("&DATETYPE=").append(URLEncoder.encode(args[4], "UTF-8")).toString();
  48.         s1 = (new StringBuilder()).append(s1).append("&REPORTTYPE=").append(URLEncoder.encode(args[5], "UTF-8")).toString();
  49.         s1 = (new StringBuilder()).append(s1).append("&REPORTDATE=").append(URLEncoder.encode(s, "UTF-8")).toString();
  50.         URL url = new URL("https://reportingitc.apple.com/autoingestion.tft?");
  51.         httpsurlconnection = (HttpsURLConnection)url.openConnection();
  52.         httpsurlconnection.setRequestMethod("POST");
  53.         httpsurlconnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
  54.         httpsurlconnection.setDoOutput(true);
  55.         OutputStreamWriter outputstreamwriter = new OutputStreamWriter(httpsurlconnection.getOutputStream());
  56.         outputstreamwriter.write(s1);
  57.         outputstreamwriter.flush();
  58.         outputstreamwriter.close();
  59.         if(httpsurlconnection.getHeaderField("ERRORMSG") != null)
  60.             System.out.println(httpsurlconnection.getHeaderField("ERRORMSG"));
  61.         else
  62.         if(httpsurlconnection.getHeaderField("filename") != null)
  63.             getFile(httpsurlconnection);
  64.         if(httpsurlconnection != null)
  65.         {
  66.             httpsurlconnection.disconnect();
  67.             httpsurlconnection = null;
  68.         }
  69.         break MISSING_BLOCK_LABEL_468;
  70.         Exception exception;
  71.         exception;
  72.         exception.printStackTrace();
  73.         System.out.println("The report you requested is not available at this time.  Please try again in a few minutes.");
  74.         if(httpsurlconnection != null)
  75.         {
  76.             httpsurlconnection.disconnect();
  77.             httpsurlconnection = null;
  78.         }
  79.         break MISSING_BLOCK_LABEL_468;
  80.         Exception exception1;
  81.         exception1;
  82.         if(httpsurlconnection != null)
  83.         {
  84.             httpsurlconnection.disconnect();
  85.             httpsurlconnection = null;
  86.         }
  87.         throw exception1;
  88.     }
  89.  
  90.     private static void getFile(HttpsURLConnection httpsurlconnection)
  91.         throws IOException
  92.     {
  93.         String s = httpsurlconnection.getHeaderField("filename");
  94.         System.out.println(s);
  95.         int i = 0;
  96.         BufferedInputStream bufferedinputstream = new BufferedInputStream(httpsurlconnection.getInputStream());
  97.         BufferedOutputStream bufferedoutputstream = new BufferedOutputStream(new FileOutputStream(s));
  98.         byte abyte0[] = new byte[1024];
  99.         while((i = bufferedinputstream.read(abyte0)) != -1)
  100.             bufferedoutputstream.write(abyte0, 0, i);
  101.         bufferedinputstream.close();
  102.         bufferedoutputstream.close();
  103.         System.out.println("File Downloaded Successfully ");
  104.     }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement