bump product version to 5.0.4.1
[LibreOffice.git] / connectivity / source / sdbcx / VUser.cxx
blob4104c25f17c1d82ed9532e61eb045714482595ec
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <connectivity/sdbcx/VUser.hxx>
22 #include <com/sun/star/lang/DisposedException.hpp>
23 #include <com/sun/star/sdbcx/Privilege.hpp>
24 #include <com/sun/star/sdbcx/PrivilegeObject.hpp>
25 #include "TConnection.hxx"
26 #include <connectivity/sdbcx/VCollection.hxx>
27 #include <connectivity/dbexception.hxx>
28 #include <comphelper/sequence.hxx>
31 using namespace connectivity;
32 using namespace connectivity::sdbcx;
33 using namespace ::com::sun::star::sdbc;
34 using namespace ::com::sun::star::beans;
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::container;
37 using namespace ::com::sun::star::lang;
39 IMPLEMENT_SERVICE_INFO(OUser,"com.sun.star.sdbcx.VUser","com.sun.star.sdbcx.User");
41 OUser::OUser(bool _bCase) : OUser_BASE(m_aMutex)
42 , ODescriptor(OUser_BASE::rBHelper,_bCase,true)
43 , m_pGroups(NULL)
47 OUser::OUser(const OUString& _Name, bool _bCase) : OUser_BASE(m_aMutex)
48 ,ODescriptor(OUser_BASE::rBHelper,_bCase)
49 ,m_pGroups(NULL)
51 m_Name = _Name;
54 OUser::~OUser( )
56 delete m_pGroups;
59 void OUser::disposing()
61 OPropertySetHelper::disposing();
62 ::osl::MutexGuard aGuard(m_aMutex);
63 if(m_pGroups)
64 m_pGroups->disposing();
67 Any SAL_CALL OUser::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
69 Any aRet = ODescriptor::queryInterface( rType);
70 return aRet.hasValue() ? aRet : OUser_BASE::queryInterface( rType);
73 Sequence< Type > SAL_CALL OUser::getTypes( ) throw(RuntimeException, std::exception)
75 return ::comphelper::concatSequences(ODescriptor::getTypes(),OUser_BASE::getTypes());
78 ::cppu::IPropertyArrayHelper* OUser::createArrayHelper( ) const
80 Sequence< Property > aProps;
81 describeProperties(aProps);
82 return new ::cppu::OPropertyArrayHelper(aProps);
86 ::cppu::IPropertyArrayHelper & OUser::getInfoHelper()
88 return *getArrayHelper();
91 // XUser
92 void SAL_CALL OUser::changePassword( const OUString& /*objPassword*/, const OUString& /*newPassword*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException, std::exception)
94 ::osl::MutexGuard aGuard(m_aMutex);
95 checkDisposed(OUser_BASE::rBHelper.bDisposed);
96 ::dbtools::throwFeatureNotImplementedSQLException( "XUser::changePassword", *this );
99 // XGroupsSupplier
100 Reference< XNameAccess > SAL_CALL OUser::getGroups( ) throw(RuntimeException, std::exception)
102 ::osl::MutexGuard aGuard(m_aMutex);
103 checkDisposed(OUser_BASE::rBHelper.bDisposed);
107 if ( !m_pGroups )
108 refreshGroups();
110 catch( const RuntimeException& )
112 // allowed to leave this method
113 throw;
115 catch( const Exception& )
117 // allowed
120 return const_cast<OUser*>(this)->m_pGroups;
124 SAL_WNOUNREACHABLE_CODE_PUSH
126 sal_Int32 SAL_CALL OUser::getPrivileges( const OUString& /*objName*/, sal_Int32 /*objType*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
128 ::osl::MutexGuard aGuard(m_aMutex);
129 checkDisposed(OUser_BASE::rBHelper.bDisposed);
130 ::dbtools::throwFeatureNotImplementedSQLException( "XAuthorizable::changePassword", *this );
131 return 0;
134 sal_Int32 SAL_CALL OUser::getGrantablePrivileges( const OUString& /*objName*/, sal_Int32 /*objType*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
136 ::osl::MutexGuard aGuard(m_aMutex);
137 checkDisposed(OUser_BASE::rBHelper.bDisposed);
138 ::dbtools::throwFeatureNotImplementedSQLException( "XAuthorizable::getGrantablePrivileges", *this );
139 return 0;
142 SAL_WNOUNREACHABLE_CODE_POP
145 void SAL_CALL OUser::grantPrivileges( const OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
147 ::osl::MutexGuard aGuard(m_aMutex);
148 checkDisposed(OUser_BASE::rBHelper.bDisposed);
149 ::dbtools::throwFeatureNotImplementedSQLException( "XAuthorizable::grantPrivileges", *this );
152 void SAL_CALL OUser::revokePrivileges( const OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
154 ::osl::MutexGuard aGuard(m_aMutex);
155 checkDisposed(OUser_BASE::rBHelper.bDisposed);
156 ::dbtools::throwFeatureNotImplementedSQLException( "XAuthorizable::revokePrivileges", *this );
159 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OUser::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
161 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
164 OUString SAL_CALL OUser::getName( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
166 return m_Name;
169 void SAL_CALL OUser::setName( const OUString& /*aName*/ ) throw(::com::sun::star::uno::RuntimeException, std::exception)
171 OSL_FAIL( "OUser::setName: not implemented!" );
172 // not allowed to throw an SQLException here ...
175 // XInterface
176 void SAL_CALL OUser::acquire() throw()
178 OUser_BASE::acquire();
181 void SAL_CALL OUser::release() throw()
183 OUser_BASE::release();
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */