Beispiel #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()), CharPool.SLASH, CharPool.PERIOD));
    sb.append(StringPool.CLOSE_PARENTHESIS);

    if (trashRenderer != null) {
      return trashRenderer.getNewName(oldName, sb.toString());
    } else {
      return getNewName(oldName, sb.toString());
    }
  }
Beispiel #2
0
  public static List<CalEvent> getMonthEvent(ThemeDisplay themeDisplay, EventDisplayModel evModel) {
    List<CalEvent> lstEvents = new ArrayList<CalEvent>();
    TimeZone timeZone = themeDisplay.getTimeZone();
    Locale locale = themeDisplay.getLocale();
    java.util.Calendar curCal = CalendarFactoryUtil.getCalendar(timeZone, locale);

    int curDay = curCal.get(Calendar.DAY_OF_MONTH);
    int curMonth = curCal.get(Calendar.MONTH);
    int curYear = curCal.get(Calendar.YEAR);
    int maxDayOfMonth = curCal.getActualMaximum(Calendar.DATE);

    GregorianCalendar gregCal = new GregorianCalendar();
    gregCal.set(Calendar.MONTH, curMonth);
    gregCal.set(Calendar.YEAR, curYear);

    try {
      for (int i = 1; i < maxDayOfMonth; i++) {
        List<CalEvent> tempEvents = new ArrayList<CalEvent>();
        gregCal.set(Calendar.DATE, i);
        tempEvents.addAll(
            CalEventServiceUtil.getEvents(themeDisplay.getScopeGroupId(), gregCal, new String()));
        lstEvents.addAll(tempEvents);
      }
      return lstEvents;
    } catch (PortalException e) {
      // TODO Auto-generated catch block
      _log.error(e);
      return null;
    } catch (SystemException e) {
      // TODO Auto-generated catch block
      _log.error(e);
      return null;
    }
  }
Beispiel #3
0
  public String getNewName(ThemeDisplay themeDisplay, String oldName) {
    Format dateFormatDateTime =
        FastDateFormatFactoryUtil.getDateTime(themeDisplay.getLocale(), themeDisplay.getTimeZone());

    StringBundler sb = new StringBundler(5);

    sb.append(oldName);
    sb.append(StringPool.SPACE);
    sb.append(StringPool.OPEN_PARENTHESIS);
    sb.append(
        StringUtil.replace(dateFormatDateTime.format(new Date()), CharPool.SLASH, CharPool.PERIOD));
    sb.append(StringPool.CLOSE_PARENTHESIS);

    return sb.toString();
  }
  @Override
  public void processAction(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig portletConfig,
      ActionRequest actionRequest,
      ActionResponse actionResponse)
      throws Exception {

    File file = null;

    try {
      ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

      long groupId = ParamUtil.getLong(actionRequest, "groupId");
      boolean privateLayout = ParamUtil.getBoolean(actionRequest, "privateLayout");
      long[] layoutIds = ParamUtil.getLongValues(actionRequest, "layoutIds");
      String fileName = ParamUtil.getString(actionRequest, "exportFileName");
      String range = ParamUtil.getString(actionRequest, "range");

      Date startDate = null;
      Date endDate = null;

      if (range.equals("dateRange")) {
        int startDateMonth = ParamUtil.getInteger(actionRequest, "startDateMonth");
        int startDateDay = ParamUtil.getInteger(actionRequest, "startDateDay");
        int startDateYear = ParamUtil.getInteger(actionRequest, "startDateYear");
        int startDateHour = ParamUtil.getInteger(actionRequest, "startDateHour");
        int startDateMinute = ParamUtil.getInteger(actionRequest, "startDateMinute");
        int startDateAmPm = ParamUtil.getInteger(actionRequest, "startDateAmPm");

        if (startDateAmPm == Calendar.PM) {
          startDateHour += 12;
        }

        startDate =
            PortalUtil.getDate(
                startDateMonth,
                startDateDay,
                startDateYear,
                startDateHour,
                startDateMinute,
                themeDisplay.getTimeZone(),
                new PortalException());

        int endDateMonth = ParamUtil.getInteger(actionRequest, "endDateMonth");
        int endDateDay = ParamUtil.getInteger(actionRequest, "endDateDay");
        int endDateYear = ParamUtil.getInteger(actionRequest, "endDateYear");
        int endDateHour = ParamUtil.getInteger(actionRequest, "endDateHour");
        int endDateMinute = ParamUtil.getInteger(actionRequest, "endDateMinute");
        int endDateAmPm = ParamUtil.getInteger(actionRequest, "endDateAmPm");

        if (endDateAmPm == Calendar.PM) {
          endDateHour += 12;
        }

        endDate =
            PortalUtil.getDate(
                endDateMonth,
                endDateDay,
                endDateYear,
                endDateHour,
                endDateMinute,
                themeDisplay.getTimeZone(),
                new PortalException());
      } else if (range.equals("fromLastPublishDate")) {
        LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(groupId, privateLayout);

        UnicodeProperties settingsProperties = layoutSet.getSettingsProperties();

        long lastPublishDate =
            GetterUtil.getLong(settingsProperties.getProperty("last-publish-date"));

        if (lastPublishDate > 0) {
          Calendar cal = Calendar.getInstance(themeDisplay.getTimeZone(), themeDisplay.getLocale());

          endDate = cal.getTime();

          cal.setTimeInMillis(lastPublishDate);

          startDate = cal.getTime();
        }
      } else if (range.equals("last")) {
        int rangeLast = ParamUtil.getInteger(actionRequest, "last");

        Date now = new Date();

        startDate = new Date(now.getTime() - (rangeLast * Time.HOUR));

        endDate = now;
      }

      file =
          LayoutServiceUtil.exportLayoutsAsFile(
              groupId,
              privateLayout,
              layoutIds,
              actionRequest.getParameterMap(),
              startDate,
              endDate);

      HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);
      HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse);

      ServletResponseUtil.sendFile(
          request, response, fileName, new FileInputStream(file), ContentTypes.APPLICATION_ZIP);

      setForward(actionRequest, ActionConstants.COMMON_NULL);
    } catch (Exception e) {
      _log.error(e, e);

      SessionErrors.add(actionRequest, e.getClass().getName());

      String pagesRedirect = ParamUtil.getString(actionRequest, "pagesRedirect");

      sendRedirect(actionRequest, actionResponse, pagesRedirect);
    } finally {
      FileUtil.delete(file);
    }
  }
