/**
  * Returns the StatisticUpdateManager bean (created via spring)
  *
  * @return the StatisticUpdateManager bean (created via spring)
  */
 private StatisticUpdateService getStatisticUpdateManager() {
   if (CoreSpringFactory.containsBean(StatisticUpdateService.class)) {
     return (StatisticUpdateService) CoreSpringFactory.getBean(StatisticUpdateService.class);
   } else {
     return null;
   }
 }
Exemple #2
0
 @Override
 public Controller createFooterController(final UserRequest ureq, final WindowControl wControl) {
   Controller footerCtr = null;
   // ----------- footer, optional (e.g. for copyright, powerd by) ------------------
   if (CoreSpringFactory.containsBean("fullWebApp.FooterControllerCreator")) {
     final ControllerCreator footerCreator =
         (ControllerCreator) CoreSpringFactory.getBean("fullWebApp.FooterControllerCreator");
     footerCtr = footerCreator.createController(ureq, wControl);
   }
   return footerCtr;
 }
Exemple #3
0
 @Override
 public Controller createTopNavController(final UserRequest ureq, final WindowControl wControl) {
   Controller topnavCtr = null;
   // ----------- topnav, optional (e.g. for imprint, logout) ------------------
   if (CoreSpringFactory.containsBean("fullWebApp.TopNavControllerCreator")) {
     final ControllerCreator topnavControllerCreator =
         (ControllerCreator) CoreSpringFactory.getBean("fullWebApp.TopNavControllerCreator");
     topnavCtr = topnavControllerCreator.createController(ureq, wControl);
   }
   return topnavCtr;
 }
  private void refreshUIState() {
    boolean enabled = false;
    String cronExpression = "";
    if (CoreSpringFactory.containsBean("schedulerFactoryBean")) {
      log.info("refreshUIState: schedulerFactoryBean found");
      final Object schedulerFactoryBean = CoreSpringFactory.getBean("schedulerFactoryBean");
      if (schedulerFactoryBean != null && schedulerFactoryBean instanceof Scheduler) {
        final Scheduler schedulerBean = (Scheduler) schedulerFactoryBean;
        int triggerState;
        try {
          triggerState =
              schedulerBean.getTriggerState("updateStatisticsTrigger", null /* trigger group */);
          enabled = (triggerState != Trigger.STATE_NONE) && (triggerState != Trigger.STATE_ERROR);
          log.info(
              "refreshUIState: updateStatisticsTrigger state was "
                  + triggerState
                  + ", enabled now: "
                  + enabled);
        } catch (final SchedulerException e) {
          log.warn(
              "refreshUIState: Got a SchedulerException while asking for the updateStatisticsTrigger's state",
              e);
        }
      }
      final CronTriggerBean triggerBean =
          (CronTriggerBean) CoreSpringFactory.getBean("updateStatisticsTrigger");
      final JobDetail jobDetail = triggerBean.getJobDetail();
      enabled &= jobDetail.getName().equals("statistics.job.enabled");
      log.info("refreshUIState: statistics.job.enabled check, enabled now: " + enabled);
      cronExpression = triggerBean.getCronExpression();
      final StatisticUpdateService statisticUpdateManager = getStatisticUpdateManager();
      if (statisticUpdateManager == null) {
        log.info("refreshUIState: statisticUpdateManager not configured");
        enabled = false;
      } else {
        enabled &= statisticUpdateManager.isEnabled();
        log.info("refreshUIState: statisticUpdateManager configured, enabled now: " + enabled);
      }
    } else {
      log.info("refreshUIState: schedulerFactoryBean not found");
    }
    if (enabled) {
      content.contextPut(
          "status",
          getTranslator().translate("statistics.status.enabled", new String[] {cronExpression}));
    } else {
      content.contextPut("status", getTranslator().translate("statistics.status.disabled"));
    }
    content.contextPut("statisticEnabled", enabled);

    recalcLastUpdated();

    updateStatisticUpdateOngoingFlag();
  }
