public String getGroupName() {
   if (groupId != -1) {
     try {
       GenericGroup gr =
           ((com.idega.core.data.GenericGroupHome)
                   com.idega.data.IDOLookup.getHomeLegacy(GenericGroup.class))
               .findByPrimaryKeyLegacy(groupId);
       return gr.getName();
     } catch (Exception ex) {
       return null;
     }
   }
   return null;
 }
    public void main(IWContext iwc) throws Exception {

      String save = iwc.getParameter("save");
      if (save != null) {
        String stringGroupId = iwc.getParameter(GroupGroupSetter.PARAMETER_GROUP_ID);
        int groupId = Integer.parseInt(stringGroupId);

        String[] related = iwc.getParameterValues(GroupGroupSetter.FIELDNAME_SELECTION_DOUBLE_BOX);

        GenericGroup group =
            ((com.idega.core.data.GenericGroupHome)
                    com.idega.data.IDOLookup.getHomeLegacy(GenericGroup.class))
                .findByPrimaryKeyLegacy(groupId);
        List currentRelationShip = group.getParentGroups();

        if (related != null) {

          if (currentRelationShip != null) {
            for (int i = 0; i < related.length; i++) {
              int id = Integer.parseInt(related[i]);
              GenericGroup gr =
                  ((com.idega.core.data.GenericGroupHome)
                          com.idega.data.IDOLookup.getHomeLegacy(GenericGroup.class))
                      .findByPrimaryKeyLegacy(id);
              if (!currentRelationShip.remove(gr)) {
                gr.addGroup(group);
              }
            }

            Iterator iter = currentRelationShip.iterator();
            while (iter.hasNext()) {
              Object item = iter.next();
              ((GenericGroup) item).removeGroup(group);
            }

          } else {
            for (int i = 0; i < related.length; i++) {
              ((com.idega.core.data.GenericGroupHome)
                      com.idega.data.IDOLookup.getHomeLegacy(GenericGroup.class))
                  .findByPrimaryKeyLegacy(Integer.parseInt(related[i]))
                  .addGroup(group);
            }
          }

        } else if (currentRelationShip != null) {
          Iterator iter = currentRelationShip.iterator();
          while (iter.hasNext()) {
            Object item = iter.next();
            ((GenericGroup) item).removeGroup(group);
          }
        }

        this.close();
        this.setParentToReload();
      } else {
        LineUpElements(iwc);
      }

      /*
            Enumeration enum = iwc.getParameterNames();
             System.err.println("--------------------------------------------------");
            if(enum != null){
              while (enum.hasMoreElements()) {
                Object item = enum.nextElement();
                if(item.equals("save")){
                  this.close();
                }
                String val[] = iwc.getParameterValues((String)item);
                System.err.print(item+" = ");
                if(val != null){
                  for (int i = 0; i < val.length; i++) {
                    System.err.print(val[i]+", ");
                  }
                }
                System.err.println();
              }
            }
      */
    }