Example #1
0
  @Override
  public void init(FilterConfig filterConfig) {
    super.init(filterConfig);

    _basicAuthEnabled = GetterUtil.getBoolean(filterConfig.getInitParameter("basic_auth"));
    _digestAuthEnabled = GetterUtil.getBoolean(filterConfig.getInitParameter("digest_auth"));

    String propertyPrefix = filterConfig.getInitParameter("portal_property_prefix");

    String[] hostsAllowed = null;

    if (Validator.isNull(propertyPrefix)) {
      hostsAllowed = StringUtil.split(filterConfig.getInitParameter("hosts.allowed"));
      _httpsRequired = GetterUtil.getBoolean(filterConfig.getInitParameter("https.required"));
    } else {
      hostsAllowed = PropsUtil.getArray(propertyPrefix + "hosts.allowed");
      _httpsRequired = GetterUtil.getBoolean(PropsUtil.get(propertyPrefix + "https.required"));
    }

    for (String hostAllowed : hostsAllowed) {
      _hostsAllowed.add(hostAllowed);
    }

    _usePermissionChecker =
        GetterUtil.getBoolean(filterConfig.getInitParameter("use_permission_checker"));
  }
  private static List<String> _getDependencies(String bundleId, List<String> dependencies) {

    if (!ArrayUtil.contains(PropsValues.JAVASCRIPT_BUNDLE_IDS, bundleId)) {
      return dependencies;
    }

    String[] bundleDependencies =
        PropsUtil.getArray(PropsKeys.JAVASCRIPT_BUNDLE_DEPENDENCIES, new Filter(bundleId));

    for (String bundleDependency : bundleDependencies) {
      String[] bundleDependencyDependencies =
          PropsUtil.getArray(
              PropsKeys.JAVASCRIPT_BUNDLE_DEPENDENCIES, new Filter(bundleDependency));

      if (!ArrayUtil.contains(bundleDependencyDependencies, bundleId)) {
        _getDependencies(bundleDependency, dependencies);
      }

      dependencies.add(bundleDependency);
    }

    dependencies.add(bundleId);

    return dependencies;
  }
 private PortalInstances() {
   _companyIds = new long[0];
   _autoLoginIgnoreHosts =
       SetUtil.fromArray(PropsUtil.getArray(PropsKeys.AUTO_LOGIN_IGNORE_HOSTS));
   _autoLoginIgnorePaths =
       SetUtil.fromArray(PropsUtil.getArray(PropsKeys.AUTO_LOGIN_IGNORE_PATHS));
   _virtualHostsIgnoreHosts =
       SetUtil.fromArray(PropsUtil.getArray(PropsKeys.VIRTUAL_HOSTS_IGNORE_HOSTS));
   _virtualHostsIgnorePaths =
       SetUtil.fromArray(PropsUtil.getArray(PropsKeys.VIRTUAL_HOSTS_IGNORE_PATHS));
 }
  public void addUser(
      long companyId,
      long userId,
      String password,
      String firstName,
      String middleName,
      String lastName,
      String emailAddress) {

    try {
      CyrusServiceUtil.addUser(userId, emailAddress, password);

      // Expect

      String addUserCmd = PropsUtil.get(PropsKeys.MAIL_HOOK_CYRUS_ADD_USER);

      addUserCmd = StringUtil.replace(addUserCmd, "%1%", String.valueOf(userId));

      Runtime rt = Runtime.getRuntime();

      Process p = rt.exec(addUserCmd);

      ProcessUtil.close(p);
    } catch (Exception e) {
      _log.error(e, e);
    }
  }
