protected void validate(String bundleSymbolicName, String contextName) throws PortalException {

    if (Validator.isNull(bundleSymbolicName) && Validator.isNull(contextName)) {

      throw new ModuleNamespaceException();
    }
  }
Пример #2
0
  @Override
  protected void addSearchLocalizedTerm(
      BooleanQuery searchQuery, SearchContext searchContext, String field, boolean like)
      throws Exception {

    if (Validator.isNull(field)) {
      return;
    }

    String value = String.valueOf(searchContext.getAttribute(field));

    if (Validator.isNull(value)) {
      value = searchContext.getKeywords();
    }

    if (Validator.isNull(value)) {
      return;
    }

    field = DocumentImpl.getLocalizedName(searchContext.getLocale(), field);

    if (searchContext.isAndSearch()) {
      searchQuery.addRequiredTerm(field, value, like);
    } else {
      searchQuery.addTerm(field, value, like);
    }
  }
  @Override
  public int compare(Portlet portlet1, Portlet portlet2) {
    String portletTitle1 = StringPool.BLANK;
    String portletTitle2 = StringPool.BLANK;

    if (_servletContext != null) {
      portletTitle1 = PortalUtil.getPortletTitle(portlet1, _servletContext, _locale);
      portletTitle2 = PortalUtil.getPortletTitle(portlet2, _servletContext, _locale);
    } else {
      portletTitle1 = PortalUtil.getPortletTitle(portlet1, _locale);
      portletTitle2 = PortalUtil.getPortletTitle(portlet2, _locale);
    }

    if (Validator.isNull(portletTitle1) && Validator.isNull(portletTitle2)) {

      return 0;
    }

    if (Validator.isNull(portletTitle1)) {
      return 1;
    }

    if (Validator.isNull(portletTitle2)) {
      return -1;
    }

    Collator collator = Collator.getInstance(_locale);

    return collator.compare(portletTitle1, portletTitle2);
  }
  public String getParameter(String url, String name, boolean escaped) {
    if (Validator.isNull(url) || Validator.isNull(name)) {
      return StringPool.BLANK;
    }

    String[] parts = StringUtil.split(url, CharPool.QUESTION);

    if (parts.length == 2) {
      String[] params = null;

      if (escaped) {
        params = StringUtil.split(parts[1], "&");
      } else {
        params = StringUtil.split(parts[1], CharPool.AMPERSAND);
      }

      for (String param : params) {
        String[] kvp = StringUtil.split(param, CharPool.EQUAL);

        if ((kvp.length == 2) && kvp[0].equals(name)) {
          return kvp[1];
        }
      }
    }

    return StringPool.BLANK;
  }
Пример #5
0
  private void _process(String key, String[] classes, LifecycleEvent lifecycleEvent)
      throws ActionException {

    for (String className : classes) {
      if (Validator.isNull(className)) {
        return;
      }

      if (_log.isDebugEnabled()) {
        _log.debug("Process event " + className);
      }

      LifecycleAction lifecycleAction = (LifecycleAction) InstancePool.get(className);

      lifecycleAction.processLifecycleEvent(lifecycleEvent);
    }

    if (Validator.isNull(key)) {
      return;
    }

    for (LifecycleAction lifecycleAction : _instance._getLifecycleActions(key)) {

      lifecycleAction.processLifecycleEvent(lifecycleEvent);
    }
  }
