Examples of MediaResource


Examples of org.olat.core.gui.media.MediaResource

  @Override
  protected void event(UserRequest ureq, Component source, Event event) {
    if (source == showFileButton){
      File exportFile = new File(exportDir, targetFileName);
      MediaResource resource = new MimedFileMediaResource(exportFile, "application/vnd.ms-excel; charset="+charset, true);
      ureq.getDispatchResult().setResultingMediaResource(resource);
      showFileButton.setDirty(false);
    }
  }
View Full Code Here

Examples of org.olat.core.gui.media.MediaResource

   *
   */
  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) {
      return false;
    } finally {
      FileUtils.closeSafely(fOut);
      mr.release();
    }
    return true;
  }
View Full Code Here

Examples of org.olat.core.gui.media.MediaResource

     
      // successfull login
      UserDeletionManager.getInstance().setIdentityAsActiv(ureq.getIdentity());
      ureq.getUserSession().getIdentityEnvironment().addAttributes(
          ShibbolethModule.getAttributeTranslator().translateAttributesMap(attributesMap));
      MediaResource mr = ureq.getDispatchResult().getResultingMediaResource();
      if (!(mr instanceof RedirectMediaResource)) {
        DispatcherAction.redirectToDefaultDispatcher(resp); // error, redirect to login screen
        return;
      }
     
View Full Code Here

Examples of org.olat.core.gui.media.MediaResource

          }
          dts.activate(ureq, dt, null); // null: start with main entry point of controller
        } else if (repoEntry.getCanDownload()) {
          // else not launchable in olat, but downloadable -> send the document
          // directly to browser but "downloadable" (pdf, word, excel)
          MediaResource mr = handler.getAsMediaResource(ores);
          RepositoryManager.getInstance().incrementDownloadCounter(repoEntry);
          ureq.getDispatchResult().setResultingMediaResource(mr);
          return;
        } else { // neither launchable nor downloadable -> show details         
          //REVIEW:pb:replace EntryChangedEvent with a more specific event
View Full Code Here

Examples of org.swordapp.server.MediaResource

            throws SwordServerException, SwordAuthException
    {
        try
        {
            InputStream stream = bitstream.retrieve();
            MediaResource mr = new MediaResource(stream, bitstream.getFormat().getMIMEType(), null, true);
            mr.setContentMD5(bitstream.getChecksum());
            mr.setLastModified(this.getLastModified(context, bitstream));
            return mr;
        }
        catch (IOException e)
        {
            throw new SwordServerException(e);
View Full Code Here

Examples of org.swordapp.server.MediaResource

        }

        // Note that at this stage, if we don't have a desiredContentType, it will
        // be null, and the disseminator is free to choose the format
        InputStream stream = disseminator.disseminate(context, item);
        MediaResource mr = new MediaResource(stream, disseminator.getContentType(), disseminator.getPackaging());
        return mr;
    }
View Full Code Here

Examples of org.swordapp.server.MediaResource

                    }
                }

                // if we get to here we are either allowed to access the bitstream without credentials,
                // or we have been authenticated with acceptable credentials
                MediaResource mr = this.getBitstreamResource(ctx, bitstream);
                if (sc != null)
                {
                    sc.abort();
                }
                if (ctx.isValid())
                {
                    ctx.abort();
                }
                return mr;
            }
            else
            {
                // request for an item
                Item item = urlManager.getItem(ctx, uri);
                if (item == null)
                {
                    // item now found in the database, so 404 the client
                    // Arguably, we should try to authenticate first, but it's not so important
                    throw new SwordError(404);
                }

                // find out, now we know what we're being asked for, whether this is allowed
                WorkflowManagerFactory.getInstance().retrieveContent(ctx, item);

                // we can do this in principle but now find out whether the item is accessible without credentials
                boolean accessible = this.isAccessible(ctx, item);

                if (!accessible)
                {
                    // try to authenticate, and if successful switch the contexts around
                    sc = this.doAuth(authCredentials);
                    ctx.abort();
                    ctx = sc.getContext();
                }

                // if we get to here we are either allowed to access the bitstream without credentials,
                // or we have been authenticated
                MediaResource mr = this.getItemResource(ctx, item, urlManager, uri, accept);
                // sc.abort();
                ctx.abort();
                return mr;
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.