Example #5
0
  protected int getRangeSize(String name) {
    if (name.equals(_NAME)) {
      return PropsValues.COUNTER_INCREMENT;
    }

    String incrementType = null;

    int pos = name.indexOf(CharPool.POUND);

    if (pos != -1) {
      incrementType = name.substring(0, pos);
    } else {
      incrementType = name;
    }

    Integer rangeSize = _rangeSizeMap.get(incrementType);

    if (rangeSize == null) {
      rangeSize =
          GetterUtil.getInteger(
              PropsUtil.get(PropsKeys.COUNTER_INCREMENT_PREFIX + incrementType),
              PropsValues.COUNTER_INCREMENT);

      _rangeSizeMap.put(incrementType, rangeSize);
    }

    return rangeSize.intValue();
  }
  public static void updateSetup(HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    UnicodeProperties unicodeProperties =
        PropertiesParamUtil.getProperties(request, _PROPERTIES_PREFIX);

    unicodeProperties.setProperty(
        PropsKeys.LIFERAY_HOME, SystemProperties.get(PropsKeys.LIFERAY_HOME));

    boolean databaseConfigured = _isDatabaseConfigured(unicodeProperties);

    _processDatabaseProperties(request, unicodeProperties, databaseConfigured);

    updateLanguage(request, response);

    unicodeProperties.put(PropsKeys.SETUP_WIZARD_ENABLED, String.valueOf(false));

    PropsUtil.addProperties(unicodeProperties);

    if (!databaseConfigured) {
      _reloadServletContext(request, unicodeProperties);
    }

    _updateCompany(request);
    _updateAdminUser(request, unicodeProperties);

    _initPlugins();

    boolean propertiesFileCreated = _writePropertiesFile(unicodeProperties);

    HttpSession session = request.getSession();

    session.setAttribute(WebKeys.SETUP_WIZARD_PROPERTIES, unicodeProperties);
    session.setAttribute(WebKeys.SETUP_WIZARD_PROPERTIES_FILE_CREATED, propertiesFileCreated);
  }
  protected String[] getStaticPortletIds(String position) throws PortalException {

    Layout layout = getLayout();

    String selector1 = StringPool.BLANK;

    Group group = layout.getGroup();

    if (group.isUser()) {
      selector1 = LayoutTypePortletConstants.STATIC_PORTLET_USER_SELECTOR;
    } else if (group.isOrganization()) {
      selector1 = LayoutTypePortletConstants.STATIC_PORTLET_ORGANIZATION_SELECTOR;
    } else if (group.isRegularSite()) {
      selector1 = LayoutTypePortletConstants.STATIC_PORTLET_REGULAR_SITE_SELECTOR;
    }

    String selector2 = layout.getFriendlyURL();

    String[] portletIds = PropsUtil.getArray(position, new Filter(selector1, selector2));

    for (int i = 0; i < portletIds.length; i++) {
      portletIds[i] = JS.getSafeName(portletIds[i]);
    }

    return portletIds;
  }
  public void updateBlocked(long companyId, long userId, List<String> blocked) {

    String home = PropsUtil.get(PropsKeys.MAIL_HOOK_CYRUS_HOME);

    File file = new File(home + "/" + userId + ".procmail.blocked");

    if ((blocked == null) || (blocked.size() == 0)) {
      file.delete();

      return;
    }

    StringBundler sb = new StringBundler(blocked.size() * 9);

    for (int i = 0; i < blocked.size(); i++) {
      String emailAddress = blocked.get(i);

      sb.append("\n");
      sb.append(":0\n");
      sb.append("* ^From.*");
      sb.append(emailAddress);
      sb.append("\n");
      sb.append("{\n");
      sb.append(":0\n");
      sb.append("/dev/null\n");
      sb.append("}\n");
    }

    try {
      FileUtil.write(file, sb.toString());
    } catch (Exception e) {
      _log.error(e, e);
    }
  }
  protected void verifyObsoletePortalProperty(String key) throws Exception {
    String value = PropsUtil.get(key);

    if (value != null) {
      _log.error("Portal property \"" + key + "\" is obsolete");
    }
  }
  public Set<String> getReminderQueryQuestions() throws PortalException, SystemException {

    Set<String> questions = new TreeSet<String>();

    List<Organization> organizations =
        OrganizationLocalServiceUtil.getUserOrganizations(getUserId());

    for (Organization organization : organizations) {
      Set<String> organizationQuestions = organization.getReminderQueryQuestions(getLanguageId());

      if (organizationQuestions.size() == 0) {
        Organization parentOrganization = organization.getParentOrganization();

        while ((organizationQuestions.size() == 0) && (parentOrganization != null)) {

          organizationQuestions = parentOrganization.getReminderQueryQuestions(getLanguageId());

          parentOrganization = parentOrganization.getParentOrganization();
        }
      }

      questions.addAll(organizationQuestions);
    }

    if (questions.size() == 0) {
      Set<String> defaultQuestions =
          SetUtil.fromArray(PropsUtil.getArray(PropsKeys.USERS_REMINDER_QUERIES_QUESTIONS));

      questions.addAll(defaultQuestions);
    }

    return questions;
  }
  public HostConfiguration getHostConfiguration(String location) throws IOException {

    if (_log.isDebugEnabled()) {
      _log.debug("Location is " + location);
    }

    HostConfiguration hostConfiguration = new HostConfiguration();

    hostConfiguration.setHost(new URI(location, false));

    if (isProxyHost(hostConfiguration.getHost())) {
      hostConfiguration.setProxy(_PROXY_HOST, _PROXY_PORT);
    }

    HttpConnectionManager httpConnectionManager = _httpClient.getHttpConnectionManager();

    HttpConnectionManagerParams httpConnectionManagerParams = httpConnectionManager.getParams();

    int defaultMaxConnectionsPerHost =
        httpConnectionManagerParams.getMaxConnectionsPerHost(hostConfiguration);

    int maxConnectionsPerHost =
        GetterUtil.getInteger(
            PropsUtil.get(
                HttpImpl.class.getName() + ".max.connections.per.host",
                new Filter(hostConfiguration.getHost())));

    if ((maxConnectionsPerHost > 0) && (maxConnectionsPerHost != defaultMaxConnectionsPerHost)) {

      httpConnectionManagerParams.setMaxConnectionsPerHost(
          hostConfiguration, maxConnectionsPerHost);
    }

    int timeout =
        GetterUtil.getInteger(
            PropsUtil.get(
                HttpImpl.class.getName() + ".timeout", new Filter(hostConfiguration.getHost())));

    if (timeout > 0) {
      HostParams hostParams = hostConfiguration.getParams();

      hostParams.setIntParameter(HttpConnectionParams.CONNECTION_TIMEOUT, timeout);
      hostParams.setIntParameter(HttpConnectionParams.SO_TIMEOUT, timeout);
    }

    return hostConfiguration;
  }
  public void deleteUser(long companyId, long userId) {
    try {
      CyrusServiceUtil.deleteUser(userId);

      // Expect

      String deleteUserCmd = PropsUtil.get(PropsKeys.MAIL_HOOK_CYRUS_DELETE_USER);

      deleteUserCmd = StringUtil.replace(deleteUserCmd, "%1%", String.valueOf(userId));

      Runtime rt = Runtime.getRuntime();

      Process p = rt.exec(deleteUserCmd);

      ProcessUtil.close(p);

      // Procmail

      String home = PropsUtil.get(PropsKeys.MAIL_HOOK_CYRUS_HOME);

      File file = new File(home + "/" + userId + ".procmail.blocked");

      if (file.exists()) {
        file.delete();
      }

      file = new File(home + "/" + userId + ".procmail.forward");

      if (file.exists()) {
        file.delete();
      }

      file = new File(home + "/" + userId + ".vacation");

      if (file.exists()) {
        file.delete();
      }

      file = new File(home + "/" + userId + ".vacation.cache");

      if (file.exists()) {
        file.delete();
      }
    } catch (Exception e) {
      _log.error(e, e);
    }
  }
  public void addForward(
      long companyId,
      long userId,
      List<Filter> filters,
      List<String> emailAddresses,
      boolean leaveCopy) {

    try {
      if (emailAddresses != null) {
        String home = PropsUtil.get(PropsKeys.MAIL_HOOK_CYRUS_HOME);

        File file = new File(home + "/" + userId + ".procmail.forward");

        if ((filters.size() > 0) || (emailAddresses.size() > 0) || (leaveCopy)) {

          StringBundler sb = new StringBundler();

          for (int i = 0; i < filters.size(); i++) {
            Filter filter = filters.get(i);

            sb.append(":0\n");
            sb.append("* ^(From|Cc|To).*");
            sb.append(filter.getEmailAddress());
            sb.append("\n");
            sb.append("| $DELIVER -e -a $USER -m user.$USER.");
            sb.append(filter.getFolder());
            sb.append("\n\n");
          }

          if (leaveCopy) {
            sb.append(":0 c\n");
            sb.append("| $DELIVER -e -a $USER -m user.$USER\n\n");
          }

          if (emailAddresses.size() > 0) {
            sb.append(":0\n");
            sb.append("!");

            for (String emailAddress : emailAddresses) {
              sb.append(" ");
              sb.append(emailAddress);
            }
          }

          String content = sb.toString();

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

          FileUtil.write(file, content);
        } else {
          file.delete();
        }
      }
    } catch (Exception e) {
      _log.error(e, e);
    }
  }
