pkp / ots

PKP XML Parsing Service
GNU General Public License v3.0
32 stars 19 forks source link

Installation Error:(unittest.sh) #2

Closed VidhyaApple closed 9 years ago

VidhyaApple commented 9 years ago

When I run unittest.sh, it errors out.

Errors:

PHPUnit 3.7.29 by Sebastian Bergmann.

Configuration read from /home/quotequadsco/public_html/xmlps/phpunit.xml

.................FstdClass Object ( [error] => File name (fileName) parameter is missing. [status] => error [flashMessages] => Array ( )

)

Time: 4.17 seconds, Memory: 43.00Mb

There was 1 failure:

1) ApiTest\Controller\ApiControllerTest::testSubmitAction Failed asserting that two strings are identical. --- Expected +++ Actual @@ @@ -error +success

/home/quotequadsco/public_html/xmlps/module/Api/test/ApiTest/Controller/JobControllerTest.php:64

FAILURES! Tests: 18, Assertions: 56, Failures: 1.

VidhyaApple commented 9 years ago

When I try to run http://quotequads.co.in/xmlps/public/api/job/submit? 'email' => 'vidhu.chel@gmail.com' 'password' => 'Vidhya@123' 'fileName' => 's.docx' 'citationStyleHash' => 'c6de5efe3294b26391ea343053c19a84'

Am getting following errors: {"error":"File name (fileName) parameter is missing.","status":"error","flashMessages":[]}

axfelix commented 9 years ago

Hi Vidhya,

Thanks for this -- I think you're onto something, as I just tried running the test script in our demo instance (http://pkp-udev.lib.sfu.ca) and the same test failed. That said, it looks like you may not be posting to submit correctly, as it does require the file content to be sent along as another parameter (https://github.com/pkp/xmlps#api; n.b. that this is relatively easy to do with PHP curl but not at all easy with CLI curl, and I've been thinking of changing it to fix this). However, the error you're seeing does indicate that something else might be amiss; I'll take a look. It's possible that in a (relatively) recent commit, the encoding performed on the uploaded file content was changed but the test wasn't updated to reflect that...

Can you verify for me that you're able to submit through the web interface (assuming you've got that running as well) meanwhile?

VidhyaApple commented 9 years ago

my site (Web interface)- I could upload file and it was submitted successfully. Initially the job was in pending and after some time it displayed failed .

image

my site (Web service)- Error: {"error":"File name (fileName) parameter is missing.","status":"error","flashMessages":[]} URL-http://quotequads.co.in/xmlps/public/api/job/submit?'email' => 'vidhu.chel@gmail.com' 'password' => 'Vidhya@123' 'fileName' => 'document.docx' 'citationStyleHash' => 'c6de5efe3294b26391ea343053c19a84', 'fileContent' => '...'

http://pkp-udev.lib.sfu.ca (web interface)- It was working perfectly as I expect. But from yesterday am getting the error. image

http://pkp-udev.lib.sfu.ca (Web service)- Same error: {"error":"File name (fileName) parameter is missing.","status":"error","flashMessages":[]} URL - http://pkp-udev.lib.sfu.ca/api/job/submit?'email' => 'vidhu.chel@gmail.com' 'password' => 'Vidhya@123' 'fileName' => 'document.docx' 'citationStyleHash' => 'c6de5efe3294b26391ea343053c19a84', 'fileContent' => '...'

In the fileName parameter,Should I give full file path? Or Is anything wrong with the URL???

VidhyaApple commented 9 years ago

Can I get an update???

axfelix commented 9 years ago

Hi Vidya,

I've fixed our instance so that you should be able to check job status -- that way you can tell whether the documents you're submitting /should/ be passing in your cloned instance (most, but not all, doc/docx/odf should pass). I'm now on holidays, but I'll be looking further into why the tests are failing when doing a post and will let you know when I have an answer.

VidhyaApple commented 9 years ago

I want to use web service rather than your web interface.can you give me a URL structure to get an XML through web service..so that I can include that URL in my PHP program On 22 Dec 2014 23:14, "axfelix" notifications@github.com wrote:

Hi Vidya,

I've fixed our instance so that you should be able to check job status -- that way you can tell whether the documents you're submitting /should/ be passing in your cloned instance (most, but not all, doc/docx/odf should pass). I'm now on holidays, but I'll be looking further into why the tests are failing when doing a post and will let you know when I have an answer.

— Reply to this email directly or view it on GitHub.

axfelix commented 9 years ago

I understand that's the goal -- I'm trying to figure out why the unit tests are failing so that I can solve that.

VidhyaApple commented 9 years ago

I hope that I will implement pkp into my project.I will let u know if am facing any issue regarding this. On 23 Dec 2014 00:35, "axfelix" notifications@github.com wrote:

I understand that's the goal -- I'm trying to figure out why the unit tests are failing so that I can solve that.

— Reply to this email directly or view it on GitHub.

VidhyaApple commented 9 years ago

I've fixed our instance so that you should be able to check job status -- that way you can tell whether the documents you're submitting /should/ be passing in your cloned instance (most, but not all, doc/docx/odf should pass)

yet When I run - http://pkp-udev.lib.sfu.ca (web interface)- Getting an same error

image

Could you pls tell me how to proceed further?

axfelix commented 9 years ago

Hi Vidhya,

Have you cleared your browser cache? I'm sorry for my slow responses over the holidays, but I've been unable to duplicate your issue with the web frontend since I fixed it several days ago.

VidhyaApple commented 9 years ago

Thanks for your valuable time and reply. Ya I have cleared my browser cache and tried but no luck..I need nlm xml alone. Is there any other way to get nlm xml without web interface or frontend. As I need only nlm xml,I tried MeTypesetTest.php (Module/NlmxmlConversion/test/NlmxmlConversionTest/Model/Converter) but got some error.

And Can I know why http://pkp-udev.lib.sfu.ca (web interface) errors out nowadays?

axfelix commented 9 years ago

Hi Vidhya,

In my last response, I was referring to having fixed the web interface at pkp-udev; I'm not sure if we were misunderstanding one another or not. Regardless, everything should now be fixed, including the unit tests (which were indeed written against an earlier version of the api POST functionality). Please do a fresh checkout and let me know how it works.

VidhyaApple commented 9 years ago

I updated the changes and tried unittest. getting following errors

root@gains [/home/quotequadsco/public_html/xmlps]# ./unittest.sh PHPUnit 3.7.29 by Sebastian Bergmann.


Configuration read from /home/quotequadsco/public_html/xmlps/phpunit.xml

................E

Time: 3.98 seconds, Memory: 41.00Mb

There was 1 error:

1) ApiTest\Controller\ApiControllerTest::testSubmitActionCannotBeAccessedLoggedO ut Doctrine\DBAL\DBALException: An exception occurred while executing 'INSERT INTO document (path, conversionStage, mimeType, size, jobId) VALUES (?, ?, ?, ?, ?)' with params ["\/tmp\/UNITTEST_document.txt", 10, null, 9, 130]:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'mimeType' cannot b e null

/home/quotequadsco/public_html/xmlps/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBAL Exception.php:91 /home/quotequadsco/public_html/xmlps/vendor/doctrine/dbal/lib/Doctrine/DBAL/Stat ement.php:165 /home/quotequadsco/public_html/xmlps/vendor/doctrine/orm/lib/Doctrine/ORM/Persis ters/BasicEntityPersister.php:279 /home/quotequadsco/public_html/xmlps/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOf Work.php:952 /home/quotequadsco/public_html/xmlps/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOf Work.php:335 /home/quotequadsco/public_html/xmlps/vendor/doctrine/orm/lib/Doctrine/ORM/Entity Manager.php:389 /home/quotequadsco/public_html/xmlps/vendor/xmlps/library/DAO/DAO.php:171 /home/quotequadsco/public_html/xmlps/module/Api/test/ApiTest/Controller/JobContr ollerTest.php:137 /home/quotequadsco/public_html/xmlps/vendor/xmlps/library/UnitTest/ControllerTes t.php:78 /home/quotequadsco/public_html/xmlps/module/Api/test/ApiTest/Controller/JobContr ollerTest.php:29

