protected void updateBasicConfiguration(
      PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    boolean displayScopeFacet =
        GetterUtil.getBoolean(getParameter(actionRequest, "displayScopeFacet"));
    boolean displayAssetCategoriesFacet =
        GetterUtil.getBoolean(getParameter(actionRequest, "displayAssetCategoriesFacet"));
    boolean displayAssetTagsFacet =
        GetterUtil.getBoolean(getParameter(actionRequest, "displayAssetTagsFacet"));
    boolean displayAssetTypeFacet =
        GetterUtil.getBoolean(getParameter(actionRequest, "displayAssetTypeFacet"));
    boolean displayFolderFacet =
        GetterUtil.getBoolean(getParameter(actionRequest, "displayFolderFacet"));
    boolean displayUserFacet =
        GetterUtil.getBoolean(getParameter(actionRequest, "displayUserFacet"));
    boolean displayModifiedRangeFacet =
        GetterUtil.getBoolean(getParameter(actionRequest, "displayModifiedRangeFacet"));

    String searchConfiguration = ContentUtil.get(SearchWebConfigurationValues.FACET_CONFIGURATION);

    JSONObject configurationJSONObject = JSONFactoryUtil.createJSONObject(searchConfiguration);

    JSONArray oldFacetsJSONArray = configurationJSONObject.getJSONArray("facets");

    if (oldFacetsJSONArray == null) {
      if (_log.isWarnEnabled()) {
        _log.warn(
            "The resource "
                + SearchWebConfigurationValues.FACET_CONFIGURATION
                + " is missing a valid facets JSON array");
      }
    }

    JSONArray newFacetsJSONArray = JSONFactoryUtil.createJSONArray();

    for (int i = 0; i < oldFacetsJSONArray.length(); i++) {
      JSONObject oldFacetJSONObject = oldFacetsJSONArray.getJSONObject(i);

      String fieldName = oldFacetJSONObject.getString("fieldName");

      if ((displayScopeFacet && fieldName.equals("groupId"))
          || (displayAssetCategoriesFacet && fieldName.equals("assetCategoryIds"))
          || (displayAssetTagsFacet && fieldName.equals("assetTagNames"))
          || (displayAssetTypeFacet && fieldName.equals("entryClassName"))
          || (displayFolderFacet && fieldName.equals("folderId"))
          || (displayUserFacet && fieldName.equals("userId"))
          || (displayModifiedRangeFacet && fieldName.equals("modified"))) {

        newFacetsJSONArray.put(oldFacetJSONObject);
      }
    }

    configurationJSONObject.put("facets", newFacetsJSONArray);

    searchConfiguration = configurationJSONObject.toString();

    setPreference(actionRequest, "searchConfiguration", searchConfiguration);
  }
Exemplo n.º 2
0
  public static String getEmailPageAddedBody(PortletPreferences preferences) {
    String emailPageAddedBody = preferences.getValue("emailPageAddedBody", StringPool.BLANK);

    if (Validator.isNotNull(emailPageAddedBody)) {
      return emailPageAddedBody;
    } else {
      return ContentUtil.get(PropsUtil.get(PropsKeys.WIKI_EMAIL_PAGE_ADDED_BODY));
    }
  }
  protected List<Element> getDDMStructures(String fileName) throws DocumentException {

    String xml = ContentUtil.get("com/liferay/portal/events/dependencies/" + fileName);

    Document document = SAXReaderUtil.read(xml);

    Element rootElement = document.getRootElement();

    return rootElement.elements("structure");
  }
Exemplo n.º 4
0
  public static String getEmailMessageAddedBody(PortletPreferences preferences) {

    String emailMessageAddedBody = preferences.getValue("emailMessageAddedBody", StringPool.BLANK);

    if (Validator.isNotNull(emailMessageAddedBody)) {
      return emailMessageAddedBody;
    } else {
      return ContentUtil.get(PropsValues.MESSAGE_BOARDS_EMAIL_MESSAGE_ADDED_BODY);
    }
  }
