|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  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 |     | 
     | 
  |  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 |     | 
                             | 
  |  73 |     | 
                             | 
  |  74 |     | 
                             | 
  |  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);      | 
  |  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 |     | 
   }  |