Caused by PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'mime Type' cannot be null

/home/quotequadsco/public_html/xmlps/vendor/doctrine/dbal/lib/Doctrine/DBAL/Stat ement.php:165 /home/quotequadsco/public_html/xmlps/vendor/doctrine/orm/lib/Doctrine/ORM/Persis ters/BasicEntityPersister.php:279 /home/quotequadsco/public_html/xmlps/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOf Work.php:952 /home/quotequadsco/public_html/xmlps/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOf Work.php:335 /home/quotequadsco/public_html/xmlps/vendor/doctrine/orm/lib/Doctrine/ORM/Entity Manager.php:389 /home/quotequadsco/public_html/xmlps/vendor/xmlps/library/DAO/DAO.php:171 /home/quotequadsco/public_html/xmlps/module/Api/test/ApiTest/Controller/JobContr ollerTest.php:137 /home/quotequadsco/public_html/xmlps/vendor/xmlps/library/UnitTest/ControllerTes t.php:78 /home/quotequadsco/public_html/xmlps/module/Api/test/ApiTest/Controller/JobContr ollerTest.php:29

FAILURES! Tests: 17, Assertions: 52, Errors: 1.


So, I changed 'mimetype' to be null in the database and tried unittest,it errors out


Configuration read from /home/quotequadsco/public_html/xmlps/phpunit.xml

................E

Time: 3.77 seconds, Memory: 40.75Mb

There was 1 error:

1) ApiTest\Controller\ApiControllerTest::testSubmitActionCannotBeAccessedLoggedOut Doctrine\DBAL\DBALException: An exception occurred while executing 'DELETE FROM user WHERE id = ?' with params [2347]:

SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (quotequa_mysql.job, CONSTRAINT FK_FBD8E0F864B64DCC FOREIGN KEY (userId) REFERENCES user (id))

/home/quotequadsco/public_html/xmlps/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:91 /home/quotequadsco/public_html/xmlps/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:855 /home/quotequadsco/public_html/xmlps/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:467 /home/quotequadsco/public_html/xmlps/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php:591 /home/quotequadsco/public_html/xmlps/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:1029 /home/quotequadsco/public_html/xmlps/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:362 /home/quotequadsco/public_html/xmlps/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:389 /home/quotequadsco/public_html/xmlps/vendor/xmlps/library/DAO/DAO.php:184 /home/quotequadsco/public_html/xmlps/vendor/xmlps/library/UnitTest/TestHelper.php:68 /home/quotequadsco/public_html/xmlps/module/Api/test/ApiTest/Controller/JobControllerTest.php:149 /home/quotequadsco/public_html/xmlps/vendor/xmlps/library/UnitTest/ControllerTest.php:53

Caused by PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (quotequa_mysql.job, CONSTRAINT FK_FBD8E0F864B64DCC FOREIGN KEY (userId) REFERENCES user (id))

/home/quotequadsco/public_html/xmlps/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:855 /home/quotequadsco/public_html/xmlps/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:467 /home/quotequadsco/public_html/xmlps/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php:591 /home/quotequadsco/public_html/xmlps/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:1029 /home/quotequadsco/public_html/xmlps/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:362 /home/quotequadsco/public_html/xmlps/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:389 /home/quotequadsco/public_html/xmlps/vendor/xmlps/library/DAO/DAO.php:184 /home/quotequadsco/public_html/xmlps/vendor/xmlps/library/UnitTest/TestHelper.php:68 /home/quotequadsco/public_html/xmlps/module/Api/test/ApiTest/Controller/JobControllerTest.php:149 /home/quotequadsco/public_html/xmlps/vendor/xmlps/library/UnitTest/ControllerTest.php:53

FAILURES! Tests: 17, Assertions: 53, Errors: 1.


axfelix commented 9 years ago

Hi Vidhya,

You might want to try replacing the old DB, as I can't duplicate that.

VidhyaApple commented 9 years ago

