Clover Coverage Report - Kuali Student 1.1.0-SNAPSHOT (Aggregated)
Coverage timestamp: Tue Feb 15 2011 04:04:07 EST
../../../../../../../img/srcFileCovDistChart0.png 48% of files have more coverage
23   92   7   5.75
4   56   0.3   4
4     1.75  
1    
 
  MessageRPCPreloader       Line # 36 23 0% 7 31 0% 0.0
 
No Tests
 
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.messages;
17   
18   
19    import java.lang.reflect.Method;
20    import java.util.Arrays;
21    import java.util.HashMap;
22    import java.util.Map;
23   
24    import org.apache.log4j.Logger;
25    import org.kuali.rice.core.resourceloader.GlobalResourceLoader;
26    import org.kuali.student.common.ui.server.gwt.MessagesRpcGwtServlet;
27    import org.kuali.student.common.ui.server.serialization.KSSerializationPolicy;
28    import org.kuali.student.common.ui.server.serialization.SerializationUtils;
29    import org.kuali.student.core.messages.dto.Message;
30    import org.kuali.student.core.messages.dto.MessageGroupKeyList;
31    import org.kuali.student.core.messages.dto.MessageList;
32    import org.kuali.student.core.messages.service.MessageService;
33   
34    import com.google.gwt.user.server.rpc.RPC;
35   
 
36    public class MessageRPCPreloader {
37    final Logger LOG = Logger.getLogger(MessageRPCPreloader.class);
38    private final String MESSAGE_SERVICE_MOCK = "ks.messageServiceMock";
39    private final String MESSAGE_SERVICE = "{http://student.kuali.org/wsdl/messages}MessageService";
40   
41    MessageService messageService;
42   
 
43  0 toggle public MessageRPCPreloader(){
44   
45    }
46   
 
47  0 toggle public MessageService getMessageService() {
48  0 if (messageService == null){
49  0 setMessageService((MessageService)GlobalResourceLoader.getService(MESSAGE_SERVICE_MOCK));
50  0 if (messageService == null){
51  0 setMessageService((MessageService)GlobalResourceLoader.getService(MESSAGE_SERVICE));
52    }
53    }
54  0 return messageService;
55    }
56   
 
57  0 toggle public void setMessageService(MessageService serviceImpl) {
58  0 this.messageService = serviceImpl;
59    }
60   
 
61  0 toggle public String getMessagesByGroupsEncodingString(String locale, String[] keys){
62  0 Method serviceMethod;
63  0 try {
64  0 serviceMethod = MessagesRpcGwtServlet.class.getMethod("getMessagesByGroups", String.class,MessageGroupKeyList.class);
65   
66  0 MessageGroupKeyList messageGroupKeyList = new MessageGroupKeyList();
67  0 messageGroupKeyList.setMessageGroupKeys(Arrays.asList(keys));
68   
69  0 MessageList messageList = getMessageService().getMessagesByGroups(locale,messageGroupKeyList);
70   
71  0 Map<Class<?>, Boolean> whitelist = new HashMap<Class<?>, Boolean>();
72  0 whitelist.put(MessageService.class, true);
73  0 whitelist.put(MessageList.class, true);
74  0 whitelist.put(MessageGroupKeyList.class,true);
75  0 whitelist.put(Message.class,true);
76  0 whitelist.put(MessageGroupKeyList.class,true);
77   
78  0 KSSerializationPolicy myPolicy = new KSSerializationPolicy(whitelist);
79   
80    //String serializedData = RPC.encodeResponseForSuccess(serviceMethod, messageList,KSSerializationPolicy.getInstance());
81  0 String serializedData = RPC.encodeResponseForSuccess(serviceMethod, messageList,myPolicy);
82   
83   
84  0 return SerializationUtils.escapeForSingleQuotedJavaScriptString(serializedData);
85    } catch (Exception e) {
86  0 LOG.error(e);
87  0 return "";
88    }
89   
90    }
91   
92    }