summaryrefslogtreecommitdiff
path: root/libcmis/libcmis-0.2.3-allowable-actions.patch
blob: 8cd84abdfd779755a4ac58e795564897025c8f2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
diff -ur libcmis-0.2.3/src/libcmis/allowable-actions.cxx misc/build/libcmis-0.2.3/src/libcmis/allowable-actions.cxx
--- libcmis-0.2.3/src/libcmis/allowable-actions.cxx	2012-07-03 16:47:28.063183460 +0200
+++ misc/build/libcmis-0.2.3/src/libcmis/allowable-actions.cxx	2012-07-03 16:48:24.178187938 +0200
@@ -28,14 +28,122 @@
 
 #include "allowable-actions.hxx"
 #include "object.hxx"
+#include "xml-utils.hxx"
 
 using namespace std;
 
 namespace libcmis
 {
-    AllowableActions::AllowableActions( ) :
+    ObjectAction::ObjectAction( xmlNodePtr node ) :
+        m_type( ObjectAction::DeleteObject ),
+        m_enabled( false ),
+        m_valid( false )
+    {
+        try
+        {
+            m_type = parseType( string( ( char* ) node->name ) );
+            m_valid = true;
+        }
+        catch ( const Exception& e )
+        {
+            m_valid = false;
+        }
+
+        // Invalid xsd:bool will be mean false... not sure what the spec says
+        try
+        {
+            xmlChar* content = xmlNodeGetContent( node );
+            m_enabled = parseBool( string( ( char* )content ) );
+            xmlFree( content );
+        }
+        catch ( const Exception& e )
+        {
+            m_enabled = false;
+        }
+    }
+
+    ObjectAction::Type ObjectAction::parseType( string type ) throw ( Exception )
+    {
+        Type value = DeleteObject;
+        if ( type == "canDeleteObject" )
+            value = DeleteObject;
+        else if ( type == "canUpdateProperties" )
+            value = UpdateProperties;
+        else if ( type == "canGetFolderTree" )
+            value = GetFolderTree;
+        else if ( type == "canGetProperties" )
+            value = GetProperties;
+        else if ( type == "canGetObjectRelationships" )
+            value = GetObjectRelationships;
+        else if ( type == "canGetObjectParents" )
+            value = GetObjectParents;
+        else if ( type == "canGetFolderParent" )
+            value = GetFolderParent;
+        else if ( type == "canGetDescendants" )
+            value = GetDescendants;
+        else if ( type == "canMoveObject" )
+            value = MoveObject;
+        else if ( type == "canDeleteContentStream" )
+            value = DeleteContentStream;
+        else if ( type == "canCheckOut" )
+            value = CheckOut;
+        else if ( type == "canCancelCheckOut" )
+            value = CancelCheckOut;
+        else if ( type == "canCheckIn" )
+            value = CheckIn;
+        else if ( type == "canSetContentStream" )
+            value = SetContentStream;
+        else if ( type == "canGetAllVersions" )
+            value = GetAllVersions;
+        else if ( type == "canAddObjectToFolder" )
+            value = AddObjectToFolder;
+        else if ( type == "canRemoveObjectFromFolder" )
+            value = RemoveObjectFromFolder;
+        else if ( type == "canGetContentStream" )
+            value = GetContentStream;
+        else if ( type == "canApplyPolicy" )
+            value = ApplyPolicy;
+        else if ( type == "canGetAppliedPolicies" )
+            value = GetAppliedPolicies;
+        else if ( type == "canRemovePolicy" )
+            value = RemovePolicy;
+        else if ( type == "canGetChildren" )
+            value = GetChildren;
+        else if ( type == "canCreateDocument" )
+            value = CreateDocument;
+        else if ( type == "canCreateFolder" )
+            value = CreateFolder;
+        else if ( type == "canCreateRelationship" )
+            value = CreateRelationship;
+        else if ( type == "canDeleteTree" )
+            value = DeleteTree;
+        else if ( type == "canGetRenditions" )
+            value = GetRenditions;
+        else if ( type == "canGetACL" )
+            value = GetACL;
+        else if ( type == "canApplyACL" )
+            value = ApplyACL;
+        else
+            throw Exception( "Invalid AllowableAction type: " + type );
+        
+        return value;
+    }
+
+    AllowableActions::AllowableActions( xmlNodePtr node ) :
         m_states( )
     {
+        for ( xmlNodePtr child = node->children; child; child = child->next )
+        {
+            // Check for non text children... "\n" is also a node ;)
+            if ( !xmlNodeIsText( child ) )
+            {
+                ObjectAction action( child );
+                if ( action.isValid( ) )
+                    m_states.insert( pair< libcmis::ObjectAction::Type, bool >(
+                                action.getType( ),
+                                action.isEnabled() ) );
+            }
+        }
     }
 
     AllowableActions::AllowableActions( const AllowableActions& copy ) :
diff -ur libcmis-0.2.3/src/libcmis/allowable-actions.hxx misc/build/libcmis-0.2.3/src/libcmis/allowable-actions.hxx
--- libcmis-0.2.3/src/libcmis/allowable-actions.hxx	2012-07-03 16:47:28.018183456 +0200
+++ misc/build/libcmis-0.2.3/src/libcmis/allowable-actions.hxx	2012-07-03 16:48:24.178187938 +0200
@@ -29,6 +29,11 @@
 #define _ALLOWABLE_ACTIONS_HXX_
 
 #include <map>
+#include <string>
+
+#include <libxml/tree.h>
+
+#include "exception.hxx"
 
 namespace libcmis
 {
@@ -37,8 +42,6 @@
     class ObjectAction
     {
         public:
-            virtual ~ObjectAction( ){ }
-
             enum Type
             {
                 DeleteObject,
@@ -71,6 +74,25 @@
                 GetACL,
                 ApplyACL
             };
+
+        private:
+            Type m_type;
+            bool m_enabled;
+            bool m_valid;
+
+        public:
+            ObjectAction( xmlNodePtr node );
+            virtual ~ObjectAction( ){ }
+
+            Type getType( ) { return m_type; }
+            bool isEnabled( ) { return m_enabled; }
+            bool isValid( ) { return m_valid; }
+
+            /** Parses the permission name into one of the enum values or throws
+                an exception for invalid input strings.
+              */
+            static Type parseType( std::string type ) throw ( Exception );
+
     };
 
     /** Class providing access to the allowed actions on an object.
@@ -81,7 +103,7 @@
             std::map< ObjectAction::Type, bool > m_states;
 
         public:
-            AllowableActions( );
+            AllowableActions( xmlNodePtr node );
             AllowableActions( const AllowableActions& copy );
             virtual ~AllowableActions( );
 
Only in libcmis-0.2.3/src/libcmis: atom-allowable-actions.cxx
Only in libcmis-0.2.3/src/libcmis: atom-allowable-actions.hxx
diff -ur libcmis-0.2.3/src/libcmis/atom-document.hxx misc/build/libcmis-0.2.3/src/libcmis/atom-document.hxx
--- libcmis-0.2.3/src/libcmis/atom-document.hxx	2012-07-03 16:47:28.094183463 +0200
+++ misc/build/libcmis-0.2.3/src/libcmis/atom-document.hxx	2012-07-03 16:48:24.178187938 +0200
@@ -35,6 +35,7 @@
 
 #include "document.hxx"
 #include "exception.hxx"
+#include "folder.hxx"
 #include "atom-object.hxx"
 
 class AtomDocument : public libcmis::Document, public AtomObject
diff -ur libcmis-0.2.3/src/libcmis/atom-object.cxx misc/build/libcmis-0.2.3/src/libcmis/atom-object.cxx
--- libcmis-0.2.3/src/libcmis/atom-object.cxx	2012-07-03 16:47:28.095183463 +0200
+++ misc/build/libcmis-0.2.3/src/libcmis/atom-object.cxx	2012-07-03 16:48:24.179187937 +0200
@@ -435,12 +435,14 @@
         // Get the infos URL as we may not have it
         m_infosUrl = getLink( "self", "application/atom+xml;type=entry" )->getHref( );
 
-        // Get the URL to the allowableActions
-        AtomLink* allowableActionsLink = getLink( "http://docs.oasis-open.org/ns/cmis/link/200908/allowableactions", "application/cmisallowableactions+xml" );
-        if ( NULL != allowableActionsLink )
+        // Get the allowableActions
+        xpathObj = xmlXPathEvalExpression( BAD_CAST( "//cmis:allowableActions" ), xpathCtx );
+        if ( xpathObj && xpathObj->nodesetval && xpathObj->nodesetval->nodeNr > 0 )
         {
-            m_allowableActions.reset( new AtomAllowableActions( m_session, allowableActionsLink->getHref( ) ) );
+            xmlNodePtr node = xpathObj->nodesetval->nodeTab[0];
+            m_allowableActions.reset( new libcmis::AllowableActions( node ) );
         }
+        xmlXPathFreeObject( xpathObj );
 
         // First get the type id as it will give us the property definitions
         string typeIdReq( "//cmis:propertyId[@propertyDefinitionId='cmis:objectTypeId']/cmis:value/text()" );
diff -ur libcmis-0.2.3/src/libcmis/atom-object.hxx misc/build/libcmis-0.2.3/src/libcmis/atom-object.hxx
--- libcmis-0.2.3/src/libcmis/atom-object.hxx	2012-07-03 16:47:28.043183458 +0200
+++ misc/build/libcmis-0.2.3/src/libcmis/atom-object.hxx	2012-07-03 16:48:24.179187937 +0200
@@ -30,7 +30,7 @@
 
 #include <libxml/tree.h>
 
-#include "atom-allowable-actions.hxx"
+#include "allowable-actions.hxx"
 #include "object.hxx"
 
 class AtomPubSession;
@@ -64,7 +64,7 @@
         libcmis::ObjectTypePtr m_typeDescription;
 
         std::map< std::string, libcmis::PropertyPtr > m_properties;
-        boost::shared_ptr< AtomAllowableActions > m_allowableActions;
+        boost::shared_ptr< libcmis::AllowableActions > m_allowableActions;
 
         std::vector< AtomLink > m_links;
 
diff -ur libcmis-0.2.3/src/libcmis/atom-session.cxx misc/build/libcmis-0.2.3/src/libcmis/atom-session.cxx
--- libcmis-0.2.3/src/libcmis/atom-session.cxx	2012-07-03 16:47:27.989183454 +0200
+++ misc/build/libcmis-0.2.3/src/libcmis/atom-session.cxx	2012-07-03 16:48:24.179187937 +0200
@@ -311,6 +311,7 @@
     string pattern = getWorkspace().getUriTemplate( atom::UriTemplate::ObjectById );
     map< string, string > vars;
     vars[URI_TEMPLATE_VAR_ID] = id;
+    vars[string( "includeAllowableActions" )] = string( "true" );
     string url = createUrl( pattern, vars );
 
     try
@@ -340,6 +341,7 @@
     string pattern = getWorkspace().getUriTemplate( atom::UriTemplate::ObjectByPath );
     map< string, string > vars;
     vars[URI_TEMPLATE_VAR_PATH] = path;
+    vars[string( "includeAllowableActions" )] = string( "true" );
     string url = createUrl( pattern, vars );
 
     try
diff -ur libcmis-0.2.3/src/libcmis/Makefile.am misc/build/libcmis-0.2.3/src/libcmis/Makefile.am
--- libcmis-0.2.3/src/libcmis/Makefile.am	2012-07-03 16:47:28.021183457 +0200
+++ misc/build/libcmis-0.2.3/src/libcmis/Makefile.am	2012-07-03 16:48:24.177187939 +0200
@@ -32,8 +32,6 @@
 	atom-utils.cxx \
 	atom-workspace.hxx \
 	atom-workspace.cxx \
-	atom-allowable-actions.hxx \
-	atom-allowable-actions.cxx \
 	allowable-actions.cxx \
 	property.cxx \
 	property-type.cxx \
diff -ur libcmis-0.2.3/src/libcmis/makefile.mk misc/build/libcmis-0.2.3/src/libcmis/makefile.mk
--- libcmis-0.2.3/src/libcmis/makefile.mk	2012-07-03 16:47:28.052183459 +0200
+++ misc/build/libcmis-0.2.3/src/libcmis/makefile.mk	2012-07-03 16:48:24.179187937 +0200
@@ -25,7 +25,6 @@
 
 SLOFILES= \
     $(SLO)$/allowable-actions.obj \
-	$(SLO)$/atom-allowable-actions.obj \
 	$(SLO)$/atom-document.obj \
 	$(SLO)$/atom-folder.obj \
 	$(SLO)$/atom-object-type.obj \