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>");
    }
  }
Ejemplo n.º 2
0
  public boolean equals(Object obj) {
    if (obj == null) {
      return false;
    }

    KeyValuePair kvp = (KeyValuePair) obj;

    String key = kvp.getKey();

    if (_key.equals(key)) {
      return true;
    } else {
      return false;
    }
  }
Ejemplo n.º 3
0
  /** TODO: Remove. This should extend from EditFileEntryAction once it is modularized. */
  protected void addMultipleFileEntries(
      PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    List<KeyValuePair> validFileNameKVPs = new ArrayList<>();
    List<KeyValuePair> invalidFileNameKVPs = new ArrayList<>();

    String[] selectedFileNames =
        ParamUtil.getParameterValues(actionRequest, "selectedFileName", new String[0], false);

    for (String selectedFileName : selectedFileNames) {
      addMultipleFileEntries(
          portletConfig,
          actionRequest,
          actionResponse,
          selectedFileName,
          validFileNameKVPs,
          invalidFileNameKVPs);
    }

    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

    for (KeyValuePair validFileNameKVP : validFileNameKVPs) {
      String fileName = validFileNameKVP.getKey();
      String originalFileName = validFileNameKVP.getValue();

      JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

      jsonObject.put("added", Boolean.TRUE);
      jsonObject.put("fileName", fileName);
      jsonObject.put("originalFileName", originalFileName);

      jsonArray.put(jsonObject);
    }

    for (KeyValuePair invalidFileNameKVP : invalidFileNameKVPs) {
      String fileName = invalidFileNameKVP.getKey();
      String errorMessage = invalidFileNameKVP.getValue();

      JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

      jsonObject.put("added", Boolean.FALSE);
      jsonObject.put("errorMessage", errorMessage);
      jsonObject.put("fileName", fileName);
      jsonObject.put("originalFileName", fileName);

      jsonArray.put(jsonObject);
    }

    JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonArray);
  }
  public void importPermissions(String resourceName, long resourcePK, long newResourcePK)
      throws PortalException, SystemException {

    if (!MapUtil.getBoolean(_parameterMap, PortletDataHandlerKeys.PERMISSIONS)) {

      return;
    }

    List<KeyValuePair> permissions =
        _permissionsMap.get(getPrimaryKeyString(resourceName, resourcePK));

    if (permissions == null) {
      return;
    }

    Map<Long, String[]> roleIdsToActionIds = new HashMap<Long, String[]>();

    for (KeyValuePair permission : permissions) {
      String roleName = permission.getKey();

      Role role = null;

      Team team = null;

      if (roleName.startsWith(PermissionExporter.ROLE_TEAM_PREFIX)) {
        roleName = roleName.substring(PermissionExporter.ROLE_TEAM_PREFIX.length());

        try {
          team = TeamLocalServiceUtil.getTeam(_groupId, roleName);
        } catch (NoSuchTeamException nste) {
          if (_log.isWarnEnabled()) {
            _log.warn("Team " + roleName + " does not exist");
          }

          continue;
        }
      }

      try {
        if (team != null) {
          role = RoleLocalServiceUtil.getTeamRole(_companyId, team.getTeamId());
        } else {
          role = RoleLocalServiceUtil.getRole(_companyId, roleName);
        }
      } catch (NoSuchRoleException nsre) {
        if (_log.isWarnEnabled()) {
          _log.warn("Role " + roleName + " does not exist");
        }

        continue;
      }

      String[] actionIds = StringUtil.split(permission.getValue());

      roleIdsToActionIds.put(role.getRoleId(), actionIds);
    }

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

    if (ResourceBlockLocalServiceUtil.isSupported(resourceName)) {
      ResourceBlockLocalServiceUtil.setIndividualScopePermissions(
          _companyId, _groupId, resourceName, newResourcePK, roleIdsToActionIds);
    } else {
      ResourcePermissionLocalServiceUtil.setResourcePermissions(
          _companyId,
          resourceName,
          ResourceConstants.SCOPE_INDIVIDUAL,
          String.valueOf(newResourcePK),
          roleIdsToActionIds);
    }
  }
Ejemplo n.º 5
0
  public int compareTo(Object obj) {
    KeyValuePair kvp = (KeyValuePair) obj;

    return _key.compareTo(kvp.getKey());
  }
Ejemplo n.º 6
0
  public InputSource resolveEntity(String publicId, String systemId) {
    ClassLoader classLoader = getClass().getClassLoader();

    if (_log.isDebugEnabled()) {
      _log.debug("Resolving entity " + publicId + " " + systemId);
    }

    if (publicId != null) {
      for (int i = 0; i < _PUBLIC_IDS.length; i++) {
        KeyValuePair kvp = _PUBLIC_IDS[i];

        if (publicId.equals(kvp.getKey())) {
          InputStream is = classLoader.getResourceAsStream(_DEFINITIONS_PATH + kvp.getValue());

          if (_log.isDebugEnabled()) {
            _log.debug("Entity found for public id " + systemId);
          }

          return new InputSource(is);
        }
      }
    } else if (systemId != null) {
      for (int i = 0; i < _SYSTEM_IDS.length; i++) {
        KeyValuePair kvp = _SYSTEM_IDS[i];

        if (systemId.equals(kvp.getKey())) {
          InputStream is = classLoader.getResourceAsStream(_DEFINITIONS_PATH + kvp.getValue());

          if (_log.isDebugEnabled()) {
            _log.debug("Entity found for system id " + systemId);
          }

          InputSource inputSource = new InputSource(is);

          inputSource.setSystemId(kvp.getKey());

          return inputSource;
        }
      }

      if (!systemId.endsWith(".dtd") && !systemId.endsWith(".xsd")) {
        throw new XNIException("Invalid system id " + systemId);
      }

      if (!systemId.startsWith(Http.HTTP_WITH_SLASH)
          && !systemId.startsWith(Http.HTTPS_WITH_SLASH)) {

        InputStream inputStream = classLoader.getResourceAsStream(systemId);

        if (inputStream != null) {
          InputSource inputSource = new InputSource(inputStream);

          inputSource.setSystemId(systemId);

          return inputSource;
        } else {
          throw new XNIException("Invalid system id " + systemId);
        }
      }
    }

    if (_log.isDebugEnabled()) {
      _log.debug("No entity found for " + publicId + " " + systemId);
    }

    return null;
  }