public void main(IWContext iwc) throws Exception {
    ELUtil.getInstance().autowire(this);

    String val = iwc.getParameter("submitBtn");
    if (!StringUtil.isEmpty(val)) {
      dao.createDish(
          iwc.getParameter("dishName"),
          iwc.getParameter("dishDescription"),
          iwc.getParameter("dishPrice"));
    }

    Layer container = new Layer(); // 	<div>
    add(container);

    IWResourceBundle iwrb = getResourceBundle(iwc);

    Form form = new Form();
    container.add(form);

    createField(form, "Dish", "dish_name", new TextInput("dishName"), iwrb);
    createField(form, "Description", "description", new TextArea("dishDescription"), iwrb);
    createField(form, "Price", "price", new TextInput("dishPrice"), iwrb);

    SubmitButton submitBtn =
        new SubmitButton("submitBtn", iwrb.getLocalizedString("submit", "Submit"));
    form.add(submitBtn);
  }
  public boolean initializeEvent(IWContext iwc) {
    this._appId = iwc.getParameter(IW_FRAMESET_PAGE_PARAMETER);
    this._src = iwc.getParameter(PRM_IW_BROWSE_EVENT_SOURCE);
    this._ctrlTarget = iwc.getParameter(IW_FRAME_NAME_PARAMETER);

    return (this._appId != null && this._src != null && this._ctrlTarget != null);
  }
    public void main(IWContext iwc) throws Exception {

      Form myForm = new Form();
      myForm.maintainParameter(_PARAMETER_GROUP_ID);

      int groupId = -1;
      try {
        groupId = Integer.parseInt(iwc.getParameter(_PARAMETER_GROUP_ID));
      } catch (Exception ex) {
        // do Nothing
      }

      if (iwc.getParameter("commit") != null) {

        // Save

        // System.out.println("----------------------------");
        // System.out.println("users: "+iwc.getParameterValues(_USERS_RELATED));

        UserGroupBusiness.updateUsersInGroup(groupId, iwc.getParameterValues(_USERS_RELATED));

        this.setParentToReload();
        this.close();

      } else {
        UserList uList = new UserList(_USERS_RELATED);

        List lDirect =
            com.idega.core.user.business.UserGroupBusiness.getUsersContainedDirectlyRelated(
                groupId);
        Set direct = new HashSet();
        if (lDirect != null) {
          Iterator iter = lDirect.iterator();
          while (iter.hasNext()) {
            User item = (User) iter.next();
            direct.add(Integer.toString(item.getGroupID()));
          }
        }
        uList.setDirectlyRelatedUserIds(direct);

        List lNotDirect =
            com.idega.core.user.business.UserGroupBusiness.getUsersContainedNotDirectlyRelated(
                groupId);
        Set notDirect = new HashSet();
        if (lNotDirect != null) {
          Iterator iter2 = lNotDirect.iterator();
          while (iter2.hasNext()) {
            User item = (User) iter2.next();
            notDirect.add(Integer.toString(item.getGroupID()));
          }
        }
        uList.setRelatedUserIdsNotDirectly(notDirect);

        myForm.add(uList);

        myForm.add(new SubmitButton("commit", "    OK   "));
        myForm.add(new CloseButton("  Cancel  "));
        this.add(myForm);
      }
    }
  public void main(IWContext iwc) throws Exception {
    try {
      if (iwc.isParameterSet(PARAMETER_RACE)) {
        race =
            ConverterUtility.getInstance()
                .convertGroupToRace(new Integer(iwc.getParameter(PARAMETER_RACE)));
      }
    } catch (Exception e) {
    }

    Layer layer = new Layer(Layer.DIV);
    layer.setStyleClass("raceElement");
    layer.setID("raceParticipants");

    Layer headerLayer = new Layer(Layer.DIV);
    headerLayer.setStyleClass("raceParticipantsHeader");
    layer.add(headerLayer);

    Layer headingLayer = new Layer(Layer.DIV);
    headingLayer.setStyleClass("raceParticipantHeading");
    headingLayer.add(new Text(getHeading()));
    headerLayer.add(headingLayer);

    layer.add(getRaceParticipantList(iwc));

    add(layer);
  }
  private String getFeedByEvents(String extraURI, RSSRequest rssRequest) {
    IWContext iwc = getIWContext(rssRequest);
    String uri = extraURI.substring("group/".length(), extraURI.length());
    String feedFile =
        "events_" + getTypesString(uri) + getPeriod(uri) + iwc.getLocale().getLanguage() + ".xml";

    if (rssFileURIsCacheList.contains(feedFile)) return feedFile;
    String events = extraURI.substring("events/".length());
    String eventsPeriod = null;
    List eventsList = new ArrayList();
    int index = -1;
    String title = "";
    if (events.indexOf("+") == -1) {
      eventsList.add(events.substring(0, events.indexOf("/")));
      events = events.substring(events.indexOf("/") + 1, events.length());
    } else {
      while (true) {
        index = events.indexOf("+");
        if (index == -1) {
          index = events.indexOf("/");
          eventsList.add(events.substring(0, index));
          events = events.substring(index + 1, events.length());
          title = title + events.substring(0, index);
          break;
        } else {
          title = title + events.substring(0, index) + ", ";
          eventsList.add(events.substring(0, index));
          events = events.substring(index + 1, events.length());
        }
      }
    }

    eventsPeriod = events;
    Timestamp from = null;
    Timestamp to = null;
    CalBusiness calendar = new CalBusinessBean();
    List entries = null;
    if (eventsPeriod.length() != 0) {
      String fromStr = eventsPeriod.substring(0, DATE_LENGTH);
      String toStr = eventsPeriod.substring(DATE_LENGTH + 1, eventsPeriod.length() - 1);
      from = getTimeStampFromString(fromStr);
      to = getTimeStampFromString(toStr);
      Collection coll = calendar.getEntriesBetweenTimestamps(from, to);
      entries = new ArrayList();
      title = title + fromStr + "-" + toStr;
      for (Iterator iter = coll.iterator(); iter.hasNext(); ) {
        CalendarEntry element = (CalendarEntry) iter.next();
        if (eventsList.contains(element.getEntryTypeName())) {
          entries.add(element);
        }
      }
    } else entries = new ArrayList(calendar.getEntriesByEvents(eventsList));

    if (entries.isEmpty())
      return getFeed(NO_ENTRIES_FOUND_TITLE, NO_ENTRIES_FOUND_FILE, null, rssRequest, iwc);
    else {
      return getFeed(title, feedFile, entries, rssRequest, iwc);
    }
  }
  @Override
  public void handleRSSRequest(RSSRequest rssRequest) throws IOException {
    String feedParentFolder = null;
    String feedFile = null;
    String category = getCategory(rssRequest.getExtraUri());
    String extraURI = rssRequest.getExtraUri();
    if (extraURI == null) {
      extraURI = CoreConstants.EMPTY;
    }
    if ((!extraURI.endsWith(CoreConstants.SLASH)) && (extraURI.length() != 0)) {
      extraURI = extraURI.concat(CoreConstants.SLASH);
    }

    List<String> categories = new ArrayList<String>();
    List<String> articles = new ArrayList<String>();
    if (category != null) categories.add(category);

    IWContext iwc = getIWContext(rssRequest);
    String language = iwc.getLocale().getLanguage();

    if (StringUtil.isEmpty(extraURI)) {
      feedParentFolder = ARTICLE_RSS;
      feedFile = "all_".concat(language).concat(".xml");
    } else if (category != null) {
      feedParentFolder =
          ARTICLE_RSS.concat("category/").concat(category).concat(CoreConstants.SLASH);
      feedFile = "feed_.".concat(language).concat(".xml");
    } else {
      //	Have page URI
      feedParentFolder = ARTICLE_RSS.concat("page/").concat(extraURI);
      feedFile = "feed_".concat(language).concat(".xml");
      categories = getCategoriesByURI(extraURI, iwc);
      if (ListUtil.isEmpty(categories)) {
        articles = getArticlesByURI(extraURI, iwc);
      }
    }

    String realURI = CoreConstants.WEBDAV_SERVLET_URI + feedParentFolder + feedFile;
    if (rssFileURIsCacheList.contains(feedFile)) {
      try {
        this.dispatch(realURI, rssRequest);
      } catch (ServletException e) {
        LOGGER.log(Level.WARNING, "Error dispatching: " + realURI, e);
      }
    } else {
      //	Generate RSS and store and the dispatch to it and add a listener to that directory
      try {
        // todo code the 3 different cases (see description)
        searchForArticles(rssRequest, feedParentFolder, feedFile, categories, articles, extraURI);
        rssFileURIsCacheList.add(feedFile);

        this.dispatch(realURI, rssRequest);
      } catch (Exception e) {
        LOGGER.log(Level.WARNING, "Error while searching or dispatching: " + realURI, e);
        throw new IOException(e.getMessage());
      }
    }
  }
  public Table getNavigationTable(IWContext iwc) {

    int usersSize = 0;
    if (this.users != null) {
      usersSize = this.users.size();
    }

    int maxPage = (int) Math.ceil(usersSize / this.USERS_PER_PAGE);

    Table navigationTable = new Table(3, 1);
    navigationTable.setCellpadding(2);
    navigationTable.setCellspacing(0);
    navigationTable.setWidth(Table.HUNDRED_PERCENT);
    navigationTable.setBorder(0);
    navigationTable.setWidth(1, "33%");
    navigationTable.setWidth(2, "33%");
    navigationTable.setWidth(3, "33%");
    navigationTable.setAlignment(2, 1, Table.HORIZONTAL_ALIGN_CENTER);
    navigationTable.setAlignment(3, 1, Table.HORIZONTAL_ALIGN_RIGHT);

    Text prev = getSmallText(localize("previous", "Previous"));
    Text next = getSmallText(localize("next", "Next"));
    Text info =
        getSmallText(
            localize("page", "Page")
                + " "
                + (this.currentPage + 1)
                + " "
                + localize("of", "of")
                + " "
                + (maxPage + 1));
    if (this.currentPage > 0) {
      Link lPrev = getLink(getSmallText(localize("previous", "Previous")), iwc);
      lPrev.addParameter(this.PARAMETER_CURRENT_PAGE, Integer.toString(this.currentPage - 1));
      lPrev.addParameter(this.PARAMETER_SEARCH, iwc.getParameter(this.PARAMETER_SEARCH));
      if (this.showAll) {
        lPrev.addParameter(this.PARAMETER_VIEW_ALL, "true");
      }
      navigationTable.add(lPrev, 1, 1);
    } else {
      navigationTable.add(prev, 1, 1);
    }
    navigationTable.add(info, 2, 1);

    if (this.currentPage < maxPage) {
      Link lNext = getLink(getSmallText(localize("next", "Next")), iwc);
      lNext.addParameter(this.PARAMETER_CURRENT_PAGE, Integer.toString(this.currentPage + 1));
      lNext.addParameter(this.PARAMETER_SEARCH, iwc.getParameter(this.PARAMETER_SEARCH));
      if (this.showAll) {
        lNext.addParameter(this.PARAMETER_VIEW_ALL, "true");
      }
      navigationTable.add(lNext, 3, 1);
    } else {
      navigationTable.add(next, 3, 1);
    }
    return navigationTable;
  }
 private void clearApplicationCategoryViewerCache(IWContext iwc) {
   IWCacheManager2 cacheManager = IWCacheManager2.getInstance(iwc.getIWMainApplication());
   Map<Serializable, ?> cache = cacheManager.getCache(ApplicationCategoryViewer.CACHE_KEY);
   if (cache != null) {
     cache.clear();
   }
   BuilderLogic.getInstance().clearAllCaches();
   IWCacheManager.getInstance(iwc.getIWMainApplication()).clearAllCaches();
 }
  private String getFeedByLedger(String extraURI, RSSRequest rssRequest) {
    IWContext iwc = getIWContext(rssRequest);
    //		String feedFile = "ledger_"+extraURI.substring("ledger/".length(),
    // extraURI.length()-1)+"_"+iwc.getLocale().getLanguage()+".xml";
    String uri = extraURI.substring("ledger/".length(), extraURI.length());
    String feedFile =
        "ledger_" + getName(uri) + getPeriod(uri) + "_" + iwc.getLocale().getLanguage() + ".xml";
    if (rssFileURIsCacheList.contains(feedFile)) return PATH_TO_FEED_PARENT_FOLDER + feedFile;
    String ledger = extraURI.substring("ledger/".length());
    String ledgerID = ledger.substring(0, ledger.indexOf("/"));
    String ledgerPeriod = ledger.substring(ledgerID.length() + 1, ledger.length());
    Timestamp from = null;
    Timestamp to = null;
    CalBusiness calendar = new CalBusinessBean();
    int ledgerIdInt;
    List entries = null;
    try {
      ledgerIdInt = Integer.parseInt(ledgerID);
    } catch (NumberFormatException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      return getFeed(
          INCORRECT_URI_TITLE, INCORRECT_URI_FILE, null, rssRequest, getIWContext(rssRequest));
    }

    LedgerVariationsHandler ledgerVariationsHandler = new DefaultLedgerVariationsHandler();
    String title =
        ((DefaultLedgerVariationsHandler) ledgerVariationsHandler)
            .getCalBusiness(iwc)
            .getLedger(Integer.parseInt(ledgerID))
            .getName();

    if (ledgerPeriod.length() != 0) {
      String fromStr = ledgerPeriod.substring(0, DATE_LENGTH);
      String toStr = ledgerPeriod.substring(DATE_LENGTH + 1, ledgerPeriod.length() - 1);
      from = getTimeStampFromString(fromStr);
      to = getTimeStampFromString(toStr);
      if (to.before(from))
        return getFeed(INCORRECT_PERIOD_TITLE, INCORRECT_PERIOD_FILE, null, rssRequest, iwc);
      title = title + " " + fromStr + "-" + toStr;
      Collection coll = calendar.getEntriesBetweenTimestamps(from, to);
      entries = new ArrayList();
      for (Iterator iter = coll.iterator(); iter.hasNext(); ) {
        CalendarEntry element = (CalendarEntry) iter.next();
        if (element.getLedgerID() == ledgerIdInt) {
          entries.add(element);
        }
      }
    } else entries = new ArrayList(calendar.getEntriesByLedgerID(ledgerIdInt));
    if (entries.isEmpty())
      return getFeed(NO_ENTRIES_FOUND_TITLE, NO_ENTRIES_FOUND_FILE, null, rssRequest, iwc);
    else {

      return getFeed(title, feedFile, entries, rssRequest, iwc);
    }
  }
  protected Locale getCurrentLocale() {
    IWContext iwc = CoreUtil.getIWContext();
    Locale locale = iwc == null ? null : iwc.getCurrentLocale();

    if (locale == null) {
      locale = IWMainApplication.getDefaultIWMainApplication().getDefaultLocale();
    }

    return locale == null ? Locale.ENGLISH : locale;
  }
