Esempio n. 1
0
  @Override
  public String getNewName(
      ThemeDisplay themeDisplay, String className, long classPK, String oldName)
      throws PortalException {

    TrashRenderer trashRenderer = null;

    if (Validator.isNotNull(className) && (classPK > 0)) {
      TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className);

      trashRenderer = trashHandler.getTrashRenderer(classPK);
    }

    Format dateFormatDateTime =
        FastDateFormatFactoryUtil.getDateTime(themeDisplay.getLocale(), themeDisplay.getTimeZone());

    StringBundler sb = new StringBundler(3);

    sb.append(StringPool.OPEN_PARENTHESIS);
    sb.append(
        StringUtil.replace(
            dateFormatDateTime.format(new Date()),
            new String[] {StringPool.SLASH, StringPool.COLON},
            new String[] {StringPool.PERIOD, StringPool.PERIOD}));
    sb.append(StringPool.CLOSE_PARENTHESIS);

    if (trashRenderer != null) {
      return trashRenderer.getNewName(oldName, sb.toString());
    } else {
      return getNewName(oldName, sb.toString());
    }
  }
Esempio n. 2
0
  public TimeZone getTimeZone() {
    if (_timeZone != null) {
      return _timeZone;
    }

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

    _timeZone = themeDisplay.getTimeZone();

    return _timeZone;
  }
  /**
   * Returns an export layout settings map if the type is {@link
   * ExportImportConfigurationConstants#TYPE_EXPORT_LAYOUT}; otherwise, returns either a local or
   * remote publish layout settings map, depending on the staging type.
   *
   * @param portletRequest the portlet request
   * @param groupId the primary key of the group
   * @param type the export/import option type
   * @return an export layout settings map if the type is an export layout; otherwise, returns
   *     either a local or remote publish layout settings map, depending on the staging type
   */
  public static Map<String, Serializable> buildSettingsMap(
      PortletRequest portletRequest, long groupId, int type) throws PortalException {

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

    boolean privateLayout = ParamUtil.getBoolean(portletRequest, "privateLayout");

    Map<Long, Boolean> layoutIdMap = ExportImportHelperUtil.getLayoutIdMap(portletRequest);

    if (type == ExportImportConfigurationConstants.TYPE_EXPORT_LAYOUT) {
      long[] layoutIds = ExportImportHelperUtil.getLayoutIds(layoutIdMap);

      return buildExportLayoutSettingsMap(
          themeDisplay.getUserId(),
          groupId,
          privateLayout,
          layoutIds,
          portletRequest.getParameterMap(),
          themeDisplay.getLocale(),
          themeDisplay.getTimeZone());
    }

    Group stagingGroup = GroupLocalServiceUtil.getGroup(groupId);

    Group liveGroup = stagingGroup.getLiveGroup();

    Map<String, String[]> parameterMap =
        ExportImportConfigurationParameterMapFactory.buildParameterMap(portletRequest);

    if (liveGroup != null) {
      long[] layoutIds = ExportImportHelperUtil.getLayoutIds(layoutIdMap, liveGroup.getGroupId());

      return buildPublishLayoutLocalSettingsMap(
          themeDisplay.getUserId(),
          stagingGroup.getGroupId(),
          liveGroup.getGroupId(),
          privateLayout,
          layoutIds,
          parameterMap,
          themeDisplay.getLocale(),
          themeDisplay.getTimeZone());
    }

    UnicodeProperties groupTypeSettingsProperties = stagingGroup.getTypeSettingsProperties();

    String remoteAddress =
        ParamUtil.getString(
            portletRequest,
            "remoteAddress",
            groupTypeSettingsProperties.getProperty("remoteAddress"));

    remoteAddress = StagingUtil.stripProtocolFromRemoteAddress(remoteAddress);

    int remotePort =
        ParamUtil.getInteger(
            portletRequest,
            "remotePort",
            GetterUtil.getInteger(groupTypeSettingsProperties.getProperty("remotePort")));
    String remotePathContext =
        ParamUtil.getString(
            portletRequest,
            "remotePathContext",
            groupTypeSettingsProperties.getProperty("remotePathContext"));
    boolean secureConnection =
        ParamUtil.getBoolean(
            portletRequest,
            "secureConnection",
            GetterUtil.getBoolean(groupTypeSettingsProperties.getProperty("secureConnection")));
    long remoteGroupId =
        ParamUtil.getLong(
            portletRequest,
            "remoteGroupId",
            GetterUtil.getLong(groupTypeSettingsProperties.getProperty("remoteGroupId")));
    boolean remotePrivateLayout = ParamUtil.getBoolean(portletRequest, "remotePrivateLayout");

    StagingUtil.validateRemote(
        groupId, remoteAddress, remotePort, remotePathContext, secureConnection, remoteGroupId);

    return buildPublishLayoutRemoteSettingsMap(
        themeDisplay.getUserId(),
        groupId,
        privateLayout,
        layoutIdMap,
        parameterMap,
        remoteAddress,
        remotePort,
        remotePathContext,
        secureConnection,
        remoteGroupId,
        remotePrivateLayout,
        themeDisplay.getLocale(),
        themeDisplay.getTimeZone());
  }