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 #ifndef _DOCUMENT_HXX_
29 #define _DOCUMENT_HXX_
30 
31 #include <iostream>
32 #include <string>
33 #include <vector>
34 
35 #include <boost/shared_ptr.hpp>
36 
37 #include "libcmis/exception.hxx"
38 #include "libcmis/libcmis-api.h"
39 #include "libcmis/object.hxx"
40 
41 namespace libcmis
42 {
43     class Folder;
44     class Session;
45 
46     /** Interface for a CMIS Document object.
47       */
48     class LIBCMIS_API Document : public virtual Object
49     {
50         public:
Document(Session * session)51             Document( Session* session ) : Object( session ) { }
~Document()52             virtual ~Document( ) { }
53 
54             /** Get the folder parents for the document.
55 
56                 Note that an unfiled document will have no parent folder.
57 
58                 @return the parents folder if any.
59               */
60             virtual std::vector< boost::shared_ptr< Folder > > getParents( ) = 0;
61 
62             /** Get the content stream without using a temporary file.
63 
64                 <p>The stream may not contain anything if there is
65                 no content or if something wrong happened during the
66                 download.</p>
67 
68                 @param streamId of the rendition
69                 @return
70                     An input stream to read the data from.
71 
72                 @throws Exception
73                     if anything wrong happened during the file transfer.
74                     In such a case, the content of the stream can't be
75                     guaranteed.
76               */
77             virtual boost::shared_ptr< std::istream > getContentStream( std::string streamId = std::string( ) )
78                         = 0;
79 
80             /** Set or replace the content stream of the document.
81 
82                 @param is the output stream containing the new data for the content stream
83                 @param contentType the mime-type of the new content stream
84                 @param filename the filename to set for the file
85                 @param overwrite if set to false, don't overwrite the content stream if one is already set.
86 
87                 @throw Exception if anything happens during the upload like a wrong authentication,
88                                 no rights to set the stream, server doesn't have the ContentStreamUpdatability
89                                 capability.
90               */
91             virtual void setContentStream( boost::shared_ptr< std::ostream > os, std::string contentType,
92                                            std::string filename, bool overwrite = true ) = 0;
93 
94             /** Get the content mime type.
95               */
96             virtual std::string getContentType( );
97 
98             /** Get the content stream filename.
99               */
100             virtual std::string getContentFilename( );
101 
102             /** Get the content length in bytes.
103               */
104             virtual long getContentLength( );
105 
106             /** Checks out the document and returns the object corresponding to the
107                 created Private Working Copy.
108 
109                 \return the Private Working Copy document
110               */
111             virtual boost::shared_ptr< Document > checkOut( ) = 0;
112 
113             /** Cancels the checkout if the document is a private working copy, or
114                 throws an exception.
115               */
116             virtual void cancelCheckout( ) = 0;
117 
118             /** Check in the private working copy and create a new version or throw
119                 an exception.
120 
121                 The current object will be updated to reflect the changes performed
122                 on the server side.
123 
124                 \param isMajor defines it the version to create is a major or minor one
125                 \param comment contains the checkin comment
126                 \param properties the properties to set the new version
127                 \param stream the content stream to set for the new version
128                 \param contentType the mime type of the stream to set
129 
130                 \return the document with the new version
131               */
132             virtual boost::shared_ptr< Document > checkIn( bool isMajor, std::string comment,
133                                   const std::map< std::string, PropertyPtr >& properties,
134                                   boost::shared_ptr< std::ostream > stream,
135                                   std::string contentType, std::string fileName ) = 0;
136 
137             virtual std::vector< boost::shared_ptr< Document > > getAllVersions( ) = 0;
138 
139             // virtual methods form Object
140             virtual std::vector< std::string > getPaths( );
141 
142             virtual std::string toString( );
143     };
144     typedef boost::shared_ptr< Document > DocumentPtr;
145 }
146 
147 #endif
148