Commit e01aba9f34e2e66d7ec30c1821284c0bdd71daa9
1 parent
99024a67
Modified CMIS AtomPub helper class fetching KTAPI object to attempt re-auth and …
…send auth request if the session is invalid for whatever reason (was happening sometimes and causing issues with the eZ Publish NXC CMIS client extension on some systems. Committed by: Paul Barrett
Showing
4 changed files
with
22 additions
and
15 deletions
lib/api/ktcmis/services/CMISNavigationService.inc.php
| ... | ... | @@ -127,8 +127,7 @@ class CMISNavigationService { |
| 127 | 127 | // if this is not a folder, cannot get children |
| 128 | 128 | $folderId = CMISUtil::decodeObjectId($folderId, $type); |
| 129 | 129 | // NOTE this will quite possibly break the webservices |
| 130 | - if ($type != 'Folder') | |
| 131 | - { | |
| 130 | + if ($type != 'Folder') { | |
| 132 | 131 | return $children; |
| 133 | 132 | } |
| 134 | 133 | ... | ... |
webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php
| ... | ... | @@ -64,7 +64,7 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { |
| 64 | 64 | // node request e.g.: node/F2 |
| 65 | 65 | if (urldecode($this->params[0]) == 'Root Folder') |
| 66 | 66 | { |
| 67 | - $folderId = CMISUtil::encodeObjectId('Folder', 1); | |
| 67 | + $folderId = CMISUtil::encodeObjectId(FOLDER, 1); | |
| 68 | 68 | $folderName = urldecode($this->params[0]); |
| 69 | 69 | } |
| 70 | 70 | else if ($this->params[0] == 'path') | ... | ... |
webservice/atompub/cmis/KT_cmis_atom_service_helper.inc.php
| ... | ... | @@ -531,8 +531,16 @@ class KT_cmis_atom_service_helper { |
| 531 | 531 | { |
| 532 | 532 | if(!isset(self::$ktapi)) |
| 533 | 533 | { |
| 534 | - self::$ktapi = new KTAPI(); | |
| 535 | - self::$ktapi->get_active_session(session_id()); | |
| 534 | + self::$ktapi = new KTAPI(); | |
| 535 | + $active = self::$ktapi->get_active_session(session_id()); | |
| 536 | + | |
| 537 | + if (PEAR::isError($active)) | |
| 538 | + { | |
| 539 | + // invoke auth code, session must be restarted | |
| 540 | + if(!KT_atom_HTTPauth::isLoggedIn()) { | |
| 541 | + KT_atom_HTTPauth::login('KnowledgeTree DMS', 'You must authenticate to enter this realm'); | |
| 542 | + } | |
| 543 | + } | |
| 536 | 544 | } |
| 537 | 545 | return self::$ktapi; |
| 538 | 546 | } | ... | ... |
webservice/atompub/cmis/index.php
| ... | ... | @@ -46,12 +46,20 @@ $accessProtocol = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on')) ? 'h |
| 46 | 46 | define('KT_APP_BASE_URI', $accessProtocol . '://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/?/'); |
| 47 | 47 | define('KT_APP_SYSTEM_URI', $accessProtocol . '://'.$_SERVER['HTTP_HOST']); |
| 48 | 48 | define('KT_ATOM_LIB_FOLDER', '../../classes/atompub/'); |
| 49 | - | |
| 50 | 49 | define('CMIS_APP_BASE_URI', trim(KT_APP_BASE_URI, '/')); |
| 51 | 50 | define('CMIS_APP_SYSTEM_URI', KT_APP_SYSTEM_URI); |
| 52 | 51 | define('CMIS_ATOM_LIB_FOLDER', trim(KT_ATOM_LIB_FOLDER, '/') . '/cmis/'); |
| 53 | 52 | |
| 54 | 53 | /** |
| 54 | + * Check Realm Authentication | |
| 55 | + */ | |
| 56 | +require_once(KT_ATOM_LIB_FOLDER.'KT_atom_HTTPauth.inc.php'); | |
| 57 | + | |
| 58 | +if(!KT_atom_HTTPauth::isLoggedIn()) { | |
| 59 | + KT_atom_HTTPauth::login('KnowledgeTree DMS', 'You must authenticate to enter this realm'); | |
| 60 | +} | |
| 61 | + | |
| 62 | +/** | |
| 55 | 63 | * Includes |
| 56 | 64 | */ |
| 57 | 65 | include_once(KT_ATOM_LIB_FOLDER.'XMLns2array.inc.php'); |
| ... | ... | @@ -62,17 +70,9 @@ include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_responseFeed.inc.php'); //Con |
| 62 | 70 | include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_serviceDoc.inc.php'); //Containing the servicedoc class allowing easy ServiceDocument generation |
| 63 | 71 | include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_service.inc.php'); //Containing the servicedoc class allowing easy ServiceDocument generation |
| 64 | 72 | |
| 73 | +// services | |
| 65 | 74 | include_once('KT_cmis_atom_server.services.inc.php'); |
| 66 | 75 | |
| 67 | -/** | |
| 68 | - * Check Realm Authentication | |
| 69 | - */ | |
| 70 | -require_once(KT_ATOM_LIB_FOLDER.'KT_atom_HTTPauth.inc.php'); | |
| 71 | - | |
| 72 | -if(!KT_atom_HTTPauth::isLoggedIn()) { | |
| 73 | - KT_atom_HTTPauth::login('KnowledgeTree DMS', 'You must authenticate to enter this realm'); | |
| 74 | -} | |
| 75 | - | |
| 76 | 76 | //Start the AtomPubProtocol Routing Engine |
| 77 | 77 | $APP = new KT_cmis_atom_server(); |
| 78 | 78 | ... | ... |