Coverage Report - org.kuali.student.common.ui.server.gwt.DataGwtServlet
 
Classes in this File Line Coverage Branch Coverage Complexity
DataGwtServlet
0%
0/20
N/A
2.833
 
 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.Map;
 19  
 
 20  
 import org.apache.log4j.Logger;
 21  
 import org.kuali.student.common.ui.client.service.BaseDataOrchestrationRpcService;
 22  
 import org.kuali.student.common.ui.client.service.DataSaveResult;
 23  
 import org.kuali.student.common.ui.client.service.exceptions.OperationFailedException;
 24  
 import org.kuali.student.core.assembly.data.Data;
 25  
 import org.kuali.student.core.assembly.data.Metadata;
 26  
 import org.kuali.student.core.exceptions.DataValidationErrorException;
 27  
 import org.kuali.student.core.rice.authorization.PermissionType;
 28  
 
 29  
 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
 30  
 
 31  
 /**
 32  
  * Generic implementation of data gwt data operations calls.
 33  
  *
 34  
  */
 35  0
 public class DataGwtServlet extends RemoteServiceServlet implements BaseDataOrchestrationRpcService {
 36  
 
 37  
         private static final long serialVersionUID = 1L;
 38  
 
 39  0
         final Logger LOG = Logger.getLogger(DataGwtServlet.class);
 40  
 
 41  
         private DataService dataService;
 42  
         
 43  
         @Override
 44  
         public Data getData(String id) throws OperationFailedException {
 45  
                 try{
 46  0
                         return dataService.getData(id);
 47  0
                 } catch (Exception e) {
 48  0
                         LOG.error("Could not get Data ", e);
 49  0
                         throw new OperationFailedException("Failed to get data");
 50  
                 }
 51  
         }
 52  
 
 53  
         @Override
 54  
         public Metadata getMetadata(String id, Map<String, String> idAttributes) throws OperationFailedException {
 55  
                 try{
 56  0
                         return dataService.getMetadata(id, idAttributes);
 57  0
                 } catch (Exception e) {
 58  0
                         LOG.error("Could not get metadata ", e);
 59  0
                         throw new OperationFailedException("Failed to get metadata");
 60  
                 }
 61  
         }
 62  
 
 63  
         @Override
 64  
         public DataSaveResult saveData(Data data) throws OperationFailedException {
 65  
                 try{
 66  0
                         return dataService.saveData(data);
 67  0
                 }catch (DataValidationErrorException dvee){
 68  0
                         return new DataSaveResult(dvee.getValidationResults(), null);
 69  0
                 } catch (Exception e) {
 70  0
                         LOG.error("Could not save data ", e);
 71  0
                         throw new OperationFailedException("Failed to save data");
 72  
                 } 
 73  
         }
 74  
 
 75  
         @Override
 76  
         public Boolean isAuthorized(PermissionType type, Map<String,String> attributes) {
 77  0
                 return dataService.isAuthorized(type, attributes);
 78  
         }
 79  
 
 80  
         public DataService getDataService() {
 81  0
                 return dataService;
 82  
         }
 83  
 
 84  
         public void setDataService(DataService dataService) {
 85  0
                 this.dataService = dataService;
 86  0
         }
 87  
 
 88  
 }