protected SocialActivityFeedEntry doInterpret(SocialActivity activity, ThemeDisplay themeDisplay)
      throws Exception {

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (!CalEventPermission.contains(permissionChecker, activity.getClassPK(), ActionKeys.VIEW)) {

      return null;
    }

    String groupName = StringPool.BLANK;

    if (activity.getGroupId() != themeDisplay.getScopeGroupId()) {
      groupName = getGroupName(activity.getGroupId(), themeDisplay);
    }

    String creatorUserName = getUserName(activity.getUserId(), themeDisplay);

    int activityType = activity.getType();

    // Link

    CalEvent event = CalEventLocalServiceUtil.getEvent(activity.getClassPK());

    String link =
        themeDisplay.getPortalURL()
            + themeDisplay.getPathMain()
            + "/calendar/find_event?redirect="
            + themeDisplay.getURLCurrent()
            + "&eventId="
            + activity.getClassPK();

    // Title

    String titlePattern = null;

    if (activityType == CalendarActivityKeys.ADD_EVENT) {
      titlePattern = "activity-calendar-add-event";
    } else if (activityType == CalendarActivityKeys.UPDATE_EVENT) {
      titlePattern = "activity-calendar-update-event";
    }

    if (Validator.isNotNull(groupName)) {
      titlePattern += "-in";
    }

    String eventTitle = wrapLink(link, HtmlUtil.escape(cleanContent(event.getTitle())));

    Object[] titleArguments = new Object[] {groupName, creatorUserName, eventTitle};

    String title = themeDisplay.translate(titlePattern, titleArguments);

    // Body

    String body = StringPool.BLANK;

    return new SocialActivityFeedEntry(link, title, body);
  }
  public ViewPerformanceAppraisalLevels toEscapedModel() {
    if (isEscapedModel()) {
      return (ViewPerformanceAppraisalLevels) this;
    } else {
      ViewPerformanceAppraisalLevels model = new ViewPerformanceAppraisalLevelsImpl();

      model.setNew(isNew());
      model.setEscapedModel(true);

      model.setId(HtmlUtil.escape(getId()));
      model.setLevelId(getLevelId());
      model.setNumberOrder(getNumberOrder());
      model.setCompetencyId(getCompetencyId());
      model.setRootId(getRootId());
      model.setLevelName(HtmlUtil.escape(getLevelName()));
      model.setPaId(getPaId());
      model.setUserId(getUserId());
      model.setPeriodId(getPeriodId());
      model.setTotalLevelPoint(getTotalLevelPoint());
      model.setIsPassed(getIsPassed());

      model =
          (ViewPerformanceAppraisalLevels)
              Proxy.newProxyInstance(
                  ViewPerformanceAppraisalLevels.class.getClassLoader(),
                  new Class[] {ViewPerformanceAppraisalLevels.class},
                  new ReadOnlyBeanHandler(model));

      return model;
    }
  }
