| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * File containing the ObjectState Gateway class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @copyright Copyright (C) eZ Systems AS. All rights reserved. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @license For full copyright and license information view LICENSE file distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | namespace eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Gateway; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use eZ\Publish\Core\Base\Exceptions\DatabaseException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Gateway; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use eZ\Publish\SPI\Persistence\Content\ObjectState; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use eZ\Publish\SPI\Persistence\Content\ObjectState\Group; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Doctrine\DBAL\DBALException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use PDOException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | class ExceptionConversion extends Gateway | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      * The wrapped gateway. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      * @var \eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Gateway | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     protected $innerGateway; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      * Creates a new exception conversion gateway around $innerGateway. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * @param \eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Gateway $innerGateway | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     public function __construct(Gateway $innerGateway) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         $this->innerGateway = $innerGateway; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     public function loadObjectStateData($stateId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             return $this->innerGateway->loadObjectStateData($stateId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         } catch (DBALException | PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |             throw DatabaseException::wrap($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     public function loadObjectStateDataByIdentifier($identifier, $groupId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |             return $this->innerGateway->loadObjectStateDataByIdentifier($identifier, $groupId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         } catch (DBALException | PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             throw DatabaseException::wrap($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     public function loadObjectStateListData($groupId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             return $this->innerGateway->loadObjectStateListData($groupId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         } catch (DBALException | PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             throw DatabaseException::wrap($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     public function loadObjectStateGroupData($groupId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |             return $this->innerGateway->loadObjectStateGroupData($groupId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         } catch (DBALException | PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |             throw DatabaseException::wrap($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     public function loadObjectStateGroupDataByIdentifier($identifier) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |             return $this->innerGateway->loadObjectStateGroupDataByIdentifier($identifier); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         } catch (DBALException | PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |             throw DatabaseException::wrap($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     public function loadObjectStateGroupListData($offset, $limit) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |             return $this->innerGateway->loadObjectStateGroupListData($offset, $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         } catch (DBALException | PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |             throw DatabaseException::wrap($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     public function insertObjectState(ObjectState $objectState, $groupId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |             return $this->innerGateway->insertObjectState($objectState, $groupId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |         } catch (DBALException | PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |             throw DatabaseException::wrap($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     public function updateObjectState(ObjectState $objectState) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |             return $this->innerGateway->updateObjectState($objectState); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         } catch (DBALException | PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |             throw DatabaseException::wrap($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     public function deleteObjectState($stateId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |             return $this->innerGateway->deleteObjectState($stateId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         } catch (DBALException | PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |             throw DatabaseException::wrap($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     public function updateObjectStateLinks($oldStateId, $newStateId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |             return $this->innerGateway->updateObjectStateLinks($oldStateId, $newStateId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |         } catch (DBALException | PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |             throw DatabaseException::wrap($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     public function deleteObjectStateLinks($stateId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |             return $this->innerGateway->deleteObjectStateLinks($stateId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         } catch (DBALException | PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |             throw DatabaseException::wrap($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     public function insertObjectStateGroup(Group $objectStateGroup) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |             return $this->innerGateway->insertObjectStateGroup($objectStateGroup); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |         } catch (DBALException | PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |             throw DatabaseException::wrap($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     public function updateObjectStateGroup(Group $objectStateGroup) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |             return $this->innerGateway->updateObjectStateGroup($objectStateGroup); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |         } catch (DBALException | PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |             throw DatabaseException::wrap($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |     public function deleteObjectStateGroup($groupId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |             return $this->innerGateway->deleteObjectStateGroup($groupId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |         } catch (DBALException | PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |             throw DatabaseException::wrap($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |     public function setContentState($contentId, $groupId, $stateId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |             return $this->innerGateway->setContentState($contentId, $groupId, $stateId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |         } catch (DBALException | PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |             throw DatabaseException::wrap($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |     public function loadObjectStateDataForContent($contentId, $stateGroupId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |             return $this->innerGateway->loadObjectStateDataForContent($contentId, $stateGroupId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         } catch (DBALException | PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |             throw DatabaseException::wrap($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 180 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 181 |  |  |     public function getContentCount($stateId) | 
            
                                                                        
                            
            
                                    
            
            
                | 182 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 183 |  |  |         try { | 
            
                                                                        
                            
            
                                    
            
            
                | 184 |  |  |             return $this->innerGateway->getContentCount($stateId); | 
            
                                                                        
                            
            
                                    
            
            
                | 185 |  |  |         } catch (DBALException | PDOException $e) { | 
            
                                                                        
                            
            
                                    
            
            
                | 186 |  |  |             throw DatabaseException::wrap($e); | 
            
                                                                        
                            
            
                                    
            
            
                | 187 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 188 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |     public function updateObjectStatePriority($stateId, $priority) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             return $this->innerGateway->updateObjectStatePriority($stateId, $priority); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |         } catch (DBALException | PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |             throw DatabaseException::wrap($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 198 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 199 |  |  |  |