View Javadoc
1   package org.kuali.ole.ncip.bo;
2   
3   import java.util.HashMap;
4   import java.util.Map;
5   import java.util.Set;
6   
7   /**
8    * Created with IntelliJ IDEA.
9    * User: sheiksalahudeenm
10   * Date: 8/19/13
11   * Time: 8:38 PM
12   * To change this template use File | Settings | File Templates.
13   */
14  public class OLENCIPErrorResponse {
15      private Map<String,String> errorMap=new HashMap<String,String>();
16      public static final String parentStartTag ="<response>";
17      public static final String startTag ="<";
18      public static final String endTag =">";
19      public static final String slash ="/";
20      public static final String parentEndTag ="</response>";
21  
22  
23      public Map<String, String> getErrorMap() {
24          return errorMap;
25      }
26  
27      public void setErrorMap(Map<String, String> errorMap) {
28          this.errorMap = errorMap;
29      }
30      public String getErrorXml(String serviceName){
31          StringBuffer responseMessge=new StringBuffer();
32          if(this.getErrorMap()!=null){
33              //responseMessge.append(parentStartTag);
34              if(serviceName!=null && !serviceName.equalsIgnoreCase("")){
35                  responseMessge.append(startTag+serviceName+endTag);
36              }
37              else{
38                  responseMessge.append(parentStartTag);
39              }
40              for (Map.Entry<String, String> entry : this.getErrorMap().entrySet()) {
41                  responseMessge.append(startTag+entry.getKey()+endTag+entry.getValue()+startTag+slash+entry.getKey()+endTag);
42  
43              }
44              if(serviceName!=null && !serviceName.equalsIgnoreCase("")){
45                  responseMessge.append(startTag+slash+serviceName+endTag);
46              }
47              else{
48                  responseMessge.append(parentEndTag);
49              }
50             // responseMessge.append(parentEndTag);
51              return responseMessge.toString();
52          }
53          return null;
54      }
55  }