webdavcontent.cxx (c1c10f68) webdavcontent.cxx (06594b87)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 54 unchanged lines hidden (view full) ---

63#include <com/sun/star/ucb/InteractiveNetworkWriteException.hpp>
64#include <com/sun/star/ucb/MissingInputStreamException.hpp>
65#include <com/sun/star/ucb/MissingPropertiesException.hpp>
66#include <com/sun/star/ucb/NameClash.hpp>
67#include <com/sun/star/ucb/NameClashException.hpp>
68#include <com/sun/star/ucb/OpenCommandArgument2.hpp>
69#include <com/sun/star/ucb/OpenMode.hpp>
70#include <com/sun/star/ucb/PostCommandArgument2.hpp>
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 54 unchanged lines hidden (view full) ---

63#include <com/sun/star/ucb/InteractiveNetworkWriteException.hpp>
64#include <com/sun/star/ucb/MissingInputStreamException.hpp>
65#include <com/sun/star/ucb/MissingPropertiesException.hpp>
66#include <com/sun/star/ucb/NameClash.hpp>
67#include <com/sun/star/ucb/NameClashException.hpp>
68#include <com/sun/star/ucb/OpenCommandArgument2.hpp>
69#include <com/sun/star/ucb/OpenMode.hpp>
70#include <com/sun/star/ucb/PostCommandArgument2.hpp>
71#include <com/sun/star/ucb/PropertyCommandArgument.hpp>
71#include <com/sun/star/ucb/TransferInfo.hpp>
72#include <com/sun/star/ucb/UnsupportedCommandException.hpp>
73#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
74#include <com/sun/star/ucb/UnsupportedNameClashException.hpp>
75#include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
76#include <com/sun/star/ucb/XCommandInfo.hpp>
77#include <com/sun/star/ucb/XPersistentPropertySet.hpp>
78#include <com/sun/star/uno/XComponentContext.hpp>

--- 685 unchanged lines hidden (view full) ---

764 static_cast< cppu::OWeakObject * >( this ),
765 -1 ) ),
766 Environment );
767 // Unreachable
768 }
769
770 aRet = uno::makeAny( createNewContent( aArg ) );
771 }
72#include <com/sun/star/ucb/TransferInfo.hpp>
73#include <com/sun/star/ucb/UnsupportedCommandException.hpp>
74#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
75#include <com/sun/star/ucb/UnsupportedNameClashException.hpp>
76#include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
77#include <com/sun/star/ucb/XCommandInfo.hpp>
78#include <com/sun/star/ucb/XPersistentPropertySet.hpp>
79#include <com/sun/star/uno/XComponentContext.hpp>

--- 685 unchanged lines hidden (view full) ---

