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.rice.authorization.PermissionType; |
26 | |
import org.kuali.student.common.ui.client.service.BaseDataOrchestrationRpcService; |
27 | |
import org.kuali.student.common.ui.client.service.DataSaveResult; |
28 | |
import org.kuali.student.common.ui.client.service.exceptions.OperationFailedException; |
29 | |
import org.kuali.student.common.validation.dto.ValidationResultInfo; |
30 | |
|
31 | |
import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | 0 | public class DataGwtServlet extends RemoteServiceServlet implements BaseDataOrchestrationRpcService { |
38 | |
|
39 | |
private static final long serialVersionUID = 1L; |
40 | |
|
41 | 0 | final Logger LOG = Logger.getLogger(DataGwtServlet.class); |
42 | |
|
43 | |
private DataService dataService; |
44 | |
|
45 | |
@Override |
46 | |
public Data getData(String id) throws OperationFailedException { |
47 | |
try{ |
48 | 0 | return dataService.getData(id); |
49 | 0 | } catch (Exception e) { |
50 | 0 | LOG.error("Could not get Data ", e); |
51 | 0 | throw new OperationFailedException("Failed to get data"); |
52 | |
} |
53 | |
} |
54 | |
|
55 | |
@Override |
56 | |
public Metadata getMetadata(String id, Map<String, String> idAttributes) throws OperationFailedException { |
57 | |
try{ |
58 | 0 | return dataService.getMetadata(id, idAttributes); |
59 | 0 | } catch (Exception e) { |
60 | 0 | LOG.error("Could not get metadata ", e); |
61 | 0 | throw new OperationFailedException("Failed to get metadata"); |
62 | |
} |
63 | |
} |
64 | |
|
65 | |
@Override |
66 | |
public DataSaveResult saveData(Data data) throws OperationFailedException { |
67 | |
try{ |
68 | 0 | return dataService.saveData(data); |
69 | 0 | } catch (DataValidationErrorException dvee){ |
70 | |
|
71 | |
|
72 | |
|
73 | 0 | DataSaveResult saveResult = new DataSaveResult(); |
74 | 0 | saveResult.setValidationResults(dvee.getValidationResults()); |
75 | 0 | return saveResult; |
76 | 0 | } catch (Exception e) { |
77 | 0 | LOG.error("Could not save data ", e); |
78 | 0 | throw new OperationFailedException("Failed to save data"); |
79 | |
} |
80 | |
} |
81 | |
|
82 | |
@Override |
83 | |
public List<ValidationResultInfo> validate(Data data) |
84 | |
throws OperationFailedException { |
85 | |
try{ |
86 | 0 | return dataService.validateData(data); |
87 | 0 | } catch (Exception e) { |
88 | 0 | LOG.error("Could not validate data ", e); |
89 | 0 | throw new OperationFailedException("Failed to data"); |
90 | |
} |
91 | |
} |
92 | |
|
93 | |
@Override |
94 | |
public Boolean isAuthorized(PermissionType type, Map<String,String> attributes) { |
95 | 0 | return dataService.isAuthorized(type, attributes); |
96 | |
} |
97 | |
|
98 | |
public DataService getDataService() { |
99 | 0 | return dataService; |
100 | |
} |
101 | |
|
102 | |
public void setDataService(DataService dataService) { |
103 | 0 | this.dataService = dataService; |
104 | 0 | } |
105 | |
|
106 | |
|
107 | |
} |