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 #include "ado/AUsers.hxx"
27 #include "ado/AUser.hxx"
28 #include "ado/ATable.hxx"
29 #include "ado/AConnection.hxx"
30 #include <com/sun/star/sdbc/XRow.hpp>
31 #include <com/sun/star/sdbc/XResultSet.hpp>
32 #include "connectivity/sdbcx/IRefreshable.hxx"
33 #include <comphelper/types.hxx>
34 #include <connectivity/dbexception.hxx>
35 #include "resource/ado_res.hrc"
36
37 using namespace comphelper;
38 using namespace connectivity;
39 using namespace connectivity::ado;
40 using namespace com::sun::star::uno;
41 using namespace com::sun::star::lang;
42 using namespace com::sun::star::beans;
43 using namespace com::sun::star::sdbc;
44 using namespace com::sun::star::container;
45
46 typedef connectivity::sdbcx::OCollection OCollection_TYPE;
47
createObject(const::rtl::OUString & _rName)48 sdbcx::ObjectType OUsers::createObject(const ::rtl::OUString& _rName)
49 {
50 return new OAdoUser(m_pCatalog,isCaseSensitive(),_rName);
51 }
52 // -------------------------------------------------------------------------
impl_refresh()53 void OUsers::impl_refresh() throw(RuntimeException)
54 {
55 m_aCollection.Refresh();
56 }
57 // -------------------------------------------------------------------------
createDescriptor()58 Reference< XPropertySet > OUsers::createDescriptor()
59 {
60 return new OUserExtend(m_pCatalog,isCaseSensitive());
61 }
62 // -------------------------------------------------------------------------
63 // XAppend
appendObject(const::rtl::OUString & _rForName,const Reference<XPropertySet> & descriptor)64 sdbcx::ObjectType OUsers::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
65 {
66 OUserExtend* pUser = NULL;
67 if ( !getImplementation( pUser, descriptor ) || pUser == NULL )
68 m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_USER_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) );
69
70 ADOUsers* pUsers = (ADOUsers*)m_aCollection;
71 pUsers->Append(OLEVariant(pUser->getImpl()),OLEString(pUser->getPassword()));
72
73 return createObject( _rForName );
74 }
75 // -------------------------------------------------------------------------
76 // XDrop
dropObject(sal_Int32,const::rtl::OUString _sElementName)77 void OUsers::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
78 {
79 m_aCollection.Delete(_sElementName);
80 }
81 // -------------------------------------------------------------------------
82
83
84