Beispiel #1
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;
    }
  }
 /**
  * Default article.
  *
  * @param request the request
  * @param response the response
  */
 public void defaultArticle(ActionRequest request, ActionResponse response) {
   String defaultArticle = ParamUtil.getString(request, ARTICLE_ID);
   PortletPreferences preferences = request.getPreferences();
   try {
     preferences.setValue(DEFAULT_ARTICLE, defaultArticle);
     preferences.store();
   } catch (ReadOnlyException e) {
     LOG.error(e);
   } catch (ValidatorException e) {
     LOG.error(e);
   } catch (IOException e) {
     LOG.error(e);
   }
   SessionMessages.add(request, ARTICLE_DEAFULT);
 }
 @Override
 public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
     throws IOException, PortletException {
   String id = resourceRequest.getResourceID();
   if (id.equalsIgnoreCase("getBrokerTopics")) {
     JSONArray topics = JSONFactoryUtil.createJSONArray();
     long brokerId = ParamUtil.getLong(resourceRequest, "brokerId");
     long brokerMessageListenerId = ParamUtil.getLong(resourceRequest, "brokerMessageListenerId");
     try {
       Broker b = BrokerLocalServiceUtil.fetchBroker(brokerId);
       BrokerMessageListener bml =
           (brokerMessageListenerId > 0)
               ? BrokerMessageListenerLocalServiceUtil.fetchBrokerMessageListener(
                   brokerMessageListenerId)
               : null;
       String[] topicsArr = b.getTopics().split(";");
       for (int i = 0; i < topicsArr.length; i++) {
         JSONObject obj = JSONFactoryUtil.createJSONObject();
         obj.put("topic", topicsArr[i]);
         boolean checked = false;
         if (bml != null) {
           String[] messageListenerTopcs = bml.getTopics().split(";");
           for (int j = 0; j < messageListenerTopcs.length && !checked; j++) {
             if (messageListenerTopcs[j].equalsIgnoreCase(topicsArr[i])) checked = true;
           }
         }
         obj.put("checked", checked);
         topics.put(obj);
       }
     } catch (Exception e) {
       logger.error(e);
     }
     resourceResponse.getWriter().println(topics.toString());
   }
 }
  public Citizen getCitizenByUser(Long userId) {
    try {
      log.info("1.====userLiferayId:" + userId);
      TaiKhoanNguoiDung taiKhoanNguoiDung =
          TaiKhoanNguoiDungLocalServiceUtil.findByTaiKhoanNguoiDungId(userId);
      if (taiKhoanNguoiDung != null) {
        log.info("2.====taikhoannguoidungid:" + taiKhoanNguoiDung.getId());
        CongDan congDan =
            CongDanLocalServiceUtil.findByTaiKhoanNguoiDungId(taiKhoanNguoiDung.getId());
        if (congDan != null) {
          log.info("3.====congdanid:" + congDan.getId());

          return getCongDanSoap(congDan);
        } else {
          log.info("====Khong tim thay cong dan voi taikhoanid:" + taiKhoanNguoiDung.getId());
        }
      } else {
        log.info("=====Khong tim thay tai khoan voi account:" + userId);
      }
    } catch (Exception e) {
      // TODO: handle exception
      log.error("===lOI XAY RA", e);
      e.printStackTrace();
    }
    return null;
  }
 static {
   try {
     _shadowMatchCacheField =
         ReflectionUtil.getDeclaredField(AspectJExpressionPointcut.class, "shadowMatchCache");
   } catch (Exception e) {
     _log.error(e, e);
   }
 }
