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.Map; |
19 | |
|
20 | |
import org.apache.log4j.Logger; |
21 | |
import org.kuali.student.common.assembly.data.Data; |
22 | |
import org.kuali.student.common.assembly.data.Metadata; |
23 | |
import org.kuali.student.common.exceptions.DataValidationErrorException; |
24 | |
import org.kuali.student.common.rice.authorization.PermissionType; |
25 | |
import org.kuali.student.common.ui.client.service.BaseDataOrchestrationRpcService; |
26 | |
import org.kuali.student.common.ui.client.service.DataSaveResult; |
27 | |
import org.kuali.student.common.ui.client.service.exceptions.OperationFailedException; |
28 | |
|
29 | |
import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
30 | |
|
31 | |
|
32 | |
|
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 | |
} |