Exemplo n.º 5
0
  public static String getEmailMessageUpdatedSignature(PortletPreferences preferences) {

    String emailMessageUpdatedSignature =
        preferences.getValue("emailMessageUpdatedSignature", StringPool.BLANK);

    if (Validator.isNotNull(emailMessageUpdatedSignature)) {
      return emailMessageUpdatedSignature;
    } else {
      return ContentUtil.get(PropsValues.MESSAGE_BOARDS_EMAIL_MESSAGE_UPDATED_SIGNATURE);
    }
  }
Exemplo n.º 6
0
  public static String getEmailMessageUpdatedSubject(PortletPreferences preferences) {

    String emailMessageUpdatedSubject =
        preferences.getValue("emailMessageUpdatedSubject", StringPool.BLANK);

    if (Validator.isNotNull(emailMessageUpdatedSubject)) {
      return emailMessageUpdatedSubject;
    } else {
      return ContentUtil.get(PropsValues.MESSAGE_BOARDS_EMAIL_MESSAGE_UPDATED_SUBJECT);
    }
  }
Exemplo n.º 7
0
  public static String getEmailPageUpdatedSubjectPrefix(PortletPreferences preferences) {

    String emailPageUpdatedSubject =
        preferences.getValue("emailPageUpdatedSubjectPrefix", StringPool.BLANK);

    if (Validator.isNotNull(emailPageUpdatedSubject)) {
      return emailPageUpdatedSubject;
    } else {
      return ContentUtil.get(PropsUtil.get(PropsKeys.WIKI_EMAIL_PAGE_UPDATED_SUBJECT_PREFIX));
    }
  }
Exemplo n.º 8
0
  public static String getEmailPageAddedSignature(PortletPreferences preferences) {

    String emailPageAddedSignature =
        preferences.getValue("emailPageAddedSignature", StringPool.BLANK);

    if (Validator.isNotNull(emailPageAddedSignature)) {
      return emailPageAddedSignature;
    } else {
      return ContentUtil.get(PropsUtil.get(PropsKeys.WIKI_EMAIL_PAGE_ADDED_SIGNATURE));
    }
  }
Exemplo n.º 9
0
  public static String getEmailEventReminderSubject(PortletPreferences preferences) {

    String emailEventReminderSubject =
        preferences.getValue("emailEventReminderSubject", StringPool.BLANK);

    if (Validator.isNotNull(emailEventReminderSubject)) {
      return emailEventReminderSubject;
    } else {
      return ContentUtil.get(PropsUtil.get(PropsKeys.CALENDAR_EMAIL_EVENT_REMINDER_SUBJECT));
    }
  }
Exemplo n.º 10
0
  public static String getEmailMessageAddedSubjectPrefix(PortletPreferences preferences) {

    String emailMessageAddedSubjectPrefix =
        preferences.getValue("emailMessageAddedSubjectPrefix", StringPool.BLANK);

    if (Validator.isNotNull(emailMessageAddedSubjectPrefix)) {
      return emailMessageAddedSubjectPrefix;
    } else {
      return ContentUtil.get(PropsValues.MESSAGE_BOARDS_EMAIL_MESSAGE_ADDED_SUBJECT_PREFIX);
    }
  }
  @Override
  public void postProcess(
      long companyId, PortletRequest portletRequest, PortletPreferences portletPreferences)
      throws SystemException {

    removeDefaultValue(
        portletRequest,
        portletPreferences,
        "emailFromAddress",
        LoginUtil.getEmailFromName(portletPreferences, companyId));
    removeDefaultValue(
        portletRequest,
        portletPreferences,
        "emailFromName",
        LoginUtil.getEmailFromName(portletPreferences, companyId));

    String languageId = LocaleUtil.toLanguageId(LocaleUtil.getSiteDefault());

    removeDefaultValue(
        portletRequest,
        portletPreferences,
        "emailPasswordResetBody_" + languageId,
        ContentUtil.get(PropsValues.ADMIN_EMAIL_PASSWORD_RESET_BODY));
    removeDefaultValue(
        portletRequest,
        portletPreferences,
        "emailPasswordResetSubject_" + languageId,
        ContentUtil.get(PropsValues.ADMIN_EMAIL_PASSWORD_RESET_SUBJECT));
    removeDefaultValue(
        portletRequest,
        portletPreferences,
        "emailPasswordSentBody_" + languageId,
        ContentUtil.get(PropsValues.ADMIN_EMAIL_PASSWORD_SENT_BODY));
    removeDefaultValue(
        portletRequest,
        portletPreferences,
        "emailPasswordSentSubject_" + languageId,
        ContentUtil.get(PropsValues.ADMIN_EMAIL_PASSWORD_SENT_SUBJECT));
  }