Пример #6
0
  public String getDigest(String password) {
    if (Validator.isNull(getScreenName())) {
      throw new IllegalStateException("Screen name cannot be null");
    } else if (Validator.isNull(getEmailAddress())) {
      throw new IllegalStateException("Email address cannot be null");
    }

    StringBundler sb = new StringBundler(5);

    String digest1 =
        DigesterUtil.digestHex(Digester.MD5, getEmailAddress(), Portal.PORTAL_REALM, password);

    sb.append(digest1);
    sb.append(StringPool.COMMA);

    String digest2 =
        DigesterUtil.digestHex(Digester.MD5, getScreenName(), Portal.PORTAL_REALM, password);

    sb.append(digest2);
    sb.append(StringPool.COMMA);

    String digest3 =
        DigesterUtil.digestHex(
            Digester.MD5, String.valueOf(getUserId()), Portal.PORTAL_REALM, password);

    sb.append(digest3);

    return sb.toString();
  }
  protected void validate(long entryId, long userId, String fullName, String emailAddress)
      throws PortalException {

    if (Validator.isNull(fullName)) {
      throw new ContactFullNameException();
    }

    if (Validator.isNull(emailAddress)) {
      throw new RequiredEntryEmailAddressException();
    }

    if (!Validator.isEmailAddress(emailAddress)) {
      throw new EntryEmailAddressException();
    }

    if (entryId > 0) {
      Entry entry = entryPersistence.findByPrimaryKey(entryId);

      if (!StringUtil.equalsIgnoreCase(emailAddress, entry.getEmailAddress())) {

        validateEmailAddress(userId, emailAddress);
      }
    } else {
      validateEmailAddress(userId, emailAddress);
    }
  }
  @Override
  protected String getTitlePattern(String groupName, SocialActivity activity) {

    int activityType = activity.getType();

    if (activityType == JournalActivityKeys.ADD_ARTICLE) {
      if (Validator.isNull(groupName)) {
        return "activity-journal-article-add-web-content";
      } else {
        return "activity-journal-article-add-web-content-in";
      }
    } else if (activityType == JournalActivityKeys.UPDATE_ARTICLE) {
      if (Validator.isNull(groupName)) {
        return "activity-journal-article-update-web-content";
      } else {
        return "activity-journal-article-update-web-content-in";
      }
    } else if (activityType == SocialActivityConstants.TYPE_MOVE_TO_TRASH) {
      if (Validator.isNull(groupName)) {
        return "activity-journal-article-move-to-trash";
      } else {
        return "activity-journal-article-move-to-trash-in";
      }
    } else if (activityType == SocialActivityConstants.TYPE_RESTORE_FROM_TRASH) {

      if (Validator.isNull(groupName)) {
        return "activity-journal-article-restore-from-trash";
      } else {
        return "activity-journal-article-restore-from-trash-in";
      }
    }

    return null;
  }
Пример #9
0
  @Override
  protected Summary doGetSummary(
      Document document,
      Locale locale,
      String snippet,
      PortletURL portletURL,
      PortletRequest portletRequest,
      PortletResponse portletResponse) {

    String title = document.get(Field.TITLE);

    String content = snippet;

    if (Validator.isNull(snippet)) {
      content = document.get(Field.DESCRIPTION);

      if (Validator.isNull(content)) {
        content = StringUtil.shorten(document.get(Field.CONTENT), 200);
      }
    }

    String resourcePrimKey = document.get(Field.ENTRY_CLASS_PK);

    portletURL.setParameter("mvcPath", "/admin/view_article.jsp");
    portletURL.setParameter("resourcePrimKey", resourcePrimKey);

    return new Summary(title, content, portletURL);
  }
  @Override
  protected String[] doLogin(HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    long companyId = PortalUtil.getCompanyId(request);

    if (!isEnabled(companyId)) {
      return null;
    }

    String login = ParamUtil.getString(request, getLoginParam());

    if (Validator.isNull(login)) {
      return null;
    }

    String password = ParamUtil.getString(request, getPasswordParam());

    if (Validator.isNull(password)) {
      return null;
    }

    Company company = PortalUtil.getCompany(request);

    String authType = company.getAuthType();

    long userId = 0;

    if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
      userId = _userLocalService.getUserIdByEmailAddress(company.getCompanyId(), login);
    } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
      userId = _userLocalService.getUserIdByScreenName(company.getCompanyId(), login);
    } else if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
      userId = GetterUtil.getLong(login);
    } else {
      return null;
    }

    if (userId > 0) {
      User user = _userLocalService.getUserById(userId);

      String userPassword = user.getPassword();

      if (!user.isPasswordEncrypted()) {
        userPassword = PasswordEncryptorUtil.encrypt(userPassword);
      }

      String encPassword = PasswordEncryptorUtil.encrypt(password, userPassword);

      if (!userPassword.equals(password) && !userPassword.equals(encPassword)) {

        return null;
      }
    }

    String[] credentials =
        new String[] {String.valueOf(userId), password, Boolean.FALSE.toString()};

    return credentials;
  }
  protected void validate(String name, String description, String xsd) throws PortalException {

    if (Validator.isNull(name)) {
      throw new StructureNameException();
    } else if (Validator.isNull(description)) {
      throw new StructureDescriptionException();
    }

    if (Validator.isNull(xsd)) {
      throw new StructureXsdException();
    } else {
      try {
        Document doc = SAXReaderUtil.read(xsd);

        Element root = doc.getRootElement();

        List<Element> children = root.elements();

        if (children.size() == 0) {
          throw new StructureXsdException();
        }

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

        validate(children, elNames);
      } catch (Exception e) {
        throw new StructureXsdException();
      }
    }
  }
  @Override
  protected String getTitlePattern(String groupName, SocialActivity activity) {

    int activityType = activity.getType();

    long receiverUserId = activity.getReceiverUserId();

    if (activityType == MBActivityKeys.ADD_MESSAGE) {
      if (receiverUserId == 0) {
        if (Validator.isNull(groupName)) {
          return "activity-message-boards-message-add-message";
        } else {
          return "activity-message-boards-message-add-message-in";
        }
      } else {
        if (Validator.isNull(groupName)) {
          return "activity-message-boards-message-reply-message";
        } else {
          return "activity-message-boards-message-reply-message-in";
        }
      }
    } else if ((activityType == MBActivityKeys.REPLY_MESSAGE) && (receiverUserId > 0)) {

      if (Validator.isNull(groupName)) {
        return "activity-message-boards-message-reply-message";
      } else {
        return "activity-message-boards-message-reply-message-in";
      }
    }

    return null;
  }