Thank you so much ! I fixed that DB issue,now unit test is run successfully. I will try web service and let you know soon

VidhyaApple commented 9 years ago

Hi axfelix,

I tried web service using below mentioned url,I think am not parsing correct url path, If so,pls guide me

http://quotequads.co.in/pkp/public/api/job/submit?'email' => 'vidhu.chel@gmail.com' 'password' =>       'Vidhya@123' 'fileName' => 'document.docx' 'citationStyleHash' => 'c6de5efe3294b26391ea343053c19a84', 'fileContent' => '...'

Error: {"error":"File name (fileName) parameter is missing.","status":"error","flashMessages":[]}

In which location, should the file be stored?

axfelix commented 9 years ago

Hey Vidhya,

Can I ask how you're making that POST request (eg with CLI curl or with PHP curl)? As I mentioned, it can be difficult to combine string and data parameters when using CLI curl.

axfelix commented 9 years ago

There's example code for using the XMLPS API in lines 189 - 265 of this file, by the way: https://github.com/pkp/ojs-markup/blob/master/MarkupPluginUtilities.inc.php

VidhyaApple commented 9 years ago

Hi axfelix, I feel sorry as I don't know how to use cURL. Some API usage guide is there in the API section of the xmlps home page.


API

There is a simple REST API available to submit, view and retrieve jobs from/to the server.

Submit

Submit a job to the server. The citationStyleHash is an internal identifier for the requested citaton style. A list of hashes can be retrieved through the citationStyleList API. The API will return the job id which can be used to retrieve the completed job later or to query the server for the job status.

URL: api/job/submit Request type: POST Parameters:

email password fileName fileContent citationStyleHash I.e.

http://example.com/api/job/submit POST parameters: 'email' => 'user@example.com' 'password' => 'passowrd' 'fileName' => 'document.docx' 'citationStyleHash' => 'c6de5efe3294b26391ea343053c19a84', 'fileContent' => '...' Example response:

{"status":"success","id":123}


As per the statement above, I parsed this url

http://quotequads.co.in/pkp/public/api/job/submit?'email' => 'vidhu.chel@gmail.com' 'password' =>       'Vidhya@123' 'fileName' => 'document.docx' 'citationStyleHash' => 'c6de5efe3294b26391ea343053c19a84', 'fileContent' => '...'

in the address bar itslf. I din't use any php program.

VidhyaApple commented 9 years ago

function apiRequest($plugin, $action, $params = array(), $isPost = false, $execute = true) { $journal = Request::getJournal(); $journalId = $journal->getId(); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $params['email'] = $plugin->getSetting($journalId, 'markupHostUser'); $params['password'] = $plugin->getSetting($journalId, 'markupHostPass'); if ($isPost) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); $params = array(); } $apiUrl = self::apiUrl($plugin, $action, $params); if (!$execute) { return array('channel' => $ch, 'apiUrl' => $apiUrl); } curl_setopt($ch, CURLOPT_URL, $apiUrl); $response = curl_exec($ch); $response = json_decode($response, true); if (!$response) { $error = curl_error($ch); if (empty($error)) { $error = 'HTTP status: ' . curl_getinfo($ch, CURLINFO_HTTP_CODE); } $response = array( 'status' => 'error', 'error' => $error, ); } curl_close($ch); return $response; }

function submitFile($plugin, $fileName, $filePath) { $journal = Request::getJournal(); $journalId = $journal->getId(); $params = array( 'fileName' => $fileName, 'fileContent' => file_get_contents($filePath), 'citationStyleHash' => $plugin->getSetting($journalId, 'cslStyle'), ); return self::apiRequest($plugin, 'submit', $params, true); } The above mentioned program is from the https://github.com/pkp/ojs-markup/blob/master/MarkupPluginUtilities.inc.php which you suggested.

I don't have any clue,what's the $plugin parameter in the code.So, Can you pls tel me how to customize this code to use web service?

axfelix commented 9 years ago

Hi Vidhya,

I'm afraid you can't just do an HTTP POST by pasting parameters into the URL bar like that -- GET will work like that for some APIs, including ours, but not POST. The code I linked you to is part of an Open Journal Systems plugin that's designed to utilize our API by sending Word files to our webservice for conversion to JATS; it makes use of php cURL.

