OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
EstateDataService.cs
Go to the documentation of this file.
1 /*
2  * Copyright (c) Contributors, http://opensimulator.org/
3  * See CONTRIBUTORS.TXT for a full list of copyright holders.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of the OpenSimulator Project nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 using System;
29 using System.Collections.Generic;
30 using OpenMetaverse;
31 using log4net;
32 using Nini.Config;
33 using System.Reflection;
34 using OpenSim.Services.Base;
35 using OpenSim.Services.Interfaces;
36 using OpenSim.Data;
37 using OpenSim.Framework;
38 
39 namespace OpenSim.Services.EstateService
40 {
42  {
43 // private static readonly ILog m_log =
44 // LogManager.GetLogger(
45 // MethodBase.GetCurrentMethod().DeclaringType);
46 
48 
49  public EstateDataService(IConfigSource config)
50  : base(config)
51  {
52  string dllName = String.Empty;
53  string connString = String.Empty;
54 
55  // Try reading the [DatabaseService] section, if it exists
56  IConfig dbConfig = config.Configs["DatabaseService"];
57  if (dbConfig != null)
58  {
59  dllName = dbConfig.GetString("StorageProvider", String.Empty);
60  connString = dbConfig.GetString("ConnectionString", String.Empty);
61  connString = dbConfig.GetString("EstateConnectionString", connString);
62  }
63 
64  // Try reading the [EstateDataStore] section, if it exists
65  IConfig estConfig = config.Configs["EstateDataStore"];
66  if (estConfig != null)
67  {
68  dllName = estConfig.GetString("StorageProvider", dllName);
69  connString = estConfig.GetString("ConnectionString", connString);
70  }
71 
72  // We tried, but this doesn't exist. We can't proceed
73  if (dllName == String.Empty)
74  throw new Exception("No StorageProvider configured");
75 
76  m_database = LoadPlugin<IEstateDataStore>(dllName, new Object[] { connString });
77  if (m_database == null)
78  throw new Exception("Could not find a storage interface in the given module");
79  }
80 
81  public EstateSettings LoadEstateSettings(UUID regionID, bool create)
82  {
83  return m_database.LoadEstateSettings(regionID, create);
84  }
85 
86  public EstateSettings LoadEstateSettings(int estateID)
87  {
88  return m_database.LoadEstateSettings(estateID);
89  }
90 
92  {
93  return m_database.CreateNewEstate();
94  }
95 
96  public List<EstateSettings> LoadEstateSettingsAll()
97  {
98  return m_database.LoadEstateSettingsAll();
99  }
100 
102  {
103  m_database.StoreEstateSettings(es);
104  }
105 
106  public List<int> GetEstates(string search)
107  {
108  return m_database.GetEstates(search);
109  }
110 
111  public List<int> GetEstatesAll()
112  {
113  return m_database.GetEstatesAll();
114  }
115 
116  public List<int> GetEstatesByOwner(UUID ownerID)
117  {
118  return m_database.GetEstatesByOwner(ownerID);
119  }
120 
121  public bool LinkRegion(UUID regionID, int estateID)
122  {
123  return m_database.LinkRegion(regionID, estateID);
124  }
125 
126  public List<UUID> GetRegions(int estateID)
127  {
128  return m_database.GetRegions(estateID);
129  }
130 
131  public bool DeleteEstate(int estateID)
132  {
133  return m_database.DeleteEstate(estateID);
134  }
135  }
136 }
bool LinkRegion(UUID regionID, int estateID)
Link a region to an estate.
EstateSettings LoadEstateSettings(int estateID)
Load estate settings for an estate ID.
List< int > GetEstates(string search)
Get estate IDs.
List< EstateSettings > LoadEstateSettingsAll()
Load/Get all estate settings.
List< int > GetEstatesByOwner(UUID ownerID)
Get the IDs of all estates owned by the given user.
EstateSettings CreateNewEstate()
Create a new estate.
void StoreEstateSettings(EstateSettings es)
Store estate settings.
List< int > GetEstatesAll()
Get the IDs of all estates.
bool DeleteEstate(int estateID)
Delete an estate
Interactive OpenSim region server
Definition: OpenSim.cs:55
List< UUID > GetRegions(int estateID)
Get the UUIDs of all the regions in an estate.
EstateSettings LoadEstateSettings(UUID regionID, bool create)
Load estate settings for a region.