Examples of MediaSource


Examples of com.google.gdata.data.media.MediaSource

      throw new IllegalArgumentException(Messages.get("album_not_found",
          albumId));
    }
    PhotoEntry photo = new PhotoEntry();
    photo.setTitle(new PlainTextConstruct(name));
    MediaSource mediaSource = new MediaByteArraySource(data,
        MimeType.getContentTypeByExt(FolderUtil.getFileExt(name)));
    photo.setMediaSource(mediaSource);
    return getPicasawebService().insert(new URL(getPicasaURL(albumId)),
        photo);
  }
View Full Code Here

Examples of com.google.gdata.data.media.MediaSource

        return query;
    }

    private InputStream documentAsStream(String url) throws IOException, MalformedURLException {
        try {
            MediaSource ms = service.getMedia(mediaContent(url));
            return ms.getInputStream();
        } catch (ServiceException e) {
            throw new GoogleMediaExportFailed(url, e);
        }
    }
View Full Code Here

Examples of com.google.gdata.data.media.MediaSource

    @Test
    public void shouldGetResourceFromDocsService() throws IOException, ServiceException {
        DocsService service = mock(DocsService.class);
        DocumentListFeed feed = mock(DocumentListFeed.class);
        DocumentListEntry entry = mock(DocumentListEntry.class);
        MediaSource mediaSource = mock(MediaSource.class);
        InputStream inputStream = mock(InputStream.class);
        final MediaContent content = mock(MediaContent.class);
        final DocumentQuery query = mock(DocumentQuery.class);
        when(service.getFeed(query, DocumentListFeed.class)).thenReturn(feed);
        when(service.getMedia(content)).thenReturn(mediaSource);
        when(feed.getEntries()).thenReturn(asList(entry));
        when(entry.getContent()).thenReturn(content);
        when(content.getUri()).thenReturn("http://docs.google.com");
        when(mediaSource.getInputStream()).thenReturn(inputStream);

        LoadOdtFromGoogle storyLoader = new LoadOdtFromGoogle("user", "password", "https://docs.google.com/feeds/default/private/full/", service){

            @Override
            DocumentQuery documentQuery(String title) throws MalformedURLException {
View Full Code Here

Examples of com.google.gdata.data.media.MediaSource

      throw new DocumentListException("null passed in for required parameters");
    }

    MediaContent mc = new MediaContent();
    mc.setUri(exportUrl.toString());
    MediaSource ms = service.getMedia(mc);

    InputStream inStream = null;
    FileOutputStream outStream = null;

    try {
      inStream = ms.getInputStream();
      outStream = new FileOutputStream(filepath);

      int c;
      while ((c = inStream.read()) != -1) {
        outStream.write(c);
View Full Code Here

Examples of com.google.gdata.data.media.MediaSource

  public String getDocumentContents(String contentUrl) throws DocumentServiceException {
    DocsService svc = getDocsService();
    try {
      MediaContent mc = new MediaContent();
      mc.setUri(contentUrl);
      MediaSource ms = svc.getMedia(mc);
      InputStreamReader reader = null;
      try {
        reader = new InputStreamReader(ms.getInputStream(), "UTF8");
        BufferedReader br = new BufferedReader(reader);
        StringBuilder contents = new StringBuilder();
        String line = null;
        while ((line = br.readLine()) != null) {
          contents.append(line + "\n");
View Full Code Here

Examples of com.google.gdata.data.media.MediaSource

        watch.start();
        logger.info("Retrieving content for document from: " + exportUrl);

        MediaContent mc = new MediaContent();
        mc.setUri(exportUrl);
        MediaSource ms = service.getMedia(mc);

        InputStream inStream = ms.getInputStream();

        watch.stop();
        logger.info("Got content stream in " + watch.getTime() + " ms");

        return inStream;
View Full Code Here

Examples of com.google.gdata.data.media.MediaSource

        watch.start();
        logger.info("Exporting document from: " + exportUrl);

        MediaContent mc = new MediaContent();
        mc.setUri(exportUrl);
        MediaSource ms = service.getMedia(mc);

        InputStream inStream = null;

        try {
            inStream = ms.getInputStream();
            IOUtils.copy(inStream, out);
            out.flush();
        } finally {
            IOUtils.closeQuietly(inStream);
        }
View Full Code Here

Examples of com.google.gdata.data.media.MediaSource

      throws IOException, ServiceException {

    Preconditions.checkNotNull(entry, "entry");

    // Delegate non-media handling to base class
    MediaSource media = (entry instanceof IMediaEntry) ?
        ((IMediaEntry) entry).getMediaSource() : null;
    if (media == null) {
      return super.insert(feedUrl, entry);
    }
View Full Code Here

Examples of com.google.gdata.data.media.MediaSource

    Preconditions.checkNotNull(entry, "entry");

    // Since the input parameter is a media-edit URL, this method should
    // not be used to post Atom-only entries.  These entries should be
    // sent to the edit URL.
    MediaSource media = (entry instanceof IMediaEntry) ?
        ((IMediaEntry) entry).getMediaSource() : null;
    if (media == null) {
      throw new IllegalArgumentException(
          "Must supply media entry with a media source");
    }
View Full Code Here

Examples of com.google.gdata.data.media.MediaSource

      throw new DocumentListException("null passed in for required parameters");
    }

    MediaContent mc = new MediaContent();
    mc.setUri(exportUrl.toString());
    MediaSource ms = service.getMedia(mc);

    InputStream inStream = null;
    FileOutputStream outStream = null;

    try {
      inStream = ms.getInputStream();
      outStream = new FileOutputStream(filepath);

      int c;
      while ((c = inStream.read()) != -1) {
        outStream.write(c);
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.