Exemplo n.º 12
0
  protected void processInactiveRequest(
      HttpServletRequest request, HttpServletResponse response, String messageKey)
      throws IOException {

    response.setContentType(ContentTypes.TEXT_HTML_UTF8);

    Locale locale = LocaleUtil.getDefault();

    String message = LanguageUtil.get(locale, messageKey);

    String html = ContentUtil.get("com/liferay/portal/dependencies/inactive.html");

    html = StringUtil.replace(html, "[$MESSAGE$]", message);

    PrintWriter printWriter = response.getWriter();

    printWriter.print(html);
  }
Exemplo n.º 13
0
  public static Map<Locale, String> getEmailEntryAddedBodyMap(PortletPreferences preferences) {

    Map<Locale, String> map =
        LocalizationUtil.getLocalizationMap(preferences, "emailEntryAddedBody");

    Locale defaultLocale = LocaleUtil.getDefault();

    String defaultValue = map.get(defaultLocale);

    if (Validator.isNotNull(defaultValue)) {
      return map;
    }

    map.put(
        defaultLocale, ContentUtil.get(PropsUtil.get(PropsKeys.BOOKMARKS_EMAIL_ENTRY_ADDED_BODY)));

    return map;
  }
Exemplo n.º 14
0
  @Override
  public Map<Locale, String> getEmailFileEntryUpdatedBodyMap(PortletPreferences preferences) {

    Map<Locale, String> map =
        LocalizationUtil.getLocalizationMap(preferences, "emailFileEntryUpdatedBody");

    Locale defaultLocale = LocaleUtil.getSiteDefault();

    String defaultValue = map.get(defaultLocale);

    if (Validator.isNotNull(defaultValue)) {
      return map;
    }

    map.put(
        defaultLocale, ContentUtil.get(PropsUtil.get(PropsKeys.DL_EMAIL_FILE_ENTRY_UPDATED_BODY)));

    return map;
  }
