Bug 886711

Summary: Error when using pull for project type raw when the document name does not include a type extension
Product: [Retired] Zanata Reporter: David Mason <damason>
Component: Component-MavenAssignee: David Mason <damason>
Status: CLOSED CURRENTRELEASE QA Contact: Ding-Yi Chen <dchen>
Severity: high Docs Contact:
Priority: medium    
Version: 2.0CC: zanata-bugs
Target Milestone: ---   
Target Release: 2.1   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: 2.1-SNAPSHOT (20121214-0032) Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-26 04:06:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 864277, 864280    

Description David Mason 2012-12-12 23:38:14 UTC
Description of problem:
When using pull command with projectType=raw, if the project contains any documents that have been uploaded as raw documents, but the document name does not include an extension matching the type, a 500 error (caused by NullPointerException) is returned by the server.

Version-Release number of selected component (if applicable):
Server version 2.0.3

How reproducible:

Steps to Reproduce:
1. Use curl to upload a raw document under a name with no extension
     e.g. curl -F type=txt -F file=@document.txt -F hash=`md5sum document.txt | awk '{print $1}'`   -F first=true -F last=true   -H "X-Auth-User:USERNAME" -H "X-Auth-Token:API_KEY"    "SERVER/rest/file/source/PROJECT_SLUG/VERSION_SLUG?docId=document

     Note: docId=document has no file extension

2. Download zanata.xml for the project-version and ensure project type is raw (e.g. <project-type>raw</project-type>
3. From the directory containing zanata.xml, run zanata pull command (e.g. mvn zanata:pull)
Actual results:
500 internal server error when the process reaches the document from step 1. Some documents that have a matching extension may be pulled successfully, depending on the order that the documents are pulled.

Expected results:
All documents pulled successfully, regardless of document name.

Additional info:
Caused by use of document name to look up a file format adapter. Should use document type from database.

Comment 1 David Mason 2012-12-13 05:28:00 UTC
Fixed in 2.1-SNAPSHOT. Generation of translated raw documents now uses document type from the database to select an appropriate adapter.

See: https://github.com/zanata/zanata/commit/22d5e22cd6bafd4df060587a6eb6141bb75dbd4d

Comment 2 Ding-Yi Chen 2012-12-14 07:53:58 UTC
VERIFIED with Zanata version 2.1-SNAPSHOT (20121214-0032)