Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / connectivity / source / sdbcx / VUser.cxx
blob31fc797210884f71dda33bb7d9fdae1d029bb455
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 <stdio.h>
22 #include "connectivity/sdbcx/VUser.hxx"
23 #include <com/sun/star/lang/DisposedException.hpp>
24 #include <com/sun/star/sdbcx/Privilege.hpp>
25 #include <com/sun/star/sdbcx/PrivilegeObject.hpp>
26 #include "TConnection.hxx"
27 #include "connectivity/sdbcx/VCollection.hxx"
28 #include <connectivity/dbexception.hxx>
29 #include <comphelper/sequence.hxx>
32 using namespace connectivity;
33 using namespace connectivity::sdbcx;
34 using namespace ::com::sun::star::sdbc;
35 using namespace ::com::sun::star::beans;
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::container;
38 using namespace ::com::sun::star::lang;
40 IMPLEMENT_SERVICE_INFO(OUser,"com.sun.star.sdbcx.VUser","com.sun.star.sdbcx.User");
42 OUser::OUser(bool _bCase) : OUser_BASE(m_aMutex)
43 , ODescriptor(OUser_BASE::rBHelper,_bCase,true)
44 , m_pGroups(NULL)
48 OUser::OUser(const OUString& _Name, bool _bCase) : OUser_BASE(m_aMutex)
49 ,ODescriptor(OUser_BASE::rBHelper,_bCase)
50 ,m_pGroups(NULL)
52 m_Name = _Name;
55 OUser::~OUser( )
57 delete m_pGroups;
60 void OUser::disposing(void)
62 OPropertySetHelper::disposing();
63 ::osl::MutexGuard aGuard(m_aMutex);
64 if(m_pGroups)
65 m_pGroups->disposing();
68 Any SAL_CALL OUser::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
70 Any aRet = ODescriptor::queryInterface( rType);
71 return aRet.hasValue() ? aRet : OUser_BASE::queryInterface( rType);
74 Sequence< Type > SAL_CALL OUser::getTypes( ) throw(RuntimeException, std::exception)
76 return ::comphelper::concatSequences(ODescriptor::getTypes(),OUser_BASE::getTypes());
79 ::cppu::IPropertyArrayHelper* OUser::createArrayHelper( ) const
81 Sequence< Property > aProps;
82 describeProperties(aProps);
83 return new ::cppu::OPropertyArrayHelper(aProps);
87 ::cppu::IPropertyArrayHelper & OUser::getInfoHelper()
89 return *const_cast<OUser*>(this)->getArrayHelper();
92 // XUser
93 void SAL_CALL OUser::changePassword( const OUString& /*objPassword*/, const OUString& /*newPassword*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException, std::exception)
95 ::osl::MutexGuard aGuard(m_aMutex);
96 checkDisposed(OUser_BASE::rBHelper.bDisposed);
97 ::dbtools::throwFeatureNotImplementedException( "XUser::changePassword", *this );
100 // XGroupsSupplier
101 Reference< XNameAccess > SAL_CALL OUser::getGroups( ) throw(RuntimeException, std::exception)
103 ::osl::MutexGuard aGuard(m_aMutex);
104 checkDisposed(OUser_BASE::rBHelper.bDisposed);
108 if ( !m_pGroups )
109 refreshGroups();
111 catch( const RuntimeException& )
113 // allowed to leave this method
114 throw;
116 catch( const Exception& )
118 // allowed
121 return const_cast<OUser*>(this)->m_pGroups;
125 SAL_WNOUNREACHABLE_CODE_PUSH
127 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)
129 ::osl::MutexGuard aGuard(m_aMutex);
130 checkDisposed(OUser_BASE::rBHelper.bDisposed);
131 ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::changePassword", *this );
132 return 0;
135 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)
137 ::osl::MutexGuard aGuard(m_aMutex);
138 checkDisposed(OUser_BASE::rBHelper.bDisposed);
139 ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::getGrantablePrivileges", *this );
140 return 0;
143 SAL_WNOUNREACHABLE_CODE_POP
146 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)
148 ::osl::MutexGuard aGuard(m_aMutex);
149 checkDisposed(OUser_BASE::rBHelper.bDisposed);
150 ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::grantPrivileges", *this );
153 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)
155 ::osl::MutexGuard aGuard(m_aMutex);
156 checkDisposed(OUser_BASE::rBHelper.bDisposed);
157 ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::revokePrivileges", *this );
160 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OUser::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
162 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
165 OUString SAL_CALL OUser::getName( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
167 return m_Name;
170 void SAL_CALL OUser::setName( const OUString& /*aName*/ ) throw(::com::sun::star::uno::RuntimeException, std::exception)
172 OSL_FAIL( "OUser::setName: not implemented!" );
173 // not allowed to throw an SQLException here ...
176 // XInterface
177 void SAL_CALL OUser::acquire() throw()
179 OUser_BASE::acquire();
182 void SAL_CALL OUser::release() throw()
184 OUser_BASE::release();
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */