Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rest-Api throws error when upload a new File #988

Closed
roesgTo opened this issue Jun 19, 2019 · 5 comments · Fixed by #992
Closed

Rest-Api throws error when upload a new File #988

roesgTo opened this issue Jun 19, 2019 · 5 comments · Fixed by #992
Labels
bug error issue and bug (fix) console deegree administration console contributions welcome asking for contribution (time and money sponsor)

Comments

@roesgTo
Copy link

roesgTo commented Jun 19, 2019

The file upload of configuration files via the REST-API does not work correctly. The Response is HTTP 200 , but there is also this error message: "Unable to upload file: datasources / feature / test-upload.xml". The file is not written to the workspace (as expected with HTTP 200).

I checked the code. Two tests are carried out:

  1. workspace-path exists?
  2. file-path exists?
    If one of the two checks fails, the above error message will appear.

Example:
"http://serverurl/config/upload/datasources/feature/test-upload2.xml"
Upload in Default-Workspace(workspace-path exists :true)
File "$Workspace/datasources/feature/test-upload2.xml" was not found (file-path exists: false
However, if this file has been previously created in the workspace, it will be successfully overwritten by the upload process (HTTP 200: "test-upload.xml uploaded")

Solution:
The file-path must be checked without the file.

current Check:
does the file "$Workspace/datasources/feature/test-upload2.xml" exist?

new Check:
does the folder "$Workspace/datasources/feature exist?

In addition, it would be very helpfull, if if another HTTP StatusCode will be returned when this error message appears (HTTP 400,404)

@tfr42
Copy link
Member

tfr42 commented Jun 24, 2019

Thanks for your feedback. Can you please check the deegree version? If the version is 3.4.4 or later the issue you are reporting may be caused by the following PR #955.
Please see the documentation how to secure the REST interface http://download.deegree.org/documentation/3.4.7/html/installation.html#securing-deegree.

@roesgTo
Copy link
Author

roesgTo commented Jun 24, 2019

I was using Version 3.4.7.
This PR implements the code, that causes the errormessage.
fa34625

          if ( !FileUtils.directoryContains( workspaceDir, dest ) ) { 
                IOUtils.write( "Unable to upload file: " + p.second + ".\n", resp.getOutputStream() );  
                return;  
            }

Maybe i am wrong, but i read this code like:
"If the File does not already exist in the Workspace, then throw an error." => Uploading a new File is not possible.

I do not get the connection to the Security of the REST interface. Sure it was a PR to secure the Rest-Interface, but the Problem is not caused by a missing Security-configuration

@tfr42 tfr42 added bug error issue and bug (fix) console deegree administration console contributions welcome asking for contribution (time and money sponsor) labels Jun 26, 2019
@tfr42
Copy link
Member

tfr42 commented Jun 26, 2019

The changes you are referring to were merged into master with PR #955 to resolve #942 and #943. The changes were done on purpose as pointed out in the deegree documentation.
We will carefully review the changes of PR #955 and discuss the change you propose during the next TMC meeting.
Of course any kind of contribution is welcome and we highly appreciate if you can open a pull request with the changes you are proposing.

@tfr42
Copy link
Member

tfr42 commented Jul 5, 2019

@roesgTo We have have discussed your proposal during todays TMC meeting. We will look for a solution asap. Can you post a curl or wget command you are using to upload a file?

@roesgTo
Copy link
Author

roesgTo commented Jul 5, 2019

We are using neither Curl nor wget. But this curl may work:
curl -X PUT -i 'http://serverurl/config/upload/datasources/feature/test-upload2.xml' --data '...'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug error issue and bug (fix) console deegree administration console contributions welcome asking for contribution (time and money sponsor)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants