Package org.olat.repository.handlers

Examples of org.olat.repository.handlers.RepositoryHandler


   * Also used by RepositoryMainController
   *
   * @param ureq
   */
  void doLaunch(UserRequest ureq) {
    RepositoryHandler typeToLaunch = RepositoryHandlerFactory.getInstance().getRepositoryHandler(repositoryEntry);
    if (typeToLaunch == null){
      StringBuilder sb = new StringBuilder(translate("error.launch"));
      sb.append(": No launcher for repository entry: ");
      sb.append(repositoryEntry.getKey());
      throw new OLATRuntimeException(RepositoryDetailsController.class,sb.toString(), null);
    }
    if (RepositoryManager.getInstance().lookupRepositoryEntry(repositoryEntry.getKey()) == null) {
      showInfo("info.entry.deleted");
      return;
    }
   
    RepositoryManager.getInstance().incrementLaunchCounter(repositoryEntry);
    OLATResourceable ores = repositoryEntry.getOlatResource();
    String displayName = getDisplayName(ureq.getLocale());

    //was brasato:: DTabs dts = getWindowControl().getDTabs();
    DTabs dts = (DTabs)Windows.getWindows(ureq).getWindow(ureq).getAttribute("DTabs");
    DTab dt = dts.getDTab(ores);
    if (dt == null) {
      // does not yet exist -> create and add
      dt = dts.createDTab(ores, displayName);
      if (dt == null) return;
     
      // build up the context path
      OLATResourceable businessOres = repositoryEntry;
      ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(businessOres);
      WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, dt.getWindowControl());
     
      Controller ctrl = typeToLaunch.getLaunchController(ores, null, ureq, bwControl);
      // if resource is an image, PDF or eq. (e.g. served by resulting media request), no controller is returned.
      // FIXME:fj:test this
      if (ctrl == null) return;
      dt.setController(ctrl);
      dts.addDTab(dt);
View Full Code Here


     */
    fireEvent(ureq, Event.DONE_EVENT);
  }

  private boolean checkIsRepositoryEntryLaunchable(UserRequest ureq) {
    RepositoryHandler type = RepositoryHandlerFactory.getInstance().getRepositoryHandler(repositoryEntry);
    RepositoryManager rm = RepositoryManager.getInstance();
   
    if (rm.isAllowedToLaunch(ureq, repositoryEntry) || (type.supportsLaunch() && ureq.getUserSession().getRoles().isOLATAdmin())) {
      return true;
    } else if(!rm.isAllowedToLaunch(ureq, repositoryEntry)){
      return false;
    }   
    if (type instanceof CourseHandler) {
View Full Code Here

    }
    return repositoryEntry.getCanLaunch();
  }

  private boolean checkIsRepositoryEntryTypeLaunchable() {
    RepositoryHandler handler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(repositoryEntry);
    return handler.supportsLaunch();
  }
View Full Code Here

   * Also used by RepositoryMainController
   *
   * @param ureq
   */
  void doDownload(UserRequest ureq) {
    RepositoryHandler typeToDownload = RepositoryHandlerFactory.getInstance().getRepositoryHandler(repositoryEntry);

    if (typeToDownload == null){
      StringBuilder sb = new StringBuilder(translate("error.download"));
      sb.append(": No download handler for repository entry: ");
      sb.append(repositoryEntry.getKey());
      throw new OLATRuntimeException(RepositoryDetailsController.class, sb.toString(), null);
    }
    OLATResource ores = OLATResourceManager.getInstance().findResourceable(repositoryEntry.getOlatResource());
    if (ores == null) {
      showError("error.download");
      return;
    }   
    boolean isAlreadyLocked = typeToDownload.isLocked(ores);
    try {     
      lockResult = typeToDownload.acquireLock(ores, ureq.getIdentity());
      if(lockResult==null || (lockResult!=null && lockResult.isSuccess() && !isAlreadyLocked)) {
        MediaResource mr = typeToDownload.getAsMediaResource(ores);
        if(mr!=null) {
          RepositoryManager.getInstance().incrementDownloadCounter(repositoryEntry);
          ureq.getDispatchResult().setResultingMediaResource(mr);
        } else {
          showError("error.export");
          fireEvent(ureq, Event.FAILED_EVENT);     
        }
      } else if(lockResult!=null && lockResult.isSuccess() && isAlreadyLocked) {
        showInfo("warning.course.alreadylocked.bySameUser", lockResult.getOwner().getName());
        lockResult = null; //invalid lock, it was already locked
      } else {
        showInfo("warning.course.alreadylocked", lockResult.getOwner().getName());
      }
    }
    finally
      if((lockResult!=null && lockResult.isSuccess() && !isAlreadyLocked)) {
        typeToDownload.releaseLock(lockResult);   
        lockResult = null;
      }
    }
  }