Пример #13
0
  protected void configureSubtypeFieldFilter(AssetEntryQuery assetEntryQuery, Locale locale)
      throws Exception {

    long[] classNameIds = getClassNameIds();
    long[] classTypeIds = getClassTypeIds();

    if (!isSubtypeFieldsFilterEnabled()
        || (classNameIds.length != 1)
        || (classTypeIds.length != 1)
        || Validator.isNull(getDDMStructureFieldName())
        || Validator.isNull(getDDMStructureFieldValue())) {

      return;
    }

    AssetRendererFactory<?> assetRendererFactory =
        AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassNameId(classNameIds[0]);

    ClassTypeReader classTypeReader = assetRendererFactory.getClassTypeReader();

    ClassType classType = classTypeReader.getClassType(classTypeIds[0], locale);

    ClassTypeField classTypeField = classType.getClassTypeField(getDDMStructureFieldName());

    assetEntryQuery.setAttribute(
        "ddmStructureFieldName",
        AssetPublisherUtil.encodeName(
            classTypeField.getClassTypeId(), getDDMStructureFieldName(), locale));
    assetEntryQuery.setAttribute("ddmStructureFieldValue", getDDMStructureFieldValue());
  }
  protected boolean validateUniqueFieldNames(ActionRequest actionRequest) {
    Locale defaultLocale = LocaleUtil.getDefault();

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

    int[] formFieldsIndexes =
        StringUtil.split(ParamUtil.getString(actionRequest, "formFieldsIndexes"), 0);

    for (int formFieldsIndex : formFieldsIndexes) {
      Map<Locale, String> fieldLabelMap =
          LocalizationUtil.getLocalizationMap(actionRequest, "fieldLabel" + formFieldsIndex);

      if (Validator.isNull(fieldLabelMap.get(defaultLocale))) {
        continue;
      }

      for (Locale locale : fieldLabelMap.keySet()) {
        String fieldLabelValue = fieldLabelMap.get(locale);

        if (Validator.isNull(fieldLabelValue)) {
          continue;
        }

        String languageId = LocaleUtil.toLanguageId(locale);

        if (!localizedUniqueFieldNames.add(languageId + "_" + fieldLabelValue)) {

          return false;
        }
      }
    }

    return true;
  }
