/**
 * Copyright  2001 The JA-SIG Collaborative.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the JA-SIG Collaborative
 *    (http://www.jasig.org/)."
 *
 * THIS SOFTWARE IS PROVIDED BY THE JA-SIG COLLABORATIVE "AS IS" AND ANY
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JA-SIG COLLABORATIVE OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */

package  org.jasig.portal.channels.groupsmanager.commands;

import org.jasig.portal.channels.groupsmanager.*;
import org.jasig.portal.services.*;
import org.jasig.portal.*;
import org.jasig.portal.channels.permissionsmanager.*;
import java.util.*;

/**
 * A Groups Manager command to instantiate a permissions manager servant
 *
 * @author Alex Vigdor
 * @version $Revision$
 */
public class AssignPermissions extends GroupsManagerCommand {

  public AssignPermissions() {
  }

   /**
    * put your documentation comment here
    * @throws Exception
    * @param sessionData
    */
   public void execute(CGroupsManagerSessionData sessionData) throws Exception{
      ChannelRuntimeData slaveRD = sessionData.runtimeData;
      String[] tgts = new String[1];
      tgts[0] = this.getCommandArg(sessionData.runtimeData);
      sessionData.servantChannel = CPermissionsManagerServantFactory.getPermissionsServant((IPermissible)Class.forName(OWNER).newInstance(),
            sessionData.staticData, null, null, tgts);
      slaveRD = (ChannelRuntimeData)sessionData.runtimeData.clone();
      Enumeration srd = slaveRD.keys();
      while (srd.hasMoreElements()) {
         slaveRD.remove(srd.nextElement());
      }
      sessionData.runtimeData = slaveRD;
   }
}
@@ -1840,16 +1840,50 @@
 .util.*;
+%0Aimport org.jasig.portal.groups.*;
 %0A%0A/**%0A *
@@ -2066,16 +2066,49 @@
 Command 
+implements GroupsManagerConstants
 %7B%0A%0A  pub
@@ -2430,17 +2430,145 @@
     
-tgts%5B0%5D =
+String%5B%5D acts = null;%0A      IEntityGroup g = (IEntityGroup) GroupsManagerXML.retrieveGroupMemberForElementId(this.getXmlDoc(sessionData),
  thi
@@ -2607,18 +2607,249 @@
 imeData)
+)
 ;%0A
+      tgts%5B0%5D = g.getKey();%0A      if (g.isEditable())%7B%0A         acts = sessionData.permissible.getActivityTokens();%0A      %7D%0A      else%7B%0A        acts = new String%5B%5D %7BVIEW_PERMISSION, SELECT_PERMISSION, ASSIGN_PERMISSION%7D; %0A      %7D%0A
       se
@@ -2935,56 +2935,31 @@
 ant(
-(IPermissible)Class.forName(OWNER).newInstance()
+sessionData.permissible
 ,%0A  
@@ -2998,20 +2998,20 @@
 , null, 
-null
+acts
 , tgts);

fix target acquisition bug, prune activity set when group is not editable