Beispiel #3
0
  /** @deprecated As of 6.2.0, replaced by {@link #getUserName(long, ServiceContext)} */
  protected String getUserName(long userId, ThemeDisplay themeDisplay) {
    try {
      if (userId <= 0) {
        return StringPool.BLANK;
      }

      User user = UserLocalServiceUtil.getUserById(userId);

      if (user.getUserId() == themeDisplay.getUserId()) {
        return HtmlUtil.escape(user.getFirstName());
      }

      String userName = user.getFullName();

      Group group = user.getGroup();

      if (group.getGroupId() == themeDisplay.getScopeGroupId()) {
        return HtmlUtil.escape(userName);
      }

      String userDisplayURL = user.getDisplayURL(themeDisplay);

      userName =
          "******"user\" href=\"" + userDisplayURL + "\">" + HtmlUtil.escape(userName) + "</a>";

      return userName;
    } catch (Exception e) {
      return StringPool.BLANK;
    }
  }
  protected String getWindowJS(PortletRequest portletRequest, JournalArticle article) {

    StringBundler sb = new StringBundler(13);

    sb.append("Liferay.Util.Window.getWindow({bodyCssClass: ");
    sb.append("'dialog-with-footer', destroyOnHide: true, dialog: ");
    sb.append(getDialogJS(article));
    sb.append(", id: '");

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    sb.append(HtmlUtil.escape(portletDisplay.getNamespace()));
    sb.append("viewSource', namespace: '");
    sb.append(portletDisplay.getNamespace());
    sb.append("', portlet: '#p_p_id_");
    sb.append(portletDisplay.getId());
    sb.append("_', portletId: '");
    sb.append(portletDisplay.getId());
    sb.append("', title: '");
    sb.append(HtmlUtil.escapeJS(HtmlUtil.escape(article.getTitle(themeDisplay.getLocale()))));
    sb.append("'});");

    return sb.toString();
  }
  @Override
  protected String getTitle(
      JSONObject jsonObject, AssetRenderer<?> assetRenderer, ServiceContext serviceContext) {

    MBMessage mbMessage = MBMessageLocalServiceUtil.fetchMBMessage(jsonObject.getLong("classPK"));

    AssetRendererFactory<?> assetRendererFactory =
        AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(
            assetRenderer.getClassName());

    String typeName = assetRendererFactory.getTypeName(serviceContext.getLocale());

    ResourceBundle resourceBundle =
        ResourceBundle.getBundle("content.Language", serviceContext.getLocale());

    if ((mbMessage != null) && mbMessage.isDiscussion()) {
      return LanguageUtil.format(
          resourceBundle,
          "x-mentioned-you-in-a-comment-in-a-x",
          new String[] {
            HtmlUtil.escape(assetRenderer.getUserName()),
            StringUtil.toLowerCase(HtmlUtil.escape(typeName))
          },
          false);
    } else {
      return LanguageUtil.format(
          resourceBundle,
          "x-mentioned-you-in-a-x",
          new String[] {
            HtmlUtil.escape(assetRenderer.getUserName()),
            StringUtil.toLowerCase(HtmlUtil.escape(typeName))
          },
          false);
    }
  }
  @Override
  protected String getBody(SocialActivity activity, ServiceContext serviceContext)
      throws Exception {

    String link = getLink(activity, serviceContext);

    String text = StringPool.BLANK;

    int activityType = activity.getType();

    if (activityType == JIRAActivityKeys.ADD_CHANGE) {
      JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(activity.getExtraData());

      text =
          interpretJIRAChangeItems(
              extraDataJSONObject.getJSONArray("jiraChangeItems"), serviceContext);
    } else if (activityType == JIRAActivityKeys.ADD_COMMENT) {
      long jiraActionId = GetterUtil.getLong(getJSONValue(activity.getExtraData(), "jiraActionId"));

      JIRAAction jiraAction = JIRAActionLocalServiceUtil.getJIRAAction(jiraActionId);

      text = HtmlUtil.escape(jiraAction.getBody());
    } else if (activityType == JIRAActivityKeys.ADD_ISSUE) {
      JIRAIssue jiraIssue = JIRAIssueLocalServiceUtil.getJIRAIssue(activity.getClassPK());

      text = HtmlUtil.escape(jiraIssue.getSummary());
    }

    return wrapLink(link, text);
  }
  @Override
  public String getScopeDescriptiveName(ThemeDisplay themeDisplay)
      throws PortalException, SystemException {

    if (getGroupId() == themeDisplay.getScopeGroupId()) {
      StringBundler sb = new StringBundler(5);

      sb.append(themeDisplay.translate("current-site"));
      sb.append(StringPool.SPACE);
      sb.append(StringPool.OPEN_PARENTHESIS);
      sb.append(HtmlUtil.escape(getDescriptiveName(themeDisplay.getLocale())));
      sb.append(StringPool.CLOSE_PARENTHESIS);

      return sb.toString();
    } else if (isLayout() && (getClassPK() == themeDisplay.getPlid())) {
      StringBundler sb = new StringBundler(5);

      sb.append(themeDisplay.translate("current-page"));
      sb.append(StringPool.SPACE);
      sb.append(StringPool.OPEN_PARENTHESIS);
      sb.append(HtmlUtil.escape(getDescriptiveName(themeDisplay.getLocale())));
      sb.append(StringPool.CLOSE_PARENTHESIS);

      return sb.toString();
    } else if (isLayoutPrototype()) {
      return themeDisplay.translate("default");
    } else {
      return HtmlUtil.escape(getDescriptiveName(themeDisplay.getLocale()));
    }
  }
  private void _buildPortletBreadcrumb(HttpServletRequest request, StringBundler sb)
      throws Exception {
    List<KeyValuePair> portletBreadcrumbList = PortalUtil.getPortletBreadcrumbList(request);

    if (portletBreadcrumbList == null) {
      return;
    }

    for (KeyValuePair kvp : portletBreadcrumbList) {
      String breadcrumbText = kvp.getKey();
      String breadcrumbURL = kvp.getValue();

      sb.append("<li><span>");

      if (Validator.isNotNull(breadcrumbURL)) {
        sb.append("<a href=\"");
        sb.append(HtmlUtil.escape(breadcrumbURL));
        sb.append("\">");
      }

      sb.append(HtmlUtil.escape(breadcrumbText));

      if (Validator.isNotNull(breadcrumbURL)) {
        sb.append("</a>");
      }

      sb.append("</span></li>");
    }
  }
  public LmisViewStaffRootOrg toEscapedModel() {
    if (isEscapedModel()) {
      return this;
    } else {
      LmisViewStaffRootOrg model = new LmisViewStaffRootOrgClp();

      model.setEscapedModel(true);

      model.setUser_id(getUser_id());
      model.setRootId(getRootId());
      model.setOrgId(getOrgId());
      model.setBodId(getBodId());
      model.setScreenName(HtmlUtil.escape(getScreenName()));
      model.setEmailAddress(HtmlUtil.escape(getEmailAddress()));

      model =
          (LmisViewStaffRootOrg)
              Proxy.newProxyInstance(
                  LmisViewStaffRootOrg.class.getClassLoader(),
                  new Class[] {LmisViewStaffRootOrg.class},
                  new ReadOnlyBeanHandler(model));

      return model;
    }
  }
  protected void getRootFolders(CommandArgument argument, Document doc, Element foldersEl)
      throws Exception {

    LinkedHashMap<String, Object> groupParams = new LinkedHashMap<String, Object>();

    groupParams.put("usersGroups", new Long(argument.getUserId()));

    List<Group> groups =
        GroupLocalServiceUtil.search(
            argument.getCompanyId(), null, null, groupParams, QueryUtil.ALL_POS, QueryUtil.ALL_POS);

    List<Organization> userOrgs =
        OrganizationLocalServiceUtil.getUserOrganizations(argument.getUserId(), true);

    for (Organization organization : userOrgs) {
      groups.add(0, organization.getGroup());
    }

    if (PropsValues.LAYOUT_USER_PRIVATE_LAYOUTS_ENABLED
        || PropsValues.LAYOUT_USER_PUBLIC_LAYOUTS_ENABLED) {

      Group userGroup =
          GroupLocalServiceUtil.getUserGroup(argument.getCompanyId(), argument.getUserId());

      groups.add(0, userGroup);
    }

    ThemeDisplay themeDisplay = argument.getThemeDisplay();

    long scopeGroupId = themeDisplay.getScopeGroupId();

    for (Group group : groups) {
      Element folderEl = doc.createElement("Folder");

      foldersEl.appendChild(folderEl);

      boolean setNameAttribute = false;

      if (group.hasStagingGroup()) {
        Group stagingGroup = group.getStagingGroup();

        if (stagingGroup.getGroupId() == scopeGroupId) {
          folderEl.setAttribute(
              "name",
              stagingGroup.getGroupId()
                  + " - "
                  + HtmlUtil.escape(stagingGroup.getDescriptiveName()));

          setNameAttribute = true;
        }
      }

      if (!setNameAttribute) {
        folderEl.setAttribute(
            "name", group.getGroupId() + " - " + HtmlUtil.escape(group.getDescriptiveName()));
      }
    }
  }
  protected void compareVersions(RenderRequest renderRequest) throws Exception {

    long fileEntryId = ParamUtil.getLong(renderRequest, "fileEntryId");

    String sourceVersion = ParamUtil.getString(renderRequest, "sourceVersion");
    String targetVersion = ParamUtil.getString(renderRequest, "targetVersion");

    FileEntry fileEntry = DLAppServiceUtil.getFileEntry(fileEntryId);

    String extension = fileEntry.getExtension();

    FileVersion sourceFileVersion = fileEntry.getFileVersion(sourceVersion);

    String sourceTitle = sourceFileVersion.getTitle();

    FileVersion targetFileVersion = fileEntry.getFileVersion(targetVersion);

    String targetTitle = targetFileVersion.getTitle();

    InputStream sourceIs = fileEntry.getContentStream(sourceVersion);
    InputStream targetIs = fileEntry.getContentStream(targetVersion);

    if (extension.equals("htm") || extension.equals("html") || extension.equals("xml")) {

      String escapedSource = HtmlUtil.escape(StringUtil.read(sourceIs));
      String escapedTarget = HtmlUtil.escape(StringUtil.read(targetIs));

      sourceIs = new UnsyncByteArrayInputStream(escapedSource.getBytes(StringPool.UTF8));
      targetIs = new UnsyncByteArrayInputStream(escapedTarget.getBytes(StringPool.UTF8));
    }

    if (DocumentConversionUtil.isEnabled()
        && DocumentConversionUtil.isConvertBeforeCompare(extension)) {

      String sourceTempFileId = DLUtil.getTempFileId(fileEntryId, sourceVersion);
      String targetTempFileId = DLUtil.getTempFileId(fileEntryId, targetVersion);

      sourceIs =
          new FileInputStream(
              DocumentConversionUtil.convert(sourceTempFileId, sourceIs, extension, "txt"));
      targetIs =
          new FileInputStream(
              DocumentConversionUtil.convert(targetTempFileId, targetIs, extension, "txt"));
    }

    List<DiffResult>[] diffResults =
        DiffUtil.diff(new InputStreamReader(sourceIs), new InputStreamReader(targetIs));

    renderRequest.setAttribute(WebKeys.SOURCE_NAME, sourceTitle + StringPool.SPACE + sourceVersion);
    renderRequest.setAttribute(WebKeys.TARGET_NAME, targetTitle + StringPool.SPACE + targetVersion);
    renderRequest.setAttribute(WebKeys.DIFF_RESULTS, diffResults);
  }
  public void visit(LinkNode linkNode) {
    append("<a href=\"");
    append(HtmlUtil.escape(linkNode.getLink()));
    append("\">");

    if (linkNode.hasAltCollectionNode()) {
      CollectionNode altCollectionNode = linkNode.getAltCollectionNode();

      traverse(altCollectionNode.getASTNodes());
    } else {
      append(HtmlUtil.escape(linkNode.getLink()));
    }

    append("</a>");
  }
 public void visit(FormattedTextNode formattedTextNode) {
   if (formattedTextNode.getContent() != null) {
     append(HtmlUtil.escape(formattedTextNode.getContent()));
   } else {
     traverse(formattedTextNode.getChildASTNodes());
   }
 }
 public void visit(UnformattedTextNode unformattedTextNode) {
   if (unformattedTextNode.hasContent()) {
     append(HtmlUtil.escape(unformattedTextNode.getContent()));
   } else {
     traverse(unformattedTextNode.getChildASTNodes());
   }
 }
  public CdsPerformanceAppraisalSlotComments toEscapedModel() {
    if (isEscapedModel()) {
      return (CdsPerformanceAppraisalSlotComments) this;
    } else {
      CdsPerformanceAppraisalSlotComments model = new CdsPerformanceAppraisalSlotCommentsImpl();

      model.setNew(isNew());
      model.setEscapedModel(true);

      model.setCdsPerformanceAppraisalSlotCommentsId(getCdsPerformanceAppraisalSlotCommentsId());
      model.setPaId(getPaId());
      model.setRootId(getRootId());
      model.setPeriodId(getPeriodId());
      model.setUserId(getUserId());
      model.setSlotId(getSlotId());
      model.setCommentBy(getCommentBy());
      model.setCommentAt(getCommentAt());
      model.setCommentContent(HtmlUtil.escape(getCommentContent()));

      model =
          (CdsPerformanceAppraisalSlotComments)
              Proxy.newProxyInstance(
                  CdsPerformanceAppraisalSlotComments.class.getClassLoader(),
                  new Class[] {CdsPerformanceAppraisalSlotComments.class},
                  new ReadOnlyBeanHandler(model));

      return model;
    }
  }
  @Override
  public Object invoke(Object proxy, Method method, Object[] arguments) throws Throwable {

    String methodName = method.getName();

    if (methodName.startsWith("set")) {
      throw new IllegalAccessException("Setter methods cannot be called on an escaped bean");
    }

    if (methodName.endsWith("isEscapedModel")) {
      return true;
    } else if (methodName.endsWith("toEscapedModel")) {
      return proxy;
    }

    Object result = null;

    try {
      result = method.invoke(_bean, arguments);
    } catch (InvocationTargetException ite) {
      throw ite.getTargetException();
    }

    if (method.getAnnotation(AutoEscape.class) != null) {
      result = HtmlUtil.escape((String) result);
    }

    return result;
  }
  protected String sanitize(String message, String defaultResult) {
    if (message == null) {
      return null;
    }

    char[] chars = message.toCharArray();
    boolean sanitized = false;

    for (int i = 0; i < chars.length; i++) {
      int c = chars[i];

      if ((c >= 0) && (c < _whitelistCharacters.length) && (_whitelistCharacters[c] == 0)) {

        chars[i] = _LOG_SANITIZER_REPLACEMENT_CHARACTER;
        sanitized = true;
      }
    }

    if (sanitized) {
      String sanitizedMessage = new String(chars);

      sanitizedMessage = sanitizedMessage.concat(_SANITIZED);

      if (_LOG_SANITIZER_ESCAPE_HTML_ENABLED) {
        return HtmlUtil.escape(sanitizedMessage);
      }

      return sanitizedMessage;
    }

    return defaultResult;
  }
  public LmisWorkingTimes toEscapedModel() {
    if (isEscapedModel()) {
      return (LmisWorkingTimes) this;
    } else {
      LmisWorkingTimes model = new LmisWorkingTimesImpl();

      model.setNew(isNew());
      model.setEscapedModel(true);

      model.setLmisWorkingTimeId(getLmisWorkingTimeId());
      model.setRootId(getRootId());
      model.setSessionName(HtmlUtil.escape(getSessionName()));
      model.setStartTime(getStartTime());
      model.setEndTime(getEndTime());
      model.setLimitLate(getLimitLate());
      model.setMaxLate(getMaxLate());
      model.setCoefficientLate(getCoefficientLate());
      model.setLimitEarly(getLimitEarly());
      model.setMaxEarly(getMaxEarly());
      model.setCoefficientEarly(getCoefficientEarly());

      model =
          (LmisWorkingTimes)
              Proxy.newProxyInstance(
                  LmisWorkingTimes.class.getClassLoader(),
                  new Class[] {LmisWorkingTimes.class},
                  new ReadOnlyBeanHandler(model));

      return model;
    }
  }
  public CdsPerformanceAppraisalSlotRating toEscapedModel() {
    if (isEscapedModel()) {
      return (CdsPerformanceAppraisalSlotRating) this;
    } else {
      CdsPerformanceAppraisalSlotRating model = new CdsPerformanceAppraisalSlotRatingImpl();

      model.setNew(isNew());
      model.setEscapedModel(true);

      model.setCdsPerformanceAppraisalSlotRatingId(getCdsPerformanceAppraisalSlotRatingId());
      model.setPaId(getPaId());
      model.setRootId(getRootId());
      model.setPeriodId(getPeriodId());
      model.setUserId(getUserId());
      model.setSlotId(getSlotId());
      model.setRatingBy(getRatingBy());
      model.setRatingAt(getRatingAt());
      model.setRatingStatus(getRatingStatus());
      model.setUserType(getUserType());
      model.setPointName(HtmlUtil.escape(getPointName()));
      model.setPointValue(getPointValue());
      model.setRatingOrgId(getRatingOrgId());

      model =
          (CdsPerformanceAppraisalSlotRating)
              Proxy.newProxyInstance(
                  CdsPerformanceAppraisalSlotRating.class.getClassLoader(),
                  new Class[] {CdsPerformanceAppraisalSlotRating.class},
                  new ReadOnlyBeanHandler(model));

      return model;
    }
  }
  @Override
  public String getScopeDescriptiveName(ThemeDisplay themeDisplay) throws PortalException {

    if (getGroupId() == themeDisplay.getScopeGroupId()) {
      return StringUtil.appendParentheticalSuffix(
          themeDisplay.translate("current-site"),
          HtmlUtil.escape(getDescriptiveName(themeDisplay.getLocale())));
    } else if (isLayout() && (getClassPK() == themeDisplay.getPlid())) {
      return StringUtil.appendParentheticalSuffix(
          themeDisplay.translate("current-page"),
          HtmlUtil.escape(getDescriptiveName(themeDisplay.getLocale())));
    } else if (isLayoutPrototype()) {
      return themeDisplay.translate("default");
    } else {
      return HtmlUtil.escape(getDescriptiveName(themeDisplay.getLocale()));
    }
  }
  @Override
  protected SocialActivityFeedEntry doInterpret(SocialActivity activity, ThemeDisplay themeDisplay)
      throws Exception {

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (!WikiPagePermission.contains(permissionChecker, activity.getClassPK(), ActionKeys.VIEW)) {

      return null;
    }

    String groupName = StringPool.BLANK;

    if (activity.getGroupId() != themeDisplay.getScopeGroupId()) {
      groupName = getGroupName(activity.getGroupId(), themeDisplay);
    }

    String creatorUserName = getUserName(activity.getUserId(), themeDisplay);

    int activityType = activity.getType();

    // Link

    WikiPageResource pageResource =
        WikiPageResourceLocalServiceUtil.getPageResource(activity.getClassPK());

    String link =
        themeDisplay.getPortalURL()
            + themeDisplay.getPathMain()
            + "/wiki/find_page?pageResourcePrimKey="
            + activity.getClassPK();

    // Title

    String titlePattern = null;

    if (activityType == WikiActivityKeys.ADD_PAGE) {
      titlePattern = "activity-wiki-add-page";
    } else if (activityType == WikiActivityKeys.UPDATE_PAGE) {
      titlePattern = "activity-wiki-update-page";
    }

    if (Validator.isNotNull(groupName)) {
      titlePattern += "-in";
    }

    String pageTitle = wrapLink(link, HtmlUtil.escape(cleanContent(pageResource.getTitle())));

    Object[] titleArguments = new Object[] {groupName, creatorUserName, pageTitle};

    String title = themeDisplay.translate(titlePattern, titleArguments);

    // Body

    String body = StringPool.BLANK;

    return new SocialActivityFeedEntry(link, title, body);
  }
