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