Coverage Report - org.kuali.student.enrollment.class1.hold.service.decorators.HoldServiceAuthorizationDecorator
 
Classes in this File Line Coverage Branch Coverage Complexity
HoldServiceAuthorizationDecorator
0%
0/84
0%
0/64
5.444
 
 1  
 package org.kuali.student.enrollment.class1.hold.service.decorators;
 2  
 
 3  
 import java.util.List;
 4  
 
 5  
 import org.kuali.rice.core.api.criteria.QueryByCriteria;
 6  
 // import org.kuali.rice.kim.service.PermissionService;
 7  
 import org.kuali.rice.kim.api.permission.PermissionService;
 8  
 import org.kuali.student.r2.common.dto.ContextInfo;
 9  
 import org.kuali.student.r2.common.dto.StatusInfo;
 10  
 import org.kuali.student.r2.common.dto.ValidationResultInfo;
 11  
 import org.kuali.student.r2.common.exceptions.AlreadyExistsException;
 12  
 import org.kuali.student.r2.common.exceptions.DataValidationErrorException;
 13  
 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
 14  
 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
 15  
 import org.kuali.student.r2.common.exceptions.MissingParameterException;
 16  
 import org.kuali.student.r2.common.exceptions.OperationFailedException;
 17  
 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
 18  
 import org.kuali.student.r2.common.exceptions.ReadOnlyException;
 19  
 import org.kuali.student.r2.common.exceptions.VersionMismatchException;
 20  
 import org.kuali.student.r2.common.infc.HoldsPermissionService;
 21  
 import org.kuali.student.r2.core.hold.dto.HoldInfo;
 22  
 import org.kuali.student.r2.core.hold.dto.IssueInfo;
 23  
 import org.kuali.student.r2.core.hold.service.HoldServiceDecorator;
 24  
 
 25  0
 public class HoldServiceAuthorizationDecorator extends HoldServiceDecorator implements HoldsPermissionService {
 26  
 
 27  
     public static final String ENRLLMENT_NAMESPACE = "KS-ENROLL";
 28  
     public static final String SERVICE_NAME = "HoldService.";
 29  
     private PermissionService permissionService;
 30  
 
 31  
     @Override
 32  
     public PermissionService getPermissionService() {
 33  0
         return permissionService;
 34  
     }
 35  
 
 36  
     @Override
 37  
     public void setPermissionService(PermissionService permissionService) {
 38  0
         this.permissionService = permissionService;
 39  0
     }
 40  
 
 41  
     @Override
 42  
     public HoldInfo getHold(String holdId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 43  0
         if (null == context) {
 44  0
             throw new MissingParameterException();
 45  
         }
 46  
 
 47  0
         if (permissionService.isAuthorized(context.getPrincipalId(), ENRLLMENT_NAMESPACE, SERVICE_NAME + "getHold", null)) {
 48  0
             return getNextDecorator().getHold(holdId, context);
 49  
         } else {
 50  0
             throw new PermissionDeniedException();
 51  
         }
 52  
     }
 53  
 
 54  
     @Override
 55  
     public List<HoldInfo> getHoldsByIssue(String issueId, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 56  0
         if (null == context) {
 57  0
             throw new MissingParameterException();
 58  
         }
 59  
 
 60  0
         if (permissionService.isAuthorized(context.getPrincipalId(), ENRLLMENT_NAMESPACE, SERVICE_NAME + "getHoldsByIssue", null)) {
 61  0
             return getNextDecorator().getHoldsByIssue(issueId, context);
 62  
         } else {
 63  0
             throw new PermissionDeniedException();
 64  
         }
 65  
     }
 66  
 
 67  
     @Override
 68  
     public List<String> searchForHoldIds(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException,
 69  
             PermissionDeniedException {
 70  0
         if (null == context) {
 71  0
             throw new MissingParameterException();
 72  
         }
 73  
 
 74  0
         if (permissionService.isAuthorized(context.getPrincipalId(), ENRLLMENT_NAMESPACE, SERVICE_NAME + "searchForHoldIds", null)) {
 75  0
             return getNextDecorator().searchForHoldIds(criteria, context);
 76  
         } else {
 77  0
             throw new PermissionDeniedException();
 78  
         }
 79  
     }
 80  
 
 81  
     @Override
 82  
     public List<HoldInfo> searchForHolds(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException,
 83  
             PermissionDeniedException {
 84  0
         if (null == context) {
 85  0
             throw new MissingParameterException();
 86  
         }
 87  
 
 88  0
         if (permissionService.isAuthorized(context.getPrincipalId(), ENRLLMENT_NAMESPACE, SERVICE_NAME + "searchForHolds", null)) {
 89  0
             return getNextDecorator().searchForHolds(criteria, context);
 90  
         } else {
 91  0
             throw new PermissionDeniedException();
 92  
         }
 93  
     }
 94  
 
 95  
     @Override
 96  
     public List<ValidationResultInfo> validateHold(String validationTypeKey, HoldInfo holdInfo, ContextInfo context) throws DoesNotExistException, InvalidParameterException,
 97  
             MissingParameterException, OperationFailedException {
 98  0
         if (null == context) {
 99  0
             throw new MissingParameterException();
 100  
         }
 101  
 
 102  0
         if (permissionService.isAuthorized(context.getPrincipalId(), ENRLLMENT_NAMESPACE, SERVICE_NAME + "validateHold", null)) {
 103  0
             return getNextDecorator().validateHold(validationTypeKey, holdInfo, context);
 104  
         } else {
 105  0
             throw new OperationFailedException("Permission Denied.");
 106  
         }
 107  
     }
 108  
 
 109  
     @Override
 110  
     public HoldInfo createHold(String personId,
 111  
             String issueId,
 112  
             String holdTypeKey,
 113  
             HoldInfo holdInfo, ContextInfo context)
 114  
             throws AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException,
 115  
             OperationFailedException, PermissionDeniedException, ReadOnlyException {
 116  0
         if (null == context) {
 117  0
             throw new MissingParameterException();
 118  
         }
 119  
 
 120  0
         if (permissionService.isAuthorized(context.getPrincipalId(), ENRLLMENT_NAMESPACE, SERVICE_NAME + "createHold", null)) {
 121  0
             return getNextDecorator().createHold(personId, issueId, holdTypeKey, holdInfo, context);
 122  
         } else {
 123  0
             throw new PermissionDeniedException();
 124  
         }
 125  
     }
 126  
 
 127  
     @Override
 128  
     public HoldInfo updateHold(String holdId, HoldInfo holdInfo, ContextInfo context) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException,
 129  
             OperationFailedException, PermissionDeniedException, VersionMismatchException, ReadOnlyException {
 130  0
         if (null == context) {
 131  0
             throw new MissingParameterException();
 132  
         }
 133  
 
 134  0
         if (permissionService.isAuthorized(context.getPrincipalId(), ENRLLMENT_NAMESPACE, SERVICE_NAME + "updateHold", null)) {
 135  0
             return getNextDecorator().updateHold(holdId, holdInfo, context);
 136  
         } else {
 137  0
             throw new PermissionDeniedException();
 138  
         }
 139  
     }
 140  
 
 141  
     @Override
 142  
     public HoldInfo releaseHold(String holdId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException,
 143  
             PermissionDeniedException {
 144  0
         if (null == context) {
 145  0
             throw new MissingParameterException();
 146  
         }
 147  
 
 148  0
         if (permissionService.isAuthorized(context.getPrincipalId(), ENRLLMENT_NAMESPACE, SERVICE_NAME + "releaseHold", null)) {
 149  0
             return getNextDecorator().releaseHold(holdId, context);
 150  
         } else {
 151  0
             throw new PermissionDeniedException();
 152  
         }
 153  
     }
 154  
 
 155  
     @Override
 156  
     public StatusInfo deleteHold(String holdId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException,
 157  
             PermissionDeniedException {
 158  0
         if (null == context) {
 159  0
             throw new MissingParameterException();
 160  
         }
 161  
 
 162  0
         if (permissionService.isAuthorized(context.getPrincipalId(), ENRLLMENT_NAMESPACE, SERVICE_NAME + "deleteHold", null)) {
 163  0
             return getNextDecorator().deleteHold(holdId, context);
 164  
         } else {
 165  0
             throw new PermissionDeniedException();
 166  
         }
 167  
     }
 168  
 
 169  
     @Override
 170  
     public IssueInfo getIssue(String issueId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException,
 171  
             PermissionDeniedException {
 172  0
         if (null == context) {
 173  0
             throw new MissingParameterException();
 174  
         }
 175  
 
 176  0
         if (permissionService.isAuthorized(context.getPrincipalId(), ENRLLMENT_NAMESPACE, SERVICE_NAME + "getIssue", null)) {
 177  0
             return getNextDecorator().getIssue(issueId, context);
 178  
         } else {
 179  0
             throw new PermissionDeniedException();
 180  
         }
 181  
     }
 182  
 
 183  
     @Override
 184  
     public List<IssueInfo> getIssuesByOrg(String organizationId, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 185  0
         if (null == context) {
 186  0
             throw new MissingParameterException();
 187  
         }
 188  
 
 189  0
         if (permissionService.isAuthorized(context.getPrincipalId(), ENRLLMENT_NAMESPACE, SERVICE_NAME + "getIssuesByOrg", null)) {
 190  0
             return getNextDecorator().getIssuesByOrg(organizationId, context);
 191  
         } else {
 192  0
             throw new PermissionDeniedException();
 193  
         }
 194  
     }
 195  
 
 196  
     @Override
 197  
     public List<IssueInfo> searchForIssues(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException,
 198  
             PermissionDeniedException {
 199  0
         if (null == context) {
 200  0
             throw new MissingParameterException();
 201  
         }
 202  
 
 203  0
         if (permissionService.isAuthorized(context.getPrincipalId(), ENRLLMENT_NAMESPACE, SERVICE_NAME + "searchForIssues", null)) {
 204  0
             return getNextDecorator().searchForIssues(criteria, context);
 205  
         } else {
 206  0
             throw new PermissionDeniedException();
 207  
         }
 208  
     }
 209  
 
 210  
     @Override
 211  
     public List<ValidationResultInfo> validateIssue(String validationTypeKey, IssueInfo issueInfo, ContextInfo context) throws DoesNotExistException, InvalidParameterException,
 212  
             MissingParameterException, OperationFailedException {
 213  0
         if (null == context) {
 214  0
             throw new MissingParameterException();
 215  
         }
 216  
 
 217  0
         if (permissionService.isAuthorized(context.getPrincipalId(), ENRLLMENT_NAMESPACE, SERVICE_NAME + "validateIssue", null)) {
 218  0
             return getNextDecorator().validateIssue(validationTypeKey, issueInfo, context);
 219  
         } else {
 220  0
             throw new OperationFailedException("Permission Denied.");
 221  
         }
 222  
     }
 223  
 
 224  
     @Override
 225  
     public IssueInfo createIssue(String issueTypeKey, IssueInfo issueInfo, ContextInfo context) throws AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException,
 226  
             OperationFailedException, PermissionDeniedException, ReadOnlyException {
 227  0
         if (null == context) {
 228  0
             throw new MissingParameterException("Missing context parameter");
 229  
         }
 230  
 
 231  0
         if (permissionService.isAuthorized(context.getPrincipalId(), ENRLLMENT_NAMESPACE, SERVICE_NAME + "createIssue", null)) {
 232  0
             return getNextDecorator().createIssue(issueTypeKey, issueInfo, context);
 233  
         } else {
 234  0
             throw new PermissionDeniedException("Permission Denied.");
 235  
         }
 236  
     }
 237  
 
 238  
     @Override
 239  
     public IssueInfo updateIssue(String issueId, IssueInfo issueInfo, ContextInfo context) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException,
 240  
             MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException, ReadOnlyException {
 241  0
         if (null == context) {
 242  0
             throw new MissingParameterException();
 243  
         }
 244  
 
 245  0
         if (permissionService.isAuthorized(context.getPrincipalId(), ENRLLMENT_NAMESPACE, SERVICE_NAME + "updateIssue", null)) {
 246  0
             return getNextDecorator().updateIssue(issueId, issueInfo, context);
 247  
         } else {
 248  0
             throw new PermissionDeniedException();
 249  
         }
 250  
     }
 251  
 
 252  
     @Override
 253  
     public StatusInfo deleteIssue(String issueId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException,
 254  
             PermissionDeniedException {
 255  0
         if (null == context) {
 256  0
             throw new MissingParameterException();
 257  
         }
 258  
 
 259  0
         if (permissionService.isAuthorized(context.getPrincipalId(), ENRLLMENT_NAMESPACE, SERVICE_NAME + "deleteIssue", null)) {
 260  0
             return getNextDecorator().deleteIssue(issueId, context);
 261  
         } else {
 262  0
             throw new PermissionDeniedException();
 263  
         }
 264  
     }
 265  
 }