Example #14
0
  public Transformer(
      String transformerListenerPropertyKey, String errorTemplatePropertyKey, boolean restricted) {

    this(errorTemplatePropertyKey, restricted);

    _transformerListenerClassNames =
        SetUtil.fromArray(PropsUtil.getArray(transformerListenerPropertyKey));
  }
  @Override
  public List<String> getConfigLocations() {
    List<String> configLocations = ListUtil.fromArray(PropsUtil.getArray(PropsKeys.SPRING_CONFIGS));

    configLocations.remove("META-INF/model-listener-spring.xml");

    return configLocations;
  }
  protected void verifyRenamedPortalProperty(String oldKey, String newKey) throws Exception {

    String value = PropsUtil.get(oldKey);

    if (value != null) {
      _log.error("Portal property \"" + oldKey + "\" was renamed to \"" + newKey + "\"");
    }
  }
Example #17
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));
    }
  }
Example #18
0
  public static boolean getEmailPageAddedEnabled(PortletPreferences preferences) {

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

    if (Validator.isNotNull(emailPageAddedEnabled)) {
      return GetterUtil.getBoolean(emailPageAddedEnabled);
    } else {
      return GetterUtil.getBoolean(PropsUtil.get(PropsKeys.WIKI_EMAIL_PAGE_ADDED_ENABLED));
    }
  }
  protected void doExecute() throws Exception {
    File inputFile = new File(serviceFileName);

    if (!inputFile.exists()) {
      getLog().warn(inputFile.getAbsolutePath() + " does not exist");

      return;
    }

    getLog().info("Building from " + serviceFileName);

    PropsUtil.set("spring.configs", "META-INF/service-builder-spring.xml");
    PropsUtil.set(PropsKeys.RESOURCE_ACTIONS_READ_PORTLET_RESOURCES, "false");

    InitUtil.initWithSpring();

    new ServiceBuilder(
        serviceFileName,
        hbmFileName,
        ormFileName,
        modelHintsFileName,
        springFileName,
        springBaseFileName,
        null,
        springDynamicDataSourceFileName,
        springHibernateFileName,
        springInfrastructureFileName,
        springShardDataSourceFileName,
        apiDir,
        implDir,
        jsonFileName,
        null,
        sqlDir,
        sqlFileName,
        sqlIndexesFileName,
        sqlIndexesPropertiesFileName,
        sqlSequencesFileName,
        autoNamespaceTables,
        beanLocatorUtil,
        propsUtil,
        pluginName,
        null);
  }
