@SynchronizeByAllEntity(entityClass = Site.class)
  @RemoteMethod
  public String execute(final Integer targetSiteId) throws IOException, ServletException {
    userSitesUrl = configStorage.get().getUserSitesUrl();

    final UserManager userManager = new UsersManager().getLogined();

    if (targetSiteId != null) {
      targetSite = userManager.getRight().getSiteRight().getSiteForEdit(targetSiteId).getSite();
      targetSites = Arrays.asList(targetSite);
    } else {
      targetSites =
          persistance.getSites(userManager.getUserId(), SiteAccessLevel.getUserAccessLevels());
      Collections.sort(targetSites, new SiteByTitleComparator());
    }

    sites = new ArrayList<Site>();
    for (final Site site : persistance.getAllSites()) {
      if (site.getType() == SiteType.COMMON
          && site.getSitePaymentSettings().getSiteStatus() == SiteStatus.ACTIVE) {
        sites.add(site);
      }
    }
    Collections.sort(sites, new SiteByTitleComparator());
    return executePage("/site/showRequestContent.jsp");
  }
  @SynchronizeByMethodParameter(entityClass = Site.class)
  @RemoteMethod
  public String sort(
      final int siteId,
      final StatisticsSortType sortType,
      final boolean desc,
      final StatisticsTimePeriodType timePeriod,
      final Integer pageNumber)
      throws IOException, ServletException {
    final UserManager userManager = new UsersManager().getLogined();
    final Site site = userManager.getRight().getSiteRight().getSiteForView(siteId).getSite();

    final List<Page> sitePages = PagesWithoutSystem.get(site.getPages());
    sessionStorage.setStatisticsTimePeriodTypeInServiceForPage(this, timePeriod);

    final Paginator paginator =
        statisticsPageSort.sort(sitePages, sortType, desc, timePeriod, pageNumber);

    getContext().getHttpServletRequest().setAttribute("paginator", paginator);
    getContext().getHttpServletRequest().setAttribute("trafficPagesSortType", sortType);
    getContext().getHttpServletRequest().setAttribute("descending", desc);
    return executePage("/site/traffic/trafficPagesList.jsp");
  }
示例#3
0
  @RemoteMethod
  public FunctionalWidgetInfo execute(final SaveScriptRequest request) throws Exception {
    final UserManager userManager = new UsersManager().getLogined();

    final WidgetItem widget;
    if (request.getWidgetId() != null) {
      widget =
          (WidgetItem)
              userManager
                  .getRight()
                  .getSiteRight()
                  .getWidgetForEditInPresentationalService(request.getWidgetId());
    } else {
      widget = null;
    }

    persistanceTransaction.execute(
        new Runnable() {

          @Override
          public void run() {
            final DraftScript draftScript = persistance.getDraftItem(request.getScriptItemId());
            if (draftScript == null || draftScript.getSiteId() <= 0) {
              throw new ScriptNotFoundException(
                  "Cannot find script item by Id=" + request.getScriptItemId());
            }

            draftScript.setText(request.getText());
            draftScript.setName(request.getName());
            draftScript.setDescription(request.getDescription());
            draftScript.setShowDescription(request.isShowDescription());
          }
        });

    return new GetFunctionalWidgetsService().createFunctionalWidgetInfo(widget, "widget", true);
  }