Пример #15
0
  public String getBaseType() {
    Class<?> model = getModel();

    String type = getType();

    String baseType = null;

    if ((model != null) && Validator.isNull(type)) {
      baseType = ModelHintsUtil.getType(model.getName(), getField());
    } else if (Validator.isNotNull(type)) {
      if (Objects.equals(type, "checkbox")
          || Objects.equals(type, "radio")
          || Objects.equals(type, "resource")) {

        baseType = type;
      } else if (Objects.equals(type, "toggle-card") || Objects.equals(type, "toggle-switch")) {

        baseType = "checkbox";
      }
    }

    if (Validator.isNull(baseType)) {
      baseType = "text";
    }

    return baseType;
  }
  protected void registerMessageListeners(String destinationName, Message message)
      throws SchedulerException {

    if (_portletLocalService == null) {
      throw new IllegalStateException("Portlet local service not initialized");
    }

    String messageListenerClassName =
        message.getString(SchedulerEngine.MESSAGE_LISTENER_CLASS_NAME);

    if (Validator.isNull(messageListenerClassName)) {
      return;
    }

    String portletId = message.getString(SchedulerEngine.PORTLET_ID);

    ClassLoader classLoader = null;

    if (Validator.isNull(portletId)) {
      classLoader = PortalClassLoaderUtil.getClassLoader();
    } else {
      Portlet portlet = _portletLocalService.getPortletById(portletId);

      if (portlet == null) {

        // No portlet found for the portlet ID. Try getting the class
        // loader where we assume the portlet ID is actually a servlet
        // context name.

        classLoader = ClassLoaderPool.getClassLoader(portletId);
      } else {
        PortletApp portletApp = portlet.getPortletApp();

        ServletContext servletContext = portletApp.getServletContext();

        classLoader = servletContext.getClassLoader();
      }
    }

    if (classLoader == null) {
      throw new SchedulerException("Unable to find class loader for portlet " + portletId);
    }

    MessageListener schedulerEventListener =
        getMessageListener(messageListenerClassName, classLoader);

    SchedulerEventMessageListenerWrapper schedulerEventListenerWrapper =
        new SchedulerEventMessageListenerWrapper();

    schedulerEventListenerWrapper.setMessageListener(schedulerEventListener);

    schedulerEventListenerWrapper.afterPropertiesSet();

    _messageBus.registerMessageListener(destinationName, schedulerEventListenerWrapper);

    message.put(
        SchedulerEngine.MESSAGE_LISTENER_UUID,
        schedulerEventListenerWrapper.getMessageListenerUUID());
  }
Пример #17
0
  protected void sendRedirect(
      PortletConfig portletConfig,
      ActionRequest actionRequest,
      ActionResponse actionResponse,
      String redirect,
      String closeRedirect)
      throws IOException {

    if (isDisplaySuccessMessage(actionRequest)) {
      addSuccessMessage(actionRequest, actionResponse);
    }

    if (Validator.isNull(redirect)) {
      redirect = (String) actionRequest.getAttribute(WebKeys.REDIRECT);
    }

    if (Validator.isNull(redirect)) {
      redirect = ParamUtil.getString(actionRequest, "redirect");
    }

    if ((portletConfig != null)
        && Validator.isNotNull(redirect)
        && Validator.isNotNull(closeRedirect)) {

      redirect = HttpUtil.setParameter(redirect, "closeRedirect", closeRedirect);

      SessionMessages.add(
          actionRequest,
          PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_CLOSE_REDIRECT,
          closeRedirect);
    }

    if (Validator.isNull(redirect)) {
      return;
    }

    // LPS-1928

    HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);

    if (BrowserSnifferUtil.isIe(request)
        && (BrowserSnifferUtil.getMajorVersion(request) == 6.0)
        && redirect.contains(StringPool.POUND)) {

      String redirectToken = "&#";

      if (!redirect.contains(StringPool.QUESTION)) {
        redirectToken = StringPool.QUESTION + redirectToken;
      }

      redirect = StringUtil.replace(redirect, StringPool.POUND, redirectToken);
    }

    redirect = PortalUtil.escapeRedirect(redirect);

    if (Validator.isNotNull(redirect)) {
      actionResponse.sendRedirect(redirect);
    }
  }
  public boolean isInheritWapLookAndFeel() {
    if (Validator.isNull(getWapThemeId()) || Validator.isNull(getWapColorSchemeId())) {

      return true;
    } else {
      return false;
    }
  }
  protected void validateCAS(ActionRequest actionRequest) throws Exception {
    boolean casEnabled =
        ParamUtil.getBoolean(actionRequest, "settings--" + PropsKeys.CAS_AUTH_ENABLED + "--");

    if (!casEnabled) {
      return;
    }

    String casLoginURL =
        ParamUtil.getString(actionRequest, "settings--" + PropsKeys.CAS_LOGIN_URL + "--");
    String casLogoutURL =
        ParamUtil.getString(actionRequest, "settings--" + PropsKeys.CAS_LOGOUT_URL + "--");
    String casServerName =
        ParamUtil.getString(actionRequest, "settings--" + PropsKeys.CAS_SERVER_NAME + "--");
    String casServerURL =
        ParamUtil.getString(actionRequest, "settings--" + PropsKeys.CAS_SERVER_URL + "--");
    String casServiceURL =
        ParamUtil.getString(actionRequest, "settings--" + PropsKeys.CAS_SERVICE_URL + "--");
    String casNoSuchUserRedirectURL =
        ParamUtil.getString(
            actionRequest, "settings--" + PropsKeys.CAS_NO_SUCH_USER_REDIRECT_URL + "--");

    if (!Validator.isUrl(casLoginURL)) {
      SessionErrors.add(actionRequest, "casLoginURLInvalid");
    }

    if (!Validator.isUrl(casLogoutURL)) {
      SessionErrors.add(actionRequest, "casLogoutURLInvalid");
    }

    if (Validator.isNull(casServerName)) {
      SessionErrors.add(actionRequest, "casServerNameInvalid");
    }

    if (Validator.isNotNull(casServerURL) && Validator.isNotNull(casServiceURL)) {

      SessionErrors.add(actionRequest, "casServerURLAndServiceURLConflict");
    } else if (Validator.isNull(casServerURL) && Validator.isNull(casServiceURL)) {

      SessionErrors.add(actionRequest, "casServerURLAndServiceURLNotSet");
    } else {
      if (Validator.isNotNull(casServerURL) && !Validator.isUrl(casServerURL)) {

        SessionErrors.add(actionRequest, "casServerURLInvalid");
      }

      if (Validator.isNotNull(casServiceURL) && !Validator.isUrl(casServiceURL)) {

        SessionErrors.add(actionRequest, "casServiceURLInvalid");
      }
    }

    if (Validator.isNotNull(casNoSuchUserRedirectURL)
        && !Validator.isUrl(casNoSuchUserRedirectURL)) {

      SessionErrors.add(actionRequest, "casNoSuchUserURLInvalid");
    }
  }