Example #20
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));
    }
  }
Example #21
0
  public static boolean getEmailEventReminderEnabled(PortletPreferences preferences) {

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

    if (Validator.isNotNull(emailEventReminderEnabled)) {
      return GetterUtil.getBoolean(emailEventReminderEnabled);
    } else {
      return GetterUtil.getBoolean(PropsUtil.get(PropsKeys.CALENDAR_EMAIL_EVENT_REMINDER_ENABLED));
    }
  }
Example #22
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));
    }
  }
Example #23
0
  public static String getEmailPageUpdatedSignature(PortletPreferences preferences) {

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

    if (Validator.isNotNull(emailPageUpdatedSignature)) {
      return emailPageUpdatedSignature;
    } else {
      return ContentUtil.get(PropsUtil.get(PropsKeys.WIKI_EMAIL_PAGE_UPDATED_SIGNATURE));
    }
  }
Example #24
0
  public static boolean getEmailEntryUpdatedEnabled(PortletPreferences preferences) {

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

    if (Validator.isNotNull(emailEntryUpdatedEnabled)) {
      return GetterUtil.getBoolean(emailEntryUpdatedEnabled);
    } else {
      return GetterUtil.getBoolean(PropsUtil.get(PropsKeys.BOOKMARKS_EMAIL_ENTRY_UPDATED_ENABLED));
    }
  }
