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
This commit is contained in:
parent
f6c0063978
commit
ff8b445dc0
@ -670,6 +670,7 @@ public:
|
|||||||
* @param rCommentVersion contains the comment to use for checkin operations
|
* @param rCommentVersion contains the comment to use for checkin operations
|
||||||
* @param rResultURL is a hacky way to get the update URL after the operation in
|
* @param rResultURL is a hacky way to get the update URL after the operation in
|
||||||
* case there was a change (introduced for the checkin operation)
|
* case there was a change (introduced for the checkin operation)
|
||||||
|
* @param rDocumentId is the document Id ( in case of CMIS ).
|
||||||
*/
|
*/
|
||||||
sal_Bool
|
sal_Bool
|
||||||
transferContent( const Content& rSourceContent,
|
transferContent( const Content& rSourceContent,
|
||||||
@ -679,7 +680,8 @@ public:
|
|||||||
const OUString & rMimeType = OUString( ),
|
const OUString & rMimeType = OUString( ),
|
||||||
bool bMajorVersion = false,
|
bool bMajorVersion = false,
|
||||||
const OUString & rCommentVersion = OUString( ),
|
const OUString & rCommentVersion = OUString( ),
|
||||||
OUString* pResultURL = NULL )
|
OUString* pResultURL = NULL,
|
||||||
|
const OUString & rDocumentId = OUString( ) )
|
||||||
throw( ::com::sun::star::ucb::CommandAbortedException,
|
throw( ::com::sun::star::ucb::CommandAbortedException,
|
||||||
::com::sun::star::uno::RuntimeException,
|
::com::sun::star::uno::RuntimeException,
|
||||||
::com::sun::star::uno::Exception );
|
::com::sun::star::uno::Exception );
|
||||||
|
@ -15,13 +15,17 @@
|
|||||||
module com { module sun { module star { module ucb {
|
module com { module sun { module star { module ucb {
|
||||||
|
|
||||||
/** This struct extends the one for transfers arguments by adding a Mime
|
/** This struct extends the one for transfers arguments by adding a Mime
|
||||||
type property to it.
|
type and a Document Id property to it.
|
||||||
*/
|
*/
|
||||||
struct GlobalTransferCommandArgument2 : GlobalTransferCommandArgument
|
struct GlobalTransferCommandArgument2 : GlobalTransferCommandArgument
|
||||||
{
|
{
|
||||||
/** contains the MIME type of the source object.
|
/** contains the MIME type of the source object.
|
||||||
*/
|
*/
|
||||||
string MimeType;
|
string MimeType;
|
||||||
|
|
||||||
|
/** contains the DocumentId of the source object.
|
||||||
|
*/
|
||||||
|
string DocumentId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,6 +21,11 @@ struct InsertCommandArgument2 : InsertCommandArgument
|
|||||||
/** contains the MIME type of the document to insert
|
/** contains the MIME type of the document to insert
|
||||||
*/
|
*/
|
||||||
string MimeType;
|
string MimeType;
|
||||||
|
|
||||||
|
/** contains the Document Id of the document to insert
|
||||||
|
*/
|
||||||
|
string DocumentId;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1960,6 +1960,9 @@ void SfxMedium::Transfer_Impl()
|
|||||||
OUString aFileName;
|
OUString aFileName;
|
||||||
Any aAny = aDestContent.getPropertyValue("Title");
|
Any aAny = aDestContent.getPropertyValue("Title");
|
||||||
aAny >>= aFileName;
|
aAny >>= aFileName;
|
||||||
|
aAny = aDestContent.getPropertyValue( OUString("ObjectId" ) );
|
||||||
|
OUString sObjectId;
|
||||||
|
aAny >>= sObjectId;
|
||||||
if ( aFileName.isEmpty() )
|
if ( aFileName.isEmpty() )
|
||||||
aFileName = GetURLObject().getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
|
aFileName = GetURLObject().getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
|
||||||
|
|
||||||
@ -2024,7 +2027,7 @@ void SfxMedium::Transfer_Impl()
|
|||||||
}
|
}
|
||||||
OUString sResultURL;
|
OUString sResultURL;
|
||||||
if (!aTransferContent.transferContent( aSourceContent, eOperation,
|
if (!aTransferContent.transferContent( aSourceContent, eOperation,
|
||||||
aFileName, nNameClash, aMimeType, bMajor, sComment, &sResultURL ))
|
aFileName, nNameClash, aMimeType, bMajor, sComment, &sResultURL, sObjectId))
|
||||||
pImp->m_eError = ERRCODE_IO_GENERAL;
|
pImp->m_eError = ERRCODE_IO_GENERAL;
|
||||||
else if ( !sResultURL.isEmpty( ) ) // Likely to happen only for checkin
|
else if ( !sResultURL.isEmpty( ) ) // Likely to happen only for checkin
|
||||||
SwitchDocumentToFile( sResultURL );
|
SwitchDocumentToFile( sResultURL );
|
||||||
|
@ -1364,6 +1364,7 @@ void globalTransfer_(
|
|||||||
ucb::InsertCommandArgument2 aArg;
|
ucb::InsertCommandArgument2 aArg;
|
||||||
aArg.Data = xInputStream;
|
aArg.Data = xInputStream;
|
||||||
aArg.MimeType = rContext.aArg.MimeType;
|
aArg.MimeType = rContext.aArg.MimeType;
|
||||||
|
aArg.DocumentId = rContext.aArg.DocumentId;
|
||||||
|
|
||||||
switch ( rContext.aArg.NameClash )
|
switch ( rContext.aArg.NameClash )
|
||||||
{
|
{
|
||||||
@ -1614,7 +1615,8 @@ void globalTransfer_(
|
|||||||
->getContentIdentifier(), // TargetURL
|
->getContentIdentifier(), // TargetURL
|
||||||
OUString(), // NewTitle;
|
OUString(), // NewTitle;
|
||||||
rContext.aArg.NameClash,
|
rContext.aArg.NameClash,
|
||||||
rContext.aArg.MimeType );
|
rContext.aArg.MimeType,
|
||||||
|
rContext.aArg.DocumentId);
|
||||||
|
|
||||||
TransferCommandContext aSubCtx(
|
TransferCommandContext aSubCtx(
|
||||||
rContext.m_xContext,
|
rContext.m_xContext,
|
||||||
|
@ -601,6 +601,32 @@ namespace cmis
|
|||||||
else
|
else
|
||||||
xRow->appendVoid( rProp );
|
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" )
|
else if ( rProp.Name == "TitleOnServer" )
|
||||||
{
|
{
|
||||||
string path;
|
string path;
|
||||||
@ -1121,29 +1147,42 @@ namespace cmis
|
|||||||
|
|
||||||
if ( pFolder != NULL )
|
if ( pFolder != NULL )
|
||||||
{
|
{
|
||||||
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( );
|
|
||||||
string newPath = pFolder->getPath( );
|
|
||||||
if ( newPath[ newPath.size( ) - 1 ] != '/' )
|
|
||||||
newPath += "/";
|
|
||||||
newPath += newName;
|
|
||||||
|
|
||||||
libcmis::ObjectPtr object;
|
libcmis::ObjectPtr object;
|
||||||
|
string newPath;
|
||||||
|
if ( m_sObjectId.isEmpty( ) )
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
object = getSession( xEnv )->getObjectByPath( newPath );
|
||||||
|
sNewPath = STD_TO_OUSTR( newPath );
|
||||||
|
}
|
||||||
|
catch ( const libcmis::Exception& )
|
||||||
|
{
|
||||||
|
// Nothing matched the path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
object = getSession( xEnv )->getObjectByPath( newPath );
|
object = getSession( xEnv )->getObject( OUSTR_TO_STDSTR( m_sObjectId) );
|
||||||
sNewPath = STD_TO_OUSTR( newPath );
|
|
||||||
}
|
}
|
||||||
catch ( const libcmis::Exception& )
|
catch ( libcmis::Exception& )
|
||||||
{
|
{
|
||||||
// Nothing matched the path
|
// Continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( NULL != object.get( ) )
|
if ( NULL != object.get( ) )
|
||||||
@ -1401,6 +1440,9 @@ namespace cmis
|
|||||||
beans::Property( OUString( "Title" ),
|
beans::Property( OUString( "Title" ),
|
||||||
-1, getCppuType( static_cast< const OUString * >( 0 ) ),
|
-1, getCppuType( static_cast< const OUString * >( 0 ) ),
|
||||||
beans::PropertyAttribute::BOUND ),
|
beans::PropertyAttribute::BOUND ),
|
||||||
|
beans::Property( OUString( "ObjectId" ),
|
||||||
|
-1, getCppuType( static_cast< const OUString * >( 0 ) ),
|
||||||
|
beans::PropertyAttribute::BOUND ),
|
||||||
beans::Property( OUString( "TitleOnServer" ),
|
beans::Property( OUString( "TitleOnServer" ),
|
||||||
-1, getCppuType( static_cast< const OUString * >( 0 ) ),
|
-1, getCppuType( static_cast< const OUString * >( 0 ) ),
|
||||||
beans::PropertyAttribute::BOUND ),
|
beans::PropertyAttribute::BOUND ),
|
||||||
@ -1648,6 +1690,8 @@ namespace cmis
|
|||||||
arg.Data = insertArg.Data;
|
arg.Data = insertArg.Data;
|
||||||
arg.ReplaceExisting = insertArg.ReplaceExisting;
|
arg.ReplaceExisting = insertArg.ReplaceExisting;
|
||||||
}
|
}
|
||||||
|
// store the document id
|
||||||
|
m_sObjectId = arg.DocumentId;
|
||||||
insert( arg.Data, arg.ReplaceExisting, arg.MimeType, xEnv );
|
insert( arg.Data, arg.ReplaceExisting, arg.MimeType, xEnv );
|
||||||
}
|
}
|
||||||
else if ( aCommand.Name == "delete" )
|
else if ( aCommand.Name == "delete" )
|
||||||
|
@ -962,7 +962,8 @@ sal_Bool Content::transferContent( const Content& rSourceContent,
|
|||||||
const OUString & rMimeType,
|
const OUString & rMimeType,
|
||||||
bool bMajorVersion,
|
bool bMajorVersion,
|
||||||
const OUString & rVersionComment,
|
const OUString & rVersionComment,
|
||||||
OUString* pResultURL )
|
OUString* pResultURL,
|
||||||
|
const OUString & rDocumentId )
|
||||||
throw( CommandAbortedException, RuntimeException, Exception )
|
throw( CommandAbortedException, RuntimeException, Exception )
|
||||||
{
|
{
|
||||||
Reference< XUniversalContentBroker > pBroker(
|
Reference< XUniversalContentBroker > pBroker(
|
||||||
@ -1015,7 +1016,8 @@ sal_Bool Content::transferContent( const Content& rSourceContent,
|
|||||||
getURL(), // TargetFolderURL,
|
getURL(), // TargetFolderURL,
|
||||||
rTitle,
|
rTitle,
|
||||||
nNameClashAction,
|
nNameClashAction,
|
||||||
rMimeType );
|
rMimeType,
|
||||||
|
rDocumentId );
|
||||||
aCommand.Argument <<= aTransferArg;
|
aCommand.Argument <<= aTransferArg;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user