| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kew.actionlist; |
| 17 | |
|
| 18 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
| 19 | |
import org.kuali.rice.kim.api.identity.principal.Principal; |
| 20 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
| 21 | |
import org.kuali.rice.kim.bo.Person; |
| 22 | |
|
| 23 | |
import javax.servlet.ServletException; |
| 24 | |
import javax.servlet.http.HttpServlet; |
| 25 | |
import javax.servlet.http.HttpServletRequest; |
| 26 | |
import javax.servlet.http.HttpServletResponse; |
| 27 | |
import java.io.IOException; |
| 28 | |
import java.io.PrintWriter; |
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | 0 | public class ActionListCountServlet extends HttpServlet { |
| 33 | |
|
| 34 | |
private static final long serialVersionUID = 260649920715567145L; |
| 35 | |
|
| 36 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ActionListCountServlet.class); |
| 37 | |
|
| 38 | |
@Override |
| 39 | |
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
| 40 | 0 | response.setContentType("text/plain"); |
| 41 | 0 | PrintWriter out = response.getWriter(); |
| 42 | 0 | int count = getCount(request); |
| 43 | 0 | out.println(Integer.toString(count)); |
| 44 | 0 | out.close(); |
| 45 | 0 | } |
| 46 | |
|
| 47 | |
private int getCount(HttpServletRequest request) { |
| 48 | |
try { |
| 49 | 0 | String id = request.getParameter("id"); |
| 50 | 0 | if (id == null || id.equals("")) { |
| 51 | 0 | return 0; |
| 52 | |
} |
| 53 | 0 | String idType = request.getParameter("idType"); |
| 54 | 0 | if (idType == null || idType.equals("")) { |
| 55 | 0 | idType = "a"; |
| 56 | |
} |
| 57 | 0 | String principalId = null; |
| 58 | 0 | if ("emplId".equalsIgnoreCase(idType) || "e".equalsIgnoreCase(idType)) { |
| 59 | 0 | Person person = KimApiServiceLocator.getPersonService().getPersonByEmployeeId(id); |
| 60 | 0 | if (person != null) { |
| 61 | 0 | principalId = person.getPrincipalId(); |
| 62 | |
} |
| 63 | 0 | } else if ("workflowId".equalsIgnoreCase(idType) || "w".equalsIgnoreCase(idType)) { |
| 64 | 0 | principalId = id; |
| 65 | 0 | } else if ("authenticationId".equalsIgnoreCase(idType) || "a".equalsIgnoreCase(idType)) { |
| 66 | 0 | Principal principal = KimApiServiceLocator.getIdentityService().getPrincipalByPrincipalName(id); |
| 67 | 0 | if (principal != null) { |
| 68 | 0 | principalId = principal.getPrincipalId(); |
| 69 | |
} |
| 70 | |
} |
| 71 | 0 | if (principalId == null) { |
| 72 | 0 | return 0; |
| 73 | |
} |
| 74 | 0 | return KEWServiceLocator.getActionListService().getCount(principalId); |
| 75 | 0 | } catch (Throwable t) { |
| 76 | 0 | LOG.error("Fatal error when querying for Action List Count", t); |
| 77 | 0 | return 0; |
| 78 | |
} |
| 79 | |
} |
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
} |