Beispiel #6
0
 public static int getEventsCount(long groupId, String type) {
   try {
     return CalEventLocalServiceUtil.getEventsCount(groupId, type);
   } catch (SystemException e) {
     // TODO Auto-generated catch block
     _log.error(e);
     return -1;
   }
 }
  public static void deleteEvent(long plid, long eventId) throws RemoteException {
    try {
      MeetingCalendarServiceUtil.deleteEvent(plid, eventId);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
  public static void deleteFeed(long groupId, long feedId) throws RemoteException {
    try {
      JournalFeedServiceUtil.deleteFeed(groupId, feedId);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
Beispiel #9
0
 protected void include(String path, RenderRequest renderRequest, RenderResponse renderResponse)
     throws IOException, PortletException {
   PortletRequestDispatcher portletRequestDispatcher =
       getPortletContext().getRequestDispatcher(path);
   if (portletRequestDispatcher == null) {
     log.error(path + " is not a valid include");
   } else {
     portletRequestDispatcher.include(renderRequest, renderResponse);
   }
 }
Beispiel #10
0
  public static List<CalEvent> getEvents(
      TimeZone timeZone, Locale locale, long groupId, String type) {
    Calendar curCal = CalendarFactoryUtil.getCalendar(timeZone, locale);

    try {
      return CalEventLocalServiceUtil.getEvents(groupId, curCal, type);
    } catch (SystemException e) {
      // TODO Auto-generated catch block
      _log.error(e);
      return null;
    }
  }
Beispiel #11
0
  static {
    if (UNSAFE_CREATE_THRESHOLD > 0) {
      try {
        _unsafeStringConstructor =
            String.class.getDeclaredConstructor(int.class, int.class, char[].class);

        _unsafeStringConstructor.setAccessible(true);
      } catch (Exception e) {
        _log.error(e, e);
      }
    }
  }
  public static com.liferay.portlet.calendar.model.CalEvent getEvent(long eventId)
      throws RemoteException {
    try {
      com.liferay.portlet.calendar.model.CalEvent returnValue =
          MeetingCalendarServiceUtil.getEvent(eventId);

      return returnValue;
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
  public static com.nss.portlet.journal.model.JournalFeedSoap getFeed(
      long groupId, java.lang.String feedId) throws RemoteException {
    try {
      com.nss.portlet.journal.model.JournalFeed returnValue =
          JournalFeedServiceUtil.getFeed(groupId, feedId);

      return com.nss.portlet.journal.model.JournalFeedSoap.toSoapModel(returnValue);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
  public static com.nss.portlet.journal.model.JournalFeedSoap addFeed(
      long groupId,
      java.lang.String feedId,
      boolean autoFeedId,
      java.lang.String name,
      java.lang.String description,
      java.lang.String type,
      java.lang.String structureId,
      java.lang.String templateId,
      java.lang.String rendererTemplateId,
      int delta,
      java.lang.String orderByCol,
      java.lang.String orderByType,
      java.lang.String targetLayoutFriendlyUrl,
      java.lang.String targetPortletId,
      java.lang.String contentField,
      java.lang.String feedType,
      double feedVersion,
      com.liferay.portal.service.ServiceContext serviceContext)
      throws RemoteException {
    try {
      com.nss.portlet.journal.model.JournalFeed returnValue =
          JournalFeedServiceUtil.addFeed(
              groupId,
              feedId,
              autoFeedId,
              name,
              description,
              type,
              structureId,
              templateId,
              rendererTemplateId,
              delta,
              orderByCol,
              orderByType,
              targetLayoutFriendlyUrl,
              targetPortletId,
              contentField,
              feedType,
              feedVersion,
              serviceContext);

      return com.nss.portlet.journal.model.JournalFeedSoap.toSoapModel(returnValue);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
Beispiel #15
0
  @Override
  public void processAction(ActionRequest request, ActionResponse response)
      throws IOException, PortletException {

    ActionRequest myRequest = request;

    if (FileUploadUtil.isMultipart(request)) {
      // logger.info("multipart!");
      try {
        myRequest = new FileUploadActionRequestWrapper(request);
      } catch (FileUploadException e) {
        logger.error(e.getMessage());
      }
    }

    super.processAction(myRequest, response);
  }
  public static Date getDateTo(long companyId, long userId) {
    Date result = null;
    try {
      result =
          ExpandoValueLocalServiceUtil.getData(
              companyId,
              User.class.getName(),
              ExpandoTableConstants.DEFAULT_TABLE_NAME,
              ExpandoTableConstants.COLUMN_ACCESS_DATE_TO,
              userId,
              result);
    } catch (Exception e) {
      _log.error("Can't access to user[" + userId + "] attributes", e);
    }

    return result;
  }
Beispiel #17
0
 static {
   try {
     _findClassMethod =
         ReflectionUtil.getDeclaredMethod(ClassLoader.class, "findClass", String.class);
     _getResourceMethod =
         ReflectionUtil.getDeclaredMethod(ClassLoader.class, "getResource", String.class);
     _getResourcesMethod =
         ReflectionUtil.getDeclaredMethod(ClassLoader.class, "getResources", String.class);
     _loadClassMethod =
         ReflectionUtil.getDeclaredMethod(
             ClassLoader.class, "loadClass", String.class, boolean.class);
   } catch (Exception e) {
     if (_log.isErrorEnabled()) {
       _log.error("Unable to locate required methods", e);
     }
   }
 }
  public static boolean isAccessByDateEnabled(long companyId, long userId) {
    boolean result = false;
    try {
      result =
          ExpandoValueLocalServiceUtil.getData(
              companyId,
              User.class.getName(),
              ExpandoTableConstants.DEFAULT_TABLE_NAME,
              ExpandoTableConstants.COLUMN_ACCESS_BY_DATE,
              userId,
              false);
    } catch (Exception e) {
      _log.error("Can't access to user[" + userId + "] attributes", e);
    }

    return result;
  }
  public static int getSessionCount(long companyId, long userId) {
    int result = 0;
    try {
      result =
          ExpandoValueLocalServiceUtil.getData(
              companyId,
              User.class.getName(),
              ExpandoTableConstants.DEFAULT_TABLE_NAME,
              ExpandoTableConstants.COLUMN_SESSION_COUNT,
              userId,
              result);
    } catch (Exception e) {
      _log.error("Can't access to user[" + userId + "] attributes", e);
    }

    return result;
  }
  public static synchronized void startApplication() {
    if (!appStarted) {
      appStarted = true;
      log.info("Log Viewer Startup");

      try {
        final boolean autoAttach = PortletPropsValues.PERMEANCE_LOG_VIEWER_AUTOATTACH_ENABLED;

        if (autoAttach) {
          log.info("Autoattaching logger");
          LogHolder.attach();
        } else {
          log.info("NOT autoattaching logger");
        }
      } catch (final Exception e) {
        log.error(e);
      }
    }
  }
 public void saveName(ActionRequest actionRequest, ActionResponse actionResponse)
     throws IOException, PortletException {
   _log.debug("saveName started");
   final String name =
       ParamUtil.get(actionRequest, MyHelloWorldMVCUtil.REQUEST_PARAM_NAME, StringPool.BLANK);
   final PortletPreferences portletPreferences = actionRequest.getPreferences();
   if (Validator.isBlank(name)) {
     _log.error("Name is blank. You must introduce valid value for name parameter.");
   } else {
     portletPreferences.setValue(MyHelloWorldMVCUtil.PORTLET_PREFERENCES_PARAM_NAME, name);
     _log.info(
         "saving new value ("
             + name
             + ") of "
             + MyHelloWorldMVCUtil.PORTLET_PREFERENCES_PARAM_NAME
             + " on portletPreferences");
     portletPreferences.store();
   }
   // Una vez que terminas la lógica de saveName forward a la vista
   actionResponse.setPortletMode(PortletMode.VIEW);
 }
Beispiel #22
0
  public static List<CalEvent> getEventFromDateRange(
      ThemeDisplay themeDisplay, Date startDate, Date endDate) {
    List<CalEvent> lstEvents = null;
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(CalEvent.class);
    dynamicQuery.add(PropertyFactoryUtil.forName("groupId").eq(themeDisplay.getScopeGroupId()));

    Criterion criterion = null;

    criterion = RestrictionsFactoryUtil.between("startDate", startDate, endDate);
    Order defaultOrder = OrderFactoryUtil.asc("startDate");

    dynamicQuery.add(criterion);
    dynamicQuery.addOrder(defaultOrder);
    try {
      lstEvents = CalEventLocalServiceUtil.dynamicQuery(dynamicQuery);
    } catch (SystemException e) {

      _log.error(e);
    }

    return lstEvents;
  }
  public void afterPropertiesSet() {
    String[] listenerClassNames =
        StringUtil.split(
            GetterUtil.getString(
                com.liferay.portal.util.PropsUtil.get(
                    "value.object.listener.com.ext.portlet.debaterevision.model.DebateItemReference")));

    if (listenerClassNames.length > 0) {
      try {
        List<ModelListener<DebateItemReference>> listenersList =
            new ArrayList<ModelListener<DebateItemReference>>();

        for (String listenerClassName : listenerClassNames) {
          listenersList.add(
              (ModelListener<DebateItemReference>) Class.forName(listenerClassName).newInstance());
        }

        listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
      } catch (Exception e) {
        _log.error(e);
      }
    }
  }
  @Override
  public void doView(RenderRequest request, RenderResponse response)
      throws IOException, PortletException {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    long groupId = themeDisplay.getScopeGroupId();

    PortletPreferences preferences = request.getPreferences();
    boolean showAnnouncer = false;
    if (themeDisplay.isSignedIn()) {
      String articleVersionId = preferences.getValue(ARTICLE_ID_CONSECUTIVE, LR_EMPTY_VALUE);
      String articleIds = preferences.getValue(ARTICLE_ID, LR_EMPTY_VALUE);
      if (!articleIds.equals(LR_EMPTY_VALUE)) {
        for (String articleId : articleIds.split(ARTICLE_SELECTION_DELIMITER)) {
          if (!AnnouncerTools.isArticle(groupId, articleId)) {
            AnnouncerTools.removeArticle(preferences, themeDisplay, articleId);
          }
          try {
            String layoutPK = String.valueOf(themeDisplay.getLayout().getPrimaryKey());
            showAnnouncer =
                AnnouncerTools.showAnnouncer(
                    themeDisplay.getRealUser().getUuid(), layoutPK, articleVersionId);
            request.setAttribute(ARTICLE_VERSION_ID, articleVersionId);
          } catch (SystemException e) {
            LOG.error(e);
          }
        }
      }
    }
    request.setAttribute(GROUP_ID, groupId);
    request.setAttribute(SHOW_ANNOUNCER, showAnnouncer);
    request.setAttribute(SIGNED_IN, themeDisplay.isSignedIn());
    String defaultArticle = preferences.getValue(DEFAULT_ARTICLE, LR_EMPTY_VALUE);
    request.setAttribute(DEFAULT_ARTICLE, defaultArticle);

    super.doView(request, response);
  }
  /**
   * @param companyId
   * @param userId
   * @return empty list, or list with values
   */
  public static List<String[]> getAllowedUserIP(long companyId, long userId) {
    String[] dataArray = null;
    try {
      dataArray =
          ExpandoValueLocalServiceUtil.getData(
              companyId,
              User.class.getName(),
              ExpandoTableConstants.DEFAULT_TABLE_NAME,
              ExpandoTableConstants.COLUMN_ALLOWED_IPS,
              userId,
              dataArray);

      dataArray =
          dataArray != null && dataArray.length > 0
              ? StringUtil.split(dataArray[0], CharPool.NEW_LINE)
              : new String[0];

    } catch (Exception e) {
      _log.error("Can't access to user[" + userId + "] attributes", e);
    }

    List<String[]> result = new LinkedList<String[]>();
    for (String ip : dataArray) {
      if (StringUtils.isBlank(ip)) continue;
      if (ip.contains("-")) {
        String[] range = ip.split("-");
        if (StringUtils.isNotBlank(range[0]) && StringUtils.isNotBlank(range[1])) {
          range[0] = range[0].trim();
          range[1] = range[1].trim();
          result.add(range);
        }
      }
      result.add(new String[] {ip.trim()});
    }
    return result;
  }
  /** Initializes the proposal rating persistence. */
  public void afterPropertiesSet() {
    String[] listenerClassNames =
        StringUtil.split(
            GetterUtil.getString(
                com.liferay.util.service.ServiceProps.get(
                    "value.object.listener.com.ext.portlet.model.ProposalRating")));

    if (listenerClassNames.length > 0) {
      try {
        List<ModelListener<ProposalRating>> listenersList =
            new ArrayList<ModelListener<ProposalRating>>();

        for (String listenerClassName : listenerClassNames) {
          listenersList.add(
              (ModelListener<ProposalRating>)
                  InstanceFactory.newInstance(getClassLoader(), listenerClassName));
        }

        listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
      } catch (Exception e) {
        _log.error(e);
      }
    }
  }
 @Override
 public OrderByComparator getDefinitionNameComparator(boolean ascending) {
   _log.error("Method is not implemented"); // TODO
   return null;
 }
  @Override
  public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception {

    long orderId = ParamUtil.getLong(request, PaypalConstants.PARAM_INVOICE);
    String status = ParamUtil.getString(request, PaypalConstants.PAYMENT_STATUS);

    LOG.info(String.format(LOG_NOTIFICATION, orderId, status));

    ShoppingOrder order = ShoppingOrderLocalServiceUtil.fetchShoppingOrder(orderId);
    List<ShoppingOrderItem> items = ShoppingOrderItemLocalServiceUtil.findByOrderId(orderId);

    if (items.isEmpty()) {
      LOG.error(String.format(LOG_UNKNOWN_ORDER, orderId));
      return null;
    }

    List<String> itemsIds = new ArrayList<String>();
    for (ShoppingOrderItem item : items) {
      itemsIds.add(Long.toString(item.getItemId()));
    }

    String query = PaypalConstants.PARAM_CMD + "=" + PaypalConstants.CMD_VALIDATE;

    Enumeration<String> enu = request.getParameterNames();

    while (enu.hasMoreElements()) {
      String name = enu.nextElement();
      String value = request.getParameter(name);
      if (LOG.isDebugEnabled()) LOG.debug(String.format(LOG_DEBUG_PARAM, name, value));
      query = query + "&" + name + "=" + HttpUtil.encodeURL(value);
    }

    if (LOG.isDebugEnabled()) LOG.debug(String.format(LOG_DEBUG_QUERY, query));

    URL url = new URL(PaypalConstants.PAYPAL_ENDPOINT);

    URLConnection urlc = url.openConnection();

    urlc.setDoOutput(true);
    urlc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

    PrintWriter pw = UnsyncPrintWriterPool.borrow(urlc.getOutputStream());

    pw.println(query);

    pw.close();

    UnsyncBufferedReader unsyncBufferedReader =
        new UnsyncBufferedReader(new InputStreamReader(urlc.getInputStream()));

    String payPalStatus = unsyncBufferedReader.readLine();

    unsyncBufferedReader.close();

    LOG.info(String.format(LOG_STATUS_RESPONSE, payPalStatus));

    if (payPalStatus.equals(PaypalConstants.TRANSACTION_VERIFIED)
        && status.equals(PaypalConstants.PAYMENT_COMPLETE)) {

      LOG.info(LOG_TRX_VERIFIED);

      order.setOrderStatus(OrderStatusEnum.PAID.toString());
      ShoppingOrderLocalServiceUtil.updateOrder(order);

      EmailNotificationUtil.sendEmailNotification(orderId);

    } else {
      LOG.error(LOG_TRX_ERROR);
    }

    return "/portal/paypal.jsp";
  }
 @Override
 public OrderByComparator getTaskUserIdComparator(boolean ascending) {
   _log.error("Method is not implemented"); // TODO
   return null;
 }
 @Override
 public OrderByComparator getInstanceStateComparator(boolean ascending) {
   _log.error("Method is not implemented"); // TODO
   return null;
 }