Coverage Report - org.kuali.student.common.ui.server.gwt.DataGwtServlet
 
Classes in this File Line Coverage Branch Coverage Complexity
DataGwtServlet
0%
0/29
N/A
3.286
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.student.common.ui.server.gwt;
 17  
 
 18  
 import java.util.List;
 19  
 import java.util.Map;
 20  
 
 21  
 import org.apache.log4j.Logger;
 22  
 import org.kuali.student.common.assembly.data.Data;
 23  
 import org.kuali.student.common.assembly.data.Metadata;
 24  
 import org.kuali.student.common.exceptions.DataValidationErrorException;
 25  
 import org.kuali.student.common.exceptions.VersionMismatchException;
 26  
 import org.kuali.student.common.rice.authorization.PermissionType;
 27  
 import org.kuali.student.common.ui.client.service.BaseDataOrchestrationRpcService;
 28  
 import org.kuali.student.common.ui.client.service.DataSaveResult;
 29  
 import org.kuali.student.common.ui.client.service.exceptions.OperationFailedException;
 30  
 import org.kuali.student.common.ui.client.service.exceptions.VersionMismatchClientException;
 31  
 import org.kuali.student.common.validation.dto.ValidationResultInfo;
 32  
 
 33  
 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
 34  
 
 35  
 /**
 36  
  * Generic implementation of data gwt data operations calls.
 37  
  *
 38  
  */
 39  0
 public class DataGwtServlet extends RemoteServiceServlet implements BaseDataOrchestrationRpcService {
 40  
 
 41  
         private static final long serialVersionUID = 1L;
 42  
 
 43  0
         final Logger LOG = Logger.getLogger(DataGwtServlet.class);
 44  
 
 45  
         private DataService dataService;
 46  
         
 47  
         @Override
 48  
         public Data getData(String id) throws OperationFailedException {
 49  
                 try{
 50  0
                         return dataService.getData(id);
 51  0
                 } catch (Exception e) {
 52  0
                         LOG.error("Could not get Data ", e);
 53  0
                         throw new OperationFailedException("Failed to get data");
 54  
                 }
 55  
         }
 56  
 
 57  
         @Override
 58  
         public Metadata getMetadata(String id, Map<String, String> idAttributes) throws OperationFailedException {
 59  
                 try{
 60  0
                         return dataService.getMetadata(id, idAttributes);
 61  0
                 } catch (Exception e) {
 62  0
                         LOG.error("Could not get metadata ", e);
 63  0
                         throw new OperationFailedException("Failed to get metadata");
 64  
                 }
 65  
         }
 66  
 
 67  
         @Override
 68  
         public DataSaveResult saveData(Data data) throws OperationFailedException, VersionMismatchClientException {
 69  
                 try{
 70  0
                         return dataService.saveData(data);
 71  0
                 } catch (DataValidationErrorException dvee){
 72  
                         //This should only get thrown if service save call resulted in validation errors. These errors
 73  
                         //should be sent to the UI using DataSaveResult instead of throwing an exception.
 74  
                         //Sending null for data value, since UI should already have it and nothing changed.
 75  0
                         DataSaveResult saveResult = new DataSaveResult();
 76  0
                         saveResult.setValidationResults(dvee.getValidationResults());
 77  0
                         return saveResult;
 78  0
                 } catch (VersionMismatchException vme){
 79  0
                     throw new VersionMismatchClientException(vme.getMessage());
 80  0
                 } catch (Exception e) {
 81  0
                         LOG.error("Could not save data ", e);
 82  0
                         throw new OperationFailedException(e.getMessage());
 83  
                 } 
 84  
         }
 85  
 
 86  
         @Override
 87  
         public List<ValidationResultInfo> validate(Data data)throws OperationFailedException {
 88  
                 try{
 89  0
                     List<ValidationResultInfo> result= dataService.validateData(data);    //result info loaded with info about conflicts [KSCM-250]
 90  0
                     return result;
 91  0
                 } catch (Exception e) {
 92  0
                         LOG.error("Could not validate data ", e);
 93  0
                         throw new OperationFailedException("Failed to  data");
 94  
                 } 
 95  
         }
 96  
 
 97  
         @Override
 98  
         public Boolean isAuthorized(PermissionType type, Map<String,String> attributes) {
 99  0
                 return dataService.isAuthorized(type, attributes);
 100  
         }
 101  
 
 102  
         public DataService getDataService() {
 103  0
                 return dataService;
 104  
         }
 105  
 
 106  
         public void setDataService(DataService dataService) {
 107  0
                 this.dataService = dataService;
 108  0
         }
 109  
 
 110  
 
 111  
 }