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
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_connectivity.hxx"
26 
27 #include <stdio.h>
28 #include "connectivity/sdbcx/VGroup.hxx"
29 #include <com/sun/star/lang/DisposedException.hpp>
30 #include <com/sun/star/sdbcx/Privilege.hpp>
31 #include <com/sun/star/sdbcx/PrivilegeObject.hpp>
32 #include <comphelper/sequence.hxx>
33 #include <connectivity/dbexception.hxx>
34 
35 // -------------------------------------------------------------------------
36 using namespace ::connectivity::sdbcx;
37 using namespace ::connectivity;
38 using namespace ::dbtools;
39 using namespace ::com::sun::star::sdbc;
40 using namespace ::com::sun::star::uno;
41 using namespace ::com::sun::star::container;
42 using namespace ::com::sun::star::lang;
43 using namespace ::com::sun::star::beans;
44 
45 IMPLEMENT_SERVICE_INFO(OGroup,"com.sun.star.sdbcx.VGroup","com.sun.star.sdbcx.Group");
46 // -------------------------------------------------------------------------
OGroup(sal_Bool _bCase)47 OGroup::OGroup(sal_Bool _bCase) :	OGroup_BASE(m_aMutex)
48 				,	ODescriptor(OGroup_BASE::rBHelper,_bCase)
49 				,	m_pUsers(NULL)
50 {
51 }
52 // -------------------------------------------------------------------------
OGroup(const::rtl::OUString & _Name,sal_Bool _bCase)53 OGroup::OGroup(const ::rtl::OUString& _Name,sal_Bool _bCase) :	OGroup_BASE(m_aMutex)
54 						,ODescriptor(OGroup_BASE::rBHelper,_bCase)
55 						,m_pUsers(NULL)
56 {
57 	m_Name = _Name;
58 }
59 // -------------------------------------------------------------------------
~OGroup()60 OGroup::~OGroup()
61 {
62 	delete m_pUsers;
63 }
64 // -------------------------------------------------------------------------
queryInterface(const Type & rType)65 Any SAL_CALL OGroup::queryInterface( const Type & rType ) throw(RuntimeException)
66 {
67     Any aRet = ODescriptor::queryInterface( rType);
68 	return aRet.hasValue() ? aRet : OGroup_BASE::queryInterface( rType);
69 }
70 // -------------------------------------------------------------------------
getTypes()71 Sequence< Type > SAL_CALL OGroup::getTypes(  ) throw(RuntimeException)
72 {
73 	return ::comphelper::concatSequences(ODescriptor::getTypes(),OGroup_BASE::getTypes());
74 }
75 // -------------------------------------------------------------------------
disposing(void)76 void OGroup::disposing(void)
77 {
78 	OPropertySetHelper::disposing();
79 
80 	::osl::MutexGuard aGuard(m_aMutex);
81 
82 	if(m_pUsers)
83 		m_pUsers->disposing();
84 }
85 // -------------------------------------------------------------------------
createArrayHelper() const86 ::cppu::IPropertyArrayHelper* OGroup::createArrayHelper( ) const
87 {
88 	Sequence< Property > aProps;
89 	describeProperties(aProps);
90 	return new ::cppu::OPropertyArrayHelper(aProps);
91 }
92 // -------------------------------------------------------------------------
getInfoHelper()93 ::cppu::IPropertyArrayHelper & OGroup::getInfoHelper()
94 {
95 	return *const_cast<OGroup*>(this)->getArrayHelper();
96 }
97 // -------------------------------------------------------------------------
getUsers()98 Reference< XNameAccess > SAL_CALL OGroup::getUsers(  ) throw(RuntimeException)
99 {
100 	::osl::MutexGuard aGuard(m_aMutex);
101 	checkDisposed(OGroup_BASE::rBHelper.bDisposed);
102 
103 	try
104 	{
105 		if ( !m_pUsers )
106 			refreshUsers();
107 	}
108 	catch( const RuntimeException& )
109 	{
110 		// allowed to leave this method
111 		throw;
112 	}
113 	catch( const Exception& )
114 	{
115 		// allowed
116 	}
117 
118 	return const_cast<OGroup*>(this)->m_pUsers;
119 }
120 // -------------------------------------------------------------------------
121 
getPrivileges(const::rtl::OUString &,sal_Int32)122 sal_Int32 SAL_CALL OGroup::getPrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
123 {
124 	::osl::MutexGuard aGuard(m_aMutex);
125 	checkDisposed(OGroup_BASE::rBHelper.bDisposed);
126 
127 	return 0;
128 }
129 // -------------------------------------------------------------------------
getGrantablePrivileges(const::rtl::OUString &,sal_Int32)130 sal_Int32 SAL_CALL OGroup::getGrantablePrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
131 {
132 	::osl::MutexGuard aGuard(m_aMutex);
133 	checkDisposed(OGroup_BASE::rBHelper.bDisposed);
134 
135 	return 0;
136 }
137 // -------------------------------------------------------------------------
grantPrivileges(const::rtl::OUString &,sal_Int32,sal_Int32)138 void SAL_CALL OGroup::grantPrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
139 {
140 	::osl::MutexGuard aGuard(m_aMutex);
141 	checkDisposed(OGroup_BASE::rBHelper.bDisposed);
142     throwFeatureNotImplementedException( "XAuthorizable::grantPrivileges", *this );
143 }
144 // -------------------------------------------------------------------------
revokePrivileges(const::rtl::OUString &,sal_Int32,sal_Int32)145 void SAL_CALL OGroup::revokePrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
146 {
147 	::osl::MutexGuard aGuard(m_aMutex);
148 	checkDisposed(OGroup_BASE::rBHelper.bDisposed);
149     throwFeatureNotImplementedException( "XAuthorizable::revokePrivileges", *this );
150 }
151 // -----------------------------------------------------------------------------
getPropertySetInfo()152 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OGroup::getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException)
153 {
154 	return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
155 }
156 // -----------------------------------------------------------------------------
getName()157 ::rtl::OUString SAL_CALL OGroup::getName(  ) throw(::com::sun::star::uno::RuntimeException)
158 {
159 	return m_Name;
160 }
161 // -----------------------------------------------------------------------------
setName(const::rtl::OUString &)162 void SAL_CALL OGroup::setName( const ::rtl::OUString& /*aName*/ ) throw(::com::sun::star::uno::RuntimeException)
163 {
164     throwFeatureNotImplementedException( "XNamed::setName", *this );
165 }
166 // -----------------------------------------------------------------------------
167 // XInterface
acquire()168 void SAL_CALL OGroup::acquire() throw()
169 {
170 	OGroup_BASE::acquire();
171 }
172 // -----------------------------------------------------------------------------
release()173 void SAL_CALL OGroup::release() throw()
174 {
175 	OGroup_BASE::release();
176 }
177 // -----------------------------------------------------------------------------
178 
179 
180