Пример #20
0
  protected void indexField(Document document, Element element, String elType, String elIndexType) {

    if (Validator.isNull(elIndexType)) {
      return;
    }

    com.liferay.portal.kernel.xml.Document structureDocument = element.getDocument();

    Element rootElement = structureDocument.getRootElement();

    String defaultLocale = GetterUtil.getString(rootElement.attributeValue("default-locale"));

    String name = encodeFieldName(element.attributeValue("name"));

    List<Element> dynamicContentElements = element.elements("dynamic-content");

    for (Element dynamicContentElement : dynamicContentElements) {
      String contentLocale =
          GetterUtil.getString(dynamicContentElement.attributeValue("language-id"));

      String[] value = new String[] {dynamicContentElement.getText()};

      if (elType.equals("multi-list")) {
        List<Element> optionElements = dynamicContentElement.elements("option");

        value = new String[optionElements.size()];

        for (int i = 0; i < optionElements.size(); i++) {
          value[i] = optionElements.get(i).getText();
        }
      }

      if (elIndexType.equals("keyword")) {
        if (Validator.isNull(contentLocale)) {
          document.addKeyword(name, value);
        } else {
          if (defaultLocale.equals(contentLocale)) {
            document.addKeyword(name, value);
          }

          document.addKeyword(name.concat(StringPool.UNDERLINE).concat(contentLocale), value);
        }
      } else if (elIndexType.equals("text")) {
        if (Validator.isNull(contentLocale)) {
          document.addText(name, StringUtil.merge(value, StringPool.SPACE));
        } else {
          if (defaultLocale.equals(contentLocale)) {
            document.addText(name, StringUtil.merge(value, StringPool.SPACE));
          }

          document.addText(
              name.concat(StringPool.UNDERLINE).concat(contentLocale),
              StringUtil.merge(value, StringPool.SPACE));
        }
      }
    }
  }