View Full Code Here

   *
   * @param ureq
   */
  void doEdit(UserRequest ureq) {
    if (!isOwner) throw new OLATSecurityException("Trying to launch editor, but not allowed: user = " + ureq.getIdentity());
    RepositoryHandler typeToEdit = RepositoryHandlerFactory.getInstance().getRepositoryHandler(repositoryEntry);
    if (!typeToEdit.supportsEdit()){
      throw new AssertException("Trying to edit repository entry which has no assoiciated editor: "+ typeToEdit);
    }
       

    OLATResourceable ores = repositoryEntry.getOlatResource();
   
    //was brasato:: DTabs dts = getWindowControl().getDTabs();
    DTabs dts = (DTabs)Windows.getWindows(ureq).getWindow(ureq).getAttribute("DTabs");
    DTab dt = dts.getDTab(ores);
    if (dt == null) {
      // does not yet exist -> create and add
      dt = dts.createDTab(ores, repositoryEntry.getDisplayname());
      if (dt == null){
        //null means DTabs are full -> warning is shown
        return;
      }
      //user activity logger is set by course factory
      Controller editorController = typeToEdit.getEditorController(ores, ureq, dt.getWindowControl());
      if(editorController == null){
        //editor could not be created -> warning is shown
        return;
      }
      dt.setController(editorController);
View Full Code Here

    } else if (source == repositoryEditPropertiesController) {
      if (event == Event.CHANGED_EVENT || event.getCommand().equals("courseChanged")) {
        // RepositoryEntry changed
        this.repositoryEntry = repositoryEditPropertiesController.getRepositoryEntry();
        updateView(ureq);
        RepositoryHandler handler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(repositoryEntry);
        boolean canDownload = repositoryEntry.getCanDownload() && handler.supportsDownload();
        detailsToolC.setEnabled(TOOL_DOWNLOAD, canDownload);
        if (checkIsRepositoryEntryTypeLaunchable()) {
          detailsToolC.setEnabled(TOOL_LAUNCH, checkIsRepositoryEntryLaunchable(ureq));
        }       
        if(event.getCommand().equals("courseChanged")) {
View Full Code Here

  /**
   * @param ureq
   */
  private void doCloseResource(UserRequest ureq) {
    removeAsListenerAndDispose(wc);
    RepositoryHandler repoHandler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(repositoryEntry);
    wc = repoHandler.getCloseResourceController(ureq, getWindowControl(), repositoryEntry);
    wc.startWorkflow();
    wc.addControllerListener(this);
    cmc = new CloseableModalController(getWindowControl(), translate("close"), wc.getInitialComponent());
    cmc.activate();
  }
View Full Code Here

    if (source == searchCtr) {
      if (cmd.equals(RepositoryTableModel.TABLE_ACTION_SELECT_ENTRY)) {
        // user selected entry to get a preview
        selectedRepositoryEntry = searchCtr.getSelectedEntry();
        RepositoryEntry repositoryEntry = searchCtr.getSelectedEntry();
        RepositoryHandler typeToLaunch = RepositoryHandlerFactory.getInstance().getRepositoryHandler(repositoryEntry);
        if (typeToLaunch == null) {
          StringBuilder sb = new StringBuilder(trans.translate("error.launch"));
          sb.append(": No launcher for repository entry: ");
          sb.append(repositoryEntry.getKey());
          throw new OLATRuntimeException(RepositoryDetailsController.class, sb.toString(), null);
        }
        // do skip the increment launch counter, this is only a preview!
        OLATResourceable ores = repositoryEntry.getOlatResource();
       
        if (previewCtr != null) {
          previewCtr.dispose();
        }
        if (previewModalCtr != null) {
          previewModalCtr.dispose();
        }
        previewCtr = typeToLaunch.getLaunchController(ores, null, ureq, getWindowControl());
        previewModalCtr = new CloseableModalController(getWindowControl(), trans.translate("referencableSearch.preview.close"), previewCtr
            .getInitialComponent());
        previewModalCtr.activate();

      } else if (cmd.equals(RepositoryTableModel.TABLE_ACTION_SELECT_LINK)) {
View Full Code Here

   * @return True upon success, false otherwise.
   *
   */
  public boolean exportDoExportContent() {
    // export resource
    RepositoryHandler rh = RepositoryHandlerFactory.getInstance().getRepositoryHandler(re);
    MediaResource mr = rh.getAsMediaResource(re.getOlatResource());
    FileOutputStream fOut = null;
    try {
      fOut = new FileOutputStream(new File(baseDirectory, CONTENT_FILE));
      FileUtils.copy(mr.getInputStream(), fOut);
    } catch (FileNotFoundException fnfe) {
View Full Code Here

    RepositoryEntry repositoryEntry = node.getReferencedRepositoryEntry();
    if (repositoryEntry == null) {
      // do nothing
      return;
    }
    RepositoryHandler typeToEdit = RepositoryHandlerFactory.getInstance().getRepositoryHandler(repositoryEntry);
    if (!typeToEdit.supportsEdit()){
      throw new AssertException("Trying to edit repository entry which has no assoiciated editor: "+ typeToEdit);
    }         
    // Open editor in new tab
    OLATResourceable ores = repositoryEntry.getOlatResource();
    DTabs dts = (DTabs)Windows.getWindows(ureq).getWindow(ureq).getAttribute("DTabs");
    DTab dt = dts.getDTab(ores);
    if (dt == null) {
      // does not yet exist -> create and add
      dt = dts.createDTab(ores, repositoryEntry.getDisplayname());
      if (dt == null){
        //null means DTabs are full -> warning is shown
        return;
      }
      //user activity logger is set by course factory
      Controller editorController = typeToEdit.getEditorController(ores, ureq, dt.getWindowControl());
      if(editorController == null){
        //editor could not be created -> warning is shown
        return;
      }
      dt.setController(editorController);
View Full Code Here

TOP

Related Classes of org.olat.repository.handlers.RepositoryHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.