1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_connectivity.hxx"
30 
31 #include <stdio.h>
32 #include "connectivity/sdbcx/VGroup.hxx"
33 #include <com/sun/star/lang/DisposedException.hpp>
34 #include <com/sun/star/sdbcx/Privilege.hpp>
35 #include <com/sun/star/sdbcx/PrivilegeObject.hpp>
36 #include <comphelper/sequence.hxx>
37 #include <connectivity/dbexception.hxx>
38 
39 // -------------------------------------------------------------------------
40 using namespace ::connectivity::sdbcx;
41 using namespace ::connectivity;
42 using namespace ::dbtools;
43 using namespace ::com::sun::star::sdbc;
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::container;
46 using namespace ::com::sun::star::lang;
47 using namespace ::com::sun::star::beans;
48 
49 IMPLEMENT_SERVICE_INFO(OGroup,"com.sun.star.sdbcx.VGroup","com.sun.star.sdbcx.Group");
50 // -------------------------------------------------------------------------
51 OGroup::OGroup(sal_Bool _bCase) :	OGroup_BASE(m_aMutex)
52 				,	ODescriptor(OGroup_BASE::rBHelper,_bCase)
53 				,	m_pUsers(NULL)
54 {
55 }
56 // -------------------------------------------------------------------------
57 OGroup::OGroup(const ::rtl::OUString& _Name,sal_Bool _bCase) :	OGroup_BASE(m_aMutex)
58 						,ODescriptor(OGroup_BASE::rBHelper,_bCase)
59 						,m_pUsers(NULL)
60 {
61 	m_Name = _Name;
62 }
63 // -------------------------------------------------------------------------
64 OGroup::~OGroup()
65 {
66 	delete m_pUsers;
67 }
68 // -------------------------------------------------------------------------
69 Any SAL_CALL OGroup::queryInterface( const Type & rType ) throw(RuntimeException)
70 {
71     Any aRet = ODescriptor::queryInterface( rType);
72 	return aRet.hasValue() ? aRet : OGroup_BASE::queryInterface( rType);
73 }
74 // -------------------------------------------------------------------------
75 Sequence< Type > SAL_CALL OGroup::getTypes(  ) throw(RuntimeException)
76 {
77 	return ::comphelper::concatSequences(ODescriptor::getTypes(),OGroup_BASE::getTypes());
78 }
79 // -------------------------------------------------------------------------
80 void OGroup::disposing(void)
81 {
82 	OPropertySetHelper::disposing();
83 
84 	::osl::MutexGuard aGuard(m_aMutex);
85 
86 	if(m_pUsers)
87 		m_pUsers->disposing();
88 }
89 // -------------------------------------------------------------------------
90 ::cppu::IPropertyArrayHelper* OGroup::createArrayHelper( ) const
91 {
92 	Sequence< Property > aProps;
93 	describeProperties(aProps);
94 	return new ::cppu::OPropertyArrayHelper(aProps);
95 }
96 // -------------------------------------------------------------------------
97 ::cppu::IPropertyArrayHelper & OGroup::getInfoHelper()
98 {
99 	return *const_cast<OGroup*>(this)->getArrayHelper();
100 }
101 // -------------------------------------------------------------------------
102 Reference< XNameAccess > SAL_CALL OGroup::getUsers(  ) throw(RuntimeException)
103 {
104 	::osl::MutexGuard aGuard(m_aMutex);
105 	checkDisposed(OGroup_BASE::rBHelper.bDisposed);
106 
107 	try
108 	{
109 		if ( !m_pUsers )
110 			refreshUsers();
111 	}
112 	catch( const RuntimeException& )
113 	{
114 		// allowed to leave this method
115 		throw;
116 	}
117 	catch( const Exception& )
118 	{
119 		// allowed
120 	}
121 
122 	return const_cast<OGroup*>(this)->m_pUsers;
123 }
124 // -------------------------------------------------------------------------
125 
126 sal_Int32 SAL_CALL OGroup::getPrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
127 {
128 	::osl::MutexGuard aGuard(m_aMutex);
129 	checkDisposed(OGroup_BASE::rBHelper.bDisposed);
130 
131 	return 0;
132 }
133 // -------------------------------------------------------------------------
134 sal_Int32 SAL_CALL OGroup::getGrantablePrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
135 {
136 	::osl::MutexGuard aGuard(m_aMutex);
137 	checkDisposed(OGroup_BASE::rBHelper.bDisposed);
138 
139 	return 0;
140 }
141 // -------------------------------------------------------------------------
142 void SAL_CALL OGroup::grantPrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
143 {
144 	::osl::MutexGuard aGuard(m_aMutex);
145 	checkDisposed(OGroup_BASE::rBHelper.bDisposed);
146     throwFeatureNotImplementedException( "XAuthorizable::grantPrivileges", *this );
147 }
148 // -------------------------------------------------------------------------
149 void SAL_CALL OGroup::revokePrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
150 {
151 	::osl::MutexGuard aGuard(m_aMutex);
152 	checkDisposed(OGroup_BASE::rBHelper.bDisposed);
153     throwFeatureNotImplementedException( "XAuthorizable::revokePrivileges", *this );
154 }
155 // -----------------------------------------------------------------------------
156 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OGroup::getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException)
157 {
158 	return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
159 }
160 // -----------------------------------------------------------------------------
161 ::rtl::OUString SAL_CALL OGroup::getName(  ) throw(::com::sun::star::uno::RuntimeException)
162 {
163 	return m_Name;
164 }
165 // -----------------------------------------------------------------------------
166 void SAL_CALL OGroup::setName( const ::rtl::OUString& /*aName*/ ) throw(::com::sun::star::uno::RuntimeException)
167 {
168     throwFeatureNotImplementedException( "XNamed::setName", *this );
169 }
170 // -----------------------------------------------------------------------------
171 // XInterface
172 void SAL_CALL OGroup::acquire() throw()
173 {
174 	OGroup_BASE::acquire();
175 }
176 // -----------------------------------------------------------------------------
177 void SAL_CALL OGroup::release() throw()
178 {
179 	OGroup_BASE::release();
180 }
181 // -----------------------------------------------------------------------------
182 
183 
184