765 static_cast< cppu::OWeakObject * >( this ),
766 -1 ) ),
767 Environment );
768 // Unreachable
769 }
770
771 aRet = uno::makeAny( createNewContent( aArg ) );
772 }
773 else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "addProperty" )))
774 {
775 ucb::PropertyCommandArgument aPropArg;
776 if ( !( aCommand.Argument >>= aPropArg ))
777 {
778 ucbhelper::cancelCommandExecution(
779 uno::makeAny( lang::IllegalArgumentException(
780 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
781 "Wrong argument type!" )),
782 static_cast< cppu::OWeakObject * >( this ),
783 -1 ) ),
784 Environment );
785 }
786
787 // TODO when/if XPropertyContainer is removed,
788 // the command execution can be canceled in addProperty
789 try
790 {
791 addProperty( aPropArg, Environment );
792 }
793 catch ( const beans::PropertyExistException &e )
794 {
795 ucbhelper::cancelCommandExecution( uno::makeAny( e ), Environment );
796 }
797 catch ( const beans::IllegalTypeException&e )
798 {
799 ucbhelper::cancelCommandExecution( uno::makeAny( e ), Environment );
800 }
801 catch ( const lang::IllegalArgumentException&e )
802 {
803 ucbhelper::cancelCommandExecution( uno::makeAny( e ), Environment );
804 }
805 }
806 else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "removeProperty" )))
807 {
808 rtl::OUString sPropName;
809 if ( !( aCommand.Argument >>= sPropName ) )
810 {
811 ucbhelper::cancelCommandExecution(
812 uno::makeAny( lang::IllegalArgumentException(
813 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
814 "Wrong argument type!" )),
815 static_cast< cppu::OWeakObject * >( this ),
816 -1 ) ),
817 Environment );
818 }
819
820 // TODO when/if XPropertyContainer is removed,
821 // the command execution can be canceled in removeProperty
822 try
823 {
824 removeProperty( sPropName, Environment );
825 }
826 catch( const beans::UnknownPropertyException &e )
827 {
828 ucbhelper::cancelCommandExecution( uno::makeAny( e ), Environment );
829 }
830 catch( const beans::NotRemoveableException &e )
831 {
832 ucbhelper::cancelCommandExecution( uno::makeAny( e ), Environment );
833 }
834 }
772 else
773 {
774 //////////////////////////////////////////////////////////////////
775 // Unsupported command
776 //////////////////////////////////////////////////////////////////
777
778 ucbhelper::cancelCommandExecution(
779 uno::makeAny( ucb::UnsupportedCommandException(

--- 35 unchanged lines hidden (view full) ---

815}
816
817//=========================================================================
818//
819// XPropertyContainer methods.
820//
821//=========================================================================
822
835 else
836 {
837 //////////////////////////////////////////////////////////////////
838 // Unsupported command
839 //////////////////////////////////////////////////////////////////
840
841 ucbhelper::cancelCommandExecution(
842 uno::makeAny( ucb::UnsupportedCommandException(

--- 35 unchanged lines hidden (view full) ---

878}
879
880//=========================================================================
881//
882// XPropertyContainer methods.
883//
884//=========================================================================
885
823// virtual
824void SAL_CALL Content::addProperty( const rtl::OUString& Name,
825 sal_Int16 Attributes,
826 const uno::Any& DefaultValue )
827 throw( beans::PropertyExistException,
828 beans::IllegalTypeException,
829 lang::IllegalArgumentException,
830 uno::RuntimeException )
886void Content::addProperty( const com::sun::star::ucb::PropertyCommandArgument &aCmdArg,
887 const uno::Reference< ucb::XCommandEnvironment >& xEnv )
888throw( beans::PropertyExistException,
889 beans::IllegalTypeException,
890 lang::IllegalArgumentException,
891 uno::RuntimeException )
831{
832// if ( m_bTransient )
833// @@@ ???
892{
893// if ( m_bTransient )
894// @@@ ???
895 const beans::Property aProperty = aCmdArg.Property;
896 const uno::Any aDefaultValue = aCmdArg.DefaultValue;
834
897
835 if ( !Name.getLength() )
836 throw lang::IllegalArgumentException();
898 // check property Name
899 if ( !aProperty.Name.getLength() )
900 throw lang::IllegalArgumentException(
901 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
902 "\"addProperty\" with empty Property.Name")),
903 static_cast< ::cppu::OWeakObject * >( this ),
904 -1 );
837
838 // Check property type.
905
906 // Check property type.
839 if ( !UCBDeadPropertyValue::supportsType( DefaultValue.getValueType() ) )
840 {
841 OSL_ENSURE( sal_False,
842 "Content::addProperty - Unsupported property type!" );
843 throw beans::IllegalTypeException();
844 }
907 if ( !UCBDeadPropertyValue::supportsType( aProperty.Type ) )
908 throw beans::IllegalTypeException(
909 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
910 "\"addProperty\" unsupported Property.Type")),
911 static_cast< ::cppu::OWeakObject * >( this ) );
845
912
913 // check default value
914 if ( aDefaultValue.hasValue() && aDefaultValue.getValueType() != aProperty.Type )
915 throw beans::IllegalTypeException(
916 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
917 "\"addProperty\" DefaultValue does not match Property.Type")),
918 static_cast< ::cppu::OWeakObject * >( this ) );
919
846 //////////////////////////////////////////////////////////////////////
847 // Make sure a property with the requested name does not already
848 // exist in dynamic and static(!) properties.
849 //////////////////////////////////////////////////////////////////////
850
920 //////////////////////////////////////////////////////////////////////
921 // Make sure a property with the requested name does not already
922 // exist in dynamic and static(!) properties.
923 //////////////////////////////////////////////////////////////////////
924
851 // @@@ Need real command environment here, but where to get it from?
852 // XPropertyContainer interface should be replaced by
853 // XCommandProcessor commands!
854 uno::Reference< ucb::XCommandEnvironment > xEnv;
925 // Take into account special properties with custom namespace
926 // using <prop:the_propname xmlns:prop="the_namespace">
927 rtl::OUString aSpecialName;
928 bool bIsSpecial = DAVProperties::isUCBSpecialProperty( aProperty.Name, aSpecialName );
855
856 // Note: This requires network access!
857 if ( getPropertySetInfo( xEnv, sal_False /* don't cache data */ )
929
930 // Note: This requires network access!
931 if ( getPropertySetInfo( xEnv, sal_False /* don't cache data */ )
858 ->hasPropertyByName( Name ) )
932 ->hasPropertyByName( bIsSpecial ? aSpecialName : aProperty.Name ) )
859 {
860 // Property does already exist.
861 throw beans::PropertyExistException();
862 }
863
864 //////////////////////////////////////////////////////////////////////
865 // Add a new dynamic property.
866 //////////////////////////////////////////////////////////////////////
867
933 {
934 // Property does already exist.
935 throw beans::PropertyExistException();
936 }
937
938 //////////////////////////////////////////////////////////////////////
939 // Add a new dynamic property.
940 //////////////////////////////////////////////////////////////////////
941
868 ProppatchValue aValue( PROPSET, Name, DefaultValue );
942 ProppatchValue aValue( PROPSET, aProperty.Name, aDefaultValue );
869
870 std::vector< ProppatchValue > aProppatchValues;
871 aProppatchValues.push_back( aValue );
872
873 try
874 {
875 // Set property value at server.
876 std::auto_ptr< DAVResourceAccess > xResAccess;

--- 5 unchanged lines hidden (view full) ---

882 {
883 osl::Guard< osl::Mutex > aGuard( m_aMutex );
884 m_xResAccess.reset( new DAVResourceAccess( *xResAccess.get() ) );
885 }
886
887 // Notify propertyset info change listeners.
888 beans::PropertySetInfoChangeEvent evt(
889 static_cast< cppu::OWeakObject * >( this ),
943
944 std::vector< ProppatchValue > aProppatchValues;
945 aProppatchValues.push_back( aValue );
946
947 try
948 {
949 // Set property value at server.
950 std::auto_ptr< DAVResourceAccess > xResAccess;

--- 5 unchanged lines hidden (view full) ---

956 {
957 osl::Guard< osl::Mutex > aGuard( m_aMutex );
958 m_xResAccess.reset( new DAVResourceAccess( *xResAccess.get() ) );
959 }
960
961 // Notify propertyset info change listeners.
962 beans::PropertySetInfoChangeEvent evt(
963 static_cast< cppu::OWeakObject * >( this ),
890 Name,
964 bIsSpecial ? aSpecialName : aProperty.Name,
891 -1, // No handle available
892 beans::PropertySetInfoChange::PROPERTY_INSERTED );
893 notifyPropertySetInfoChange( evt );
894 }
895 catch ( DAVException const & e )
896 {
897 if ( e.getStatus() == SC_FORBIDDEN )
898 {
899 // Support for setting arbitrary dead properties is optional!
900
901 // Store property locally.
965 -1, // No handle available
966 beans::PropertySetInfoChange::PROPERTY_INSERTED );
967 notifyPropertySetInfoChange( evt );
968 }
969 catch ( DAVException const & e )
970 {
971 if ( e.getStatus() == SC_FORBIDDEN )
972 {
973 // Support for setting arbitrary dead properties is optional!
974
975 // Store property locally.
902 ContentImplHelper::addProperty(
903 Name, Attributes, DefaultValue );
976 ContentImplHelper::addProperty( bIsSpecial ? aSpecialName : aProperty.Name,
977 aProperty.Attributes,
978 aDefaultValue );
904 }
905 else
906 {
907 if ( shouldAccessNetworkAfterException( e ) )
908 {
909 try
910 {
911 const ResourceType & rType = getResourceType( xEnv );
912 switch ( rType )
913 {
914 case UNKNOWN:
915 case DAV:
916 throw lang::IllegalArgumentException();
917
918 case NON_DAV:
919 // Store property locally.
979 }
980 else
981 {
982 if ( shouldAccessNetworkAfterException( e ) )
983 {
984 try
985 {
986 const ResourceType & rType = getResourceType( xEnv );
987 switch ( rType )
988 {
989 case UNKNOWN:
990 case DAV:
991 throw lang::IllegalArgumentException();
992
993 case NON_DAV:
994 // Store property locally.
920 ContentImplHelper::addProperty( Name,
921 Attributes,
922 DefaultValue );
995 ContentImplHelper::addProperty( bIsSpecial ? aSpecialName : aProperty.Name,
996 aProperty.Attributes,
997 aDefaultValue );
923 break;
924
925 default:
926 OSL_ENSURE( sal_False,
927 "Content::addProperty - "
928 "Unsupported resource type!" );
929 break;
930 }

--- 10 unchanged lines hidden (view full) ---

941 OSL_ENSURE( sal_False,
942 "Content::addProperty - "
943 "Unable to determine resource type!" );
944 }
945 }
946 }
947}
948
998 break;
999
1000 default:
1001 OSL_ENSURE( sal_False,
1002 "Content::addProperty - "
1003 "Unsupported resource type!" );
1004 break;
1005 }

--- 10 unchanged lines hidden (view full) ---

1016 OSL_ENSURE( sal_False,
1017 "Content::addProperty - "
1018 "Unable to determine resource type!" );
1019 }
1020 }
1021 }
1022}
1023
949//=========================================================================
950// virtual
951void SAL_CALL Content::removeProperty( const rtl::OUString& Name )
952 throw( beans::UnknownPropertyException,
953 beans::NotRemoveableException,
954 uno::RuntimeException )
1024void Content::removeProperty( const rtl::OUString& Name,
1025 const uno::Reference< ucb::XCommandEnvironment >& xEnv )
1026throw( beans::UnknownPropertyException,
1027 beans::NotRemoveableException,
1028 uno::RuntimeException )
955{
1029{
956 // @@@ Need real command environment here, but where to get it from?
957 // XPropertyContainer interface should be replaced by
958 // XCommandProcessor commands!
959 uno::Reference< ucb::XCommandEnvironment > xEnv;
960
961#if 0
962 // @@@ REMOVEABLE z.Z. nicht richtig an der PropSetInfo gesetzt!!!
963 try
964 {
965 beans::Property aProp
1030#if 0
1031 // @@@ REMOVEABLE z.Z. nicht richtig an der PropSetInfo gesetzt!!!
1032 try
1033 {
1034 beans::Property aProp
966 = getPropertySetInfo( xEnv, sal_False /* don't cache data */ )
967 ->getPropertyByName( Name );
1035 = getPropertySetInfo( xEnv, sal_False /* don't cache data */ )
1036 ->getPropertyByName( Name );
968
969 if ( !( aProp.Attributes & beans::PropertyAttribute::REMOVEABLE ) )
970 {
971 // Not removeable!
972 throw beans::NotRemoveableException();
973 }
974 }
975 catch ( beans::UnknownPropertyException const & )

--- 46 unchanged lines hidden (view full) ---

1022 {
1023 if ( shouldAccessNetworkAfterException( e ) )
1024 {
1025 try
1026 {
1027 const ResourceType & rType = getResourceType( xEnv );
1028 switch ( rType )
1029 {
1037
1038 if ( !( aProp.Attributes & beans::PropertyAttribute::REMOVEABLE ) )
1039 {
1040 // Not removeable!
1041 throw beans::NotRemoveableException();
1042 }
1043 }
1044 catch ( beans::UnknownPropertyException const & )

--- 46 unchanged lines hidden (view full) ---

1091 {
1092 if ( shouldAccessNetworkAfterException( e ) )
1093 {
1094 try
1095 {
1096 const ResourceType & rType = getResourceType( xEnv );
1097 switch ( rType )
1098 {
1030 case UNKNOWN:
1031 case DAV:
1032 throw beans::UnknownPropertyException();
1099 case UNKNOWN:
1100 case DAV:
1101 throw beans::UnknownPropertyException();
1033
1102
1034 case NON_DAV:
1035 // Try to remove property from local store.
1036 ContentImplHelper::removeProperty( Name );
1037 break;
1103 case NON_DAV:
1104 // Try to remove property from local store.
1105 ContentImplHelper::removeProperty( Name );
1106 break;
1038
1107
1039 default:
1040 OSL_ENSURE( sal_False,
1041 "Content::removeProperty - "
1042 "Unsupported resource type!" );
1043 break;
1108 default:
1109 OSL_ENSURE( sal_False,
1110 "Content::removeProperty - "
1111 "Unsupported resource type!" );
1112 break;
1044 }
1045 }
1046 catch ( uno::Exception const & )
1047 {
1048 OSL_ENSURE( sal_False,
1049 "Content::removeProperty - "
1050 "Unable to determine resource type!" );
1051 }

--- 4 unchanged lines hidden (view full) ---

1056 "Content::removeProperty - "
1057 "Unable to determine resource type!" );
1058// throw beans::UnknownPropertyException();
1059 }
1060 }
1061 }
1062}
1063
1113 }
1114 }
1115 catch ( uno::Exception const & )
1116 {
1117 OSL_ENSURE( sal_False,
1118 "Content::removeProperty - "
1119 "Unable to determine resource type!" );
1120 }

--- 4 unchanged lines hidden (view full) ---

1125 "Content::removeProperty - "
1126 "Unable to determine resource type!" );
1127// throw beans::UnknownPropertyException();
1128 }
1129 }
1130 }
1131}
1132
1133// virtual
1134void SAL_CALL Content::addProperty( const rtl::OUString& Name,
1135 sal_Int16 Attributes,
1136 const uno::Any& DefaultValue )
1137 throw( beans::PropertyExistException,
1138 beans::IllegalTypeException,
1139 lang::IllegalArgumentException,
1140 uno::RuntimeException )
1141{
1142 beans::Property aProperty;
1143 aProperty.Name = Name;
1144 aProperty.Type = DefaultValue.getValueType();
1145 aProperty.Attributes = Attributes;
1146 aProperty.Handle = -1;
1147
1148 addProperty( ucb::PropertyCommandArgument( aProperty, DefaultValue ),
1149 uno::Reference< ucb::XCommandEnvironment >());
1150}
1151
1152// virtual
1153void SAL_CALL Content::removeProperty( const rtl::OUString& Name )
1154 throw( beans::UnknownPropertyException,
1155 beans::NotRemoveableException,
1156 uno::RuntimeException )
1157{
1158 removeProperty( Name,
1159 uno::Reference< ucb::XCommandEnvironment >() );
1160}
1161
1064//=========================================================================
1065//
1066// XContentCreator methods.
1067//
1068//=========================================================================
1069
1070// virtual
1071uno::Sequence< ucb::ContentInfo > SAL_CALL