Exemple #5
0
 @Override
 public Controller createHeaderController(final UserRequest ureq, final WindowControl wControl) {
   Controller headerCtr = null;
   // ----------- header, optional (e.g. for logo, advertising ) ------------------
   if (CoreSpringFactory.containsBean("fullWebApp.HeaderControllerCreator")) {
     final ControllerCreator headerControllerCreator =
         (ControllerCreator) CoreSpringFactory.getBean("fullWebApp.HeaderControllerCreator");
     headerCtr = headerControllerCreator.createController(ureq, wControl);
   }
   return headerCtr;
 }
 public PortfolioFilterController(
     final UserRequest ureq, final WindowControl wControl, final EPFilterSettings filterSettings) {
   super(ureq, wControl);
   ePFMgr = (EPFrontendManager) CoreSpringFactory.getBean(EPFrontendManager.class);
   portfolioModule =
       (PortfolioAbstractHandler) CoreSpringFactory.getBean(PortfolioAbstractHandler.class);
   if (filterSettings == null) {
     this.filterSettings = new EPFilterSettings();
   } else {
     this.filterSettings = filterSettings;
   }
   // allows to instantiate with filter presets
   selectedTagsList = new ArrayList<String>(filterSettings.getTagFilter());
   selectedTypeList = new ArrayList<String>(filterSettings.getTypeFilter());
   initForm(ureq);
 }
  private BusinessGroup doCopyGroup(final String newGroupName, final Integer max) {
    BusinessGroupService businessGroupService =
        (BusinessGroupService) CoreSpringFactory.getBean(BusinessGroupService.class);
    // reload original group to prevent context proxy problems
    this.originalGroup = businessGroupService.loadBusinessGroup(this.originalGroup);
    final BGContext bgContext = this.originalGroup.getGroupContext();
    final boolean copyAreas = (flags.isEnabled(BGConfigFlags.AREAS) && copyForm.isCopyAreas());

    final BusinessGroup newGroup =
        businessGroupService.copyBusinessGroup(
            this.originalGroup,
            newGroupName,
            this.originalGroup.getDescription(),
            null,
            max,
            bgContext,
            null,
            copyAreas,
            copyForm.isCopyTools(),
            copyForm.isCopyRights(),
            copyForm.isCopyOwners(),
            copyForm.isCopyParticipants(),
            copyForm.isCopyMembersVisibility(),
            copyForm.isCopyWaitingList());
    return newGroup;
  }
  /**
   * assumes that the user seeing this controller has full access rights to the group (add/remove
   * users)
   */
  public UsersToGroupWizardController(
      final UserRequest ureq,
      final WindowControl wControl,
      final SecurityGroup aSecurityGroup,
      final MailTemplate mailTemplate) {
    // wizard has two or there steps depending whether the mail template should
    // be configured or not
    super(ureq, wControl, (mailTemplate == null ? 2 : 3));
    setBasePackage(UsersToGroupWizardController.class);

    this.securityGroup = aSecurityGroup;
    this.securityManager = (BaseSecurity) CoreSpringFactory.getBean(BaseSecurity.class);
    this.mailTemplate = mailTemplate;

    mainVc = createVelocityContainer("index");

    nextButton =
        LinkFactory.createButtonSmall((mailTemplate == null ? "finish" : "next"), mainVc, this);
    backButton = LinkFactory.createButtonSmall("back", mainVc, this);

    usersForm = new UserIdsForm(ureq, wControl);
    listenTo(usersForm);

    // init wizard title and set step 1
    setWizardTitle(translate("import.title"));
    setNextWizardStep(translate("import.title.select"), usersForm.getInitialComponent());
  }
Exemple #9
0
  public EPTOCController(
      final UserRequest ureq,
      final WindowControl wControl,
      final PortfolioStructure selectedEl,
      final PortfolioStructure rootNode,
      final EPSecurityCallback secCallback) {
    super(ureq, wControl);
    this.secCallback = secCallback;
    tocV = createVelocityContainer("toc");
    ePFMgr = (EPFrontendManager) CoreSpringFactory.getBean(EPFrontendManager.class);
    eSTMgr = (PortfolioStructureDao) CoreSpringFactory.getBean(PortfolioStructureDao.class);
    this.rootNode = rootNode;
    final AjaxTreeModel treeModel = buildTreeModel();
    treeCtr =
        new TreeController(
            ureq, getWindowControl(), translate("toc.root"), treeModel, "myjsCallback");
    treeCtr.setTreeSorting(false, false, false);
    listenTo(treeCtr);
    tocV.put("tocTree", treeCtr.getInitialComponent());
    delButton =
        LinkFactory.createCustomLink(
            "deleteButton", DELETE_LINK_CMD, "&nbsp;&nbsp;&nbsp;", Link.NONTRANSLATED, tocV, this);
    delButton.setTooltip(translate("deleteButton"), false);
    delButton.setCustomEnabledLinkCSS("b_delete_icon b_eportfolio_del_link ");
    tocV.put("deleteButton", delButton);

    if (selectedEl == null) {
      treeCtr.selectPath("/" + ROOT_NODE_IDENTIFIER + "/" + rootNode.getKey()); // select map
      refreshAddElements(ureq, rootNode);
    } else {
      final String pagePath = calculatePathByDeepestNode(selectedEl);
      treeCtr.selectPath("/" + ROOT_NODE_IDENTIFIER + "/" + rootNode.getKey() + pagePath);
      structureClicked = selectedEl;
      refreshAddElements(ureq, selectedEl);
    }

    putInitialPanel(tocV);
  }
