1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.batchingest;
17
18 import java.io.BufferedReader;
19 import java.io.FileInputStream;
20 import java.io.InputStream;
21 import java.io.InputStreamReader;
22 import java.util.List;
23
24 public class ProcessVendorFile {
25
26 public String transformStreamToRawData(InputStream inputStream) throws Exception{
27 return processRawDataToXml(readInputStream(inputStream));
28 }
29
30 private String readInputStream(InputStream inputStream) throws Exception{
31 BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
32 StringBuilder stringBuilder = new StringBuilder();
33 String line = null;
34 while ((line = reader.readLine()) != null) {
35 stringBuilder.append(line + "\n");
36 }
37 inputStream.close();
38 return stringBuilder.toString();
39 }
40
41 public String getRawXml(InputStream inputStream,List bibinfoFailure) throws Exception{
42 return getFailureRawData(readInputStream(inputStream),bibinfoFailure);
43 }
44
45 private String processRawDataToXml(String rawData) throws Exception{
46 return new MarcDataFormatTransformer().transformRawDataToXml(rawData);
47 }
48
49 private String getFailureRawData(String rawData,List bibinfoFailure) throws Exception{
50 return new MarcDataFormatTransformer().getFailureRawData(rawData,bibinfoFailure);
51 }
52
53
54
55
56 }