Piwigo / Piwigo-Java

26 stars 12 forks source link

Unablt to parse response - Piwigo 2.9 #6

Closed GentleOz closed 5 years ago

GentleOz commented 7 years ago

Hi

Getting the following error

[INFO] User admin will sync gallery http://xtremegtr.com.au/photo with directory C:\xtremephotos [INFO] will create album for C:\xtremephotos\Album1 [INFO] Connecting... [INFO] Connect successful [ERROR] Unable to parse response [ERROR] Cannot create album for C:\xtremephotos\Album1 [INFO] will upload image for C:\xtremephotos\Album1\Cage1.jpg in album with id null [ERROR] Unable to parse response [ERROR] Cannot updload image for C:\xtremephotos\Album1\Cage1.jpg [INFO] will upload image for C:\xtremephotos\Album1\Cage2.jpg in album with id null [ERROR] Unable to parse response [ERROR] Cannot updload image for C:\xtremephotos\Album1\Cage2.jpg [INFO] will upload image for C:\xtremephotos\Album1\cage3.jpg in album with id null [ERROR] Unable to parse response [ERROR] Cannot updload image for C:\xtremephotos\Album1\cage3.jpg [INFO] will upload image for C:\xtre javalog.txt mephotos\Album1\cage4.jpg in album with id null [ERROR] Unable to parse response

I have also included the java debug file

mfenetre commented 7 years ago

Hi, same error for me... [DEBUG] Class : org.piwigo.remotesync.api.response.PwgSessionGetStatusResponse [ERROR] Unable to parse response Although the XML response returned seems correct

mfenetre commented 7 years ago

working with 2.9.1 Piwigo server

mfenetre commented 7 years ago

23:41:30.666 [Thread-0] ERROR o.p.remotesync.api.client.WSClient - Unable to parse response org.simpleframework.xml.core.ElementException: Element 'available_sizes' does not have a match in class org.piwigo.remotesync.api.response.PwgSessionGetStatusResponse at line 3 at org.simpleframework.xml.core.Composite.readElement(Composite.java:527) ~[remotesync-ui.jar:0.0.13]

mfenetre commented 7 years ago

Seems to me that this part of the response

square thumb medium large xlarge xxlarge

is not understood correctly (it seems that available_sizes is not expected at all by the code ?)

plegall commented 6 years ago

I have pushed a temporary fix for this on Piwigo.com : (file include/ws_functions/pwg.php

Index: pwg.php
===================================================================
--- pwg.php (revision 2481)
+++ pwg.php (working copy)
@@ -327,8 +327,14 @@
   list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
   $res['current_datetime'] = $dbnow;
   $res['version'] = PHPWG_VERSION;
-  $res['available_sizes'] = array_keys(ImageStdParams::get_defined_type_map());

+  // Piwigo Remote Sync does not support receiving the available sizes
+  $piwigo_remote_sync_agent = 'Apache-HttpClient/';
+  if (!isset($_SERVER['HTTP_USER_AGENT']) or substr($_SERVER['HTTP_USER_AGENT'], 0, strlen($piwigo_remote_sync_agent)) !== $piwigo_remote_sync_agent)
+  {
+    $res['available_sizes'] = array_keys(ImageStdParams::get_defined_type_map());
+  }
+
   if (is_admin())
   {
     $res['upload_file_types'] = implode(

@mhelleboid this fix is not clean at all because it relies on the UserAgent, which is not specific to PiwigoRemoteSync :-/

Wouldn't it be possible for the Java code to simply ignore new fields returned by Piwigo API?

Valou447 commented 5 years ago

Hello !

First of all thank you for reporting this bug to us, attaching the log file helped us a lot in fixing this issue. Hopefully, it has been fixed in the 0.0.14 version of Piwigo Remote Sync !

Have a great day !