Beispiel #22
0
  protected String wrapLink(String link, String title) {
    title = HtmlUtil.escape(title);

    if (link == null) {
      return title;
    }

    return buildLink(link, title);
  }
  private void _buildParentGroupsBreadcrumb(
      LayoutSet layoutSet, PortletURL portletURL, ThemeDisplay themeDisplay, StringBundler sb)
      throws Exception {
    Group group = layoutSet.getGroup();

    if (group.isOrganization()) {
      Organization organization =
          OrganizationLocalServiceUtil.getOrganization(group.getOrganizationId());

      Organization parentOrganization = organization.getParentOrganization();

      if (parentOrganization != null) {
        Group parentGroup = parentOrganization.getGroup();

        LayoutSet parentLayoutSet =
            LayoutSetLocalServiceUtil.getLayoutSet(
                parentGroup.getGroupId(), layoutSet.isPrivateLayout());

        _buildParentGroupsBreadcrumb(parentLayoutSet, portletURL, themeDisplay, sb);
      }
    } else if (group.isUser()) {
      User groupUser = UserLocalServiceUtil.getUser(group.getClassPK());

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

      if (!organizations.isEmpty()) {
        Organization organization = organizations.get(0);

        Group parentGroup = organization.getGroup();

        LayoutSet parentLayoutSet =
            LayoutSetLocalServiceUtil.getLayoutSet(
                parentGroup.getGroupId(), layoutSet.isPrivateLayout());

        _buildParentGroupsBreadcrumb(parentLayoutSet, portletURL, themeDisplay, sb);
      }
    }

    int layoutsPageCount = 0;

    if (layoutSet.isPrivateLayout()) {
      layoutsPageCount = group.getPrivateLayoutsPageCount();
    } else {
      layoutsPageCount = group.getPublicLayoutsPageCount();
    }

    if ((layoutsPageCount > 0) && !group.getName().equals(GroupConstants.GUEST)) {
      String layoutSetFriendlyURL = PortalUtil.getLayoutSetFriendlyURL(layoutSet, themeDisplay);

      sb.append("<li><span><a href=\"");
      sb.append(layoutSetFriendlyURL);
      sb.append("\">");
      sb.append(HtmlUtil.escape(group.getDescriptiveName()));
      sb.append("</a></span></li>");
    }
  }
  public String getDescription(String languageId, boolean useDefault) {
    String value = LocalizationUtil.getLocalization(getDescription(), languageId, useDefault);

    if (isEscapedModel()) {
      return HtmlUtil.escape(value);
    } else {
      return value;
    }
  }
  public String getName(String languageId) {
    String value = LocalizationUtil.getLocalization(getName(), languageId);

    if (isEscapedModel()) {
      return HtmlUtil.escape(value);
    } else {
      return value;
    }
  }
  protected SocialActivityFeedEntry doInterpret(SocialActivity activity, ThemeDisplay themeDisplay)
      throws Exception {

    String creatorUserName = getUserName(activity.getUserId(), themeDisplay);
    String receiverUserName = getUserName(activity.getReceiverUserId(), themeDisplay);

    User receiverUser = UserLocalServiceUtil.getUserById(activity.getReceiverUserId());

    if (!SocialRelationLocalServiceUtil.hasRelation(
            themeDisplay.getUserId(),
            activity.getReceiverUserId(),
            SocialRelationConstants.TYPE_BI_FRIEND)
        && (themeDisplay.getUserId() != activity.getReceiverUserId())) {

      return null;
    }

    int activityType = activity.getType();

    // Link

    WallEntry wallEntry = WallEntryLocalServiceUtil.getWallEntry(activity.getClassPK());

    String link =
        themeDisplay.getPortalURL()
            + themeDisplay.getPathFriendlyURLPublic()
            + StringPool.SLASH
            + HtmlUtil.escapeURL(receiverUser.getScreenName())
            + "/profile/-/wall/"
            + activity.getClassPK();

    // Title

    String title = StringPool.BLANK;

    if (activityType == WallActivityKeys.ADD_ENTRY) {
      title =
          themeDisplay.translate(
              "activity-social-networking-wall-add-entry",
              new Object[] {creatorUserName, receiverUserName});
    }

    // Body

    StringBuilder sb = new StringBuilder();

    sb.append("<a href=\"");
    sb.append(link);
    sb.append("\">");
    sb.append(HtmlUtil.escape(cleanContent(wallEntry.getComments())));
    sb.append("</a>");

    String body = sb.toString();

    return new SocialActivityFeedEntry(link, title, body);
  }