Beispiel #5
0
  @RequestMapping
  public String ver(
      RenderRequest request,
      RenderResponse response,
      @RequestParam(required = false) Integer dias,
      Model model) {
    log.debug("Viendo el versiculo");
    TimeZone tz = null;
    DateTimeZone zone = null;
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    try {
      tz = themeDisplay.getTimeZone();
      zone = DateTimeZone.forID(tz.getID());
    } catch (IllegalArgumentException e) {
      zone = DateTimeZone.forID(ZonaHorariaUtil.getConvertedId(tz.getID()));
    }
    try {
      long scopeGroupId = themeDisplay.getScopeGroupId();

      AssetEntryQuery assetEntryQuery = new AssetEntryQuery();

      DateTime hoy =
          (DateTime)
              request.getPortletSession().getAttribute("hoy", PortletSession.APPLICATION_SCOPE);
      if (hoy == null) {
        hoy = new DateTime(zone);
        log.debug("Subiendo atributo hoy({}) a la sesion", hoy);
        request.getPortletSession().setAttribute("hoy", hoy, PortletSession.APPLICATION_SCOPE);
      }

      // Busca el contenido del dia
      String[] tags = TagsUtil.getTags(new String[4], hoy);
      tags[3] = "versiculo";

      long[] assetTagIds = AssetTagLocalServiceUtil.getTagIds(scopeGroupId, tags);

      assetEntryQuery.setAllTagIds(assetTagIds);

      List<AssetEntry> results = AssetEntryServiceUtil.getEntries(assetEntryQuery);

      log.debug("Buscando el versiculo de la semana {}", hoy);
      for (AssetEntry asset : results) {
        if (asset.getClassName().equals(JournalArticle.class.getName())) {
          JournalArticle ja = JournalArticleLocalServiceUtil.getLatestArticle(asset.getClassPK());
          String contenido =
              JournalArticleLocalServiceUtil.getArticleContent(
                  ja.getGroupId(),
                  ja.getArticleId(),
                  "view",
                  "" + themeDisplay.getLocale(),
                  themeDisplay);
          model.addAttribute("contenido", contenido);
        }
      }

    } catch (Exception e) {
      log.error("No se pudo cargar el contenido", e);
      throw new RuntimeException("No se pudo cargar el contenido", e);
    }

    return "versiculo/ver";
  }