VidhyaApple commented 9 years ago

Ya I understand that. In place of $plugin parameter,what should I parse?

axfelix commented 9 years ago

You shouldn't need that $plugin parameter at all if you're making a standalone call; I linked the plugin code to provide an example using php cURL, but the documentation on the main page of the repo should still be accurate: you need to provide credentials, a citation style, a filename, and file content. If you're not familiar with cURL, you might want to stick to the web frontend.

VidhyaApple commented 9 years ago

I submitted the post using cURL. In both web front end and also using cURL am getting the error page

image

axfelix commented 9 years ago

Hi Vidhya,

I see several successfully completed jobs on our pkp-udev instance from you over the past several days, which is good! I assume you've been able to submit to our hosted instance no problem, and these errors are with your own instance? In this case, sharing some log files may be helpful so I can get a better idea of what's going wrong; you may not have installed it correctly, but I'll need more info to help.

VidhyaApple commented 9 years ago

Actually the thing is, I don't get any error_log files when I run this instance. Just am getting the page which says error occurred during execution. How to track it then?Its a run time error it seems.

And I want to say you, In pkp-udev, If I type the citation style in the text box it will display the option from which I could select the citation style. But in my instance,it doesn't display the option of citation styles. Is that the cause of an error?

axfelix commented 9 years ago

Hm -- what does your /vendor install directory look like? I wonder if the third party modules aren't being initialized properly using our install script...

-alex

On Tue, Jan 13, 2015 at 4:25 AM, Vidhya notifications@github.com wrote:

Actually the thing is, I don't get any error_log files when I run this instance. Just am getting the page which says error occurred during execution. How to track it then?. Its a run time error it seems.

And I want to say you, In pkp-udev, If I type the citation style in the text box it will display the option from which I could select the citation style. But in my instance,it doesn't display the option of citation styles. Is that the cause of an error?

— Reply to this email directly or view it on GitHub https://github.com/pkp/xmlps/issues/2#issuecomment-69737106.

VidhyaApple commented 9 years ago

Hi axfelix, Sorry for the delay.

/vendor directory

image

axfelix commented 9 years ago

Everything looks fine there too. I'm afraid I'm not sure what your issue is at this point ...

VidhyaApple commented 9 years ago

Unit test also successfully executed. But I need to say, when running unittest I got an error


ApiTest\Controller\ApiControllerTest::testSubmitActionCannotBeAccessedLoggedO ut Doctrine\DBAL\DBALException: An exception occurred while executing 'INSERT INTO document (path, conversionStage, mimeType, size, jobId) VALUES (?, ?, ?, ?, ?)' with params ["\/tmp\/UNITTEST_document.txt", 10, null, 9, 130]:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'mimeType' cannot b e null


So, I changed 'mimetype' to be null in the database.Would it be the cause of an error?

http://quotequads.co.in/pkp/public/manager/upload - In this directory am getting that error page after i logged in.

axfelix commented 9 years ago

Hi Vidhya,

Is it possible that there's some kind of permissions issue on your server so that the install isn't able to complete properly? That could be the cause of the DB issues you're experiencing -- I'm afraid I'm unable to duplicate them on my end.

VidhyaApple commented 9 years ago

It doesn't seem like permission issue.

INSERT INTO document (path, conversionStage, mimeType, size, jobId) VALUES (?, ?, ?, ?, ?)' with params ["\/tmp\/UNITTEST_document.txt", 10, null, 9, 130]:

This is sql statement. When creating database table mimeType was declared as NotNull. But in the above mentioned sql,when trying to insert a null value to mimeType it gives an error.

axfelix commented 9 years ago

What database are you running? Our reference server is on MySQL 5.5.40...

VidhyaApple commented 9 years ago

MySQL Version 5.5.40-cll

axfelix commented 9 years ago

Hi Vidhya,

Is this still an issue? We've changed the unit tests a bit so you might not be having this problem anymore -- would be happy if I could close this.