View Javadoc

1   /*
2    * Copyright 2011 The Kuali Foundation.
3    * 
4    * Licensed under the Educational Community License, Version 1.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl1.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  }