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 _OBJECT_HXX_
29 : #define _OBJECT_HXX_
30 :
31 : #include <ctime>
32 : #include <map>
33 : #include <string>
34 :
35 : #ifndef __cplusplus
36 : #include <stdbool.h>
37 : #endif
38 :
39 : #include <boost/date_time.hpp>
40 : #include <boost/shared_ptr.hpp>
41 : #include <libxml/tree.h>
42 :
43 : #include "allowable-actions.hxx"
44 : #include "exception.hxx"
45 : #include "object-type.hxx"
46 : #include "property.hxx"
47 : #include "xmlserializable.hxx"
48 :
49 : namespace libcmis
50 : {
51 : class Folder;
52 : class Session;
53 :
54 : /** Class representing any CMIS object.
55 : */
56 : class Object : public XmlSerializable
57 : {
58 : protected:
59 : Session* m_session;
60 :
61 : libcmis::ObjectTypePtr m_typeDescription;
62 : time_t m_refreshTimestamp;
63 :
64 : /** Type id used as cache before we get it as a property
65 : */
66 : std::string m_typeId;
67 :
68 : std::map< std::string, libcmis::PropertyPtr > m_properties;
69 : boost::shared_ptr< libcmis::AllowableActions > m_allowableActions;
70 : void initializeFromNode( xmlNodePtr node );
71 :
72 : public:
73 :
74 : Object( Session* session );
75 : Object( Session* session, xmlNodePtr node );
76 : Object( const Object& copy );
77 0 : virtual ~Object( ) { }
78 :
79 : Object& operator=( const Object& copy );
80 :
81 : virtual std::string getId( );
82 : virtual std::string getName( );
83 :
84 : /** Computes the paths for the objects.
85 :
86 : Note that folders will have only path, documents may have
87 : several ones and there may be cases where there is no path
88 : at all (unfiled objects);
89 : */
90 : virtual std::vector< std::string > getPaths( );
91 :
92 : virtual std::string getBaseType( );
93 : virtual std::string getType( );
94 :
95 : virtual std::string getCreatedBy( );
96 : virtual boost::posix_time::ptime getCreationDate( );
97 : virtual std::string getLastModifiedBy( );
98 : virtual boost::posix_time::ptime getLastModificationDate( );
99 :
100 : virtual std::string getChangeToken( );
101 : virtual bool isImmutable( );
102 :
103 : /** Gives access to the properties of the object.
104 :
105 : \attention
106 : API users should consider this method as read-only as the
107 : changed properties won't be updated to the server. Updating
108 : the returned map may lead to changes loss when calling
109 : updateProperties.
110 :
111 : \sa updateProperties to change properties on the server
112 : */
113 : virtual std::map< std::string, PropertyPtr >& getProperties( );
114 : virtual AllowableActionsPtr getAllowableActions( ) { return m_allowableActions; }
115 :
116 : /** Update the object properties and return the updated object.
117 :
118 : \attention
119 : even if the returned object may have the same Id than 'this' and thus
120 : representing the same object on the server, those are still two different
121 : instances to ease memory handling.
122 : */
123 : virtual boost::shared_ptr< Object > updateProperties(
124 : const std::map< std::string, PropertyPtr >& properties ) throw ( Exception ) = 0;
125 :
126 : virtual ObjectTypePtr getTypeDescription( );
127 :
128 : /** Reload the data from the server.
129 : */
130 : virtual void refresh( ) throw ( Exception ) = 0;
131 : virtual time_t getRefreshTimestamp( ) { return m_refreshTimestamp; }
132 :
133 : virtual void remove( bool allVersions = true ) throw ( Exception ) = 0;
134 :
135 : virtual void move( boost::shared_ptr< Folder > source, boost::shared_ptr< Folder > destination ) throw ( Exception ) = 0;
136 :
137 : /** Dump the object as a string for debugging or display purpose.
138 : */
139 : virtual std::string toString( );
140 :
141 : void toXml( xmlTextWriterPtr writer );
142 : };
143 :
144 : typedef ::boost::shared_ptr< Object > ObjectPtr;
145 : }
146 :
147 : #endif
|