Пример #21
0
  private String _getJavaMethodComment(
      String[] lines, Map<String, Element> methodElementsMap, JavaMethod javaMethod) {

    String methodKey = _getMethodKey(javaMethod);

    Element methodElement = methodElementsMap.get(methodKey);

    if (methodElement == null) {
      return null;
    }

    String indent = _getIndent(lines, javaMethod);

    StringBundler sb = new StringBundler();

    sb.append(indent);
    sb.append("/**\n");

    String comment = methodElement.elementText("comment");

    if (Validator.isNotNull(comment)) {
      sb.append(_wrapText(comment, indent + " * "));
    }

    String docletTags =
        _addDocletTags(
            methodElement,
            new String[] {"version", "param", "return", "throws", "see", "since", "deprecated"},
            indent + " * ",
            _hasPublicModifier(javaMethod));

    if (Validator.isNotNull(docletTags)) {
      if (_initializeMissingJavadocs || Validator.isNotNull(comment)) {
        sb.append(indent);
        sb.append(" *\n");
      }

      sb.append(docletTags);
    }

    sb.append(indent);
    sb.append(" */\n");

    if (!_initializeMissingJavadocs && Validator.isNull(comment) && Validator.isNull(docletTags)) {

      return null;
    }

    if (!_hasPublicModifier(javaMethod)
        && Validator.isNull(comment)
        && Validator.isNull(docletTags)) {

      return null;
    }

    return sb.toString();
  }
  protected String getPortalJsp(String customJsp, String customJspDir) {
    if (Validator.isNull(customJsp) || Validator.isNull(customJspDir)) {
      return null;
    }

    int pos = customJsp.indexOf(customJspDir);

    return customJsp.substring(pos + customJspDir.length());
  }
Пример #23
0
  @Override
  public boolean isInheritLookAndFeel() {
    if (Validator.isNull(getThemeId()) || Validator.isNull(getColorSchemeId())) {

      return true;
    }

    return false;
  }
  protected void validate(String title, String content) throws PortalException {

    if (Validator.isNull(title)) {
      throw new KBArticleTitleException();
    }

    if (Validator.isNull(content)) {
      throw new KBArticleContentException();
    }
  }
Пример #25
0
  protected void validate(
      long companyId,
      boolean autoPassword,
      String password1,
      String password2,
      boolean autoScreenName,
      String screenName,
      String emailAddress,
      String firstName,
      String lastName,
      long organizationId,
      long locationId)
      throws PortalException, SystemException {

    if (!autoScreenName) {
      validateScreenName(companyId, screenName);
    }

    if (!autoPassword) {
      PasswordPolicy passwordPolicy =
          PasswordPolicyLocalServiceUtil.getDefaultPasswordPolicy(companyId);

      PwdToolkitUtil.validate(companyId, 0, password1, password2, passwordPolicy);
    }

    if (!Validator.isEmailAddress(emailAddress)) {
      throw new UserEmailAddressException();
    } else {
      // As per caGrid requirements portal can have duplicate email address for a particular company
      // Id.
      /*try {
      	User user = UserUtil.findByC_EA(companyId, emailAddress);

      	if (user != null) {
      		throw new DuplicateUserEmailAddressException();
      	}
      } catch (NoSuchUserException nsue) {
      }*/

      String[] reservedEmailAddresses =
          PrefsPropsUtil.getStringArray(companyId, PropsUtil.ADMIN_RESERVED_EMAIL_ADDRESSES);

      for (int i = 0; i < reservedEmailAddresses.length; i++) {
        if (emailAddress.equalsIgnoreCase(reservedEmailAddresses[i])) {
          throw new ReservedUserEmailAddressException();
        }
      }
    }

    if (Validator.isNull(firstName)) {
      throw new ContactFirstNameException();
    } else if (Validator.isNull(lastName)) {
      throw new ContactLastNameException();
    }
  }
  public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
      return _servletContextName;
    }

    synchronized (ClpSerializer.class) {
      if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
      }

      try {
        ClassLoader classLoader = ClpSerializer.class.getClassLoader();

        Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

        Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] {String.class});

        String portletPropsServletContextName =
            (String)
                getMethod.invoke(
                    null,
                    "com.liferay.portal.content.targeting.rule.score.points-deployment-context");

        if (Validator.isNotNull(portletPropsServletContextName)) {
          _servletContextName = portletPropsServletContextName;
        }
      } catch (Throwable t) {
        if (_log.isInfoEnabled()) {
          _log.info("Unable to locate deployment context from portlet properties");
        }
      }

      if (Validator.isNull(_servletContextName)) {
        try {
          String propsUtilServletContextName =
              PropsUtil.get(
                  "com.liferay.portal.content.targeting.rule.score.points-deployment-context");

          if (Validator.isNotNull(propsUtilServletContextName)) {
            _servletContextName = propsUtilServletContextName;
          }
        } catch (Throwable t) {
          if (_log.isInfoEnabled()) {
            _log.info("Unable to locate deployment context from portal properties");
          }
        }
      }

      if (Validator.isNull(_servletContextName)) {
        _servletContextName = "com.liferay.portal.content.targeting.rule.score.points";
      }

      return _servletContextName;
    }
  }
