/**
   * Restituisce la view della portlet.
   *
   * @param mapping The ActionMapping used to select this instance
   * @param form The optional ActionForm bean for this request (if any)
   * @param req The non-HTTP request we are processing
   * @param res The non-HTTP response we are creating
   * @return action forward
   * @throws Exception if the application business logic throws an exception.
   */
  private ActionForward processAction(
      final ActionMapping mapping,
      final ActionForm form,
      final HttpServletRequest req,
      final HttpServletResponse res)
      throws Exception {

    if (logger.isDebugEnabled()) {
      logger.debug("processAction - begin");
    }

    PortletRequest aReq = (PortletRequest) req.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);

    String hpmProcessId = ParamUtil.getString(req, KpeoplePortalConstants.HPM_PROCESS_ID);
    int idPatternType = ParamUtil.getInteger(req, "idPatternType");
    String patternName = ParamUtil.getString(req, "patternName");
    String redirectDettaglio = ParamUtil.getString(req, "redirectDettaglio");

    aReq.setAttribute(KpeoplePortalConstants.HPM_PROCESS_ID, hpmProcessId);
    aReq.setAttribute("idPatternType", idPatternType);
    aReq.setAttribute("patternName", patternName);
    aReq.setAttribute("redirectDettaglio", redirectDettaglio);

    //      recupero degli utenti dal servizio (utilizzato per gli autocomplete)
    req.setAttribute("allUsers", getAllUsers());

    if (idPatternType == PatternBrowserConstants.PATTERN_TYPE_RICHIEDI_CONTRIBUTO) {
      return mapping.findForward("/pattern-browser/create-pattern-richiedi-contributo");
    }
    if (idPatternType == PatternBrowserConstants.PATTERN_TYPE_DELEGA) {
      return mapping.findForward("/pattern-browser/create-pattern-delega");
    }
    if (idPatternType == PatternBrowserConstants.PATTERN_TYPE_ESCALATION) {
      return mapping.findForward("/pattern-browser/create-pattern-esclation");
    }
    if (idPatternType == PatternBrowserConstants.PATTERN_TYPE_PIANIFICA_RIUNIONE) {
      return mapping.findForward("/pattern-browser/create-pattern-pianifica-riunione");
    }
    if (idPatternType == PatternBrowserConstants.PATTERN_TYPE_RICHIEDI_AUTORIZZAZIONE) {
      return mapping.findForward("/pattern-browser/create-pattern-richiedi-autorizzazione");
    }
    if (idPatternType == PatternBrowserConstants.PATTERN_TYPE_SOLLECITO) {
      return mapping.findForward("/pattern-browser/create-pattern-sollecito");
    }

    if (logger.isDebugEnabled()) {
      logger.debug("processAction - end");
    }

    return mapping.findForward("/pattern-browser/view");
  }
Esempio n. 2
0
  /**
   * Restituisce la view della portlet.
   *
   * @param mapping The ActionMapping used to select this instance
   * @param form The optional ActionForm bean for this request (if any)
   * @param req The non-HTTP request we are processing
   * @param res The non-HTTP response we are creating
   * @return action forward
   * @throws Exception if the application business logic throws an exception.
   */
  private ActionForward processAction(
      final ActionMapping mapping,
      final ActionForm form,
      final HttpServletRequest req,
      final HttpServletResponse res)
      throws Exception {

    if (logger.isDebugEnabled()) {
      logger.debug("processAction - begin");
    }

    return mapping.findForward("/activities-browser/view");
  }