Exemple #10
0
  @Override
  public List<SiteInstance> getSiteInstances(final UserRequest ureq, final WindowControl wControl) {
    final List<SiteInstance> sites = new ArrayList<SiteInstance>();
    final SiteDefinitions sitedefs = (SiteDefinitions) CoreSpringFactory.getBean("olatsites");
    final List<SiteDefinition> sitedeflist = sitedefs.getSiteDefList();

    for (final Iterator<SiteDefinition> it_sites = sitedeflist.iterator(); it_sites.hasNext(); ) {
      final SiteDefinition sitedef = it_sites.next();
      final SiteInstance site = sitedef.createSite(ureq, wControl);
      if (site != null) {
        // site == null means that site is not visible to the current user
        sites.add(site);
      }
    }

    // let all extensions add sitedefinitions
    final ExtManager extm = CoreSpringFactory.getBean(ExtManager.class);
    final Class extensionPointSites = DTabs.class;
    final int cnt = extm.getExtensionCnt();
    for (int i = 0; i < cnt; i++) {
      final Extension anExt = extm.getExtension(i);
      // check for sites
      final SitesCreator sc = (SitesCreator) anExt.getExtensionFor(extensionPointSites.getName());
      if (sc != null) {
        final List extsitedefs = sc.createSiteDefinitions();
        for (final Iterator it_extsites = extsitedefs.iterator(); it_extsites.hasNext(); ) {
          final SiteDefinition sdef = (SiteDefinition) it_extsites.next();
          final SiteInstance si = sdef.createSite(ureq, wControl);
          sites.add(si);
          extm.inform(
              extensionPointSites, anExt, "added sitedefinition " + sdef.getClass().getName());
        }
      }
    }

    return sites;
  }
 @Override
 public void repositoryEntryCreated(final RepositoryEntry re) {
   final PortfolioStructureMap mapTemp =
       eSTMgr.createAndPersistPortfolioMapTemplateFromEntry(getIdentity(), re);
   // add a page, as each map should have at least one per default!
   final Translator pt =
       PackageUtil.createPackageTranslator(
           EPCreateMapController.class, getLocale(), getTranslator());
   final String title = pt.translate("new.page.title");
   final String description = pt.translate("new.page.desc");
   if (isNewTemplateAndGetsAPage) { // no additional page when this is a copy.
     final EPFrontendManager ePFMgr =
         (EPFrontendManager) CoreSpringFactory.getBean(EPFrontendManager.class);
     ePFMgr.createAndPersistPortfolioPage(mapTemp, title, description);
   }
 }
 /**
  * Constructor
  *
  * @param addCallback
  * @param ureq
  * @param wControl
  */
 public CreateStructureMapTemplateController(
     final RepositoryAddCallback addCallback,
     final UserRequest ureq,
     final WindowControl wControl) {
   super(ureq, wControl);
   eSTMgr = (PortfolioStructureDao) CoreSpringFactory.getBean(PortfolioStructureDao.class);
   if (addCallback != null) {
     // create a new template
     isNewTemplateAndGetsAPage = true;
     templateOres = eSTMgr.createPortfolioMapTemplateResource();
     addCallback.setDisplayName(translate(templateOres.getResourceableTypeName()));
     addCallback.setResourceable(templateOres);
     addCallback.setResourceName(translate("EPStructuredMapTemplate"));
     addCallback.finished(ureq);
   }
 }
 private List getMatchingEvents(final UserRequest ureq, final WindowControl wControl) {
   final Date startDate = new Date();
   final Calendar cal = Calendar.getInstance();
   cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR) + 7);
   final Date endDate = cal.getTime();
   List events = new ArrayList();
   CalendarWrapperCreator calendarWrapperCreator =
       CoreSpringFactory.getBean(CalendarWrapperCreator.class);
   final List calendars = calendarWrapperCreator.getListOfCalendarWrappers(ureq, wControl);
   calendars.addAll(calendarWrapperCreator.getListOfImportedCalendarWrappers(ureq));
   for (final Iterator iter = calendars.iterator(); iter.hasNext(); ) {
     final CalendarRenderWrapper calendarWrapper = (CalendarRenderWrapper) iter.next();
     final boolean readOnly =
         (calendarWrapper.getAccess() == CalendarRenderWrapper.ACCESS_READ_ONLY)
             && !calendarWrapper.isImported();
     final List eventsWithinPeriod =
         CalendarUtils.listEventsForPeriod(calendarWrapper.getCalendar(), startDate, endDate);
     for (final Iterator iterator = eventsWithinPeriod.iterator(); iterator.hasNext(); ) {
       final CalendarEntry event = (CalendarEntry) iterator.next();
       // skip non-public events
       if (readOnly && event.getClassification() != CalendarEntry.CLASS_PUBLIC) {
         continue;
       }
       events.add(event);
     }
   }
   // sort events
   Collections.sort(
       events,
       new Comparator() {
         @Override
         public int compare(final Object arg0, final Object arg1) {
           final Date begin0 = ((CalendarEntry) arg0).getBegin();
           final Date begin1 = ((CalendarEntry) arg1).getBegin();
           return begin0.compareTo(begin1);
         }
       });
   if (events.size() > MAX_EVENTS) {
     events = events.subList(0, MAX_EVENTS);
   }
   return events;
 }
 private NotificationService getNotificationService() {
   return (NotificationService) CoreSpringFactory.getBean(NotificationService.class);
 }
 private NotificationTypeHandlerSelector getNotificationTypeHandlerSelector() {
   return CoreSpringFactory.getBean(NotificationTypeHandlerSelector.class);
 }
 private RepositoryService getRepositoryService() {
   return CoreSpringFactory.getBean(RepositoryServiceImpl.class);
 }
 private ForumService getForumService() {
   return (ForumService) CoreSpringFactory.getBean("forumService");
 }
 private BaseSecurity getBaseSecurity() {
   return (BaseSecurity) CoreSpringFactory.getBean(BaseSecurity.class);
 }