--- 702 unchanged lines hidden (view full) ---

1774 }
1775 }
1776 else
1777 {
1778 //////////////////////////////////////////////////////////////
1779 // Optional props.
1780 //////////////////////////////////////////////////////////////
1781
1162//=========================================================================
1163//
1164// XContentCreator methods.
1165//
1166//=========================================================================
1167
1168// virtual
1169uno::Sequence< ucb::ContentInfo > SAL_CALL

--- 702 unchanged lines hidden (view full) ---

1872 }
1873 }
1874 else
1875 {
1876 //////////////////////////////////////////////////////////////
1877 // Optional props.
1878 //////////////////////////////////////////////////////////////
1879
1880 rtl::OUString aSpecialName;
1881 bool bIsSpecial = DAVProperties::isUCBSpecialProperty( rName, aSpecialName );
1882
1782 if ( !xInfo.is() )
1783 xInfo = getPropertySetInfo( xEnv,
1784 sal_False /* don't cache data */ );
1785
1883 if ( !xInfo.is() )
1884 xInfo = getPropertySetInfo( xEnv,
1885 sal_False /* don't cache data */ );
1886
1786 if ( !xInfo->hasPropertyByName( rName ) )
1887 if ( !xInfo->hasPropertyByName( bIsSpecial ? aSpecialName : rName ) )
1787 {
1788 // Check, whether property exists. Skip otherwise.
1789 // PROPPATCH::set would add the property automatically, which
1790 // is not allowed for "setPropertyValues" command!
1791 aRet[ n ] <<= beans::UnknownPropertyException(
1792 rtl::OUString::createFromAscii(
1793 "Property is unknown!" ),
1794 static_cast< cppu::OWeakObject * >( this ) );

--- 32 unchanged lines hidden (view full) ---

1827 // Read-only property!
1828 // (but could be writable, if 'getcontenttype' would be)
1829 aRet[ n ] <<= lang::IllegalAccessException(
1830 rtl::OUString::createFromAscii(
1831 "Property is read-only!" ),
1832 static_cast< cppu::OWeakObject * >( this ) );
1833 }
1834 if ( rName.equalsAsciiL(
1888 {
1889 // Check, whether property exists. Skip otherwise.
1890 // PROPPATCH::set would add the property automatically, which
1891 // is not allowed for "setPropertyValues" command!
1892 aRet[ n ] <<= beans::UnknownPropertyException(
1893 rtl::OUString::createFromAscii(
1894 "Property is unknown!" ),
1895 static_cast< cppu::OWeakObject * >( this ) );

--- 32 unchanged lines hidden (view full) ---

1928 // Read-only property!
1929 // (but could be writable, if 'getcontenttype' would be)
1930 aRet[ n ] <<= lang::IllegalAccessException(
1931 rtl::OUString::createFromAscii(
1932 "Property is read-only!" ),
1933 static_cast< cppu::OWeakObject * >( this ) );
1934 }
1935 if ( rName.equalsAsciiL(
1835 RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) )
1936 RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) )
1836 {
1837 // Read-only property!
1838 aRet[ n ] <<= lang::IllegalAccessException(
1839 rtl::OUString::createFromAscii(
1840 "Property is read-only!" ),
1841 static_cast< cppu::OWeakObject * >( this ) );
1842 }
1843 else

--- 1544 unchanged lines hidden ---
1937 {
1938 // Read-only property!
1939 aRet[ n ] <<= lang::IllegalAccessException(
1940 rtl::OUString::createFromAscii(
1941 "Property is read-only!" ),
1942 static_cast< cppu::OWeakObject * >( this ) );
1943 }
1944 else

--- 1544 unchanged lines hidden ---