Kaydet (Commit) 11066aca authored tarafından Cédric Bosdonnat's avatar Cédric Bosdonnat

cmisucp: catch the exception when getting CMIS object

Fixes crashers like the one when cancelling authentication request.
The error message are still not meaningful for the user, but this would
require libcmis API changes.

Change-Id: I22afbf4d39522a2b0dbd043a68dfef2b9308dcec
üst ddefa2de
...@@ -209,9 +209,7 @@ namespace cmis ...@@ -209,9 +209,7 @@ namespace cmis
{ {
} }
libcmis::ObjectPtr Content::getObject( ) libcmis::ObjectPtr Content::getObject( ) throw ( libcmis::Exception )
{
try
{ {
if ( !m_pObject.get() ) if ( !m_pObject.get() )
{ {
...@@ -223,11 +221,6 @@ namespace cmis ...@@ -223,11 +221,6 @@ namespace cmis
m_sObjectPath = "/"; m_sObjectPath = "/";
} }
} }
}
catch ( const libcmis::Exception& e )
{
SAL_INFO( "cmisucp", "Unexpected exception: " << e.what() );
}
return m_pObject; return m_pObject;
} }
...@@ -239,9 +232,22 @@ namespace cmis ...@@ -239,9 +232,22 @@ namespace cmis
} }
bool Content::isFolder(const uno::Reference< ucb::XCommandEnvironment >& xEnv ) bool Content::isFolder(const uno::Reference< ucb::XCommandEnvironment >& xEnv )
{
bool bIsFolder = false;
try
{ {
resetAuthProvider( xEnv ); resetAuthProvider( xEnv );
return getObject( )->getBaseType( ) == "cmis:folder"; bIsFolder = getObject( )->getBaseType( ) == "cmis:folder";
}
catch ( const libcmis::Exception& e )
{
ucbhelper::cancelCommandExecution(
ucb::IOErrorCode_GENERAL,
uno::Sequence< uno::Any >( 0 ),
xEnv,
rtl::OUString::createFromAscii( e.what() ) );
}
return bIsFolder;
} }
uno::Any Content::getBadArgExcept() uno::Any Content::getBadArgExcept()
...@@ -266,6 +272,8 @@ namespace cmis ...@@ -266,6 +272,8 @@ namespace cmis
pProps = rProperties.getConstArray(); pProps = rProperties.getConstArray();
for( sal_Int32 n = 0; n < nProps; ++n ) for( sal_Int32 n = 0; n < nProps; ++n )
{
try
{ {
const beans::Property& rProp = pProps[ n ]; const beans::Property& rProp = pProps[ n ];
...@@ -373,6 +381,15 @@ namespace cmis ...@@ -373,6 +381,15 @@ namespace cmis
else else
SAL_INFO( "cmisucp", "Looking for unsupported property " << rProp.Name ); SAL_INFO( "cmisucp", "Looking for unsupported property " << rProp.Name );
} }
catch ( const libcmis::Exception& e )
{
ucbhelper::cancelCommandExecution(
ucb::IOErrorCode_GENERAL,
uno::Sequence< uno::Any >( 0 ),
xEnv,
rtl::OUString::createFromAscii( e.what() ) );
}
}
return uno::Reference< sdbc::XRow >( xRow.get() ); return uno::Reference< sdbc::XRow >( xRow.get() );
} }
...@@ -504,15 +521,21 @@ namespace cmis ...@@ -504,15 +521,21 @@ namespace cmis
xEnv ); xEnv );
} }
try
{
// For transient content, the URL is the one of the parent // For transient content, the URL is the one of the parent
if ( m_bTransient ) if ( m_bTransient )
{ {
rtl::OUString sNewPath; rtl::OUString sNewPath;
// Try to get the object from the server if there is any // Try to get the object from the server if there is any
libcmis::Folder* pFolder = dynamic_cast< libcmis::Folder* >( getObject( ).get( ) ); libcmis::Folder* pFolder = NULL;
try
{
pFolder = dynamic_cast< libcmis::Folder* >( getObject( ).get( ) );
}
catch ( const libcmis::Exception& )
{
}
if ( pFolder != NULL ) if ( pFolder != NULL )
{ {
map< string, libcmis::PropertyPtr >::iterator it = m_pObjectProps.find( "cmis:name" ); map< string, libcmis::PropertyPtr >::iterator it = m_pObjectProps.find( "cmis:name" );
...@@ -599,11 +622,6 @@ namespace cmis ...@@ -599,11 +622,6 @@ namespace cmis
} }
} }
} }
catch ( const libcmis::Exception& e )
{
throw uno::Exception( rtl::OUString::createFromAscii( e.what( ) ), *this );
}
}
const int TRANSFER_BUFFER_SIZE = 65536; const int TRANSFER_BUFFER_SIZE = 65536;
...@@ -621,7 +639,9 @@ namespace cmis ...@@ -621,7 +639,9 @@ namespace cmis
uno::Sequence< uno::Any > Content::setPropertyValues( uno::Sequence< uno::Any > Content::setPropertyValues(
const uno::Sequence< beans::PropertyValue >& rValues, const uno::Sequence< beans::PropertyValue >& rValues,
const uno::Reference< ucb::XCommandEnvironment >& ) const uno::Reference< ucb::XCommandEnvironment >& xEnv )
{
try
{ {
// Get the already set properties if possible // Get the already set properties if possible
if ( !m_bTransient && getObject( ).get( ) ) if ( !m_bTransient && getObject( ).get( ) )
...@@ -629,6 +649,15 @@ namespace cmis ...@@ -629,6 +649,15 @@ namespace cmis
m_pObjectProps = getObject()->getProperties( ); m_pObjectProps = getObject()->getProperties( );
m_pObjectType = getObject()->getTypeDescription(); m_pObjectType = getObject()->getTypeDescription();
} }
}
catch ( const libcmis::Exception& e )
{
ucbhelper::cancelCommandExecution(
ucb::IOErrorCode_GENERAL,
uno::Sequence< uno::Any >( 0 ),
xEnv,
rtl::OUString::createFromAscii( e.what() ) );
}
sal_Int32 nCount = rValues.getLength(); sal_Int32 nCount = rValues.getLength();
uno::Sequence< uno::Any > aRet( nCount ); uno::Sequence< uno::Any > aRet( nCount );
...@@ -681,16 +710,27 @@ namespace cmis ...@@ -681,16 +710,27 @@ namespace cmis
} }
} }
try
{
if ( !m_bTransient && bChanged ) if ( !m_bTransient && bChanged )
{ {
getObject()->updateProperties(); getObject()->updateProperties();
} }
}
catch ( const libcmis::Exception& e )
{
ucbhelper::cancelCommandExecution(
ucb::IOErrorCode_GENERAL,
uno::Sequence< uno::Any >( 0 ),
xEnv,
rtl::OUString::createFromAscii( e.what() ) );
}
return aRet; return aRet;
} }
sal_Bool Content::feedSink( uno::Reference< uno::XInterface> xSink, sal_Bool Content::feedSink( uno::Reference< uno::XInterface> xSink,
const uno::Reference< ucb::XCommandEnvironment >& /*xEnv*/ ) const uno::Reference< ucb::XCommandEnvironment >& xEnv )
{ {
if ( !xSink.is() ) if ( !xSink.is() )
return sal_False; return sal_False;
...@@ -705,6 +745,8 @@ namespace cmis ...@@ -705,6 +745,8 @@ namespace cmis
if ( xDataStreamer.is() && !xOut.is() ) if ( xDataStreamer.is() && !xOut.is() )
xOut = xDataStreamer->getStream()->getOutputStream(); xOut = xDataStreamer->getStream()->getOutputStream();
try
{
libcmis::Document* document = dynamic_cast< libcmis::Document* >( getObject().get() ); libcmis::Document* document = dynamic_cast< libcmis::Document* >( getObject().get() );
boost::shared_ptr< istream > aIn = document->getContentStream( ); boost::shared_ptr< istream > aIn = document->getContentStream( );
...@@ -716,6 +758,15 @@ namespace cmis ...@@ -716,6 +758,15 @@ namespace cmis
xDataSink->setInputStream( xIn ); xDataSink->setInputStream( xIn );
else if ( xOut.is() ) else if ( xOut.is() )
copyData( xIn, xOut ); copyData( xIn, xOut );
}
catch ( const libcmis::Exception& e )
{
ucbhelper::cancelCommandExecution(
ucb::IOErrorCode_GENERAL,
uno::Sequence< uno::Any >( 0 ),
xEnv,
rtl::OUString::createFromAscii( e.what() ) );
}
return sal_True; return sal_True;
} }
...@@ -814,7 +865,7 @@ namespace cmis ...@@ -814,7 +865,7 @@ namespace cmis
return uno::Sequence< ucb::CommandInfo >(aCommandInfoTable, isFolder(xEnv) ? nProps : nProps - 2); return uno::Sequence< ucb::CommandInfo >(aCommandInfoTable, isFolder(xEnv) ? nProps : nProps - 2);
} }
::rtl::OUString Content::getParentURL() ::rtl::OUString Content::getParentURL( )
{ {
rtl::OUString sRet; rtl::OUString sRet;
...@@ -966,10 +1017,11 @@ namespace cmis ...@@ -966,10 +1017,11 @@ namespace cmis
} }
catch ( const libcmis::Exception& e ) catch ( const libcmis::Exception& e )
{ {
ucbhelper::cancelCommandExecution( uno::makeAny ucbhelper::cancelCommandExecution(
( uno::RuntimeException( rtl::OUString::createFromAscii( e.what() ), ucb::IOErrorCode_GENERAL,
static_cast< cppu::OWeakObject * >( this ) ) ), uno::Sequence< uno::Any >( 0 ),
xEnv ); xEnv,
rtl::OUString::createFromAscii( e.what() ) );
} }
} }
else else
......
...@@ -188,7 +188,7 @@ public: ...@@ -188,7 +188,7 @@ public:
queryCreatableContentsInfo( const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv ) queryCreatableContentsInfo( const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv )
throw( com::sun::star::uno::RuntimeException ); throw( com::sun::star::uno::RuntimeException );
libcmis::ObjectPtr getObject( ); libcmis::ObjectPtr getObject( ) throw ( libcmis::Exception );
}; };
} }
......
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