|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  14 |     | 
     | 
  |  15 |     | 
     | 
  |  16 |     | 
   package org.kuali.rice.kns.web.spring.form;  | 
  |  17 |     | 
     | 
  |  18 |     | 
   import java.io.PrintWriter;  | 
  |  19 |     | 
   import java.io.StringWriter;  | 
  |  20 |     | 
     | 
  |  21 |     | 
   import org.kuali.rice.kns.service.KNSServiceLocator;  | 
  |  22 |     | 
     | 
  |  23 |     | 
     | 
  |  24 |     | 
     | 
  |  25 |     | 
     | 
  |  26 |     | 
     | 
  |  27 |     | 
     | 
  |  28 |     | 
   public class IncidentReportForm extends UifFormBase { | 
  |  29 |     | 
     | 
  |  30 |     | 
       private static final long serialVersionUID = -6677581167041430694L;  | 
  |  31 |     | 
     | 
  |  32 |    0 |        protected String errorMessage = "The system has encountered an error and is unable to complete your request at this time. Please provide more information regarding this error by completing this Incident Report.";  | 
  |  33 |     | 
     | 
  |  34 |     | 
       protected Exception exception;  | 
  |  35 |     | 
       protected String exceptionMessage;  | 
  |  36 |     | 
       protected String exceptionStackTrace;  | 
  |  37 |     | 
     | 
  |  38 |     | 
       protected String userInput;  | 
  |  39 |     | 
       protected String incidentDocId;  | 
  |  40 |     | 
       protected String incidentViewId;  | 
  |  41 |     | 
       protected String controller;  | 
  |  42 |     | 
       protected String userName;  | 
  |  43 |     | 
       protected String userId;  | 
  |  44 |     | 
       protected String userEmail;  | 
  |  45 |     | 
     | 
  |  46 |     | 
       protected boolean devMode;  | 
  |  47 |     | 
     | 
  |  48 |     | 
       public IncidentReportForm() { | 
  |  49 |    0 |            super();  | 
  |  50 |    0 |            setViewTypeName("INCIDENT"); | 
  |  51 |    0 |        }  | 
  |  52 |     | 
     | 
  |  53 |     | 
         | 
  |  54 |     | 
     | 
  |  55 |     | 
     | 
  |  56 |     | 
     | 
  |  57 |     | 
     | 
  |  58 |     | 
       public String createEmailMessage() { | 
  |  59 |    0 |            String format = "Document Id: %s%n" + "View Id: %s%n" + "Handler: %s%n%n" + "User Email: %s%n"  | 
  |  60 |     | 
                   + "Person User Identifier: %s%n" + "Person Name: %s%n" + "User Input: %s%n%n" + "errorMessage: %n"  | 
  |  61 |     | 
                   + "%s";  | 
  |  62 |    0 |            String message = String.format(format, (incidentDocId == null) ? "" : incidentDocId, (incidentViewId == null) ? "" : incidentViewId,  | 
  |  63 |     | 
                   (controller == null) ? "" : controller, (userEmail == null) ? "" : userEmail, (userId == null) ? ""  | 
  |  64 |     | 
                           : userId, (userName == null) ? "" : userName, (userInput == null) ? "" : userInput,  | 
  |  65 |     | 
                   (exceptionStackTrace == null) ? "" : exceptionStackTrace);  | 
  |  66 |     | 
     | 
  |  67 |    0 |            return message;  | 
  |  68 |     | 
     | 
  |  69 |     | 
       }  | 
  |  70 |     | 
     | 
  |  71 |     | 
         | 
  |  72 |     | 
     | 
  |  73 |     | 
     | 
  |  74 |     | 
     | 
  |  75 |     | 
     | 
  |  76 |     | 
       public String createEmailSubject() { | 
  |  77 |    0 |            String env = KNSServiceLocator.getKualiConfigurationService().getPropertyString("environment"); | 
  |  78 |    0 |            String format = "%s:%s:%s";  | 
  |  79 |    0 |            String subject = String.format(format, env, (incidentViewId == null) ? "" : incidentViewId,  | 
  |  80 |     | 
                   truncateString(exceptionMessage, 180));  | 
  |  81 |    0 |            return subject;  | 
  |  82 |     | 
       }  | 
  |  83 |     | 
     | 
  |  84 |     | 
         | 
  |  85 |     | 
     | 
  |  86 |     | 
     | 
  |  87 |     | 
     | 
  |  88 |     | 
     | 
  |  89 |     | 
     | 
  |  90 |     | 
     | 
  |  91 |     | 
     | 
  |  92 |     | 
     | 
  |  93 |     | 
       protected String truncateString(String str, int maxLength) { | 
  |  94 |    0 |            if (str != null && str.length() > maxLength)  | 
  |  95 |    0 |                str = str.substring(0, maxLength);  | 
  |  96 |    0 |            return str;  | 
  |  97 |     | 
       }  | 
  |  98 |     | 
     | 
  |  99 |     | 
         | 
  |  100 |     | 
     | 
  |  101 |     | 
     | 
  |  102 |     | 
     | 
  |  103 |     | 
     | 
  |  104 |     | 
     | 
  |  105 |     | 
     | 
  |  106 |     | 
       protected String getStackTrace(Throwable t) { | 
  |  107 |    0 |            StringWriter sw = new StringWriter();  | 
  |  108 |    0 |            PrintWriter pw = new PrintWriter(sw, true);  | 
  |  109 |    0 |            t.printStackTrace(pw);  | 
  |  110 |    0 |            pw.flush();  | 
  |  111 |    0 |            sw.flush();  | 
  |  112 |    0 |            return sw.toString();  | 
  |  113 |     | 
       }  | 
  |  114 |     | 
     | 
  |  115 |     | 
         | 
  |  116 |     | 
     | 
  |  117 |     | 
     | 
  |  118 |     | 
       public String getErrorMessage() { | 
  |  119 |    0 |            return this.errorMessage;  | 
  |  120 |     | 
       }  | 
  |  121 |     | 
     | 
  |  122 |     | 
         | 
  |  123 |     | 
     | 
  |  124 |     | 
     | 
  |  125 |     | 
     | 
  |  126 |     | 
       public void setErrorMessage(String errorMessage) { | 
  |  127 |    0 |            this.errorMessage = errorMessage;  | 
  |  128 |    0 |        }  | 
  |  129 |     | 
     | 
  |  130 |     | 
         | 
  |  131 |     | 
     | 
  |  132 |     | 
     | 
  |  133 |     | 
       public String getExceptionMessage() { | 
  |  134 |    0 |            return this.exceptionMessage;  | 
  |  135 |     | 
       }  | 
  |  136 |     | 
     | 
  |  137 |     | 
         | 
  |  138 |     | 
     | 
  |  139 |     | 
     | 
  |  140 |     | 
     | 
  |  141 |     | 
       public void setExceptionMessage(String exceptionMessage) { | 
  |  142 |    0 |            this.exceptionMessage = exceptionMessage;  | 
  |  143 |    0 |        }  | 
  |  144 |     | 
     | 
  |  145 |     | 
         | 
  |  146 |     | 
     | 
  |  147 |     | 
     | 
  |  148 |     | 
       public String getExceptionStackTrace() { | 
  |  149 |    0 |            return this.exceptionStackTrace;  | 
  |  150 |     | 
       }  | 
  |  151 |     | 
     | 
  |  152 |     | 
         | 
  |  153 |     | 
     | 
  |  154 |     | 
     | 
  |  155 |     | 
     | 
  |  156 |     | 
       public void setExceptionStackTrace(String exceptionStackTrace) { | 
  |  157 |    0 |            this.exceptionStackTrace = exceptionStackTrace;  | 
  |  158 |    0 |        }  | 
  |  159 |     | 
     | 
  |  160 |     | 
         | 
  |  161 |     | 
     | 
  |  162 |     | 
     | 
  |  163 |     | 
       public String getUserInput() { | 
  |  164 |    0 |            return this.userInput;  | 
  |  165 |     | 
       }  | 
  |  166 |     | 
     | 
  |  167 |     | 
         | 
  |  168 |     | 
     | 
  |  169 |     | 
     | 
  |  170 |     | 
     | 
  |  171 |     | 
       public void setUserInput(String userInput) { | 
  |  172 |    0 |            this.userInput = userInput;  | 
  |  173 |    0 |        }  | 
  |  174 |     | 
     | 
  |  175 |     | 
         | 
  |  176 |     | 
     | 
  |  177 |     | 
     | 
  |  178 |     | 
       public boolean isDevMode() { | 
  |  179 |    0 |            return this.devMode;  | 
  |  180 |     | 
       }  | 
  |  181 |     | 
     | 
  |  182 |     | 
         | 
  |  183 |     | 
     | 
  |  184 |     | 
     | 
  |  185 |     | 
     | 
  |  186 |     | 
       public void setDevMode(boolean devMode) { | 
  |  187 |    0 |            this.devMode = devMode;  | 
  |  188 |    0 |        }  | 
  |  189 |     | 
     | 
  |  190 |     | 
         | 
  |  191 |     | 
     | 
  |  192 |     | 
     | 
  |  193 |     | 
     | 
  |  194 |     | 
       public void setIncidentDocId(String incidentDocId) { | 
  |  195 |    0 |            this.incidentDocId = incidentDocId;  | 
  |  196 |    0 |        }  | 
  |  197 |     | 
     | 
  |  198 |     | 
         | 
  |  199 |     | 
     | 
  |  200 |     | 
     | 
  |  201 |     | 
       public String getIncidentDocId() { | 
  |  202 |    0 |            return incidentDocId;  | 
  |  203 |     | 
       }  | 
  |  204 |     | 
     | 
  |  205 |     | 
         | 
  |  206 |     | 
     | 
  |  207 |     | 
     | 
  |  208 |     | 
     | 
  |  209 |     | 
       public void setIncidentViewId(String incidentViewId) { | 
  |  210 |    0 |            this.incidentViewId = incidentViewId;  | 
  |  211 |    0 |        }  | 
  |  212 |     | 
     | 
  |  213 |     | 
         | 
  |  214 |     | 
     | 
  |  215 |     | 
     | 
  |  216 |     | 
       public String getIncidentViewId() { | 
  |  217 |    0 |            return incidentViewId;  | 
  |  218 |     | 
       }  | 
  |  219 |     | 
     | 
  |  220 |     | 
         | 
  |  221 |     | 
     | 
  |  222 |     | 
     | 
  |  223 |     | 
     | 
  |  224 |     | 
       public void setException(Exception exception) { | 
  |  225 |    0 |            this.exception = exception;  | 
  |  226 |    0 |            setExceptionStackTrace(getStackTrace(exception));  | 
  |  227 |    0 |            setExceptionMessage(exception.getMessage());  | 
  |  228 |    0 |        }  | 
  |  229 |     | 
     | 
  |  230 |     | 
         | 
  |  231 |     | 
     | 
  |  232 |     | 
     | 
  |  233 |     | 
       public Exception getException() { | 
  |  234 |    0 |            return exception;  | 
  |  235 |     | 
       }  | 
  |  236 |     | 
     | 
  |  237 |     | 
         | 
  |  238 |     | 
     | 
  |  239 |     | 
     | 
  |  240 |     | 
     | 
  |  241 |     | 
       public void setUserName(String userName) { | 
  |  242 |    0 |            this.userName = userName;  | 
  |  243 |    0 |        }  | 
  |  244 |     | 
     | 
  |  245 |     | 
         | 
  |  246 |     | 
     | 
  |  247 |     | 
     | 
  |  248 |     | 
       public String getUserName() { | 
  |  249 |    0 |            return userName;  | 
  |  250 |     | 
       }  | 
  |  251 |     | 
     | 
  |  252 |     | 
         | 
  |  253 |     | 
     | 
  |  254 |     | 
     | 
  |  255 |     | 
     | 
  |  256 |     | 
       public void setUserId(String userId) { | 
  |  257 |    0 |            this.userId = userId;  | 
  |  258 |    0 |        }  | 
  |  259 |     | 
     | 
  |  260 |     | 
         | 
  |  261 |     | 
     | 
  |  262 |     | 
     | 
  |  263 |     | 
       public String getUserId() { | 
  |  264 |    0 |            return userId;  | 
  |  265 |     | 
       }  | 
  |  266 |     | 
     | 
  |  267 |     | 
         | 
  |  268 |     | 
     | 
  |  269 |     | 
     | 
  |  270 |     | 
     | 
  |  271 |     | 
       public void setUserEmail(String userEmail) { | 
  |  272 |    0 |            this.userEmail = userEmail;  | 
  |  273 |    0 |        }  | 
  |  274 |     | 
     | 
  |  275 |     | 
         | 
  |  276 |     | 
     | 
  |  277 |     | 
     | 
  |  278 |     | 
       public String getUserEmail() { | 
  |  279 |    0 |            return userEmail;  | 
  |  280 |     | 
       }  | 
  |  281 |     | 
     | 
  |  282 |     | 
         | 
  |  283 |     | 
     | 
  |  284 |     | 
     | 
  |  285 |     | 
     | 
  |  286 |     | 
       public void setController(String controller) { | 
  |  287 |    0 |            this.controller = controller;  | 
  |  288 |    0 |        }  | 
  |  289 |     | 
     | 
  |  290 |     | 
         | 
  |  291 |     | 
     | 
  |  292 |     | 
     | 
  |  293 |     | 
       public String getController() { | 
  |  294 |    0 |            return controller;  | 
  |  295 |     | 
       }  | 
  |  296 |     | 
     | 
  |  297 |     | 
   }  |