Example #25
0
  private static void _enableTransactions() throws Exception {
    if (_log.isDebugEnabled()) {
      _log.debug("Enable transactions");
    }

    PropsValues.SPRING_HIBERNATE_SESSION_DELEGATED =
        GetterUtil.getBoolean(PropsUtil.get(PropsKeys.SPRING_HIBERNATE_SESSION_DELEGATED));

    Field field = ReflectionUtil.getDeclaredField(ServiceBeanAopCacheManager.class, "_annotations");

    field.set(null, new ConcurrentHashMap<MethodInvocation, Annotation[]>());
  }
Example #26
0
  private String _readConfigurationFile(String propertyName, String format) throws IOException {

    ClassLoader classLoader = getClass().getClassLoader();

    String configurationFile = PropsUtil.get(propertyName, new Filter(format));

    if (Validator.isNotNull(configurationFile)) {
      return HttpUtil.URLtoString(classLoader.getResource(configurationFile));
    } else {
      return StringPool.BLANK;
    }
  }
  protected void initControlChannel() throws Exception {
    Properties controlProperties =
        PropsUtil.getProperties(PropsKeys.CLUSTER_LINK_CHANNEL_PROPERTIES_CONTROL, false);

    String controlProperty =
        controlProperties.getProperty(PropsKeys.CLUSTER_LINK_CHANNEL_PROPERTIES_CONTROL);

    ClusterRequestReceiver clusterRequestReceiver = new ClusterRequestReceiver(this);

    _controlJChannel =
        createJChannel(controlProperty, clusterRequestReceiver, _DEFAULT_CLUSTER_NAME);
  }
  protected void upgradeRatingsEntry(long classNameId) throws Exception {
    String className = PortalUtil.getClassName(classNameId);

    if (ArrayUtil.contains(PropsValues.RATINGS_UPGRADE_THUMBS_CLASS_NAMES, className)) {

      upgradeRatingsEntryThumbs(classNameId);
    } else {
      int defaultRatingsStarsNormalizationFactor =
          GetterUtil.getInteger(
              PropsUtil.get(
                  PropsKeys.RATINGS_UPGRADE_STARS_NORMALIZATION_FACTOR, new Filter("default")),
              5);

      int ratingsStarsNormalizationFactor =
          GetterUtil.getInteger(
              PropsUtil.get(
                  PropsKeys.RATINGS_UPGRADE_STARS_NORMALIZATION_FACTOR, new Filter(className)),
              defaultRatingsStarsNormalizationFactor);

      upgradeRatingsEntryStars(classNameId, ratingsStarsNormalizationFactor);
    }
  }
Example #29
0
  public Transformer(String errorTemplatePropertyKey, boolean restricted) {
    Set<String> langTypes = TemplateManagerUtil.getSupportedLanguageTypes(errorTemplatePropertyKey);

    for (String langType : langTypes) {
      String errorTemplateId = PropsUtil.get(errorTemplatePropertyKey, new Filter(langType));

      if (Validator.isNotNull(errorTemplateId)) {
        _errorTemplateIds.put(langType, errorTemplateId);
      }
    }

    _restricted = restricted;
  }
Example #30
0
  @Override
  public void init(FilterConfig filterConfig) {
    super.init(filterConfig);

    _basicAuthEnabled = GetterUtil.getBoolean(filterConfig.getInitParameter("basic_auth"));
    _digestAuthEnabled = GetterUtil.getBoolean(filterConfig.getInitParameter("digest_auth"));

    String propertyPrefix = filterConfig.getInitParameter("portal_property_prefix");

    String[] hostsAllowedArray = null;

    if (Validator.isNull(propertyPrefix)) {
      hostsAllowedArray = StringUtil.split(filterConfig.getInitParameter("hosts.allowed"));
      _httpsRequired = GetterUtil.getBoolean(filterConfig.getInitParameter("https.required"));
    } else {
      hostsAllowedArray = PropsUtil.getArray(propertyPrefix + "hosts.allowed");
      _httpsRequired = GetterUtil.getBoolean(PropsUtil.get(propertyPrefix + "https.required"));
    }

    for (int i = 0; i < hostsAllowedArray.length; i++) {
      _hostsAllowed.add(hostsAllowedArray[i]);
    }
  }