Coverage Report - org.kuali.rice.kew.actions.LogDocumentActionAction
 
Classes in this File Line Coverage Branch Coverage Complexity
LogDocumentActionAction
0%
0/14
0%
0/2
1.4
 
 1  
 /*
 2  
  * Copyright 2005-2007 The Kuali Foundation
 3  
  * 
 4  
  * 
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  * 
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.kew.actions;
 18  
 
 19  
 import org.apache.log4j.MDC;
 20  
 import org.kuali.rice.kew.actionrequest.ActionRequestValue;
 21  
 import org.kuali.rice.kew.actiontaken.ActionTakenValue;
 22  
 import org.kuali.rice.kew.exception.InvalidActionTakenException;
 23  
 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
 24  
 import org.kuali.rice.kew.util.KEWConstants;
 25  
 import org.kuali.rice.kim.api.entity.principal.PrincipalContract;
 26  
 
 27  
 import java.util.List;
 28  
 
 29  
 
 30  
 /**
 31  
  * Simply records an action taken with an annotation.  
 32  
  *
 33  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 34  
  */
 35  
 public class LogDocumentActionAction extends ActionTakenEvent {
 36  
 
 37  0
     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(LogDocumentActionAction.class);
 38  
 
 39  
     /**
 40  
      * @param rh RouteHeader for the document upon which the action is taken.
 41  
      * @param principal User taking the action.
 42  
      */
 43  
     public LogDocumentActionAction(DocumentRouteHeaderValue rh, PrincipalContract principal) {
 44  0
         super(KEWConstants.ACTION_TAKEN_LOG_DOCUMENT_ACTION_CD, rh, principal);
 45  0
     }
 46  
 
 47  
     /**
 48  
      * @param rh RouteHeader for the document upon which the action is taken.
 49  
      * @param principal User taking the action.
 50  
      * @param annotation User comment on the action taken
 51  
      */
 52  
     public LogDocumentActionAction(DocumentRouteHeaderValue rh, PrincipalContract principal, String annotation) {
 53  0
         super(KEWConstants.ACTION_TAKEN_LOG_DOCUMENT_ACTION_CD, rh, principal, annotation);
 54  0
     }
 55  
 
 56  
     /* (non-Javadoc)
 57  
      * @see org.kuali.rice.kew.actions.ActionTakenEvent#validateActionRules()
 58  
      */
 59  
     @Override
 60  
     public String validateActionRules() {
 61  
         // log action is always valid so return no error message
 62  0
         return "";
 63  
     }
 64  
 
 65  
     /**
 66  
      * Records the non-routed document action. - Checks to make sure the document status allows the action. Records the action.
 67  
      * 
 68  
      * @throws InvalidActionTakenException
 69  
      */
 70  
     public void recordAction() throws InvalidActionTakenException {
 71  0
         MDC.put("docId", getRouteHeader().getDocumentId());
 72  
 
 73  0
         String errorMessage = validateActionRules();
 74  0
         if (!org.apache.commons.lang.StringUtils.isEmpty(errorMessage)) {
 75  0
             throw new InvalidActionTakenException(errorMessage);
 76  
         }
 77  
 
 78  0
         LOG.debug("Logging document action");
 79  0
         ActionTakenValue actionTaken = saveActionTaken(Boolean.FALSE);
 80  
         // LogDocumentAction should not contact the PostProcessor which is why we don't call notifyActionTaken
 81  
        
 82  0
     }
 83  
 
 84  
         @Override
 85  
         public String validateActionRules(List<ActionRequestValue> actionRequests) {
 86  
         // log action is always valid so return no error message
 87  0
                 return "";
 88  
         }
 89  
 }