1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.kuali.rice.edl.impl; |
18 |
|
|
19 |
|
import java.io.IOException; |
20 |
|
|
21 |
|
import javax.servlet.RequestDispatcher; |
22 |
|
import javax.servlet.ServletException; |
23 |
|
import javax.servlet.http.HttpServlet; |
24 |
|
import javax.servlet.http.HttpServletRequest; |
25 |
|
import javax.servlet.http.HttpServletResponse; |
26 |
|
|
27 |
|
import org.apache.commons.lang.StringUtils; |
28 |
|
import org.apache.log4j.Logger; |
29 |
|
import org.kuali.rice.kew.exception.WorkflowRuntimeException; |
30 |
|
import org.kuali.rice.kew.service.KEWServiceLocator; |
31 |
|
import org.kuali.rice.kns.util.GlobalVariables; |
32 |
|
import org.kuali.rice.kns.util.IncidentReportUtils; |
33 |
|
import org.kuali.rice.kns.util.KNSConstants; |
34 |
|
import org.w3c.dom.Document; |
35 |
|
import org.w3c.dom.Element; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
@author |
42 |
|
|
43 |
|
|
|
|
| 0% |
Uncovered Elements: 58 (58) |
Complexity: 15 |
Complexity Density: 0.38 |
|
44 |
|
public class EDLServlet extends HttpServlet { |
45 |
|
|
46 |
|
private static final long serialVersionUID = -6344765194278430690L; |
47 |
|
|
48 |
|
private static final Logger LOG = Logger.getLogger(EDLServlet.class); |
49 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
50 |
0
|
@Override... |
51 |
|
public void init() throws ServletException { |
52 |
0
|
try { |
53 |
0
|
KEWServiceLocator.getEDocLiteService().initEDLGlobalConfig(); |
54 |
|
} catch (Exception e) { |
55 |
0
|
LOG.error("Error initializing EDL", e); |
56 |
|
} |
57 |
|
|
58 |
|
} |
59 |
|
|
|
|
| 0% |
Uncovered Elements: 49 (49) |
Complexity: 12 |
Complexity Density: 0.36 |
|
60 |
0
|
@Override... |
61 |
|
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
62 |
0
|
String documentId = null; |
63 |
0
|
try { |
64 |
0
|
RequestParser requestParser = new RequestParser(request); |
65 |
0
|
String inputCommand = requestParser.getParameterValue("command"); |
66 |
0
|
if (StringUtils.equals(inputCommand, "initiate")){ |
67 |
0
|
requestParser.setParameterValue("userAction","initiate"); |
68 |
|
} |
69 |
0
|
String edlName = requestParser.getParameterValue("edlName"); |
70 |
0
|
if (edlName == null) { |
71 |
0
|
edlName = requestParser.getParameterValue("docTypeName"); |
72 |
|
} |
73 |
0
|
EDLController edlController = null; |
74 |
|
|
75 |
0
|
if (edlName == null) { |
76 |
0
|
documentId = requestParser.getParameterValue("docId"); |
77 |
0
|
if (documentId == null) { |
78 |
0
|
String docFormKey = requestParser.getParameterValue(KNSConstants.DOC_FORM_KEY); |
79 |
0
|
if (docFormKey != null) { |
80 |
0
|
Document document = (Document) GlobalVariables.getUserSession().retrieveObject(docFormKey); |
81 |
0
|
Element documentState = EDLXmlUtils.getDocumentStateElement(document); |
82 |
0
|
documentId = EDLXmlUtils.getChildElementTextValue(documentState, "docId"); |
83 |
0
|
requestParser.setAttribute(KNSConstants.DOC_FORM_KEY, docFormKey); |
84 |
|
} |
85 |
0
|
if (documentId == null) { |
86 |
0
|
throw new WorkflowRuntimeException("No edl name or document id detected"); |
87 |
|
} |
88 |
|
} |
89 |
0
|
requestParser.setAttribute("docId", documentId); |
90 |
0
|
edlController = KEWServiceLocator.getEDocLiteService().getEDLController(new Long(documentId)); |
91 |
|
} else { |
92 |
0
|
edlController = KEWServiceLocator.getEDocLiteService().getEDLController(edlName); |
93 |
|
} |
94 |
|
|
95 |
|
|
96 |
|
|
97 |
0
|
if(inputCommand == null && requestParser.getParameterValue("docId") != null && !"POST".equals(request.getMethod())){ |
98 |
|
|
99 |
0
|
if(!(request.getParameterMap().size() > 2)){ |
100 |
0
|
requestParser.setParameterValue("command", "displayDocSearchView"); |
101 |
0
|
LOG.info("command parameter was not passed with the request, and only document ID was. Defaulted command to 'displayDocSearchView' to ensure docContent remains."); |
102 |
|
} |
103 |
|
} |
104 |
|
|
105 |
0
|
EDLControllerChain controllerChain = new EDLControllerChain(); |
106 |
0
|
controllerChain.addEdlController(edlController); |
107 |
|
|
108 |
0
|
controllerChain.renderEDL(requestParser, response); |
109 |
|
|
110 |
|
} catch (Exception e) { |
111 |
0
|
LOG.error("Error processing EDL", e); |
112 |
0
|
outputError(request, response, e, documentId); |
113 |
|
} |
114 |
|
} |
115 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
116 |
0
|
private void outputError(HttpServletRequest request, HttpServletResponse response, Exception exception, String documentId) throws ServletException, IOException {... |
117 |
0
|
IncidentReportUtils.populateRequestForIncidentReport(exception, ""+documentId, "eDoc Lite", request); |
118 |
0
|
RequestDispatcher rd = getServletContext().getRequestDispatcher(request.getServletPath() + "/../../kr/kualiExceptionIncidentReport.do"); |
119 |
0
|
rd.forward(request, response); |
120 |
|
} |
121 |
|
|
122 |
|
} |