Beispiel #27
0
  protected String wrapLink(String link, String key, ServiceContext serviceContext) {

    String title = serviceContext.translate(HtmlUtil.escape(key));

    if (link == null) {
      return title;
    }

    return buildLink(link, title);
  }
  private static String[][] _singleToPairArray(String[] array) {
    String[][] pairArray = new String[array.length][2];

    for (int i = 0; i < array.length; i++) {
      pairArray[i][0] = HtmlUtil.escape(array[i]);
      pairArray[i][1] = array[i];
    }

    return pairArray;
  }
  protected String interpretJIRAChangeItem(
      JSONObject jiraChangeItem, ServiceContext serviceContext) {

    String field = jiraChangeItem.getString("field");

    field = StringUtil.replace(StringUtil.toLowerCase(field), StringPool.SPACE, StringPool.DASH);

    String newString = jiraChangeItem.getString("newString");
    String newValue = jiraChangeItem.getString("newValue");

    if (Validator.isNull(newString)) {
      return StringPool.BLANK;
    }

    StringBundler sb = new StringBundler(2);

    if (field.equals("description") || field.equals("summary")) {
      sb.append(serviceContext.translate("activity-social-coding-jira-add-change-" + field));
      sb.append("<br />");
    } else if (field.equals("assignee")
        || field.equals("attachment")
        || field.equals("fix-version")
        || field.equals("issuetype")
        || field.equals("priority")
        || field.equals("resolution")
        || field.equals("status")
        || field.equals("version")) {

      sb.append(
          serviceContext.translate(
              "activity-social-coding-jira-add-change-" + field,
              new Object[] {HtmlUtil.escape(newString)}));
      sb.append("<br />");
    } else if (field.equals("link") && newValue.startsWith("LEP-")) {
      sb.append(
          serviceContext.translate(
              "activity-social-coding-jira-add-change-" + field,
              new Object[] {HtmlUtil.escape(newValue)}));
      sb.append("<br />");
    }

    return sb.toString();
  }
  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);
    }
  }