All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.internet2.middleware.grouper.app.gsh.delMember Maven / Gradle / Ivy

There is a newer version: 5.13.5
Show newest version
/**
 * Copyright 2014 Internet2
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 * Copyright (C) 2006-2007 blair christensen.
 * All Rights Reserved.
 *
 * You may use and distribute under the same terms as Grouper itself.
 */

package edu.internet2.middleware.grouper.app.gsh;
import bsh.CallStack;
import bsh.Interpreter;
import edu.internet2.middleware.grouper.Group;
import edu.internet2.middleware.grouper.GroupFinder;
import edu.internet2.middleware.grouper.GrouperSession;
import edu.internet2.middleware.grouper.Field;
import edu.internet2.middleware.grouper.Member;
import edu.internet2.middleware.grouper.SubjectFinder;
import edu.internet2.middleware.grouper.exception.GroupNotFoundException;
import edu.internet2.middleware.grouper.exception.InsufficientPrivilegeException;
import edu.internet2.middleware.grouper.exception.MemberDeleteException;
import edu.internet2.middleware.grouper.exception.SchemaException;
import edu.internet2.middleware.subject.Subject;
import edu.internet2.middleware.subject.SubjectNotFoundException;
import edu.internet2.middleware.subject.SubjectNotUniqueException;

/**
 * Delete a member.
 * 

* @author blair christensen. * @version $Id: delMember.java,v 1.5 2009-11-02 03:50:51 mchyzer Exp $ * @since 0.0.1 */ public class delMember { // PUBLIC CLASS METHODS // /** * Delete a member. *

* @param i BeanShell interpreter. * @param stack BeanShell call stack. * @param group Delete {@link Member} from {@link Group} with this name. * @param subjId Delete {@link Subject} with this subject id as a member. * @return True if succeeds. * @throws GrouperShellException * @since 0.0.1 */ public static boolean invoke( Interpreter i, CallStack stack, String group, String subjId ) throws GrouperShellException { GrouperShell.setOurCommand(i, true); try { GrouperSession s = GrouperShell.getSession(i); return invoke(s, group, subjId, Group.getDefaultList()); } catch (GroupNotFoundException eGNF) { GrouperShell.error(i, eGNF); } catch (InsufficientPrivilegeException eIP) { GrouperShell.error(i, eIP); } catch (MemberDeleteException eMD) { GrouperShell.error(i, eMD); } catch (SubjectNotFoundException eSNF) { GrouperShell.error(i, eSNF); } catch (SubjectNotUniqueException eSNU) { GrouperShell.error(i, eSNU); } return false; } // public static boolean invoke(i, stack, group, subjId) /** * Delete a member. *

* @param i BeanShell interpreter. * @param stack BeanShell call stack. * @param group Delete {@link Member} from {@link Group} with this name. * @param subjId Delete {@link Subject} with this subject id as a member. * @param field * @return True if succeeds. * @throws GrouperShellException * @since 0.0.1 */ public static boolean invoke( Interpreter i, CallStack stack, String group, String subjId, Field field ) throws GrouperShellException { GrouperShell.setOurCommand(i, true); try { GrouperSession s = GrouperShell.getSession(i); return invoke(s, group, subjId, field); } catch (GroupNotFoundException eGNF) { GrouperShell.error(i, eGNF); } catch (InsufficientPrivilegeException eIP) { GrouperShell.error(i, eIP); } catch (MemberDeleteException eMD) { GrouperShell.error(i, eMD); } catch (SubjectNotFoundException eSNF) { GrouperShell.error(i, eSNF); } catch (SubjectNotUniqueException eSNU) { GrouperShell.error(i, eSNU); } catch (SchemaException e) { GrouperShell.error(i, e); } return false; } /** * Delete a member. *

* @param grouperSession * @param group Delete {@link Member} from {@link Group} with this name. * @param subjId Delete {@link Subject} with this subject id as a member. * @param field * @return True if succeeds. */ public static boolean invoke(GrouperSession grouperSession, String group, String subjId, Field field) { Group g = GroupFinder.findByName(grouperSession, group, true); Subject subj = SubjectFinder.findByIdOrIdentifier(subjId, true); g.deleteMember(subj, field); return true; } } // public class delMember





© 2015 - 2024 Weber Informatics LLC | Privacy Policy