001 /**
002 * Copyright 2005-2012 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.kim.web.struts.action;
017
018 import org.apache.commons.lang.StringUtils;
019 import org.apache.log4j.Logger;
020 import org.kuali.rice.core.api.util.RiceKeyConstants;
021 import org.kuali.rice.kim.api.KimConstants;
022 import org.kuali.rice.kim.api.group.Group;
023 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
024 import org.kuali.rice.kim.web.struts.form.IdentityManagementDocumentFormBase;
025 import org.kuali.rice.kim.web.struts.form.IdentityManagementGroupDocumentForm;
026 import org.kuali.rice.krad.util.GlobalVariables;
027 import org.kuali.rice.krad.util.KRADConstants;
028
029 import javax.servlet.http.HttpServletRequest;
030
031 /**
032 * This is a description of what this class does - jonathan don't forget to fill this in.
033 *
034 * @author Kuali Rice Team (rice.collab@kuali.org)
035 *
036 */
037 public class IdentityManagementGroupInquiry extends IdentityManagementBaseInquiryAction {
038 private static final Logger LOG = Logger.getLogger(IdentityManagementGroupInquiry.class);
039
040 /**
041 * This overridden method ...
042 *
043 * @see org.kuali.rice.kim.web.struts.action.IdentityManagementBaseInquiryAction#loadKimObject(javax.servlet.http.HttpServletRequest, org.kuali.rice.kim.web.struts.form.IdentityManagementDocumentFormBase)
044 */
045 @Override
046 protected void loadKimObject(HttpServletRequest request, IdentityManagementDocumentFormBase form) {
047 IdentityManagementGroupDocumentForm groupDocumentForm = (IdentityManagementGroupDocumentForm) form;
048 String id = request.getParameter(KimConstants.PrimaryKeyConstants.GROUP_ID);
049 String altId = request.getParameter(KimConstants.AttributeConstants.GROUP_ID);
050
051 String groupId = StringUtils.isNotEmpty(id) ? id : altId;
052 Group group = null;
053 if (StringUtils.isNotEmpty(groupId)) {
054 group = KimApiServiceLocator.getGroupService().getGroup(groupId);
055 } else {
056 String namespaceCode = request.getParameter(KimConstants.UniqueKeyConstants.NAMESPACE_CODE);
057 String groupName = request.getParameter(KimConstants.UniqueKeyConstants.GROUP_NAME);
058
059 if (!StringUtils.isBlank(namespaceCode) && !StringUtils.isBlank(groupName)) {
060 group = KimApiServiceLocator.getGroupService().getGroupByNamespaceCodeAndName(namespaceCode, groupName);
061 }
062 }
063 if (group != null) {
064 getUiDocumentService().loadGroupDoc(groupDocumentForm.getGroupDocument(), group);
065 } else {
066 LOG.error("No records found for Group Inquiry.");
067 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, RiceKeyConstants.ERROR_INQUIRY);
068 }
069 }
070
071 }