summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorCao Cuong Ngo <cao.cuong.ngo@gmail.com>2013-08-02 15:04:40 +0200
committerCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2013-09-02 13:51:54 +0200
commitff8b445dc003ea9da8d7040030250e7f08ff2fde (patch)
tree13bcd29d490b9052c1e235b92c10eeb36a492fff /ucb
parentf6c006397896ae8b431a0ab85c89ab677d6ab981 (diff)
CMIS: add document ID when saving.
The document ID is needed in case the get object by path of the CMIS document doesn't work (like Google Drive) Change-Id: I151d5433a19caeaf4a542b69cd9e95dde58722e7
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/core/ucbcmds.cxx4
-rw-r--r--ucb/source/ucp/cmis/cmis_content.cxx78
2 files changed, 64 insertions, 18 deletions
diff --git a/ucb/source/core/ucbcmds.cxx b/ucb/source/core/ucbcmds.cxx
index 8702ac6bf52b..87a677305c37 100644
--- a/ucb/source/core/ucbcmds.cxx
+++ b/ucb/source/core/ucbcmds.cxx
@@ -1364,6 +1364,7 @@ void globalTransfer_(
ucb::InsertCommandArgument2 aArg;
aArg.Data = xInputStream;
aArg.MimeType = rContext.aArg.MimeType;
+ aArg.DocumentId = rContext.aArg.DocumentId;
switch ( rContext.aArg.NameClash )
{
@@ -1614,7 +1615,8 @@ void globalTransfer_(
->getContentIdentifier(), // TargetURL
OUString(), // NewTitle;
rContext.aArg.NameClash,
- rContext.aArg.MimeType );
+ rContext.aArg.MimeType,
+ rContext.aArg.DocumentId);
TransferCommandContext aSubCtx(
rContext.m_xContext,
diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx
index f9a5a9a46f53..2d687ea73b04 100644
--- a/ucb/source/ucp/cmis/cmis_content.cxx
+++ b/ucb/source/ucp/cmis/cmis_content.cxx
@@ -601,6 +601,32 @@ namespace cmis
else
xRow->appendVoid( rProp );
}
+ else if ( rProp.Name == "ObjectId" )
+ {
+ OUString sId;
+ try
+ {
+ sId = STD_TO_OUSTR( getObject( xEnv )->getId() );
+ }
+ catch ( const libcmis::Exception& )
+ {
+ if ( !m_pObjectProps.empty() )
+ {
+ map< string, libcmis::PropertyPtr >::iterator it = m_pObjectProps.find( "cmis:objectId" );
+ if ( it != m_pObjectProps.end( ) )
+ {
+ vector< string > values = it->second->getStrings( );
+ if ( !values.empty() )
+ sId = STD_TO_OUSTR( values.front( ) );
+ }
+ }
+ }
+
+ if ( !sId.isEmpty( ) )
+ xRow->appendString( rProp, sId );
+ else
+ xRow->appendVoid( rProp );
+ }
else if ( rProp.Name == "TitleOnServer" )
{
string path;
@@ -1121,29 +1147,42 @@ namespace cmis
if ( pFolder != NULL )
{
- map< string, libcmis::PropertyPtr >::iterator it = m_pObjectProps.find( "cmis:name" );
- if ( it == m_pObjectProps.end( ) )
+ libcmis::ObjectPtr object;
+ string newPath;
+ if ( m_sObjectId.isEmpty( ) )
{
- ucbhelper::cancelCommandExecution( uno::makeAny
- ( uno::RuntimeException( "Missing name property",
- static_cast< cppu::OWeakObject * >( this ) ) ),
- xEnv );
- }
- string newName = it->second->getStrings( ).front( );
- string newPath = pFolder->getPath( );
- if ( newPath[ newPath.size( ) - 1 ] != '/' )
- newPath += "/";
- newPath += newName;
+ map< string, libcmis::PropertyPtr >::iterator it = m_pObjectProps.find( "cmis:name" );
+ if ( it == m_pObjectProps.end( ) )
+ {
+ ucbhelper::cancelCommandExecution( uno::makeAny
+ ( uno::RuntimeException( "Missing name property",
+ static_cast< cppu::OWeakObject * >( this ) ) ),
+ xEnv );
+ }
+ string newName = it->second->getStrings( ).front( );
+ newPath = pFolder->getPath( );
+ if ( newPath[ newPath.size( ) - 1 ] != '/' )
+ newPath += "/";
+ newPath += newName;
- libcmis::ObjectPtr object;
+ try
+ {
+ object = getSession( xEnv )->getObjectByPath( newPath );
+ sNewPath = STD_TO_OUSTR( newPath );
+ }
+ catch ( const libcmis::Exception& )
+ {
+ // Nothing matched the path
+ }
+ }
+ else
try
{
- object = getSession( xEnv )->getObjectByPath( newPath );
- sNewPath = STD_TO_OUSTR( newPath );
+ object = getSession( xEnv )->getObject( OUSTR_TO_STDSTR( m_sObjectId) );
}
- catch ( const libcmis::Exception& )
+ catch ( libcmis::Exception& )
{
- // Nothing matched the path
+ // Continue
}
if ( NULL != object.get( ) )
@@ -1401,6 +1440,9 @@ namespace cmis
beans::Property( OUString( "Title" ),
-1, getCppuType( static_cast< const OUString * >( 0 ) ),
beans::PropertyAttribute::BOUND ),
+ beans::Property( OUString( "ObjectId" ),
+ -1, getCppuType( static_cast< const OUString * >( 0 ) ),
+ beans::PropertyAttribute::BOUND ),
beans::Property( OUString( "TitleOnServer" ),
-1, getCppuType( static_cast< const OUString * >( 0 ) ),
beans::PropertyAttribute::BOUND ),
@@ -1648,6 +1690,8 @@ namespace cmis
arg.Data = insertArg.Data;
arg.ReplaceExisting = insertArg.ReplaceExisting;
}
+ // store the document id
+ m_sObjectId = arg.DocumentId;
insert( arg.Data, arg.ReplaceExisting, arg.MimeType, xEnv );
}
else if ( aCommand.Name == "delete" )