Exemplo n.º 15
0
  public static Map<Locale, String> getEmailEntryUpdatedSubjectMap(PortletPreferences preferences) {

    Map<Locale, String> map =
        LocalizationUtil.getLocalizationMap(preferences, "emailEntryUpdatedSubject");

    Locale defaultLocale = LocaleUtil.getDefault();

    String defaultValue = map.get(defaultLocale);

    if (Validator.isNotNull(defaultValue)) {
      return map;
    }

    map.put(
        defaultLocale,
        ContentUtil.get(PropsUtil.get(PropsKeys.BOOKMARKS_EMAIL_ENTRY_UPDATED_SUBJECT)));

    return map;
  }
  protected String getPageDiff(long companyId, WikiPage latestPage, WikiPage page, Locale locale)
      throws SystemException {

    try {
      String templateId = "com/liferay/portlet/wiki/dependencies/rss.vm";

      String templateContent = ContentUtil.get(templateId);

      Template template =
          TemplateManagerUtil.getTemplate(
              TemplateManager.VELOCITY,
              new StringTemplateResource(templateId, templateContent),
              TemplateContextType.STANDARD);

      template.put("companyId", companyId);
      template.put("contextLine", Diff.CONTEXT_LINE);
      template.put("diffUtil", new DiffUtil());
      template.put("languageUtil", LanguageUtil.getLanguage());
      template.put("locale", locale);

      String sourceContent = WikiUtil.processContent(latestPage.getContent());
      String targetContent = WikiUtil.processContent(page.getContent());

      sourceContent = HtmlUtil.escape(sourceContent);
      targetContent = HtmlUtil.escape(targetContent);

      List<DiffResult>[] diffResults =
          DiffUtil.diff(
              new UnsyncStringReader(sourceContent), new UnsyncStringReader(targetContent));

      template.put("sourceResults", diffResults[0]);
      template.put("targetResults", diffResults[1]);

      UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter();

      template.processTemplate(unsyncStringWriter);

      return unsyncStringWriter.toString();
    } catch (Exception e) {
      throw new SystemException(e);
    }
  }
  @Override
  public Map<Locale, String> getEmailAssetEntryAddedSubjectMap(PortletPreferences preferences) {

    Map<Locale, String> map =
        LocalizationUtil.getLocalizationMap(preferences, "emailAssetEntryAddedSubject");

    Locale defaultLocale = LocaleUtil.getDefault();

    String defaultValue = map.get(defaultLocale);

    if (Validator.isNotNull(defaultValue)) {
      return map;
    }

    map.put(
        defaultLocale,
        ContentUtil.get(PropsUtil.get(PropsKeys.ASSET_PUBLISHER_EMAIL_ASSET_ENTRY_ADDED_SUBJECT)));

    return map;
  }
  protected String formatPortalPortalProperties() throws Exception {
    if (!portalSource) {
      return ContentUtil.get("portal.properties");
    }

    String fileName = "portal-impl/src/portal.properties";

    File file = new File(BASEDIR + fileName);

    String content = fileUtil.read(file);

    StringBundler sb = new StringBundler();

    UnsyncBufferedReader unsyncBufferedReader =
        new UnsyncBufferedReader(new UnsyncStringReader(content));

    String line = null;

    while ((line = unsyncBufferedReader.readLine()) != null) {
      line = trimLine(line, true);

      if (line.startsWith(StringPool.TAB)) {
        line = line.replaceFirst(StringPool.TAB, StringPool.FOUR_SPACES);
      }

      sb.append(line);
      sb.append("\n");
    }

    unsyncBufferedReader.close();

    String newContent = sb.toString();

    if (newContent.endsWith("\n")) {
      newContent = newContent.substring(0, newContent.length() - 1);
    }

    compareAndAutoFixContent(file, fileName, content, newContent);

    return newContent;
  }