Exemple #11
0
 public static String readPersonId() {
   String personId = null;
   try {
     FacesContext context = FacesContext.getCurrentInstance();
     IWContext iwContext = IWContext.getIWContext(context);
     personId = iwContext.getCurrentUser().getPersonalID();
   } catch (Throwable ex) {
     log.warn("Unable to read Personal Id from IWContext", ex);
   }
   return personId == null ? EhealthConstants.DEFAULT_PERSON_ID : personId;
 }
  private int parseAction(final IWContext iwc) {
    int action = ACTION_VIEW_FORM;

    if (iwc.isParameterSet(PARAMETER_FORM_SUBMIT)) {
      action = ACTION_FORM_SUBMIT;
    } else if (iwc.isParameterSet(PARAMETER_CANCEL)) {
      action = ACTION_CANCEL;
    }

    return action;
  }
  public Collection<SearchResult> getArticleSearchResults(
      String folder, List<String> categories, IWContext iwc) {
    if (folder == null) {
      return null;
    }
    if (iwc == null) {
      iwc = IWContext.getInstance();
      if (iwc == null) {
        return null;
      }
    }

    IWTimestamp oldest = null;

    if (this.numberOfDaysDisplayed > 0) {
      oldest = IWTimestamp.RightNow();
      oldest.addDays(-this.numberOfDaysDisplayed);
    }

    IWSlideSession session = null;
    try {
      session = (IWSlideSession) IBOLookup.getSessionInstance(iwc, IWSlideSession.class);
    } catch (IBOLookupException e) {
      e.printStackTrace();
      return null;
    }
    String webDavUri = null;
    try {
      webDavUri = session.getWebdavServerURI();
    } catch (RemoteException e) {
      e.printStackTrace();
    }
    if (webDavUri != null) {
      if (folder.startsWith(webDavUri)) {
        folder = folder.substring(webDavUri.length());
      }
      if (folder.startsWith(CoreConstants.SLASH)) {
        folder = folder.substring(1);
      }
    }
    SearchRequest articleSearch = null;
    try {
      articleSearch = getSearchRequest(folder, iwc.getCurrentLocale(), oldest, categories);
    } catch (SearchException e) {
      e.printStackTrace();
      return null;
    }
    ContentSearch searchBusiness = new ContentSearch(iwc.getIWMainApplication());
    searchBusiness.setToUseRootAccessForSearch(true);
    searchBusiness.setToUseDescendingOrder(true);
    Search search = searchBusiness.createSearch(articleSearch);
    return search.getSearchResults();
  }
  protected String getHost() {
    ICDomain domain = null;
    IWContext iwc = CoreUtil.getIWContext();
    if (iwc == null) {
      domain = IWMainApplication.getDefaultIWApplicationContext().getDomain();
    } else domain = iwc.getDomain();

    int port = domain.getServerPort();
    String host = domain.getServerProtocol().concat("://").concat(domain.getServerName());
    if (port > 0) host = host.concat(":").concat(String.valueOf(port));
    return host;
  }
 protected String getCacheState(IWContext iwc, String cacheStatePrefix) {
   Product prod = getSelectedProduct(iwc);
   //    System.out.println("[ProductCatalog] gettingCacheState");
   String returnString = cacheStatePrefix + getICObjectInstanceID();
   if (iwc.isParameterSet(CATEGORY_ID)) {
     returnString = returnString + "_" + iwc.getParameter(CATEGORY_ID);
   }
   if (prod != null) {
     returnString = returnString + "_" + prod.getID();
   }
   return returnString;
 }
 public Collection<Phone> getPhones() {
   IWContext iwc = getIwc();
   if (!iwc.isLoggedOn()) {
     return Collections.emptyList();
   }
   User user = iwc.getCurrentUser();
   @SuppressWarnings("unchecked")
   Collection<Phone> phones = user.getPhones();
   if (ListUtil.isEmpty(phones)) {
     return Collections.emptyList();
   }
   return phones;
 }
 public Collection<Email> getEmails() {
   IWContext iwc = getIwc();
   if (!iwc.isLoggedOn()) {
     return Collections.emptyList();
   }
   User user = iwc.getCurrentUser();
   @SuppressWarnings("unchecked")
   Collection<Email> emails = user.getEmails();
   if (ListUtil.isEmpty(emails)) {
     return Collections.emptyList();
   }
   return emails;
 }
  protected boolean doRedirectToLoginPage(
      ServerManager manager, ParameterList requestParameters, IWContext iwc, String realm) {
    boolean goToLogin = true;
    // Log user out if this is an authentication request for a new association
    // (i.e. another Relying Party or an expired association) or if this is a new request
    // after a completed successful one (loginExpireTime is removed on successful login)
    String loginExpireHandle =
        requestParameters.hasParameter(OpenIDConstants.PARAMETER_ASSOCIATE_HANDLE)
            ? "openid-login-"
                + requestParameters.getParameterValue(OpenIDConstants.PARAMETER_ASSOCIATE_HANDLE)
            : null;
    Date currentTime = new Date();
    if (loginExpireHandle == null) {
      String simpleRegHandle = "openid-simpleRegHandle-" + realm;
      Date loginExpirationTime = (Date) iwc.getSessionAttribute(simpleRegHandle);

      if (loginExpirationTime == null || currentTime.after(loginExpirationTime)) {
        if (iwc.isLoggedOn()) {
          // Make user log in again
          LoginBusinessBean loginBusiness = getLoginBusiness(iwc.getRequest());
          loginBusiness.logOutUser(iwc);
        }
        int expireInMilliSeconds = manager.getExpireIn() * 1000;
        iwc.setSessionAttribute(
            simpleRegHandle, new Date(currentTime.getTime() + expireInMilliSeconds));
        goToLogin = true;
      } else {
        // coming here again in the same request/association
        goToLogin = !iwc.isLoggedOn();
      }
    } else {
      Date loginExpirationTime = (Date) iwc.getSessionAttribute(loginExpireHandle);

      if (loginExpirationTime == null || currentTime.after(loginExpirationTime)) {
        if (iwc.isLoggedOn()) {
          // Make user log in again
          LoginBusinessBean loginBusiness = getLoginBusiness(iwc.getRequest());
          loginBusiness.logOutUser(iwc);
        }
        int expireInMilliSeconds = manager.getExpireIn() * 1000;
        iwc.setSessionAttribute(
            loginExpireHandle, new Date(currentTime.getTime() + expireInMilliSeconds));
        goToLogin = true;
      } else {
        // coming here again in the same request/association
        goToLogin = !iwc.isLoggedOn();
      }
    }
    return goToLogin;
  }
  protected void init(IWContext iwc) {
    this.form = new Form();
    this.form.maintainParameter(SchoolUserChooser.PARAMETER_SCHOOL_ID);

    this.searchString = iwc.getParameter(this.PARAMETER_SEARCH);
    this.iwrb =
        iwc.getIWMainApplication()
            .getBundle(BuilderConstants.STANDARD_IW_BUNDLE_IDENTIFIER)
            .getResourceBundle(iwc);
    this.showAll = iwc.isParameterSet(this.PARAMETER_VIEW_ALL);
    if (iwc.isParameterSet(this.PARAMETER_CURRENT_PAGE)) {
      this.currentPage = Integer.parseInt(iwc.getParameter(this.PARAMETER_CURRENT_PAGE));
    }
    try {
      SchoolUserBusiness biz = getSchoolUserBusiness(iwc);
      int[] userTypes = {
        SchoolUserBusinessBean.USER_TYPE_HEADMASTER,
        SchoolUserBusinessBean.USER_TYPE_ASSISTANT_HEADMASTER,
        SchoolUserBusinessBean.USER_TYPE_IB_COORDINATOR,
        SchoolUserBusinessBean.USER_TYPE_STUDY_AND_WORK_COUNCEL,
        SchoolUserBusinessBean.USER_TYPE_TEACHER,
        SchoolUserBusinessBean.USER_TYPE_WEB_ADMIN,
        SchoolUserBusinessBean.USER_TYPE_SCHOOL_MASTER,
        SchoolUserBusinessBean.USER_TYPE_CONTACT_PERSON,
        SchoolUserBusinessBean.USER_TYPE_EXPEDITION,
        SchoolUserBusinessBean.USER_TYPE_PROJECT_MANAGER
      };

      School prov = getProvider(iwc);

      if (prov == null) {
        SchoolUserHome userHome;
        userHome = (SchoolUserHome) IDOLookup.getHome(SchoolUser.class);
        Collection schoolUsers = userHome.findByTypes(userTypes);

        this.users = new Vector();
        Iterator iter = schoolUsers.iterator();
        while (iter.hasNext()) {
          SchoolUser sUser = (SchoolUser) iter.next();
          this.users.add(sUser.getUser());
        }
      } else {
        this.users = biz.getUsers(prov, userTypes);
      }
    } catch (FinderException ex) {
      ex.printStackTrace();
    } catch (RemoteException ex) {
      ex.printStackTrace();
    }
  }
 private boolean isAllowAction(IWContext iwc) {
   Object allowValue = iwc.getRequest().getAttribute(OpenIDConstants.PARAMETER_ALLOWED);
   if (allowValue != null) {
     return true;
   } else {
     String paramValue = iwc.getParameter(OpenIDConstants.PARAMETER_ALLOWED);
     String sessionValue = (String) iwc.getSessionAttribute(OpenIDConstants.PARAMETER_ALLOWED);
     iwc.removeSessionAttribute(OpenIDConstants.PARAMETER_ALLOWED);
     if (paramValue != null && paramValue.equals(sessionValue)) {
       iwc.getRequest().setAttribute(OpenIDConstants.PARAMETER_ALLOWED, "true");
       return true;
     }
   }
   return false;
 }
  protected User getCurrentUser() {
    User user = null;
    try {
      LoginSession loginSession = ELUtil.getInstance().getBean(LoginSession.class);
      user = loginSession.getUser();
    } catch (Exception e) {
      LOGGER.log(Level.WARNING, "Error getting current user");
    }

    if (user == null) {
      IWContext iwc = CoreUtil.getIWContext();
      user = iwc == null ? null : iwc.isLoggedOn() ? iwc.getCurrentUser() : null;
    }

    return user;
  }
  private User getPupilFromParam(IWContext iwc) throws RemoteException {
    User child = null;
    // Parameter name returning chosen User from SearchUserModule
    this.uniqueUserSearchParam = SearchUserModule.getUniqueUserParameterName(UNIQUE_SUFFIX);

    if (iwc.isParameterSet(PARAM_PUPIL_ID)) {
      String idStr = iwc.getParameter(PARAM_PUPIL_ID);
      int childID = Integer.parseInt(idStr);
      child = getUserBusiness(iwc).getUser(childID);
    } else if (iwc.isParameterSet(this.uniqueUserSearchParam)) {
      int childID = Integer.parseInt(iwc.getParameter(this.uniqueUserSearchParam));
      child = getUserBusiness(iwc).getUser(childID);
    }

    return child;
  }
  /**
   * Gets the scripts that is need for this element to work
   *
   * @return script files uris
   */
  public static List<String> getNeededScripts(IWContext iwc) {

    List<String> scripts = new ArrayList<String>();

    scripts.add(CoreConstants.DWR_ENGINE_SCRIPT);
    scripts.add(CoreConstants.DWR_UTIL_SCRIPT);

    Web2Business web2 = WFUtil.getBeanInstance(iwc, Web2Business.SPRING_BEAN_IDENTIFIER);
    if (web2 != null) {
      JQuery jQuery = web2.getJQuery();
      scripts.add(jQuery.getBundleURIToJQueryLib());

      scripts.add(web2.getBundleUriToHumanizedMessagesScript());

    } else {
      Logger.getLogger("ContentShareComponent")
          .log(
              Level.WARNING,
              "Failed getting Web2Business no jQuery and it's plugins files were added");
    }

    IWMainApplication iwma = iwc.getApplicationContext().getIWMainApplication();
    IWBundle iwb = iwma.getBundle(UserConstants.IW_BUNDLE_IDENTIFIER);
    scripts.add(iwb.getVirtualPathWithFileNameString("javascript/GroupJoinerHelper.js"));
    scripts.add("/dwr/interface/GroupService.js");

    return scripts;
  }
 public void main(IWContext iwc) throws Exception {
   super.main(iwc);
   init(iwc);
   setTitle(this.iwrb.getLocalizedString(WINDOW_NAME, "Update League Template Window"));
   addTitle(
       this.iwrb.getLocalizedString(WINDOW_NAME, "Update League Template Window"),
       TITLE_STYLECLASS);
   if (this.group != null) {
     if (this.group.getGroupType().equals(IWMemberConstants.GROUP_TYPE_CLUB_DIVISION_TEMPLATE)
         || this.group.getGroupType().equals(IWMemberConstants.GROUP_TYPE_LEAGUE)) {
       String action = iwc.getParameter(ACTION);
       if (action == null) {
         addForm(iwc);
       } else if (action.equals(ACTION_CANCEL)) {
         close();
       } else if (action.equals(ACTION_UPDATE)) {
         addInfo(iwc);
         updateChildren(iwc);
       }
     } else {
       add(
           this.iwrb.getLocalizedString(
               WRONG_GROUP_TYPE,
               "Please select either a league, or a division template under a league."));
     }
   } else {
     add(
         this.iwrb.getLocalizedString(
             WRONG_GROUP_TYPE,
             "Please select either a league, or a division template under a league."));
   }
 }
 private DropdownMenu getDropDownOfQueries(String key, IWContext iwc)
     throws RemoteException, FinderException {
   SortedMap sortedMap = new TreeMap(new StringAlphabeticalComparator(iwc.getCurrentLocale()));
   DropdownMenu drp = new DropdownMenu(key);
   Iterator iterator = getQueryService(iwc).getQueries(iwc).iterator();
   while (iterator.hasNext()) {
     EntityRepresentation userQuery = (EntityRepresentation) iterator.next();
     String name = (String) userQuery.getColumnValue(QueryRepresentation.NAME_KEY);
     String id = userQuery.getPrimaryKey().toString();
     if (sortedMap.containsKey(name)) {
       // usually the items have different names therefore we implement
       // a very simple solution
       name += " (1)";
     }
     sortedMap.put(name, id);
   }
   Iterator sortedIterator = sortedMap.entrySet().iterator();
   while (sortedIterator.hasNext()) {
     Map.Entry entry = (Map.Entry) sortedIterator.next();
     String id = (String) entry.getValue();
     String name = (String) entry.getKey();
     drp.addMenuElement(id, name);
   }
   return drp;
 }
  public void main(IWContext iwc) throws Exception {
    _editPermission = (iwc.hasEditPermission(this) || this.isOwnerOfProject(iwc));
    Text tBreak = (Text) Text.getBreak().clone();
    tBreak.setFontSize(Text.FONT_SIZE_7_HTML_1);
    this.addAtBeginning(tBreak);

    IWBundle iwb = this.getBundle(iwc);
    IWResourceBundle iwrb = iwb.getResourceBundle(iwc);

    // this.addAtBeginning(new Text(this.getGroupName(),true,false,true));
    super.main(iwc);
    if (_editPermission) {
      Table table = new Table(8, 1);
      table.setHorizontalAlignment("left");
      table.setCellpadding(0);
      table.setCellpadding(0);

      table.setWidth(1, "6");
      table.setWidth(3, "6");
      table.setWidth(5, "12");
      table.setWidth(7, "6");

      //      table.add(getAddAndRemoveGroupLinkIcon(iwc, iwb),2,1);
      //      table.add(getAddAndRemoveGroupLink(iwc, iwrb),4,1);
      //
      //      table.add(getAddAndRemoveUserLinkIcon(iwc, iwb),6,1);
      //      table.add(getAddAndRemoveUserLink(iwc, iwrb),8,1);

      table.add(getAddAndRemoveUserLinkIcon(iwc, iwb), 2, 1);
      table.add(getAddAndRemoveUserLink(iwc, iwrb), 4, 1);

      this.add(table);
    }
  }
  /** @see com.idega.presentation.ui.InterfaceObject#handleKeepStatus(IWContext) */
  public void handleKeepStatus(IWContext iwc) {
    initilizeValues();
    String name = iwc.getParameter(getName());

    String nameDay = null;
    String nameMonth = null;
    String nameYear = null;
    if (name != null && !"".equals(name)) {
      nameDay = name.substring(8, 10);
      nameMonth = name.substring(5, 7);
      nameYear = name.substring(0, 4);
    }

    if (this.theDay != null && nameDay != null) {
      this.theDay.setSelectedElement(nameDay);
    }

    if (nameMonth != null) {
      this.theMonth.setSelectedElement(nameMonth);
    }

    if (this.theYear != null && nameYear != null) {
      this.theYear.setSelectedElement(nameYear);
    }

    if (name != null) {
      this.theWholeDate.setValue(name);
    }
  }
 private QueryService getQueryService(IWContext iwc) {
   try {
     return (QueryService)
         IBOLookup.getServiceInstance(iwc.getApplicationContext(), QueryService.class);
   } catch (RemoteException ex) {
     throw new RuntimeException("[QueryUploader]: Can't retrieve QueryService");
   }
 }
 @Override
 public void main(IWContext iwc) {
   empty();
   if (this.chooserButtonImage == null) {
     IWBundle iwb = iwc.getIWMainApplication().getBundle(CoreConstants.IW_USER_BUNDLE_IDENTIFIER);
     setChooseButtonImage(iwb.getImage("magnifyingglass.gif", "Choose"));
   }
 }
  private String getFeed(
      String title, String feedFileName, Collection entries, RSSRequest rssRequest, IWContext iwc) {
    if (rssFileURIsCacheList.contains(feedFileName))
      return PATH_TO_FEED_PARENT_FOLDER + feedFileName;
    Date now = new Date();
    RSSBusiness rss = null;
    try {
      rss = IBOLookup.getServiceInstance(iwc, RSSBusiness.class);
    } catch (IBOLookupException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    String serverName = iwc.getServerURL();
    serverName = serverName.substring(0, serverName.length() - 1);
    SyndFeed feed = null;

    feed =
        rss.createNewFeed(
            title,
            serverName,
            FEED_DESCRIPTION,
            "atom_1.0",
            iwc.getCurrentLocale().toString(),
            new Timestamp(now.getTime()));

    if (entries != null) feed.setEntries(getFeedEntries(entries));

    try {
      String feedContent = rss.convertFeedToAtomXMLString(feed);
      IWSlideService service = this.getIWSlideService(rssRequest);
      service.uploadFileAndCreateFoldersFromStringAsRoot(
          PATH_TO_FEED_PARENT_FOLDER,
          feedFileName,
          feedContent,
          RSSAbstractProducer.RSS_CONTENT_TYPE,
          true);
      rssFileURIsCacheList.add(feedFileName);
    } catch (RemoteException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return PATH_TO_FEED_PARENT_FOLDER + feedFileName;
  }