Coverage Report - org.kuali.student.common.ui.server.gwt.BaseRpcGwtServletAbstract
 
Classes in this File Line Coverage Branch Coverage Complexity
BaseRpcGwtServletAbstract
0%
0/78
0%
0/4
3
 
 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.gwt;
 17  
 
 18  
 import java.util.List;
 19  
 
 20  
 import org.apache.log4j.Logger;
 21  
 import org.kuali.rice.kim.service.PermissionService;
 22  
 import org.kuali.student.common.ui.client.service.BaseRpcService;
 23  
 import org.kuali.student.common.util.security.SecurityUtils;
 24  
 import org.kuali.student.core.dictionary.old.dto.ObjectStructure;
 25  
 import org.kuali.student.core.dictionary.service.old.DictionaryService;
 26  
 import org.kuali.student.core.exceptions.DoesNotExistException;
 27  
 import org.kuali.student.core.exceptions.InvalidParameterException;
 28  
 import org.kuali.student.core.exceptions.MissingParameterException;
 29  
 import org.kuali.student.core.exceptions.OperationFailedException;
 30  
 import org.kuali.student.core.search.dto.SearchCriteriaTypeInfo;
 31  
 import org.kuali.student.core.search.dto.SearchRequest;
 32  
 import org.kuali.student.core.search.dto.SearchResult;
 33  
 import org.kuali.student.core.search.dto.SearchResultTypeInfo;
 34  
 import org.kuali.student.core.search.dto.SearchTypeInfo;
 35  
 import org.kuali.student.core.search.service.SearchService;
 36  
 
 37  
 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
 38  
 
 39  
 /**
 40  
  * This abstract service delegates search & dictionary operations to the web service being remoted.
 41  
  * Extend this class for gwt servlets only if you the service being remoted has dictionary
 42  
  * and search operations 
 43  
  * 
 44  
  * @author Kuali Student Team
 45  
  *
 46  
  */
 47  0
 public abstract class BaseRpcGwtServletAbstract<SEI> extends RemoteServiceServlet implements BaseRpcService{
 48  0
         final Logger LOG = Logger.getLogger(BaseRpcGwtServletAbstract.class);
 49  
     private static final long serialVersionUID = 1L;
 50  
     
 51  
     protected SEI service;
 52  
     protected PermissionService permissionService;
 53  
         
 54  
     
 55  
     public SEI getService(){
 56  0
         return this.service;
 57  
     }
 58  
        
 59  
     public void setService(SEI service) {
 60  0
         this.service = service;
 61  0
     };
 62  
 
 63  
     public PermissionService getPermissionService() {
 64  0
             return permissionService;
 65  
     }
 66  
 
 67  
         public void setPermissionService(PermissionService permissionService) {
 68  0
             this.permissionService = permissionService;
 69  0
     }
 70  
 
 71  
         /**
 72  
      * @see org.kuali.student.core.dictionary.service.old.DictionaryService#getObjectStructure(java.lang.String)
 73  
      */
 74  
     @Override
 75  
     public ObjectStructure getObjectStructure(String objectTypeKey) {
 76  0
         return ((DictionaryService)getService()).getObjectStructure(objectTypeKey);        
 77  
     }
 78  
 
 79  
     /**
 80  
      * @see org.kuali.student.core.dictionary.service.old.DictionaryService#getObjectTypes()
 81  
      */
 82  
     @Override
 83  
     public List<String> getObjectTypes() {
 84  0
         return ((DictionaryService)getService()).getObjectTypes();
 85  
     }
 86  
     
 87  
     /**
 88  
      * @see org.kuali.student.core.search.service.SearchService#getSearchCriteriaType(java.lang.String)
 89  
      */
 90  
     @Override
 91  
     public SearchCriteriaTypeInfo getSearchCriteriaType(String searchCriteriaTypeKey){
 92  
         try {
 93  0
             return ((SearchService)getService()).getSearchCriteriaType(searchCriteriaTypeKey);
 94  0
         } catch (DoesNotExistException e) {
 95  0
                 LOG.error(e);
 96  0
         } catch (InvalidParameterException e) {
 97  0
                 LOG.error(e);
 98  0
         } catch (MissingParameterException e) {
 99  0
                 LOG.error(e);
 100  0
         } catch (OperationFailedException e) {
 101  0
                 LOG.error(e);
 102  0
         }
 103  
         
 104  0
         return null;
 105  
     }
 106  
     
 107  
     /**
 108  
      * @throws OperationFailedException 
 109  
      * @see org.kuali.student.core.search.service.SearchService#getSearchCriteriaTypes()
 110  
      */
 111  
     @Override
 112  
     public List<SearchCriteriaTypeInfo> getSearchCriteriaTypes(){
 113  
         try {
 114  0
             return ((SearchService)getService()).getSearchCriteriaTypes();
 115  0
         } catch (OperationFailedException e) {
 116  0
                 LOG.error(e);
 117  
         }
 118  0
         return null;
 119  
     }
 120  
     
 121  
     /**
 122  
      * @see org.kuali.student.core.search.service.SearchService#getSearchResultType(java.lang.String)
 123  
      */
 124  
     @Override
 125  
     public SearchResultTypeInfo getSearchResultType(String searchResultTypeKey){
 126  
         try {
 127  0
             return ((SearchService)getService()).getSearchResultType(searchResultTypeKey);
 128  0
         } catch (DoesNotExistException e) {
 129  0
                 LOG.error(e);
 130  0
         } catch (InvalidParameterException e) {
 131  0
                 LOG.error(e);
 132  0
         } catch (MissingParameterException e) {
 133  0
                 LOG.error(e);
 134  0
         } catch (OperationFailedException e) {
 135  0
                 LOG.error(e);
 136  0
         }
 137  0
         return null;
 138  
     }
 139  
     
 140  
     /**
 141  
      * @see org.kuali.student.core.search.service.SearchService#getSearchResultTypes()
 142  
      */
 143  
     @Override
 144  
     public List<SearchResultTypeInfo> getSearchResultTypes(){
 145  
         try {
 146  0
             return ((SearchService)getService()).getSearchResultTypes();
 147  0
         } catch (OperationFailedException e) {
 148  0
                 LOG.error(e);
 149  
         }
 150  0
         return null;
 151  
     }
 152  
     
 153  
     /**
 154  
      * @see org.kuali.student.core.search.service.SearchService#getSearchType(java.lang.String)
 155  
      */
 156  
     @Override
 157  
     public SearchTypeInfo getSearchType(String searchTypeKey){
 158  
         try {
 159  0
             return ((SearchService)getService()).getSearchType(searchTypeKey);
 160  0
         } catch (DoesNotExistException e) {
 161  0
                 LOG.error(e);
 162  0
         } catch (InvalidParameterException e) {
 163  0
                 LOG.error(e);
 164  0
         } catch (MissingParameterException e) {
 165  0
                 LOG.error(e);
 166  0
         } catch (OperationFailedException e) {
 167  0
                 LOG.error(e);
 168  0
         }
 169  0
         return null;
 170  
     }
 171  
     
 172  
     /**
 173  
      * @see org.kuali.student.core.search.service.SearchService#getSearchTypes()
 174  
      */
 175  
     @Override
 176  
     public List<SearchTypeInfo> getSearchTypes(){
 177  
         try {
 178  0
             return ((SearchService)getService()).getSearchTypes();
 179  0
         } catch (OperationFailedException e) {
 180  0
                 LOG.error(e);
 181  
         }
 182  0
         return null;
 183  
     }
 184  
     
 185  
     /**
 186  
      * @see org.kuali.student.core.search.service.SearchService#getSearchTypesByCriteria(java.lang.String)
 187  
      */
 188  
     @Override
 189  
     public List<SearchTypeInfo> getSearchTypesByCriteria(String searchCriteriaTypeKey){
 190  
         try {
 191  0
             return ((SearchService)getService()).getSearchTypes();
 192  0
         } catch (OperationFailedException e) {
 193  0
                 LOG.error(e);
 194  
         }
 195  0
         return null;
 196  
     }
 197  
     
 198  
     /**
 199  
      * @see org.kuali.student.core.search.service.SearchService#getSearchTypesByResult(java.lang.String)
 200  
      */
 201  
     @Override
 202  
     public List<SearchTypeInfo> getSearchTypesByResult(String searchResultTypeKey){
 203  
         try {
 204  0
             return ((SearchService)getService()).getSearchTypesByResult(searchResultTypeKey);
 205  0
         } catch (DoesNotExistException e) {
 206  0
                 LOG.error(e);
 207  0
         } catch (InvalidParameterException e) {
 208  0
                 LOG.error(e);
 209  0
         } catch (MissingParameterException e) {
 210  0
                 LOG.error(e);
 211  0
         } catch (OperationFailedException e) {
 212  0
                 LOG.error(e);
 213  0
         }
 214  0
         return null;
 215  
     }
 216  
     
 217  
     /**
 218  
      * @see org.kuali.student.core.search.service.SearchService#search(org.kuali.student.core.search.dto.SearchRequest)
 219  
      */
 220  
     @Override
 221  
     public SearchResult search(SearchRequest searchRequest) {                
 222  
         try {
 223  0
                         return ((SearchService)getService()).search(searchRequest);
 224  0
                 } catch (MissingParameterException e) {
 225  0
                         LOG.error(e);
 226  
                 } 
 227  0
                 return null;
 228  
     }        
 229  
 
 230  
         protected String getCurrentUser() {
 231  0
                 String username = SecurityUtils.getCurrentUserId();
 232  
                 //backdoorId is only for convenience
 233  0
                 if(username==null&&this.getThreadLocalRequest().getSession().getAttribute("backdoorId")!=null){
 234  0
                         username=(String)this.getThreadLocalRequest().getSession().getAttribute("backdoorId");
 235  
         }
 236  0
                 return username;
 237  
         }
 238  
 }