1
2
3
4
5
6
7
8
9 package org.kuali.student.common.ui.server.gwt;
10
11 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
12 import java.util.ArrayList;
13 import org.kuali.student.common.ui.client.service.MessagesRpcService;
14 import org.kuali.student.r2.common.dto.LocaleInfo;
15 import org.kuali.student.r2.common.dto.StatusInfo;
16 import org.kuali.student.r2.common.exceptions.DataValidationErrorException;
17 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
18 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
19 import org.kuali.student.r2.common.exceptions.MissingParameterException;
20 import org.kuali.student.r2.common.exceptions.OperationFailedException;
21 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
22 import org.kuali.student.r2.common.exceptions.ReadOnlyException;
23 import org.kuali.student.r2.common.exceptions.VersionMismatchException;
24 import org.kuali.student.r2.common.messages.dto.MessageInfo;
25 import org.kuali.student.r2.common.messages.service.MessageService;
26 import org.kuali.student.r2.common.util.ContextUtils;
27
28 public class MessagesRpcGwtServlet extends RemoteServiceServlet implements MessagesRpcService {
29
30 private static final long serialVersionUID = 1L;
31
32 private MessageService serviceImpl;
33
34 @Override
35 public StatusInfo createMessage(MessageInfo messageInfo)
36 throws DoesNotExistException,
37 InvalidParameterException,
38 MissingParameterException,
39 OperationFailedException,
40 PermissionDeniedException {
41 try {
42 return serviceImpl.createMessage(messageInfo.getLocale(), messageInfo.getGroupName(), messageInfo.getMessageKey(), messageInfo, ContextUtils.getContextInfo());
43 } catch (DataValidationErrorException ex) {
44
45 throw new OperationFailedException ("data errors", ex);
46 }
47
48 }
49
50 @Override
51 public ArrayList<String> getMessageGroups()
52 throws InvalidParameterException,
53 MissingParameterException,
54 OperationFailedException,
55 PermissionDeniedException {
56 return new ArrayList (serviceImpl.getMessageGroupKeys(ContextUtils.getContextInfo()));
57 }
58
59
60
61 @Override
62 public ArrayList<LocaleInfo> getLocales() throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
63 return new ArrayList (serviceImpl.getLocales(ContextUtils.getContextInfo()));
64 }
65
66 @Override
67 public MessageInfo getMessage(String localeKey, String messageGroupKey, String messageKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
68 LocaleInfo localeInfo = new LocaleInfo();
69 localeInfo.setLocaleLanguage(localeKey);
70 return serviceImpl.getMessage(localeInfo, messageGroupKey, messageKey, ContextUtils.getContextInfo());
71 }
72
73 @Override
74 public ArrayList<MessageInfo> getMessagesByGroup(String localeKey, String messageGroupKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
75 LocaleInfo localeInfo = new LocaleInfo();
76 localeInfo.setLocaleLanguage(localeKey);
77 return new ArrayList (serviceImpl.getMessagesByGroup(localeInfo, messageGroupKey, ContextUtils.getContextInfo()));
78 }
79
80 @Override
81 public ArrayList<MessageInfo> getMessagesByGroups(String localeKey, ArrayList<String> messageGroupKeys) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
82 LocaleInfo localeInfo = new LocaleInfo();
83 localeInfo.setLocaleLanguage(localeKey);
84 return new ArrayList (serviceImpl.getMessagesByGroups(localeInfo, messageGroupKeys, ContextUtils.getContextInfo()));
85 }
86
87 @Override
88 public MessageInfo updateMessage(String localeKey, String messageGroupKey, String messageKey, MessageInfo messageInfo)
89 throws DoesNotExistException,
90 InvalidParameterException,
91 MissingParameterException,
92 OperationFailedException,
93 PermissionDeniedException,
94 ReadOnlyException,
95 VersionMismatchException {
96 LocaleInfo localeInfo = new LocaleInfo();
97 localeInfo.setLocaleLanguage(localeKey);
98 try {
99 return serviceImpl.updateMessage(localeInfo, messageGroupKey, messageKey, messageInfo, ContextUtils.getContextInfo());
100 } catch (DataValidationErrorException ex) {
101
102 throw new OperationFailedException ("data errors", ex);
103 }
104 }
105
106 public MessageService getServiceImpl() {
107 return serviceImpl;
108 }
109
110 public void setServiceImpl(MessageService impl) {
111 this.serviceImpl = impl;
112 }
113
114 }