pngriba / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

MoveDocumentTo(Document parent, Document child) does not work for file uploaded with out convertion #559

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Upload a document with out converting
2. Create a folder or get the reference to an existing folder
3. Call MoveDocumentTo API of DocumentsRequest class 

What is the expected output? What do you see instead?

Expected output is that the document (which is file uploaded without 
conversion) is moved to the desired folder.

What version of the product are you using? On what operating system?

Version - 1.9
OS - Windows 7; 

Please provide any additional information below.

The error is happening because in MoveDocumentTo API anther Document object 
(payload in below code) is being constructed which has same properties as that 
of uploaded document (passed as parameter). Since this uploaded document type 
is Unknown an exception is thrown.

public Document MoveDocumentTo(Document parent, Document child) {
            if (parent == null || child == null) {
                throw new ArgumentNullException("parent or child can not be null");
            }

            if (parent.AtomEntry.Content == null || parent.AtomEntry.Content.AbsoluteUri == null) {
                throw new ArgumentException("parent has no content uri");
            }

            if (parent.Type != Document.DocumentType.Folder) {
                throw new ArgumentException("wrong parent type");
            }

/// KS ->  I beleive this section is not even necessary
            Document payload = new Document();
            payload.DocumentEntry.Id = new AtomId(child.Id);
            payload.Type = child.Type;  // exception is thrown by this line of code

            // to do that, we just need to post the CHILD 
            // against the URI of the parent
            return Insert(new Uri(parent.AtomEntry.Content.AbsoluteUri), payload);
        }

Original issue reported on code.google.com by ksachdev...@gmail.com on 25 Nov 2011 at 1:51

GoogleCodeExporter commented 8 years ago
I just fixed this issue in rev. 1157 
(http://code.google.com/p/google-gdata/source/detail?r=1157) by allowing 
MoveDocumentTo to support arbitrary file types.

I also made a similar change to the Download method so that files of all types 
can be downloaded.

Original comment by ccherub...@google.com on 14 Feb 2012 at 1:51