Exemple #19
0
 public WikiPageDocument() {
   super();
   identityManager = (BaseSecurity) CoreSpringFactory.getBean(BaseSecurity.class);
 }
 private BaseSecurityEBL getBaseSecurityEBL() {
   return CoreSpringFactory.getBean(BaseSecurityEBL.class);
 }
  /**
   * @param ureq
   * @param cpRoot
   * @param showMenu
   * @param activateFirstPage
   */
  CPDisplayController(
      final UserRequest ureq,
      final WindowControl wControl,
      final VFSContainer rootContainer,
      final boolean showMenu,
      final boolean activateFirstPage,
      final String initialUri,
      final OLATResourceable ores) {
    super(ureq, wControl);
    this.rootContainer = rootContainer;

    // wrapper velocity container for page content
    this.myContent = createVelocityContainer("cpDisplay");
    // the cp component, added to the velocity

    if (!ureq.getUserSession().getRoles().isGuestOnly()) {
      final SearchServiceUIFactory searchServiceUIFactory =
          (SearchServiceUIFactory) CoreSpringFactory.getBean(SearchServiceUIFactory.class);
      searchCtrl =
          searchServiceUIFactory.createInputController(ureq, wControl, DisplayOption.BUTTON, null);
      myContent.put("search_input", searchCtrl.getInitialComponent());
    }

    // TODO:gs:a
    // may add an additional config for disabling, enabling IFrame style or not in CP mode
    // but always disable IFrame display when in screenreader mode (no matter whether style gets
    // ugly)
    if (getWindowControl().getWindowBackOffice().getWindowManager().isForScreenReader()) {
      cpComponent = new HtmlStaticPageComponent("", rootContainer);
      cpComponent.addListener(this);
      myContent.put("cpContent", cpComponent);
    } else {
      cpContentCtr =
          new IFrameDisplayController(ureq, getWindowControl(), rootContainer, null, ores);
      cpContentCtr.setAllowDownload(true);
      listenTo(cpContentCtr);
      myContent.put("cpContent", cpContentCtr.getInitialComponent());
    }

    // even if we do not show the menu, we need to build parse the manifest and
    // find the first node to display at startup
    final VFSItem mani = rootContainer.resolve("imsmanifest.xml");
    if (mani == null || !(mani instanceof VFSLeaf)) {
      throw new OLATRuntimeException(
          "error.manifest.missing",
          null,
          this.getClass().getPackage().getName(),
          "CP " + rootContainer + " has no imsmanifest",
          null);
    }
    // initialize tree model in any case
    ctm = new CPManifestTreeModel((VFSLeaf) mani);

    if (showMenu) {
      // the menu is only initialized when needed.
      cpTree = new MenuTree("cpDisplayTree");
      cpTree.setTreeModel(ctm);
      cpTree.addListener(this);
    }

    LoggingResourceable nodeInfo = null;
    if (activateFirstPage) {
      // set content to first accessible child or root node if no children
      // available
      TreeNode node = ctm.getRootNode();
      if (node == null) {
        throw new OLATRuntimeException(
            CPDisplayController.class,
            "root node of content packaging was null, file:" + rootContainer,
            null);
      }
      while (node != null && !node.isAccessible()) {
        if (node.getChildCount() > 0) {
          node = (TreeNode) node.getChildAt(0);
        } else {
          node = null;
        }
      }
      if (node != null) { // node.isAccessible
        final String nodeUri = (String) node.getUserObject();
        if (cpContentCtr != null) {
          cpContentCtr.setCurrentURI(nodeUri);
        }
        if (cpComponent != null) {
          cpComponent.setCurrentURI(nodeUri);
        }
        if (showMenu) {
          cpTree.setSelectedNodeId(node.getIdent());
        }
        // activate the selected node in the menu (skips the root node that is
        // empty anyway and saves one user click)
        selNodeId = node.getIdent();

        nodeInfo = LoggingResourceable.wrapCpNode(nodeUri);
      }
    } else if (initialUri != null) {
      // set page
      if (cpContentCtr != null) {
        cpContentCtr.setCurrentURI(initialUri);
      }
      if (cpComponent != null) {
        cpComponent.setCurrentURI(initialUri);
      }
      // update menu
      final TreeNode newNode = ctm.lookupTreeNodeByHref(initialUri);
      if (newNode != null) { // user clicked on a link which is listed in the
        // toc
        if (cpTree != null) {
          cpTree.setSelectedNodeId(newNode.getIdent());
        } else {
          selNodeId = newNode.getIdent();
        }
      }
      nodeInfo = LoggingResourceable.wrapCpNode(initialUri);
    }
    // Note: the ores has a typename of ICourse - see
    // CPCourseNode.createNodeRunConstructorResult
    // which has the following line:
    // OresHelper.createOLATResourceableInstance(ICourse.class,
    // userCourseEnv.getCourseEnvironment().getCourseResourceableId());
    // therefore we use OresHelper.calculateTypeName(ICourse.class) here
    if (ores != null
        && nodeInfo != null
        && !OresHelper.calculateTypeName(ICourse.class).equals(ores.getResourceableTypeName())) {
      addLoggingResourceable(LoggingResourceable.wrap(ores, OlatResourceableType.cp));
      ThreadLocalUserActivityLogger.log(
          LearningResourceLoggingAction.LEARNING_RESOURCE_OPEN, getClass(), nodeInfo);
    }

    putInitialPanel(myContent);
  }
Exemple #22
0
 private EPArtefactHandler<?> getArtefactHandler(final AbstractArtefact artefact) {
   final PortfolioAbstractHandler portfolioModule =
       (PortfolioAbstractHandler) CoreSpringFactory.getBean(PortfolioAbstractHandler.class);
   return portfolioModule.getArtefactHandler(artefact);
 }
 @Override
 public MetaInfo getMetaInfo() {
   BaseSecurity baseSecurity = CoreSpringFactory.getBean(BaseSecurity.class);
   ThumbnailService thumbnailService = CoreSpringFactory.getBean(ThumbnailService.class);
   return new MetaInfoFileImpl(thumbnailService, baseSecurity, this);
 }