View Javadoc

1   /**
2    * Copyright 2005-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kim.web.struts.action;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.apache.log4j.Logger;
20  import org.kuali.rice.core.api.util.RiceKeyConstants;
21  import org.kuali.rice.kim.api.KimConstants;
22  import org.kuali.rice.kim.api.group.Group;
23  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
24  import org.kuali.rice.kim.web.struts.form.IdentityManagementDocumentFormBase;
25  import org.kuali.rice.kim.web.struts.form.IdentityManagementGroupDocumentForm;
26  import org.kuali.rice.krad.util.GlobalVariables;
27  import org.kuali.rice.krad.util.KRADConstants;
28  
29  import javax.servlet.http.HttpServletRequest;
30  
31  /**
32   * This is a description of what this class does - jonathan don't forget to fill this in. 
33   * 
34   * @author Kuali Rice Team (rice.collab@kuali.org)
35   *
36   */
37  public class IdentityManagementGroupInquiry extends IdentityManagementBaseInquiryAction {
38  	private static final Logger LOG = Logger.getLogger(IdentityManagementGroupInquiry.class);	
39  	
40  	/**
41  	 * This overridden method ...
42  	 * 
43  	 * @see org.kuali.rice.kim.web.struts.action.IdentityManagementBaseInquiryAction#loadKimObject(javax.servlet.http.HttpServletRequest, org.kuali.rice.kim.web.struts.form.IdentityManagementDocumentFormBase)
44  	 */
45  	@Override
46  	protected void loadKimObject(HttpServletRequest request, IdentityManagementDocumentFormBase form) {
47          IdentityManagementGroupDocumentForm groupDocumentForm = (IdentityManagementGroupDocumentForm) form;
48          String groupId = request.getParameter(KimConstants.PrimaryKeyConstants.GROUP_ID);
49          
50          Group group = null;
51          if (StringUtils.isNotEmpty(groupId)) {
52          	group = KimApiServiceLocator.getGroupService().getGroup(groupId);
53          } else {
54          	String namespaceCode = request.getParameter(KimConstants.UniqueKeyConstants.NAMESPACE_CODE);
55          	String groupName = request.getParameter(KimConstants.UniqueKeyConstants.GROUP_NAME);
56          	
57          	if (!StringUtils.isBlank(namespaceCode) && !StringUtils.isBlank(groupName)) {
58          		group = KimApiServiceLocator.getGroupService().getGroupByNamespaceCodeAndName(namespaceCode, groupName);
59              }
60          }
61          if (group != null) {
62          	getUiDocumentService().loadGroupDoc(groupDocumentForm.getGroupDocument(), group);
63          } else {
64          	LOG.error("No records found for Group Inquiry.");
65              GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, RiceKeyConstants.ERROR_INQUIRY);
66          }
67  	}
68  	
69  }