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 _ALLOWABLE_ACTIONS_HXX_
29 : #define _ALLOWABLE_ACTIONS_HXX_
30 :
31 : #include <map>
32 : #include <string>
33 :
34 : #include <boost/shared_ptr.hpp>
35 : #include <libxml/tree.h>
36 :
37 : #include "exception.hxx"
38 :
39 : namespace libcmis
40 : {
41 : class Object;
42 :
43 : class ObjectAction
44 : {
45 : public:
46 : enum Type
47 : {
48 : DeleteObject,
49 : UpdateProperties,
50 : GetFolderTree,
51 : GetProperties,
52 : GetObjectRelationships,
53 : GetObjectParents,
54 : GetFolderParent,
55 : GetDescendants,
56 : MoveObject,
57 : DeleteContentStream,
58 : CheckOut,
59 : CancelCheckOut,
60 : CheckIn,
61 : SetContentStream,
62 : GetAllVersions,
63 : AddObjectToFolder,
64 : RemoveObjectFromFolder,
65 : GetContentStream,
66 : ApplyPolicy,
67 : GetAppliedPolicies,
68 : RemovePolicy,
69 : GetChildren,
70 : CreateDocument,
71 : CreateFolder,
72 : CreateRelationship,
73 : DeleteTree,
74 : GetRenditions,
75 : GetACL,
76 : ApplyACL
77 : };
78 :
79 : private:
80 : Type m_type;
81 : bool m_enabled;
82 : bool m_valid;
83 :
84 : public:
85 : ObjectAction( xmlNodePtr node );
86 0 : virtual ~ObjectAction( ){ }
87 :
88 : Type getType( ) { return m_type; }
89 : bool isEnabled( ) { return m_enabled; }
90 : bool isValid( ) { return m_valid; }
91 :
92 : /** Parses the permission name into one of the enum values or throws
93 : an exception for invalid input strings.
94 : */
95 : static Type parseType( std::string type ) throw ( Exception );
96 :
97 : };
98 :
99 : /** Class providing access to the allowed actions on an object.
100 : */
101 : class AllowableActions
102 : {
103 : protected:
104 : std::map< ObjectAction::Type, bool > m_states;
105 :
106 : public:
107 : /** Default constructor for testing purpose
108 : */
109 : AllowableActions( );
110 : AllowableActions( xmlNodePtr node );
111 : AllowableActions( const AllowableActions& copy );
112 : virtual ~AllowableActions( );
113 :
114 : AllowableActions& operator=( const AllowableActions& copy );
115 :
116 : /** Returns the permissions for the corresponding actions.
117 : */
118 : bool isAllowed( ObjectAction::Type action );
119 :
120 : /** Returns true if the action was defined, false if the default
121 : value is used.
122 : */
123 : bool isDefined( ObjectAction::Type action );
124 : };
125 : typedef boost::shared_ptr< AllowableActions > AllowableActionsPtr;
126 : }
127 :
128 : #endif
|