[Libreoffice-commits] .: 2 commits - libcmis/libcmis-0.2.3-allowable-actions.patch libcmis/makefile.mk ucb/source
Cédric Bosdonnat
cbosdo at kemper.freedesktop.org
Tue Jul 3 08:10:08 PDT 2012
libcmis/libcmis-0.2.3-allowable-actions.patch | 284 ++++++++++++++++++++++++++
libcmis/makefile.mk | 2
ucb/source/ucp/cmis/cmis_content.cxx | 9
ucb/source/ucp/cmis/cmis_content.hxx | 1
ucb/source/ucp/cmis/cmis_datasupplier.cxx | 8
ucb/source/ucp/cmis/cmis_url.cxx | 23 +-
ucb/source/ucp/cmis/cmis_url.hxx | 2
7 files changed, 325 insertions(+), 4 deletions(-)
New commits:
commit 478c65b490912b2d334fab79f80d3eecbdbe0dac
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date: Tue Jul 3 17:06:49 2012 +0200
libcmis: added a patch to workaround an alfresco bug and avoid HTTP requests
Change-Id: Ifbdaa6fce3812ff7d5c884527924b0b321133856
diff --git a/libcmis/libcmis-0.2.3-allowable-actions.patch b/libcmis/libcmis-0.2.3-allowable-actions.patch
new file mode 100644
index 0000000..8cd84ab
--- /dev/null
+++ b/libcmis/libcmis-0.2.3-allowable-actions.patch
@@ -0,0 +1,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 \
diff --git a/libcmis/makefile.mk b/libcmis/makefile.mk
index cedddf9..b5ffd5d 100644
--- a/libcmis/makefile.mk
+++ b/libcmis/makefile.mk
@@ -46,6 +46,8 @@ TARFILE_MD5=0d2dcdfbf28d6208751b33057f5361f0
# Pushed upstream in both master and libcmis-0.2 branches
PATCH_FILES+=libcmis-0.2.3.patch
+# Pushed upstream to master branch, but not to libcmis-0.2
+PATCH_FILES+=libcmis-0.2.3-allowable-actions.patch
.IF "$(OS)$(COM)" == "WNTMSC"
PATCH_FILES+=boost-win.patch
commit 735e9b090edf1a315823577d5d2da8c671a3d139
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date: Mon Jul 2 16:41:01 2012 +0200
CMIS UCP: fallback to URL with id as the mark if we can't get the path
This situation will happen in several cases:
* We don't have the permission to retrieve the object parents
* For unfiled objects... though I'm still wondering how those could
sneak into the UI.
Change-Id: I2095334fa1c9152389c5c824e34375bf48bfbedf
diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx
index dbc9332..057b3d6 100644
--- a/ucb/source/ucp/cmis/cmis_content.cxx
+++ b/ucb/source/ucp/cmis/cmis_content.cxx
@@ -162,6 +162,7 @@ namespace cmis
// Split the URL into bits
m_sURL = m_xIdentifier->getContentIdentifier( );
cmis::URL url( m_sURL );
+ SAL_INFO( "cmisucp", "Content::Content() " << m_sURL );
// Look for a cached session, key is binding url + repo id
rtl::OUString sSessionId = url.getBindingUrl( ) + url.getRepositoryId( );
@@ -174,6 +175,7 @@ namespace cmis
}
m_sObjectPath = url.getObjectPath( );
+ m_sObjectId = url.getObjectId( );
m_sBindingUrl = url.getBindingUrl( );
}
@@ -189,6 +191,7 @@ namespace cmis
// Split the URL into bits
m_sURL = m_xIdentifier->getContentIdentifier( );
cmis::URL url( m_sURL );
+ SAL_INFO( "cmisucp", "Content::Content() " << m_sURL );
// Look for a cached session, key is binding url + repo id
rtl::OUString sSessionId = url.getBindingUrl( ) + url.getRepositoryId( );
@@ -201,6 +204,7 @@ namespace cmis
}
m_sObjectPath = url.getObjectPath( );
+ m_sObjectId = url.getObjectId( );
m_sBindingUrl = url.getBindingUrl( );
// Get the object type
@@ -218,10 +222,13 @@ namespace cmis
{
if ( !m_sObjectPath.isEmpty( ) )
m_pObject = m_pSession->getObjectByPath( OUSTR_TO_STDSTR( m_sObjectPath ) );
+ else if (!m_sObjectId.isEmpty( ) )
+ m_pObject = m_pSession->getObject( OUSTR_TO_STDSTR( m_sObjectId ) );
else
{
m_pObject = m_pSession->getRootFolder( );
m_sObjectPath = "/";
+ m_sObjectId = rtl::OUString( );
}
}
@@ -440,6 +447,8 @@ namespace cmis
{
if ( !m_sObjectPath.isEmpty( ) )
m_pSession->getObjectByPath( OUSTR_TO_STDSTR( m_sObjectPath ) );
+ else if ( !m_sObjectId.isEmpty( ) )
+ m_pSession->getObject( OUSTR_TO_STDSTR( m_sObjectId ) );
// No need to handle the root folder case... how can it not exists?
}
catch ( const libcmis::Exception& )
diff --git a/ucb/source/ucp/cmis/cmis_content.hxx b/ucb/source/ucp/cmis/cmis_content.hxx
index 359aaaa..28ff5cd 100644
--- a/ucb/source/ucp/cmis/cmis_content.hxx
+++ b/ucb/source/ucp/cmis/cmis_content.hxx
@@ -71,6 +71,7 @@ private:
libcmis::Session* m_pSession;
libcmis::ObjectPtr m_pObject;
rtl::OUString m_sObjectPath;
+ rtl::OUString m_sObjectId;
rtl::OUString m_sURL;
rtl::OUString m_sBindingUrl;
diff --git a/ucb/source/ucp/cmis/cmis_datasupplier.cxx b/ucb/source/ucp/cmis/cmis_datasupplier.cxx
index 710f82a..c459dde 100644
--- a/ucb/source/ucp/cmis/cmis_datasupplier.cxx
+++ b/ucb/source/ucp/cmis/cmis_datasupplier.cxx
@@ -96,7 +96,13 @@ namespace cmis
vector< string > paths = maResults[nIndex]->pObject->getPaths( );
if ( !paths.empty( ) )
sObjectPath = paths.front( );
- // TODO Handle the unfiled objects with their id... but can they manage to come here?
+ else
+ {
+ // Handle the unfiled objects with their id...
+ // They manage to sneak here if we don't have the permission to get the object
+ // parents (and then the path)
+ sObjectPath += "#" + maResults[nIndex]->pObject->getId( );
+ }
// Get the URL from the Path
URL aUrl( mxContent->getIdentifier( )->getContentIdentifier( ) );
diff --git a/ucb/source/ucp/cmis/cmis_url.cxx b/ucb/source/ucp/cmis/cmis_url.cxx
index d7a8e7e..3357a24 100644
--- a/ucb/source/ucp/cmis/cmis_url.cxx
+++ b/ucb/source/ucp/cmis/cmis_url.cxx
@@ -57,6 +57,10 @@ namespace cmis
// Store the path to the object
m_sPath = aUrl.GetURLPath( INetURLObject::DECODE_WITH_CHARSET );
+ m_sId = aUrl.GetMark( );
+
+ if ( !m_sId.isEmpty( ) )
+ m_sPath = rtl::OUString( );
}
map< int, string > URL::getSessionParams( )
@@ -75,6 +79,11 @@ namespace cmis
return m_sPath;
}
+ rtl::OUString& URL::getObjectId( )
+ {
+ return m_sId;
+ }
+
rtl::OUString& URL::getBindingUrl( )
{
return m_sBindingUrl;
@@ -88,6 +97,7 @@ namespace cmis
void URL::setObjectPath( rtl::OUString sPath )
{
m_sPath = sPath;
+ m_sId = rtl::OUString( );
}
rtl::OUString URL::asString( )
@@ -100,9 +110,16 @@ namespace cmis
RTL_TEXTENCODING_UTF8 );
sUrl = "vnd.libreoffice.cmis+atom://" + sEncodedBinding;
- if ( m_sPath[0] != '/' )
- sUrl += "/";
- sUrl += m_sPath;
+ if ( !m_sPath.isEmpty( ) )
+ {
+ if ( m_sPath[0] != '/' )
+ sUrl += "/";
+ sUrl += m_sPath;
+ }
+ else if ( !m_sId.isEmpty( ) )
+ {
+ sUrl += "#" + m_sId;
+ }
return sUrl;
}
diff --git a/ucb/source/ucp/cmis/cmis_url.hxx b/ucb/source/ucp/cmis/cmis_url.hxx
index 4033a17..3d41690 100644
--- a/ucb/source/ucp/cmis/cmis_url.hxx
+++ b/ucb/source/ucp/cmis/cmis_url.hxx
@@ -42,6 +42,7 @@ namespace cmis
rtl::OUString m_sBindingUrl;
rtl::OUString m_sRepositoryId;
rtl::OUString m_sPath;
+ rtl::OUString m_sId;
rtl::OUString m_sUser;
rtl::OUString m_sPass;
@@ -50,6 +51,7 @@ namespace cmis
std::map< int, std::string > getSessionParams( );
rtl::OUString& getObjectPath( );
+ rtl::OUString& getObjectId( );
rtl::OUString& getBindingUrl( );
rtl::OUString& getRepositoryId( );
void setObjectPath( rtl::OUString sPath );
More information about the Libreoffice-commits
mailing list