Пример #27
0
  protected QName getQName(String name, String uri, String defaultNamespace) {
    if (Validator.isNull(name) && Validator.isNull(uri)) {
      return null;
    }

    if (Validator.isNull(uri)) {
      return _saxReader.createQName(name, _saxReader.createNamespace(defaultNamespace));
    }

    return _saxReader.createQName(name, _saxReader.createNamespace(uri));
  }
Пример #28
0
  @Override
  public boolean isEmailAddressComplete() {
    if (Validator.isNull(getEmailAddress())
        || (PropsValues.USERS_EMAIL_ADDRESS_REQUIRED
            && Validator.isNull(getDisplayEmailAddress()))) {

      return false;
    }

    return true;
  }
  @Override
  public FileEntry addPortletFileEntry(
      long groupId,
      long userId,
      String className,
      long classPK,
      String portletId,
      long folderId,
      File file,
      String fileName,
      String mimeType,
      boolean indexingEnabled)
      throws PortalException, SystemException {

    if (Validator.isNull(fileName)) {
      return null;
    }

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setAddGroupPermissions(true);
    serviceContext.setAddGuestPermissions(true);

    Repository repository = addPortletRepository(groupId, portletId, serviceContext);

    serviceContext.setAttribute("className", className);
    serviceContext.setAttribute("classPK", String.valueOf(classPK));
    serviceContext.setIndexingEnabled(indexingEnabled);

    if (Validator.isNull(mimeType) || mimeType.equals(ContentTypes.APPLICATION_OCTET_STREAM)) {

      mimeType = MimeTypesUtil.getContentType(file, fileName);
    }

    boolean dlAppHelperEnabled = DLAppHelperThreadLocal.isEnabled();

    try {
      DLAppHelperThreadLocal.setEnabled(false);

      return DLAppLocalServiceUtil.addFileEntry(
          userId,
          repository.getRepositoryId(),
          folderId,
          fileName,
          mimeType,
          fileName,
          StringPool.BLANK,
          StringPool.BLANK,
          file,
          serviceContext);
    } finally {
      DLAppHelperThreadLocal.setEnabled(dlAppHelperEnabled);
    }
  }
Пример #30
0
  protected void initLocalClusterNode() {
    InetAddress inetAddress = getBindInetAddress(_controlJChannel);

    ClusterNode clusterNode = new ClusterNode(PortalUUIDUtil.generate(), inetAddress);

    if (Validator.isNull(PropsValues.PORTAL_INSTANCE_PROTOCOL)) {
      _localClusterNode = clusterNode;

      return;
    }

    if (Validator.isNull(PropsValues.PORTAL_INSTANCE_INET_SOCKET_ADDRESS)) {
      throw new IllegalArgumentException(
          "Portal instance host name and port needs to be set in the "
              + "property \"portal.instance.inet.socket.address\"");
    }

    String[] parts =
        StringUtil.split(PropsValues.PORTAL_INSTANCE_INET_SOCKET_ADDRESS, CharPool.COLON);

    if (parts.length != 2) {
      throw new IllegalArgumentException(
          "Unable to parse the portal instance host name and port from "
              + PropsValues.PORTAL_INSTANCE_INET_SOCKET_ADDRESS);
    }

    InetAddress hostInetAddress = null;

    try {
      hostInetAddress = InetAddress.getByName(parts[0]);
    } catch (UnknownHostException uhe) {
      throw new IllegalArgumentException(
          "Unable to parse the portal instance host name and port from "
              + PropsValues.PORTAL_INSTANCE_INET_SOCKET_ADDRESS,
          uhe);
    }

    int port = -1;

    try {
      port = GetterUtil.getIntegerStrict(parts[1]);
    } catch (NumberFormatException nfe) {
      throw new IllegalArgumentException(
          "Unable to parse portal InetSocketAddress port from "
              + PropsValues.PORTAL_INSTANCE_INET_SOCKET_ADDRESS,
          nfe);
    }

    clusterNode.setPortalInetSocketAddress(new InetSocketAddress(hostInetAddress, port));

    clusterNode.setPortalProtocol(PropsValues.PORTAL_INSTANCE_PROTOCOL);

    _localClusterNode = clusterNode;
  }