Exemplo n.º 19
0
  protected void notifyUsers(
      List<User> users, AnnouncementsEntry entry, Locale locale, String toAddress, String toName)
      throws PortalException {

    if (_log.isDebugEnabled()) {
      _log.debug("Notifying " + users.size() + " users");
    }

    boolean notifyUsers = false;

    SubscriptionSender subscriptionSender = new SubscriptionSender();

    for (User user : users) {
      AnnouncementsDelivery announcementsDelivery =
          announcementsDeliveryLocalService.getUserDelivery(user.getUserId(), entry.getType());

      if (announcementsDelivery.isEmail()) {
        subscriptionSender.addRuntimeSubscribers(user.getEmailAddress(), user.getFullName());

        notifyUsers = true;
      }

      if (announcementsDelivery.isSms()) {
        String smsSn = user.getContact().getSmsSn();

        subscriptionSender.addRuntimeSubscribers(smsSn, user.getFullName());

        notifyUsers = true;
      }
    }

    if (!notifyUsers) {
      return;
    }

    String body = ContentUtil.get(PropsValues.ANNOUNCEMENTS_EMAIL_BODY);
    String fromAddress =
        PrefsPropsUtil.getStringFromNames(
            entry.getCompanyId(),
            PropsKeys.ANNOUNCEMENTS_EMAIL_FROM_ADDRESS,
            PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);
    String fromName =
        PrefsPropsUtil.getStringFromNames(
            entry.getCompanyId(),
            PropsKeys.ANNOUNCEMENTS_EMAIL_FROM_NAME,
            PropsKeys.ADMIN_EMAIL_FROM_NAME);
    String subject = ContentUtil.get(PropsValues.ANNOUNCEMENTS_EMAIL_SUBJECT);

    subscriptionSender.setBody(body);
    subscriptionSender.setCompanyId(entry.getCompanyId());
    subscriptionSender.setContextAttribute("[$ENTRY_CONTENT$]", entry.getContent(), false);
    subscriptionSender.setContextAttributes(
        "[$ENTRY_ID$]",
        entry.getEntryId(),
        "[$ENTRY_TITLE$]",
        entry.getTitle(),
        "[$ENTRY_TYPE$]",
        LanguageUtil.get(locale, entry.getType()),
        "[$ENTRY_URL$]",
        entry.getUrl(),
        "[$PORTLET_NAME$]",
        LanguageUtil.get(locale, (entry.isAlert() ? "alert" : "announcement")));
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);
    subscriptionSender.setMailId("announcements_entry", entry.getEntryId());
    subscriptionSender.setPortletId(PortletKeys.ANNOUNCEMENTS);
    subscriptionSender.setScopeGroupId(entry.getGroupId());
    subscriptionSender.setSubject(subject);

    subscriptionSender.addRuntimeSubscribers(toAddress, toName);

    subscriptionSender.flushNotificationsAsync();
  }
Exemplo n.º 20
0
  protected void exportTheme(LayoutSet layoutSet, ZipWriter zipWriter) throws Exception {

    Theme theme = layoutSet.getTheme();

    String lookAndFeelXML =
        ContentUtil.get("com/liferay/portal/dependencies/liferay-look-and-feel.xml.tmpl");

    lookAndFeelXML =
        StringUtil.replace(
            lookAndFeelXML,
            new String[] {"[$TEMPLATE_EXTENSION$]", "[$VIRTUAL_PATH$]"},
            new String[] {theme.getTemplateExtension(), theme.getVirtualPath()});

    String servletContextName = theme.getServletContextName();

    ServletContext servletContext = ServletContextPool.get(servletContextName);

    if (servletContext == null) {
      if (_log.isWarnEnabled()) {
        _log.warn("Servlet context not found for theme " + theme.getThemeId());
      }

      return;
    }

    File themeZip = new File(zipWriter.getPath() + "/theme.zip");

    ZipWriter themeZipWriter = ZipWriterFactoryUtil.getZipWriter(themeZip);

    themeZipWriter.addEntry("liferay-look-and-feel.xml", lookAndFeelXML);

    File cssPath = null;
    File imagesPath = null;
    File javaScriptPath = null;
    File templatesPath = null;

    if (!theme.isLoadFromServletContext()) {
      ThemeLoader themeLoader = ThemeLoaderFactory.getThemeLoader(servletContextName);

      if (themeLoader == null) {
        _log.error(servletContextName + " does not map to a theme loader");
      } else {
        String realPath =
            themeLoader.getFileStorage().getPath() + StringPool.SLASH + theme.getName();

        cssPath = new File(realPath + "/css");
        imagesPath = new File(realPath + "/images");
        javaScriptPath = new File(realPath + "/javascript");
        templatesPath = new File(realPath + "/templates");
      }
    } else {
      cssPath = new File(servletContext.getRealPath(theme.getCssPath()));
      imagesPath = new File(servletContext.getRealPath(theme.getImagesPath()));
      javaScriptPath = new File(servletContext.getRealPath(theme.getJavaScriptPath()));
      templatesPath = new File(servletContext.getRealPath(theme.getTemplatesPath()));
    }

    exportThemeFiles("css", cssPath, themeZipWriter);
    exportThemeFiles("images", imagesPath, themeZipWriter);
    exportThemeFiles("javascript", javaScriptPath, themeZipWriter);
    exportThemeFiles("templates", templatesPath, themeZipWriter);
  }