Esempio n. 3
0
  static {
    _allMediaGalleryMimeTypes.addAll(
        SetUtil.fromArray(PropsUtil.getArray(PropsKeys.DL_FILE_ENTRY_PREVIEW_AUDIO_MIME_TYPES)));
    _allMediaGalleryMimeTypes.addAll(
        SetUtil.fromArray(PropsUtil.getArray(PropsKeys.DL_FILE_ENTRY_PREVIEW_VIDEO_MIME_TYPES)));
    _allMediaGalleryMimeTypes.addAll(
        SetUtil.fromArray(PropsUtil.getArray(PropsKeys.DL_FILE_ENTRY_PREVIEW_IMAGE_MIME_TYPES)));

    _allMediaGalleryMimeTypesString = StringUtil.merge(_allMediaGalleryMimeTypes);

    String[] fileIcons = null;

    try {
      fileIcons = PropsUtil.getArray(PropsKeys.DL_FILE_ICONS);
    } catch (Exception e) {
      if (_log.isDebugEnabled()) {
        _log.debug(e, e);
      }

      fileIcons = new String[] {StringPool.BLANK};
    }

    for (int i = 0; i < fileIcons.length; i++) {

      // Only process non wildcard extensions

      if (!StringPool.STAR.equals(fileIcons[i])) {

        // Strip starting period

        String extension = fileIcons[i];

        if (extension.length() > 0) {
          extension = extension.substring(1);
        }

        _fileIcons.add(extension);
      }
    }

    String[] genericNames = PropsUtil.getArray(PropsKeys.DL_FILE_GENERIC_NAMES);

    for (String genericName : genericNames) {
      _populateGenericNamesMap(genericName);
    }
  }
  @Override
  public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception {

    long orderId = ParamUtil.getLong(request, PaypalConstants.PARAM_INVOICE);
    String status = ParamUtil.getString(request, PaypalConstants.PAYMENT_STATUS);

    LOG.info(String.format(LOG_NOTIFICATION, orderId, status));

    ShoppingOrder order = ShoppingOrderLocalServiceUtil.fetchShoppingOrder(orderId);
    List<ShoppingOrderItem> items = ShoppingOrderItemLocalServiceUtil.findByOrderId(orderId);

    if (items.isEmpty()) {
      LOG.error(String.format(LOG_UNKNOWN_ORDER, orderId));
      return null;
    }

    List<String> itemsIds = new ArrayList<String>();
    for (ShoppingOrderItem item : items) {
      itemsIds.add(Long.toString(item.getItemId()));
    }

    String query = PaypalConstants.PARAM_CMD + "=" + PaypalConstants.CMD_VALIDATE;

    Enumeration<String> enu = request.getParameterNames();

    while (enu.hasMoreElements()) {
      String name = enu.nextElement();
      String value = request.getParameter(name);
      if (LOG.isDebugEnabled()) LOG.debug(String.format(LOG_DEBUG_PARAM, name, value));
      query = query + "&" + name + "=" + HttpUtil.encodeURL(value);
    }

    if (LOG.isDebugEnabled()) LOG.debug(String.format(LOG_DEBUG_QUERY, query));

    URL url = new URL(PaypalConstants.PAYPAL_ENDPOINT);

    URLConnection urlc = url.openConnection();

    urlc.setDoOutput(true);
    urlc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

    PrintWriter pw = UnsyncPrintWriterPool.borrow(urlc.getOutputStream());

    pw.println(query);

    pw.close();

    UnsyncBufferedReader unsyncBufferedReader =
        new UnsyncBufferedReader(new InputStreamReader(urlc.getInputStream()));

    String payPalStatus = unsyncBufferedReader.readLine();

    unsyncBufferedReader.close();

    LOG.info(String.format(LOG_STATUS_RESPONSE, payPalStatus));

    if (payPalStatus.equals(PaypalConstants.TRANSACTION_VERIFIED)
        && status.equals(PaypalConstants.PAYMENT_COMPLETE)) {

      LOG.info(LOG_TRX_VERIFIED);

      order.setOrderStatus(OrderStatusEnum.PAID.toString());
      ShoppingOrderLocalServiceUtil.updateOrder(order);

      EmailNotificationUtil.sendEmailNotification(orderId);

    } else {
      LOG.error(LOG_TRX_ERROR);
    }

    return "/portal/paypal.jsp";
  }
  public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
    try {

      log.debug(":: VIEW STUDENT SEARCH " + this.viewJSP);

      PortletPreferences preferences = renderRequest.getPreferences();
      boolean showSearcher =
          GetterUtil.getBoolean(preferences.getValue("showSearcher", StringPool.TRUE));
      boolean showScreenName =
          GetterUtil.getBoolean(preferences.getValue("showScreenName", StringPool.TRUE));
      boolean showEmail =
          GetterUtil.getBoolean(preferences.getValue("showEmail", StringPool.FALSE));

      long teamId = ParamUtil.getLong(renderRequest, "team", 0);

      List<Team> teams = TeamLocalServiceUtil.getGroupTeams(themeDisplay.getScopeGroupId());

      renderRequest.setAttribute("showSearcher", showSearcher);
      renderRequest.setAttribute("showScreenName", showScreenName);
      renderRequest.setAttribute("showEmail", showEmail);

      PortletURL iteratorURL = renderResponse.createRenderURL();
      iteratorURL.setParameter("team", String.valueOf(teamId));

      /*iteratorURL.setParameter("showSearcher" ,  String.valueOf(showSearcher));
      iteratorURL.setParameter("showScreenName" , String.valueOf(showScreenName));
      iteratorURL.setParameter("showEmail" ,  String.valueOf(showEmail));*/

      UserSearchContainer userSearchContainer = new UserSearchContainer(renderRequest, iteratorURL);
      UserDisplayTerms displayTerms = (UserDisplayTerms) userSearchContainer.getDisplayTerms();
      LinkedHashMap<String, Object> params = new LinkedHashMap<String, Object>();
      params.put("usersGroups", new Long(themeDisplay.getScopeGroupId()));

      Course course = CourseLocalServiceUtil.fetchByGroupCreatedId(themeDisplay.getScopeGroupId());

      if (log.isDebugEnabled()) {
        log.debug("NAME " + displayTerms.getFirstName());
        log.debug("SURNAME " + displayTerms.getLastName());
        log.debug("SCREEN NAME " + displayTerms.getScreenName());
        log.debug("EMAIL ADDRESS " + displayTerms.getEmailAddress());
        log.debug("KEYWORDS " + displayTerms.getKeywords());
        log.debug("START " + userSearchContainer.getStart());
        log.debug("END  " + userSearchContainer.getEnd());

        log.debug("ADVANCED SEARCH " + displayTerms.isAdvancedSearch());
        log.debug("AND OPERATOR " + displayTerms.isAndOperator());
        log.debug("TEAM " + teamId);
      }

      if (log.isDebugEnabled()) {
        log.debug("NAME " + ParamUtil.getString(renderRequest, "firstName"));
      }

      if (course != null) {
        try {
          if (displayTerms.isAdvancedSearch()) {
            userSearchContainer.setResults(
                CourseLocalServiceUtil.getStudentsFromCourse(
                    themeDisplay.getCompanyId(),
                    themeDisplay.getScopeGroupId(),
                    userSearchContainer.getStart(),
                    userSearchContainer.getEnd(),
                    teamId,
                    displayTerms.getFirstName(),
                    displayTerms.getLastName(),
                    displayTerms.getScreenName(),
                    displayTerms.getEmailAddress(),
                    displayTerms.isAndOperator()));

            userSearchContainer.setTotal(
                CourseLocalServiceUtil.getStudentsFromCourseCount(
                    course.getCourseId(),
                    teamId,
                    displayTerms.getFirstName(),
                    displayTerms.getLastName(),
                    displayTerms.getScreenName(),
                    displayTerms.getEmailAddress(),
                    displayTerms.isAndOperator()));

          } else {
            userSearchContainer.setResults(
                CourseLocalServiceUtil.getStudentsFromCourse(
                    themeDisplay.getCompanyId(),
                    themeDisplay.getScopeGroupId(),
                    userSearchContainer.getStart(),
                    userSearchContainer.getEnd(),
                    teamId,
                    displayTerms.getKeywords(),
                    displayTerms.getKeywords(),
                    displayTerms.getKeywords(),
                    displayTerms.getKeywords(),
                    true));

            userSearchContainer.setTotal(
                CourseLocalServiceUtil.getStudentsFromCourseCount(
                    course.getCourseId(),
                    teamId,
                    displayTerms.getKeywords(),
                    displayTerms.getKeywords(),
                    displayTerms.getKeywords(),
                    displayTerms.getKeywords(),
                    true));
          }

        } catch (SystemException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
      if (log.isDebugEnabled()) {
        log.debug(" -- TOTAL: " + userSearchContainer.getTotal());
        log.debug(" -- SIZE: " + userSearchContainer.getResults().size());
      }

      renderRequest.setAttribute("searchContainer", userSearchContainer);
      renderRequest.setAttribute("team", teamId);
      renderRequest.setAttribute("teams", teams);

    } catch (SystemException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (PortalException e) {
      // TODO: handle exception
      e.printStackTrace();
    }

    this.include(this.viewJSP, renderRequest, renderResponse);
  }
  @Override
  public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {

    List<AssetVocabulary> vocabularies = new ArrayList<AssetVocabulary>();
    Map<AssetVocabulary, List<AssetCategory>> vocabulariesMap =
        new HashMap<AssetVocabulary, List<AssetCategory>>();
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
    long[] categoryIds = ParamUtil.getLongValues(renderRequest, "categoryIds");
    try {

      Group siteGroup = themeDisplay.getSiteGroup();
      long scopeGroupId = themeDisplay.getScopeGroupId();
      vocabularies.addAll(
          AssetVocabularyServiceUtil.getGroupVocabularies(siteGroup.getGroupId(), false));

      if (scopeGroupId != themeDisplay.getCompanyGroupId()) {
        vocabularies.addAll(
            AssetVocabularyServiceUtil.getGroupVocabularies(
                themeDisplay.getCompanyGroupId(), false));
      }

      long classNameId = PortalUtil.getClassNameId(Announcement.class);

      // Select announcement vocabularies for announcement only.
      for (AssetVocabulary vocabulary : vocabularies) {
        vocabulary = vocabulary.toEscapedModel();

        int vocabularyCategoriesCount =
            AssetCategoryServiceUtil.getVocabularyCategoriesCount(
                vocabulary.getGroupId(), vocabulary.getVocabularyId());

        if (vocabularyCategoriesCount == 0) {
          continue;
        }

        UnicodeProperties settingsProperties = vocabulary.getSettingsProperties();

        long[] selectedClassNameIds =
            StringUtil.split(settingsProperties.getProperty("selectedClassNameIds"), 0L);

        if ((selectedClassNameIds.length > 0)
            && (selectedClassNameIds[0] != AssetCategoryConstants.ALL_CLASS_NAME_IDS)
            && !ArrayUtil.contains(selectedClassNameIds, classNameId)) {
          continue;
        }

        List<AssetCategory> assetCategories =
            AssetCategoryServiceUtil.getVocabularyRootCategories(
                themeDisplay.getScopeGroupId(),
                vocabulary.getVocabularyId(),
                QueryUtil.ALL_POS,
                QueryUtil.ALL_POS,
                null);
        vocabulariesMap.put(vocabulary, assetCategories);
      }
    } catch (SystemException e) {
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(e);
      }
      LOGGER.error("SystemException: unable to get types or currencies or vocabularies");
    } catch (PortalException e) {
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(e);
      }
      LOGGER.error("SystemException: unable to get types or currencies or vocabularies");
    }

    renderRequest.setAttribute("vocabulariesMap", vocabulariesMap);
    renderRequest.setAttribute("categoryIds", StringUtil.merge(categoryIds));
    renderRequest.setAttribute("htmlUtil", HtmlUtil.getHtml());

    super.doView(renderRequest, renderResponse);
  }
  public void loadCategoriesFromCsv(ActionRequest actionRequest, ActionResponse actionResponse)
      throws IOException, PortletException, PortalException, SystemException {

    LOGGER.info("Begin  AssetCategoriesImporter");
    UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest);
    ThemeDisplay themeDisplay =
        (ThemeDisplay) uploadPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);
    Map<String, FileItem[]> multipartParameterMap = uploadPortletRequest.getMultipartParameterMap();

    File file = null;
    BufferedReader bufferedReader = null;
    AssetVocabulary assetVocabulary = null;
    long userId = themeDisplay.getUserId();
    long groupId = themeDisplay.getScopeGroupId();

    ServiceContext serviceContext =
        ServiceContextFactory.getInstance(AssetCategory.class.getName(), uploadPortletRequest);

    // create vocabulary
    try {

      assetVocabulary =
          AssetVocabularyLocalServiceUtil.addVocabulary(
              userId,
              "Announcements",
              ServiceContextFactory.getInstance(
                  AssetVocabulary.class.getName(), uploadPortletRequest));
    } catch (DuplicateVocabularyException dve) {
      try {
        assetVocabulary =
            AssetVocabularyLocalServiceUtil.getGroupVocabulary(groupId, "Announcements");
      } catch (PortalException e) {
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug(e);
        }
        LOGGER.error(e.getMessage());
      } catch (SystemException e) {
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug(e);
        }
        LOGGER.error(e.getMessage());
      }
    }

    if (multipartParameterMap.keySet().contains("fileCategory")
        && Validator.isNotNull(assetVocabulary)) {
      try {
        file = uploadPortletRequest.getFile("fileCategory");
        bufferedReader = new BufferedReader(new FileReader(file.getAbsolutePath()));
        String line = StringPool.BLANK;
        long vocabularyId = assetVocabulary.getVocabularyId();

        String parentCategoryName = StringPool.BLANK;
        AssetCategory parentCategory = null;

        while ((line = bufferedReader.readLine()) != null) {

          // use comma as separator
          String[] categories = line.split(StringPool.SEMICOLON);

          if (categories.length == 4) {
            String parentCategoryCode = categories[0];

            if (Validator.isNull(parentCategory) || !parentCategoryName.equals(categories[1])) {
              parentCategoryName = categories[1];
              try {
                parentCategory =
                    AssetCategoryLocalServiceUtil.addCategory(
                        userId, parentCategoryName, vocabularyId, serviceContext);
                AssetCategoryPropertyLocalServiceUtil.addCategoryProperty(
                    userId, parentCategory.getCategoryId(), "Code", parentCategoryCode);
              } catch (Exception e) {
                if (LOGGER.isDebugEnabled()) {
                  LOGGER.debug(e);
                }
                LOGGER.error(e.getMessage());
              }
            }

            Map<Locale, String> titles = new HashMap<Locale, String>();
            Map<Locale, String> descriptionMap = new HashMap<Locale, String>();

            titles.put(LocaleUtil.fromLanguageId("fr_FR"), categories[3]);
            titles.put(LocaleUtil.fromLanguageId("en_US"), categories[3]);

            try {
              AssetCategory child =
                  AssetCategoryLocalServiceUtil.addCategory(
                      userId,
                      parentCategory.getCategoryId(),
                      titles,
                      descriptionMap,
                      vocabularyId,
                      null,
                      serviceContext);
              AssetCategoryPropertyLocalServiceUtil.addCategoryProperty(
                  userId, child.getCategoryId(), "Code", categories[2]);
            } catch (Exception e) {
              if (LOGGER.isDebugEnabled()) {
                LOGGER.debug(e);
              }
              LOGGER.error(e.getMessage());
            }
          }
        }
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      } finally {
        if (bufferedReader != null) {
          try {
            bufferedReader.close();
          } catch (IOException e) {
            if (LOGGER.isDebugEnabled()) {
              LOGGER.debug(e);
            }
            LOGGER.error(e.getMessage());
          }
        }
      }
    }
    LOGGER.info("End  AssetCategoriesImporter");
  }