Kaydet (Commit) b378e754 authored tarafından Cao Cuong Ngo's avatar Cao Cuong Ngo Kaydeden (comit) Cédric Bosdonnat

CMIS: fix file saving issue

Change-Id: I60cccb841fea5ce493f004c73ecf50468019f860
üst 19b76cc2
...@@ -484,7 +484,10 @@ sal_Bool MediaDescriptor::impl_addInputStream( sal_Bool bLockFile ) ...@@ -484,7 +484,10 @@ sal_Bool MediaDescriptor::impl_addInputStream( sal_Bool bLockFile )
throw css::uno::Exception("Found no URL.", throw css::uno::Exception("Found no URL.",
css::uno::Reference< css::uno::XInterface >()); css::uno::Reference< css::uno::XInterface >());
return impl_openStreamWithURL( removeFragment(sURL), bLockFile ); // Parse URL! Only the main part has to be used further. E.g. a jumpmark can make trouble
// We need to keep the full URL with Mark to store the Object ID
// in CMIS UCB
return impl_openStreamWithURL( sURL, bLockFile );
} }
catch(const css::uno::Exception& ex) catch(const css::uno::Exception& ex)
{ {
......
...@@ -2479,7 +2479,7 @@ void SfxMedium::Init_Impl() ...@@ -2479,7 +2479,7 @@ void SfxMedium::Init_Impl()
{ {
if ( aUrl.HasMark() ) if ( aUrl.HasMark() )
{ {
pImp->m_aLogicName = aUrl.GetURLNoMark( INetURLObject::NO_DECODE ); // keep the Mark to store the Document ID
GetItemSet()->Put( SfxStringItem( SID_JUMPMARK, aUrl.GetMark() ) ); GetItemSet()->Put( SfxStringItem( SID_JUMPMARK, aUrl.GetMark() ) );
} }
...@@ -2994,8 +2994,7 @@ const INetURLObject& SfxMedium::GetURLObject() const ...@@ -2994,8 +2994,7 @@ const INetURLObject& SfxMedium::GetURLObject() const
if (!pImp->m_pURLObj) if (!pImp->m_pURLObj)
{ {
pImp->m_pURLObj = new INetURLObject( pImp->m_aLogicName ); pImp->m_pURLObj = new INetURLObject( pImp->m_aLogicName );
if (pImp->m_pURLObj->HasMark()) // keep the Mark to store the Document ID
*pImp->m_pURLObj = INetURLObject( pImp->m_aLogicName ).GetURLNoMark();
} }
return *pImp->m_pURLObj; return *pImp->m_pURLObj;
......
...@@ -412,7 +412,18 @@ namespace cmis ...@@ -412,7 +412,18 @@ namespace cmis
{ {
if ( !m_pObject.get() ) if ( !m_pObject.get() )
{ {
if ( !m_sObjectPath.isEmpty( ) ) if ( !m_sObjectId.isEmpty( ) )
{
try
{
m_pObject = getSession( xEnv )->getObject( OUSTR_TO_STDSTR( m_sObjectId ) );
}
catch ( const libcmis::Exception& )
{
throw libcmis::Exception( "Object not found" );
}
}
else if ( !m_sObjectPath.isEmpty( ) )
{ {
try try
{ {
...@@ -435,7 +446,7 @@ namespace cmis ...@@ -435,7 +446,7 @@ namespace cmis
{ {
vector< libcmis::ObjectPtr > children = pParentFolder->getChildren( ); vector< libcmis::ObjectPtr > children = pParentFolder->getChildren( );
for ( vector< libcmis::ObjectPtr >::iterator it = children.begin( ); for ( vector< libcmis::ObjectPtr >::iterator it = children.begin( );
it != children.end() && !m_pObject; ++it ) it != children.end() && !m_pObject; ++it )
{ {
if ( ( *it )->getName( ) == sName ) if ( ( *it )->getName( ) == sName )
m_pObject = *it; m_pObject = *it;
...@@ -446,8 +457,6 @@ namespace cmis ...@@ -446,8 +457,6 @@ namespace cmis
throw libcmis::Exception( "Object not found" ); throw libcmis::Exception( "Object not found" );
} }
} }
else if (!m_sObjectId.isEmpty( ) )
m_pObject = getSession( xEnv )->getObject( OUSTR_TO_STDSTR( m_sObjectId ) );
else else
{ {
m_pObject = getSession( xEnv )->getRootFolder( ); m_pObject = getSession( xEnv )->getRootFolder( );
...@@ -464,7 +473,9 @@ namespace cmis ...@@ -464,7 +473,9 @@ namespace cmis
bool bIsFolder = false; bool bIsFolder = false;
try try
{ {
bIsFolder = getObject( xEnv )->getBaseType( ) == "cmis:folder"; libcmis::ObjectPtr obj = getObject( xEnv );
if ( obj )
bIsFolder = obj->getBaseType( ) == "cmis:folder";
} }
catch ( const libcmis::Exception& e ) catch ( const libcmis::Exception& e )
{ {
...@@ -536,7 +547,9 @@ namespace cmis ...@@ -536,7 +547,9 @@ namespace cmis
{ {
try try
{ {
xRow->appendBoolean( rProp, getObject( xEnv )->getBaseType( ) == "cmis:document" ); libcmis::ObjectPtr obj = getObject( xEnv );
if ( obj )
xRow->appendBoolean( rProp, obj->getBaseType( ) == "cmis:document" );
} }
catch ( const libcmis::Exception& ) catch ( const libcmis::Exception& )
{ {
...@@ -550,7 +563,11 @@ namespace cmis ...@@ -550,7 +563,11 @@ namespace cmis
{ {
try try
{ {
xRow->appendBoolean( rProp, getObject( xEnv )->getBaseType( ) == "cmis:folder" ); libcmis::ObjectPtr obj = getObject( xEnv );
if ( obj )
xRow->appendBoolean( rProp, obj->getBaseType( ) == "cmis:folder" );
else
xRow->appendBoolean( rProp, sal_False );
} }
catch ( const libcmis::Exception& ) catch ( const libcmis::Exception& )
{ {
...@@ -630,20 +647,7 @@ namespace cmis ...@@ -630,20 +647,7 @@ namespace cmis
else if ( rProp.Name == "TitleOnServer" ) else if ( rProp.Name == "TitleOnServer" )
{ {
string path; string path;
try xRow->appendString( rProp, m_sObjectPath);
{
vector< string > paths = getObject( xEnv )->getPaths( );
if ( !paths.empty( ) )
path = paths.front( );
else
path = getObject( xEnv )->getName( );
xRow->appendString( rProp, STD_TO_OUSTR( path ) );
}
catch ( const libcmis::Exception& )
{
xRow->appendVoid( rProp );
}
} }
else if ( rProp.Name == "IsReadOnly" ) else if ( rProp.Name == "IsReadOnly" )
{ {
...@@ -1151,41 +1155,30 @@ namespace cmis ...@@ -1151,41 +1155,30 @@ namespace cmis
if ( pFolder != NULL ) if ( pFolder != NULL )
{ {
libcmis::ObjectPtr object; libcmis::ObjectPtr object;
string newPath; map< string, libcmis::PropertyPtr >::iterator it = m_pObjectProps.find( "cmis:name" );
if ( m_sObjectId.isEmpty( ) ) if ( it == m_pObjectProps.end( ) )
{ {
map< string, libcmis::PropertyPtr >::iterator it = m_pObjectProps.find( "cmis:name" ); ucbhelper::cancelCommandExecution( uno::makeAny
if ( it == m_pObjectProps.end( ) ) ( uno::RuntimeException( "Missing name property",
{ static_cast< cppu::OWeakObject * >( this ) ) ),
ucbhelper::cancelCommandExecution( uno::makeAny xEnv );
( 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 string newName = it->second->getStrings( ).front( );
string newPath = OUSTR_TO_STDSTR( m_sObjectPath );
if ( !newPath.empty( ) && newPath[ newPath.size( ) - 1 ] != '/' )
newPath += "/";
newPath += newName;
try try
{ {
object = getSession( xEnv )->getObject( OUSTR_TO_STDSTR( m_sObjectId) ); if ( !m_sObjectId.isEmpty( ) )
object = getSession( xEnv )->getObject( OUSTR_TO_STDSTR( m_sObjectId) );
else
object = getSession( xEnv )->getObjectByPath( newPath );
sNewPath = STD_TO_OUSTR( newPath );
} }
catch ( libcmis::Exception& ) catch ( const libcmis::Exception& )
{ {
// Continue // Nothing matched the path
} }
if ( NULL != object.get( ) ) if ( NULL != object.get( ) )
...@@ -1272,7 +1265,8 @@ namespace cmis ...@@ -1272,7 +1265,8 @@ namespace cmis
m_pObjectType.reset( ); m_pObjectType.reset( );
m_pObjectProps.clear( ); m_pObjectProps.clear( );
m_bTransient = false; m_bTransient = false;
uno::Reference< ucb::XContentIdentifier > xId(new ::ucbhelper::ContentIdentifier(m_sURL));
m_xIdentifier = xId;
inserted(); inserted();
} }
} }
...@@ -1545,54 +1539,18 @@ namespace cmis ...@@ -1545,54 +1539,18 @@ namespace cmis
OUString sRet; OUString sRet;
SAL_INFO( "cmisucp", "Content::getParentURL()" ); SAL_INFO( "cmisucp", "Content::getParentURL()" );
OUString parentUrl = OUString( "/" );
string parentPath; if ( m_sObjectPath == "/" )
try return parentUrl;
{
libcmis::ObjectPtr pObj = getObject( uno::Reference< ucb::XCommandEnvironment >() );
libcmis::Document* document = dynamic_cast< libcmis::Document* >( pObj.get( ) );
if ( NULL != document )
{
vector< boost::shared_ptr< libcmis::Folder > > parents = document->getParents( );
if ( !parents.empty( ) )
parentPath = parents.front( )->getPath( );
}
else
{
libcmis::Folder* folder = dynamic_cast< libcmis::Folder* >( pObj.get( ) );
if ( NULL != folder )
{
libcmis::FolderPtr parentFolder = folder->getFolderParent( );
if ( NULL != parentFolder )
parentPath = parentFolder->getPath( );
}
}
}
catch ( const libcmis::Exception & )
{
// We may have an exception if we don't have the rights to
// get the parents
}
if ( !parentPath.empty() )
{
URL aUrl( m_sURL );
aUrl.setObjectPath( STD_TO_OUSTR( parentPath ) );
sRet = aUrl.asString( );
}
else else
{ {
INetURLObject aUrl( m_sURL ); INetURLObject aParentUrl( m_sURL );
if ( aUrl.getSegmentCount( ) > 0 ) string sName = OUSTR_TO_STDSTR( aParentUrl.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ) );
{ aParentUrl.removeSegment( );
URL aCmisUrl( m_sURL ); return aParentUrl.GetMainURL( INetURLObject::NO_DECODE );
aUrl.removeSegment( );
aCmisUrl.setObjectPath( aUrl.GetURLPath( INetURLObject::DECODE_WITH_CHARSET ) );
sRet = aCmisUrl.asString( );
}
} }
return sRet; return parentUrl;
} }
XTYPEPROVIDER_COMMON_IMPL( Content ); XTYPEPROVIDER_COMMON_IMPL( Content );
......
...@@ -35,8 +35,8 @@ namespace cmis ...@@ -35,8 +35,8 @@ namespace cmis
m_sPath = aUrl.GetURLPath( INetURLObject::DECODE_WITH_CHARSET ); m_sPath = aUrl.GetURLPath( INetURLObject::DECODE_WITH_CHARSET );
m_sId = aUrl.GetMark( INetURLObject::DECODE_WITH_CHARSET ); m_sId = aUrl.GetMark( INetURLObject::DECODE_WITH_CHARSET );
if ( !m_sId.isEmpty( ) ) if ( m_sPath == "/" && m_sBindingUrl.indexOf( "google" ) != -1 )
m_sPath = OUString( ); m_sId = "root";
} }
OUString& URL::getObjectPath( ) OUString& URL::getObjectPath( )
...@@ -103,7 +103,7 @@ namespace cmis ...@@ -103,7 +103,7 @@ namespace cmis
while ( nPos != -1 ); while ( nPos != -1 );
sUrl += sEncodedPath; sUrl += sEncodedPath;
} }
else if ( !m_sId.isEmpty( ) ) if ( !m_sId.isEmpty( ) )
{ {
sUrl += "#" + rtl::Uri::encode( m_sId, sUrl += "#" + rtl::Uri::encode( m_sId,
rtl_UriCharClassRelSegment, rtl_UriCharClassRelSegment,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment