LCOV - code coverage report
Current view: top level - libreoffice/workdir/unxlngi6.pro/UnpackedTarball/cmis/src/libcmis - ws-objectservice.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 101 0.0 %
Date: 2012-12-17 Functions: 0 16 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* libcmis
       2             :  * Version: MPL 1.1 / GPLv2+ / LGPLv2+
       3             :  *
       4             :  * The contents of this file are subject to the Mozilla Public License Version
       5             :  * 1.1 (the "License"); you may not use this file except in compliance with
       6             :  * the License or as specified alternatively below. You may obtain a copy of
       7             :  * the License at http://www.mozilla.org/MPL/
       8             :  *
       9             :  * Software distributed under the License is distributed on an "AS IS" basis,
      10             :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      11             :  * for the specific language governing rights and limitations under the
      12             :  * License.
      13             :  *
      14             :  * Major Contributor(s):
      15             :  * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
      16             :  *
      17             :  *
      18             :  * All Rights Reserved.
      19             :  *
      20             :  * For minor contributions see the git repository.
      21             :  *
      22             :  * Alternatively, the contents of this file may be used under the terms of
      23             :  * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
      24             :  * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
      25             :  * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
      26             :  * instead of those above.
      27             :  */
      28             : 
      29             : #include "ws-objectservice.hxx"
      30             : #include "ws-requests.hxx"
      31             : #include "ws-session.hxx"
      32             : 
      33             : using namespace std;
      34             : 
      35           0 : ObjectService::ObjectService( WSSession* session ) :
      36             :     m_session( session ),
      37           0 :     m_url( )
      38             : {
      39           0 :     m_url = session->getServiceUrl( "ObjectService" );
      40           0 : }
      41             : 
      42           0 : ObjectService::ObjectService( const ObjectService& copy ) :
      43             :     m_session( copy.m_session ),
      44           0 :     m_url( copy.m_url )
      45             : {
      46           0 : }
      47             : 
      48           0 : ObjectService::~ObjectService( )
      49             : {
      50           0 : }
      51             : 
      52           0 : ObjectService& ObjectService::operator=( const ObjectService& copy )
      53             : {
      54           0 :     if ( this != &copy )
      55             :     {
      56           0 :         m_session = copy.m_session;
      57           0 :         m_url = copy.m_url;
      58             :     }
      59             : 
      60           0 :     return *this;
      61             : }
      62             : 
      63           0 : libcmis::ObjectPtr ObjectService::getObject( string repoId, string id ) throw ( libcmis::Exception )
      64             : {
      65           0 :     libcmis::ObjectPtr object;
      66             : 
      67           0 :     GetObject request( repoId, id );
      68           0 :     vector< SoapResponsePtr > responses = m_session->soapRequest( m_url, request );
      69           0 :     if ( responses.size( ) == 1 )
      70             :     {
      71           0 :         SoapResponse* resp = responses.front( ).get( );
      72           0 :         GetObjectResponse* response = dynamic_cast< GetObjectResponse* >( resp );
      73           0 :         if ( response != NULL )
      74           0 :             object = response->getObject( );
      75             :     }
      76             : 
      77           0 :     return object;
      78             : }
      79             : 
      80           0 : libcmis::ObjectPtr ObjectService::getObjectByPath( string repoId, string path ) throw ( libcmis::Exception )
      81             : {
      82           0 :     libcmis::ObjectPtr object;
      83             : 
      84           0 :     GetObjectByPath request( repoId, path );
      85           0 :     vector< SoapResponsePtr > responses = m_session->soapRequest( m_url, request );
      86           0 :     if ( responses.size( ) == 1 )
      87             :     {
      88           0 :         SoapResponse* resp = responses.front( ).get( );
      89           0 :         GetObjectResponse* response = dynamic_cast< GetObjectResponse* >( resp );
      90           0 :         if ( response != NULL )
      91           0 :             object = response->getObject( );
      92             :     }
      93             : 
      94           0 :     return object;
      95             : }
      96             : 
      97           0 : libcmis::ObjectPtr ObjectService::updateProperties(
      98             :         string repoId, string objectId,
      99             :         const map< string, libcmis::PropertyPtr >& properties,
     100             :         string changeToken ) throw ( libcmis::Exception )
     101             : {
     102           0 :     libcmis::ObjectPtr object;
     103             : 
     104           0 :     UpdateProperties request( repoId, objectId, properties, changeToken );
     105           0 :     vector< SoapResponsePtr > responses = m_session->soapRequest( m_url, request );
     106           0 :     if ( responses.size( ) == 1 )
     107             :     {
     108           0 :         SoapResponse* resp = responses.front( ).get( );
     109           0 :         UpdatePropertiesResponse* response = dynamic_cast< UpdatePropertiesResponse* >( resp );
     110           0 :         if ( response != NULL )
     111             :         {
     112           0 :             string id = response->getObjectId( );
     113           0 :             object = getObject( repoId, id );
     114             :         }
     115             :     }
     116             : 
     117           0 :     return object;
     118             : }
     119             : 
     120           0 : void ObjectService::deleteObject( string repoId, string id, bool allVersions ) throw ( libcmis::Exception )
     121             : {
     122           0 :     class DeleteObject request( repoId, id, allVersions );
     123           0 :     m_session->soapRequest( m_url, request );
     124           0 : }
     125             :         
     126           0 : vector< string > ObjectService::deleteTree( std::string repoId, std::string folderId, bool allVersions,
     127             :         libcmis::UnfileObjects::Type unfile, bool continueOnFailure ) throw ( libcmis::Exception )
     128             : {
     129           0 :     vector< string > failedIds;
     130             : 
     131           0 :     DeleteTree request( repoId, folderId, allVersions, unfile, continueOnFailure );
     132           0 :     vector< SoapResponsePtr > responses = m_session->soapRequest( m_url, request );
     133           0 :     if ( responses.size( ) == 1 )
     134             :     {
     135           0 :         SoapResponse* resp = responses.front( ).get( );
     136           0 :         DeleteTreeResponse* response = dynamic_cast< DeleteTreeResponse* >( resp );
     137           0 :         if ( response != NULL )
     138           0 :             failedIds = response->getFailedIds( );
     139             :     }
     140             : 
     141           0 :     return failedIds;
     142             : }
     143             : 
     144           0 : void ObjectService::move( string repoId, string objectId, string destId, string srcId ) throw ( libcmis::Exception )
     145             : {
     146           0 :     MoveObject request( repoId, objectId, destId, srcId );
     147           0 :     m_session->soapRequest( m_url, request );
     148           0 : }
     149             : 
     150           0 : boost::shared_ptr< istream > ObjectService::getContentStream( string repoId, string objectId ) throw ( libcmis::Exception )
     151             : {
     152           0 :     boost::shared_ptr< istream > stream;
     153             : 
     154           0 :     GetContentStream request( repoId, objectId );
     155           0 :     vector< SoapResponsePtr > responses = m_session->soapRequest( m_url, request );
     156           0 :     if ( responses.size( ) == 1 )
     157             :     {
     158           0 :         SoapResponse* resp = responses.front( ).get( );
     159           0 :         GetContentStreamResponse* response = dynamic_cast< GetContentStreamResponse* >( resp );
     160           0 :         if ( response != NULL )
     161           0 :             stream = response->getStream( );
     162             :     }
     163             : 
     164           0 :     return stream;
     165             : }
     166             : 
     167           0 : void ObjectService::setContentStream( std::string repoId, std::string objectId, bool overwrite, std::string changeToken,
     168             :         boost::shared_ptr< std::ostream > stream, std::string contentType, std::string fileName ) throw ( libcmis::Exception )
     169             : {
     170           0 :     SetContentStream request( repoId, objectId, overwrite, changeToken, stream, contentType, fileName );
     171           0 :     m_session->soapRequest( m_url, request );
     172           0 : }
     173             : 
     174           0 : libcmis::FolderPtr ObjectService::createFolder( string repoId, const map< string, libcmis::PropertyPtr >& properties,
     175             :         string folderId ) throw ( libcmis::Exception )
     176             : {
     177           0 :     libcmis::FolderPtr folder;
     178             : 
     179           0 :     CreateFolder request( repoId, properties, folderId );
     180           0 :     vector< SoapResponsePtr > responses = m_session->soapRequest( m_url, request );
     181           0 :     if ( responses.size( ) == 1 )
     182             :     {
     183           0 :         SoapResponse* resp = responses.front( ).get( );
     184           0 :         CreateFolderResponse* response = dynamic_cast< CreateFolderResponse* >( resp );
     185           0 :         if ( response != NULL )
     186             :         {
     187           0 :             string id = response->getObjectId( );
     188           0 :             folder = m_session->getFolder( id );
     189             :         }
     190             :     }
     191             : 
     192           0 :     return folder;
     193             : }
     194             : 
     195           0 : libcmis::DocumentPtr ObjectService::createDocument( string repoId, const map< string, libcmis::PropertyPtr >& properties,
     196             :         string folderId, boost::shared_ptr< ostream > stream, string contentType, string fileName ) throw ( libcmis::Exception )
     197             : {
     198           0 :     libcmis::DocumentPtr document;
     199             : 
     200           0 :     CreateDocument request( repoId, properties, folderId, stream, contentType, fileName );
     201           0 :     vector< SoapResponsePtr > responses = m_session->soapRequest( m_url, request );
     202           0 :     if ( responses.size( ) == 1 )
     203             :     {
     204           0 :         SoapResponse* resp = responses.front( ).get( );
     205           0 :         CreateFolderResponse* response = dynamic_cast< CreateFolderResponse* >( resp );
     206           0 :         if ( response != NULL )
     207             :         {
     208           0 :             string id = response->getObjectId( );
     209           0 :             libcmis::ObjectPtr object = m_session->getObject( id );
     210           0 :             document = boost::dynamic_pointer_cast< libcmis::Document >( object );
     211             :         }
     212             :     }
     213             : 
     214           0 :     return document;
     215           0 : }

Generated by: LCOV version 1.10