public String getBrowserTimingFooter() {
    log.debug("getBrowserTimingFooter");

    String newRelicSnippet = NewRelic.getBrowserTimingFooter();
    log.debug("newRelicSnippet: " + newRelicSnippet);

    return newRelicSnippet;
  }
  /**
   * 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");
  }
  /**
   * Adds the organisation.
   *
   * @param data the data
   * @param result the result
   * @param request the request
   * @param response the response
   * @param model the model
   */
  @ActionMapping(params = "action=addOrganisation")
  public void addOrganisation(
      @Valid @ModelAttribute("orgData") final RegistrationForm data,
      final BindingResult result,
      final ActionRequest request,
      final ActionResponse response,
      final Model model) {
    m_objLog.debug("addOrganisation::start");

    final ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    if (!result.hasErrors()) {
      this.m_objFormValidator.setThemeDisplay(themeDisplay);
      this.m_objFormValidator.validate(data, result);
    }

    if (!result.hasErrors()) {
      final User user =
          CustomPortalServiceHandler.createPortalUser(
              data.getName(),
              data.getHolder(),
              data.getMail(),
              themeDisplay.getCompanyId(),
              themeDisplay.getScopeGroupId(),
              themeDisplay.getLocale(),
              true);
      if (user != null) {
        final AHOrg org =
            CustomOrgServiceHandler.addOrganisation(
                this.getCompanyId(request), -1, this.getGroupId(request), data);
        if (org == null) {
          SessionErrors.add(request, "org.form.addOrg.failed.org");
        } else {
          response.setRenderParameter("jspPage", "registerSuccess");
        }

      } else {
        SessionErrors.add(request, "org.form.addOrg.failed.user");
      }
    }

    m_objLog.debug("addOrganisation::end");
  }
Example #4
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");
  }
 public Link addLink(Link link) throws SystemException {
   _log.debug("addLink");
   long linkId = CounterLocalServiceUtil.increment(Link.class.getName());
   Link model = linkPersistence.create(linkId);
   model.setUserId(link.getUserId());
   model.setCompanyId(link.getCompanyId());
   model.setCreateDate(new Date());
   model.setModifiedDate(new Date());
   model.setApplicationId(link.getApplicationId());
   model.setDisplayName(link.getDisplayName());
   model.setType(link.getType());
   model.setUrl(link.getUrl());
   return linkPersistence.update(model, true);
 }
Example #6
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);
    }
  }
 public void saveName(ActionRequest actionRequest, ActionResponse actionResponse)
     throws IOException, PortletException {
   _log.debug("saveName started");
   final String name =
       ParamUtil.get(actionRequest, MyHelloWorldMVCUtil.REQUEST_PARAM_NAME, StringPool.BLANK);
   final PortletPreferences portletPreferences = actionRequest.getPreferences();
   if (Validator.isBlank(name)) {
     _log.error("Name is blank. You must introduce valid value for name parameter.");
   } else {
     portletPreferences.setValue(MyHelloWorldMVCUtil.PORTLET_PREFERENCES_PARAM_NAME, name);
     _log.info(
         "saving new value ("
             + name
             + ") of "
             + MyHelloWorldMVCUtil.PORTLET_PREFERENCES_PARAM_NAME
             + " on portletPreferences");
     portletPreferences.store();
   }
   // Una vez que terminas la lógica de saveName forward a la vista
   actionResponse.setPortletMode(PortletMode.VIEW);
 }
  @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";
  }
    @Override
    public CustomJspBag addingService(ServiceReference<CustomJspBag> serviceReference) {

      Registry registry = RegistryUtil.getRegistry();

      CustomJspBag customJspBag = registry.getService(serviceReference);

      List<String> customJsps = customJspBag.getCustomJsps();

      if (customJsps.isEmpty()) {
        getCustomJsps(
            customJspBag.getURLContainer(),
            customJspBag.getCustomJspDir(),
            customJspBag.getCustomJsps());

        customJsps = customJspBag.getCustomJsps();

        if (customJsps.isEmpty()) {
          return null;
        }
      }

      if (_log.isDebugEnabled()) {
        StringBundler sb = new StringBundler(customJsps.size() * 2);

        sb.append("Custom JSP files:\n");

        for (int i = 0; i < customJsps.size(); i++) {
          String customJsp = customJsps.get(0);

          sb.append(customJsp);

          if ((i + 1) < customJsps.size()) {
            sb.append(StringPool.NEW_LINE);
          }
        }

        Log log = SanitizerLogWrapper.allowCRLF(_log);

        log.debug(sb.toString());
      }

      String contextId = GetterUtil.getString(serviceReference.getProperty("context.id"));

      if (customJspBag.isCustomJspGlobal() && !_customJspBagsMap.isEmpty()) {

        try {
          verifyCustomJsps(contextId, customJspBag);
        } catch (DuplicateCustomJspException e) {
          return null;
        }
      }

      _customJspBagsMap.put(serviceReference, customJspBag);

      String contextName = GetterUtil.getString(serviceReference.getProperty("context.name"));

      try {
        initCustomJspBag(contextId, contextName, customJspBag);
      } catch (Exception e) {
        return null;
      }

      return customJspBag;
    }
  protected void verifyCustomJsps(String contextId, CustomJspBag customJspBag)
      throws DuplicateCustomJspException {

    Set<String> customJsps = new HashSet<>();

    for (String customJsp : customJspBag.getCustomJsps()) {
      String portalJsp = getPortalJsp(customJsp, customJspBag.getCustomJspDir());

      customJsps.add(portalJsp);
    }

    Map<String, String> conflictingCustomJsps = new HashMap<>();

    for (Map.Entry<ServiceReference<CustomJspBag>, CustomJspBag> entry :
        _customJspBagsMap.entrySet()) {

      CustomJspBag currentCustomJspBag = entry.getValue();

      if (!currentCustomJspBag.isCustomJspGlobal()) {
        continue;
      }

      ServiceReference<CustomJspBag> serviceReference = entry.getKey();

      String contextName = GetterUtil.getString(serviceReference.getProperty("context.name"));

      List<String> currentCustomJsps = currentCustomJspBag.getCustomJsps();

      for (String currentCustomJsp : currentCustomJsps) {
        String currentPortalJsp =
            getPortalJsp(currentCustomJsp, currentCustomJspBag.getCustomJspDir());

        if (customJsps.contains(currentPortalJsp)) {
          conflictingCustomJsps.put(currentPortalJsp, contextName);
        }
      }
    }

    if (conflictingCustomJsps.isEmpty()) {
      return;
    }

    _log.error(contextId + " conflicts with the installed hooks");

    if (_log.isDebugEnabled()) {
      Log log = SanitizerLogWrapper.allowCRLF(_log);

      StringBundler sb = new StringBundler(conflictingCustomJsps.size() * 4 + 2);

      sb.append("Colliding JSP files in ");
      sb.append(contextId);
      sb.append(StringPool.NEW_LINE);

      int i = 0;

      for (Map.Entry<String, String> entry : conflictingCustomJsps.entrySet()) {

        sb.append(entry.getKey());
        sb.append(" with ");
        sb.append(entry.getValue());

        if ((i + 1) < conflictingCustomJsps.size()) {
          sb.append(StringPool.NEW_LINE);
        }

        i++;
      }

      log.debug(sb.toString());
    }

    throw new DuplicateCustomJspException();
  }
  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");
  }
 public NewRelicWrapper() {
   log.debug("NewRelicWrapper");
 }