Coverage Report - org.kuali.student.core.workflow.ui.server.gwt.WorkflowRpcGwtServlet
 
Classes in this File Line Coverage Branch Coverage Complexity
WorkflowRpcGwtServlet
0%
0/254
0%
0/140
5.926
 
 1  
 package org.kuali.student.core.workflow.ui.server.gwt;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.Arrays;
 5  
 import java.util.HashMap;
 6  
 import java.util.List;
 7  
 import java.util.Map;
 8  
 
 9  
 import org.apache.commons.lang.StringUtils;
 10  
 import org.apache.log4j.Logger;
 11  
 import org.kuali.rice.kew.dto.DocumentContentDTO;
 12  
 import org.kuali.rice.kew.dto.DocumentDetailDTO;
 13  
 import org.kuali.rice.kew.dto.DocumentTypeDTO;
 14  
 import org.kuali.rice.kew.dto.RouteNodeInstanceDTO;
 15  
 import org.kuali.rice.kew.exception.WorkflowException;
 16  
 import org.kuali.rice.kew.service.WorkflowUtility;
 17  
 import org.kuali.rice.kew.util.KEWConstants;
 18  
 import org.kuali.rice.kew.webservice.DocumentResponse;
 19  
 import org.kuali.rice.kew.webservice.SimpleDocumentActionsWebService;
 20  
 import org.kuali.rice.kew.webservice.StandardResponse;
 21  
 import org.kuali.rice.kim.bo.entity.dto.KimPrincipalInfo;
 22  
 import org.kuali.rice.kim.bo.types.dto.AttributeSet;
 23  
 import org.kuali.rice.kim.service.IdentityManagementService;
 24  
 import org.kuali.student.common.ui.client.service.exceptions.OperationFailedException;
 25  
 import org.kuali.student.common.util.security.SecurityUtils;
 26  
 import org.kuali.student.core.rice.StudentIdentityConstants;
 27  
 import org.kuali.student.core.rice.StudentWorkflowConstants.ActionRequestType;
 28  
 import org.kuali.student.core.rice.authorization.PermissionType;
 29  
 import org.kuali.student.core.workflow.ui.client.service.WorkflowRpcService;
 30  
 
 31  
 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
 32  
 
 33  0
 public class WorkflowRpcGwtServlet extends RemoteServiceServlet implements WorkflowRpcService {
 34  
 
 35  
         private static final long serialVersionUID = 1L;
 36  
 
 37  0
         final Logger LOG = Logger.getLogger(WorkflowRpcGwtServlet.class);
 38  
         
 39  
         private SimpleDocumentActionsWebService simpleDocService;
 40  
     private WorkflowUtility workflowUtilityService;
 41  
         private IdentityManagementService identityService;
 42  
         private IdentityManagementService permissionService;
 43  
 
 44  
         @Override
 45  
         public Boolean acknowledgeDocumentWithId(String workflowId) throws OperationFailedException {
 46  
                 try{
 47  
                         //get a user name
 48  0
             String username= SecurityUtils.getCurrentUserId();
 49  
 
 50  0
                 StandardResponse stdResp = getSimpleDocService().acknowledge(workflowId, username, "");
 51  
 
 52  0
                 if(stdResp==null||StringUtils.isNotBlank(stdResp.getErrorMessage())){
 53  0
                         throw new OperationFailedException("Error found acknowledging document: " + stdResp.getErrorMessage());
 54  
                 }
 55  
 
 56  0
                 }catch(OperationFailedException e){
 57  0
             LOG.error("Error acknowledging Document with workflow id:" + workflowId, e);
 58  0
             throw new OperationFailedException("Could not acknowledge");
 59  0
                 }
 60  0
         return Boolean.valueOf(true);
 61  
         }
 62  
 
 63  
         @Override
 64  
         public Boolean adhocRequest(String workflowId, String recipientPrincipalId,
 65  
                         ActionRequestType requestType, String annotation) throws OperationFailedException {
 66  
 
 67  
         try {
 68  
             //Get a user name
 69  0
             String username = SecurityUtils.getCurrentUserId();
 70  
 
 71  0
             String fyiAnnotation = "";
 72  0
             String approveAnnotation = "";
 73  0
             String ackAnnotation = "";
 74  
 
 75  0
             if (ActionRequestType.FYI.equals(requestType)) {
 76  0
                 StandardResponse stdResp = getSimpleDocService().requestAdHocFyiToPrincipal(workflowId,recipientPrincipalId, username, fyiAnnotation);
 77  0
                 if (stdResp == null || StringUtils.isNotBlank(stdResp.getErrorMessage())) {
 78  0
                     throw new OperationFailedException("Error found in Adhoc FYI: " + stdResp.getErrorMessage());
 79  
                 }
 80  
             }
 81  0
             if (ActionRequestType.APPROVE.equals(requestType)) {
 82  0
                 StandardResponse stdResp = getSimpleDocService().requestAdHocApproveToPrincipal(workflowId, recipientPrincipalId,username, approveAnnotation);
 83  0
                 if (stdResp == null || StringUtils.isNotBlank(stdResp.getErrorMessage())) {
 84  0
                     throw new OperationFailedException("Error found in Adhoc Approve: " + stdResp.getErrorMessage());
 85  
                 }
 86  
             }
 87  0
             if (ActionRequestType.ACKNOWLEDGE.equals(requestType)) {
 88  0
                 StandardResponse stdResp = getSimpleDocService().requestAdHocAckToPrincipal(workflowId,recipientPrincipalId,username, ackAnnotation);
 89  0
                 if (stdResp == null || StringUtils.isNotBlank(stdResp.getErrorMessage())) {
 90  0
                     throw new OperationFailedException("Error found in Adhoc Ack: " + stdResp.getErrorMessage());
 91  
                 }
 92  
             }
 93  
 
 94  0
         } catch (Exception e) {
 95  0
             LOG.error("Error adhoc routing",e);
 96  0
             throw new OperationFailedException("Could not adhoc route");
 97  0
         }
 98  0
         return  Boolean.valueOf(true);
 99  
         }
 100  
 
 101  
         @Override
 102  
         public Boolean approveDocumentWithId(String workflowId) throws OperationFailedException {
 103  
 
 104  
                 try{
 105  
             //get a user name
 106  0
             String username = SecurityUtils.getCurrentUserId();
 107  0
             StandardResponse stdResp = getSimpleDocService().approve(workflowId, username, null, null, "");
 108  0
             if(stdResp==null||StringUtils.isNotBlank(stdResp.getErrorMessage())){
 109  0
                         throw new OperationFailedException("Error found approving document: " + stdResp.getErrorMessage());
 110  
                 }
 111  
 
 112  0
                 }catch(Exception e){
 113  0
             LOG.error("Error approving document",e);
 114  0
             return Boolean.FALSE;
 115  0
                 }
 116  0
         return Boolean.TRUE;
 117  
         }
 118  
 
 119  
     @Override
 120  
     public Boolean blanketApproveDocumentWithId(String workflowId) throws OperationFailedException {
 121  
 
 122  
         try{
 123  
             //get a user name
 124  0
             String username = SecurityUtils.getCurrentUserId();
 125  0
             StandardResponse stdResp = getSimpleDocService().blanketApprove(workflowId, username, null, null, "");
 126  0
             if(stdResp==null||StringUtils.isNotBlank(stdResp.getErrorMessage())){
 127  0
                 throw new OperationFailedException("Error found blanket approving document: " + stdResp.getErrorMessage());
 128  
             }
 129  
 
 130  0
         }catch(Exception e){
 131  0
             LOG.error("Error blanket approving document",e);
 132  0
             return Boolean.FALSE;
 133  0
         }
 134  0
         return Boolean.TRUE;
 135  
     }
 136  
 
 137  
         @Override
 138  
         public Boolean disapproveDocumentWithId(String workflowId) {
 139  
 
 140  
                 try{
 141  
             //get a user name
 142  0
             String username = SecurityUtils.getCurrentUserId();
 143  0
                 String disapproveComment = "Disapproved";
 144  
 
 145  0
                 StandardResponse stdResp = getSimpleDocService().disapprove(workflowId, username, disapproveComment);
 146  0
                 if(stdResp==null||StringUtils.isNotBlank(stdResp.getErrorMessage())){
 147  0
                         LOG.error("Error  disapproving document: " + stdResp.getErrorMessage());
 148  0
                         return Boolean.FALSE;
 149  
                 }
 150  0
                 }catch(Exception e){
 151  0
             LOG.error("Error disapproving document",e);
 152  0
             return Boolean.FALSE;
 153  0
                 }
 154  0
                 return Boolean.TRUE;
 155  
         }
 156  
 
 157  
         @Override
 158  
         public Boolean fyiDocumentWithId(String workflowId) {
 159  
                 try{
 160  
             //get a user name
 161  0
             String username = SecurityUtils.getCurrentUserId();
 162  
 
 163  0
                 StandardResponse stdResp = getSimpleDocService().fyi(workflowId, username);
 164  0
                 if(stdResp==null||StringUtils.isNotBlank(stdResp.getErrorMessage())){
 165  0
                         LOG.error("Error FYIing document: " + stdResp.getErrorMessage());
 166  0
                         return Boolean.FALSE;
 167  
                 }
 168  0
                 }catch(Exception e){
 169  0
             LOG.error("Error FYIing document",e);
 170  0
             return Boolean.FALSE;
 171  0
                 }
 172  0
                 return Boolean.TRUE;
 173  
         }
 174  
 
 175  
         @Override
 176  
         public Boolean withdrawDocumentWithId(String workflowId) {
 177  0
         if(simpleDocService==null){
 178  0
                 LOG.error("Workflow Service is unavailable");
 179  0
                 return Boolean.FALSE;
 180  
         }
 181  
 
 182  
                 try{
 183  0
             String username = SecurityUtils.getCurrentUserId();
 184  0
                         KimPrincipalInfo systemPrincipal = getIdentityService().getPrincipalByPrincipalName(StudentIdentityConstants.SYSTEM_USER_PRINCIPAL_NAME);
 185  0
                         if (systemPrincipal == null) {
 186  0
                                 throw new RuntimeException("Cannot find principal for system user principal name: " + StudentIdentityConstants.SYSTEM_USER_PRINCIPAL_NAME);
 187  
                         }
 188  0
                         String annotation = "Document was withdrawn by " + username;
 189  
 
 190  0
                         StandardResponse stdResp = simpleDocService.superUserDisapprove(workflowId, systemPrincipal.getPrincipalId(), null, null, annotation);
 191  0
                 if(stdResp==null||StringUtils.isNotBlank(stdResp.getErrorMessage())) {
 192  0
                         LOG.error("Error withdrawing document: " + stdResp.getErrorMessage());
 193  0
                         return Boolean.FALSE;
 194  
                 }
 195  0
                 }catch(Exception e){
 196  0
             LOG.error("Error withdrawing document",e);
 197  0
             return Boolean.FALSE;
 198  0
                 }
 199  0
                 return Boolean.TRUE;
 200  
         }
 201  
         
 202  
         @Override
 203  
         public Boolean returnDocumentWithId(String workflowId, String nodeName) {
 204  
 
 205  
         try{
 206  
             //get the current user username
 207  0
             String username = SecurityUtils.getCurrentUserId();
 208  0
             StandardResponse stdResp = getSimpleDocService().returnToPreviousNode(workflowId, username, "", nodeName);
 209  0
             if(stdResp==null||StringUtils.isNotBlank(stdResp.getErrorMessage())){
 210  0
                 throw new OperationFailedException("Error found approving document: " + stdResp.getErrorMessage());
 211  
             }
 212  
 
 213  0
         }catch(Exception e){
 214  0
             LOG.error("Error approving document",e);
 215  0
             return Boolean.FALSE;
 216  0
         }
 217  0
         return Boolean.TRUE;
 218  
         }
 219  
 
 220  
     public List<String> getPreviousRouteNodeNames(String workflowId) throws OperationFailedException {
 221  
         try {
 222  0
             String[] nodeNames = getWorkflowUtilityService().getPreviousRouteNodeNames(Long.parseLong(workflowId));
 223  0
             return Arrays.asList(nodeNames);
 224  0
         } catch (Exception e) {
 225  0
             LOG.error("Error approving document",e);
 226  0
             throw new OperationFailedException("Error getting previous node names");
 227  
         }
 228  
     }
 229  
 
 230  
         @Override
 231  
         public String getActionsRequested(String workflowId) throws OperationFailedException {
 232  
         try{
 233  0
                     if(null==workflowId || workflowId.isEmpty()){
 234  0
                             LOG.info("No workflow id was provided.");
 235  0
                             return "";
 236  
                     }
 237  
 
 238  
             //get a user name
 239  0
             String principalId = SecurityUtils.getCurrentUserId();
 240  
 
 241  
                     //Build up a string of actions requested from the attribute set.  The actions can be R,W,S,F,A,C,K. examples are "A" "AF" "FCK" "SCA"
 242  0
             LOG.debug("Calling action requested with user:"+principalId+" and workflowId:" + workflowId);
 243  
 
 244  0
             Map<String,String> results = new HashMap<String,String>();
 245  0
             AttributeSet kewActionsRequested = getWorkflowUtilityService().getActionsRequested(principalId, Long.parseLong(workflowId));
 246  0
             for (String key : kewActionsRequested.keySet()) {
 247  0
                     if ("true".equalsIgnoreCase(kewActionsRequested.get(key))) {
 248  0
                             results.put(key,"true");
 249  
                     }
 250  
             }
 251  
 
 252  
             //Use StringBuilder to avoid using string concatenations in the for loop.
 253  0
             StringBuilder actionsRequestedBuffer = new StringBuilder();
 254  
 
 255  0
             DocumentDetailDTO docDetail = getWorkflowUtilityService().getDocumentDetail(Long.parseLong(workflowId));
 256  
 
 257  0
             for(Map.Entry<String,String> entry:results.entrySet()){
 258  
                     // if saved or initiated status... must show only 'complete' button
 259  0
                     if (KEWConstants.ROUTE_HEADER_SAVED_CD.equals(docDetail.getDocRouteStatus()) || KEWConstants.ROUTE_HEADER_INITIATED_CD.equals(docDetail.getDocRouteStatus())) {
 260  
                             // show only complete button if complete or approve code in this doc status
 261  0
                             if ( (KEWConstants.ACTION_REQUEST_COMPLETE_REQ.equals(entry.getKey()) || KEWConstants.ACTION_REQUEST_APPROVE_REQ.equals(entry.getKey())) && ("true".equals(entry.getValue())) ) {
 262  0
                                     actionsRequestedBuffer.append("S");
 263  0
                         actionsRequestedBuffer.append("C");
 264  
                             }
 265  
                             // if not Complete or Approve code then show the standard buttons
 266  
                             else {
 267  0
                                 if("true".equals(entry.getValue())){
 268  0
                                         actionsRequestedBuffer.append(entry.getKey());
 269  
                                 }
 270  
                             }
 271  
                     }
 272  
                     else {
 273  0
                         if("true".equals(entry.getValue())){
 274  0
                                 actionsRequestedBuffer.append(entry.getKey());
 275  
                         // show the return to previous button if there is a COMPLETE or APPROVE action request
 276  0
                         if ( (KEWConstants.ACTION_REQUEST_COMPLETE_REQ.equals(entry.getKey()) || KEWConstants.ACTION_REQUEST_APPROVE_REQ.equals(entry.getKey())) && ("true".equals(entry.getValue())) ) {
 277  0
                             actionsRequestedBuffer.append("R");
 278  
                         }
 279  
                         }
 280  
                     }
 281  
             }
 282  
 
 283  0
             String docTypeName = getWorkflowUtilityService().getDocumentType(docDetail.getDocTypeId()).getName();
 284  
             // if user can withdraw document then add withdraw button
 285  0
             AttributeSet permDetails = new AttributeSet();
 286  0
             permDetails.put(StudentIdentityConstants.DOCUMENT_TYPE_NAME,docTypeName);
 287  0
             permDetails.put(StudentIdentityConstants.ROUTE_STATUS_CODE,docDetail.getDocRouteStatus());
 288  0
             if (getPermissionService().isAuthorizedByTemplateName(principalId, 
 289  
                             PermissionType.WITHDRAW.getPermissionNamespace(), 
 290  
                             PermissionType.WITHDRAW.getPermissionTemplateName(), permDetails, 
 291  
                             new AttributeSet(StudentIdentityConstants.DOCUMENT_NUMBER,workflowId))) {
 292  0
                     LOG.info("User '" + principalId + "' is allowed to Withdraw the Document");
 293  0
                     actionsRequestedBuffer.append("W");
 294  
             }
 295  
 
 296  0
             Map<String,String> permDetails2 = new HashMap<String,String>();
 297  0
             permDetails2.put(StudentIdentityConstants.DOCUMENT_TYPE_NAME,docTypeName);
 298  0
             permDetails2.put(StudentIdentityConstants.ROUTE_STATUS_CODE,docDetail.getDocRouteStatus());
 299  
             // first check permission with no node name
 300  0
             boolean canBlanketApprove = getPermissionService().isAuthorizedByTemplateName(principalId, 
 301  
                     PermissionType.BLANKET_APPROVE.getPermissionNamespace(), 
 302  
                     PermissionType.BLANKET_APPROVE.getPermissionTemplateName(), new AttributeSet(permDetails2), 
 303  
                     new AttributeSet(StudentIdentityConstants.DOCUMENT_NUMBER,workflowId));
 304  0
             for (String nodeName : getCurrentActiveNodeNames(docDetail.getRouteHeaderId())) {
 305  0
                 if (canBlanketApprove) {
 306  0
                     break;
 307  
                 }
 308  0
                 AttributeSet newSet = new AttributeSet(permDetails2);
 309  0
                 newSet.put(StudentIdentityConstants.ROUTE_NODE_NAME, nodeName);
 310  0
                 canBlanketApprove = getPermissionService().isAuthorizedByTemplateName(principalId, 
 311  
                         PermissionType.BLANKET_APPROVE.getPermissionNamespace(), 
 312  
                         PermissionType.BLANKET_APPROVE.getPermissionTemplateName(), newSet, 
 313  
                         new AttributeSet(StudentIdentityConstants.DOCUMENT_NUMBER,workflowId));
 314  0
             }
 315  0
             if (canBlanketApprove) {
 316  0
                 LOG.info("User '" + principalId + "' is allowed to Blanket Approve the Document");
 317  0
                 actionsRequestedBuffer.append("B");
 318  
             }
 319  
 
 320  0
             return actionsRequestedBuffer.toString();
 321  0
         } catch (Exception e) {
 322  0
                 LOG.error("Error getting actions Requested",e);
 323  0
             throw new OperationFailedException("Error getting actions Requested");
 324  
         }
 325  
         }
 326  
 
 327  
         protected List<String> getCurrentActiveNodeNames(Long routeHeaderId) throws OperationFailedException, WorkflowException {
 328  0
         List<String> currentActiveNodeNames = new ArrayList<String>();
 329  0
         RouteNodeInstanceDTO[] nodeInstances = getWorkflowUtilityService().getActiveNodeInstances(routeHeaderId);
 330  0
         if (null != nodeInstances) {
 331  0
             for (RouteNodeInstanceDTO routeNodeInstanceDTO : nodeInstances) {
 332  0
                 currentActiveNodeNames.add(routeNodeInstanceDTO.getName());
 333  
             }
 334  
         }
 335  0
         return currentActiveNodeNames;
 336  
         }
 337  
 
 338  
         @Override
 339  
         public String getDocumentStatus(String workflowId)
 340  
                         throws OperationFailedException {
 341  0
                 if (workflowId != null && !workflowId.isEmpty()){
 342  
                         try {
 343  0
                                 Long documentId = Long.valueOf(workflowId);
 344  0
                                 return workflowUtilityService.getDocumentStatus(documentId);
 345  0
                         } catch (Exception e) {
 346  0
                                 throw new OperationFailedException("Error getting document status. " + e.getMessage());
 347  
                         }
 348  
                 }
 349  
 
 350  0
                 return null;
 351  
         }
 352  
 
 353  
         @Override
 354  
         /**
 355  
          * NOTE: This method may no longer be required if workflow id is stored in the proposal.
 356  
          */
 357  
         public String getWorkflowIdFromDataId(String workflowDocType, String dataId) throws OperationFailedException {
 358  0
                 if(null==simpleDocService){
 359  0
                 throw new OperationFailedException("Workflow Service is unavailable");
 360  
         }
 361  
 
 362  
         DocumentDetailDTO docDetail;
 363  
                 try {
 364  0
                         docDetail = workflowUtilityService.getDocumentDetailFromAppId(workflowDocType, dataId);
 365  0
                 if(null==docDetail){
 366  0
                         LOG.error("Nothing found for id: "+dataId);
 367  0
                         return null;
 368  
                 }
 369  0
                 Long workflowId=docDetail.getRouteHeaderId();
 370  0
                 return null==workflowId?null:workflowId.toString();
 371  0
                 } catch (Exception e) {
 372  0
                         LOG.error("Call Failed getting workflowId for id: "+dataId, e);
 373  
                 }
 374  0
                 return null;
 375  
         }
 376  
 
 377  
         
 378  
         @Override
 379  
         public String getDataIdFromWorkflowId(String workflowId) throws OperationFailedException {
 380  0
         String username = SecurityUtils.getCurrentUserId();
 381  
 
 382  0
         DocumentResponse docResponse = getSimpleDocService().getDocument(workflowId, username);
 383  0
         if(docResponse==null||StringUtils.isNotBlank(docResponse.getErrorMessage())){
 384  0
                 throw new OperationFailedException("Error found gettting document: " + docResponse.getErrorMessage());
 385  
         }
 386  
         
 387  0
         return docResponse.getAppDocId();
 388  
         }
 389  
 
 390  
         @Override
 391  
         public List<String> getWorkflowNodes(String workflowId)
 392  
                         throws OperationFailedException {
 393  0
                 List<String> routeNodeNames = new ArrayList<String>();
 394  
 
 395  0
                 Long documentId = Long.valueOf(workflowId);
 396  
                 try{
 397  0
                         RouteNodeInstanceDTO[] routeNodes = workflowUtilityService.getActiveNodeInstances(documentId);
 398  0
                         if (routeNodes != null){
 399  0
                                 for (RouteNodeInstanceDTO routeNodeInstanceDTO : routeNodes) {
 400  0
                                         routeNodeNames.add(routeNodeInstanceDTO.getName());
 401  
                                 }
 402  
                         }
 403  
 
 404  0
                 } catch (Exception e) {
 405  0
                         throw new OperationFailedException(e.getMessage());
 406  0
                 }
 407  
 
 408  0
                 return routeNodeNames;
 409  
         }
 410  
 
 411  
         @Override
 412  
         public Boolean submitDocumentWithId(String workflowId) {
 413  
                 try {
 414  0
             if(simpleDocService==null){
 415  0
                     throw new OperationFailedException("Workflow Service is unavailable");
 416  
             }
 417  
 
 418  
             //get a user name
 419  0
             String username = SecurityUtils.getCurrentUserId();
 420  
 
 421  
             //Get the workflow ID
 422  0
             DocumentDetailDTO docDetail = workflowUtilityService.getDocumentDetail(Long.parseLong(workflowId));
 423  0
             if(docDetail==null){
 424  0
                     throw new OperationFailedException("Error found getting document. " );
 425  
             }
 426  0
             DocumentContentDTO docContent = workflowUtilityService.getDocumentContent(Long.parseLong(workflowId));
 427  
 
 428  0
             String routeComment = "Routed";
 429  
 
 430  0
             StandardResponse stdResp = simpleDocService.route(docDetail.getRouteHeaderId().toString(), username, docDetail.getDocTitle(), docContent.getApplicationContent(), routeComment);
 431  
 
 432  0
             if(stdResp==null||StringUtils.isNotBlank(stdResp.getErrorMessage())){
 433  0
                         throw new OperationFailedException("Error found routing document: " + stdResp.getErrorMessage());
 434  
                 }
 435  
 
 436  0
         } catch (Exception e) {
 437  0
             LOG.error("Error found routing document",e);
 438  0
             return Boolean.FALSE;
 439  0
         }
 440  0
         return Boolean.TRUE;
 441  
         }
 442  
 
 443  
     @Override
 444  
     public Boolean cancelDocumentWithId(String workflowId) {
 445  
         try {
 446  0
             if(simpleDocService==null){
 447  0
                 throw new OperationFailedException("Workflow Service is unavailable");
 448  
             }
 449  
 
 450  
             //get a user name
 451  0
             String username = SecurityUtils.getCurrentUserId();
 452  0
             StandardResponse stdResp = simpleDocService.cancel(workflowId, username, "");
 453  
 
 454  0
             if(stdResp==null||StringUtils.isNotBlank(stdResp.getErrorMessage())){
 455  0
                 throw new OperationFailedException("Error found cancelling document: " + stdResp.getErrorMessage());
 456  
             }
 457  
 
 458  0
         } catch (Exception e) {
 459  0
             LOG.error("Error found routing document",e);
 460  0
             return Boolean.FALSE;
 461  0
         }
 462  0
         return Boolean.TRUE;
 463  
     }
 464  
 
 465  
         @Override
 466  
     public Boolean isAuthorizedAddReviewer(String docId) throws OperationFailedException{
 467  0
                 if (docId != null && (!"".equals(docId.trim()))) {
 468  0
                         AttributeSet permissionDetails = new AttributeSet();
 469  0
                         AttributeSet roleQuals = new AttributeSet();
 470  0
                         roleQuals.put(StudentIdentityConstants.DOCUMENT_NUMBER,docId);
 471  0
                         return Boolean.valueOf(getPermissionService().isAuthorizedByTemplateName(SecurityUtils.getCurrentUserId(), PermissionType.ADD_ADHOC_REVIEWER.getPermissionNamespace(), 
 472  
                                         PermissionType.ADD_ADHOC_REVIEWER.getPermissionTemplateName(), permissionDetails, roleQuals));
 473  
                 }
 474  0
                 return Boolean.FALSE;
 475  
     }
 476  
 
 477  
         public Boolean isAuthorizedRemoveReviewers(String docId) throws OperationFailedException {
 478  
             try {
 479  0
             if (docId != null && (!"".equals(docId.trim()))) {
 480  0
                 DocumentDetailDTO docDetail = getWorkflowUtilityService().getDocumentDetail(Long.parseLong(docId));
 481  0
                 DocumentTypeDTO docType = getWorkflowUtilityService().getDocumentType(docDetail.getDocTypeId());
 482  0
                 AttributeSet permissionDetails = new AttributeSet();
 483  0
                 permissionDetails.put(StudentIdentityConstants.DOCUMENT_TYPE_NAME,docType.getName());
 484  0
                 AttributeSet roleQuals = new AttributeSet();
 485  0
                 roleQuals.put(StudentIdentityConstants.DOCUMENT_NUMBER,docId);
 486  0
                 boolean returnValue = getPermissionService().isAuthorizedByTemplateName(SecurityUtils.getCurrentUserId(), PermissionType.REMOVE_ADHOC_REVIEWERS.getPermissionNamespace(), 
 487  
                         PermissionType.REMOVE_ADHOC_REVIEWERS.getPermissionTemplateName(), permissionDetails, roleQuals);
 488  0
                 return Boolean.valueOf(returnValue);
 489  
             }
 490  0
             return Boolean.FALSE;
 491  0
             } catch (WorkflowException e) {
 492  0
                 LOG.error("Unable to get document information from Workflow for doc id " + docId);
 493  0
                 throw new OperationFailedException("Unable to get document information from Workflow for doc id " + docId);
 494  
             }
 495  
         }
 496  
 
 497  
         public void setSimpleDocService(SimpleDocumentActionsWebService simpleDocService) {
 498  0
                 this.simpleDocService = simpleDocService;
 499  0
         }
 500  
         
 501  
         public SimpleDocumentActionsWebService getSimpleDocService() throws OperationFailedException{
 502  0
                 if(simpleDocService==null){
 503  0
                 throw new OperationFailedException("Workflow Simple Document Service is unavailable");
 504  
         }
 505  
                 
 506  0
                 return simpleDocService;
 507  
         }
 508  
 
 509  
         public void setWorkflowUtilityService(WorkflowUtility workflowUtilityService) {
 510  0
                 this.workflowUtilityService = workflowUtilityService;
 511  0
         }
 512  
 
 513  
         public WorkflowUtility getWorkflowUtilityService() throws OperationFailedException{
 514  0
                 if(workflowUtilityService==null){
 515  0
                 throw new OperationFailedException("Workflow Utility Service is unavailable");
 516  
         }
 517  
                 
 518  0
                 return workflowUtilityService;
 519  
         }
 520  
 
 521  
         public void setIdentityService(IdentityManagementService identityService) {
 522  0
                 this.identityService = identityService;
 523  0
         }
 524  
 
 525  
         public IdentityManagementService getIdentityService() throws OperationFailedException{
 526  0
                 if(identityService==null){
 527  0
                 throw new OperationFailedException("Identity Service is unavailable");
 528  
         }
 529  
                 
 530  0
                 return identityService;
 531  
         }
 532  
 
 533  
         public void setPermissionService(IdentityManagementService permissionService) {
 534  0
                 this.permissionService = permissionService;
 535  0
         }
 536  
 
 537  
         public IdentityManagementService getPermissionService()throws OperationFailedException{
 538  0
                 if(permissionService==null){
 539  0
                 throw new OperationFailedException("Permission Service is unavailable");
 540  
         }
 541  
 
 542  0
                 return permissionService;
 543  
         }
 544  
 }