aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs
diff options
context:
space:
mode:
authorSean Dague2007-10-19 20:28:18 +0000
committerSean Dague2007-10-19 20:28:18 +0000
commitd4bb430f78d9a70137957c8fe42de8fa620597ef (patch)
tree49612ce0a47acaedfa826d33edbe200c4c2d8b3c /OpenSim/Framework/Data.MySQL/MySQLAssetData.cs
parentchanges to pass nini config object to the modules that get (diff)
downloadopensim-SC_OLD-d4bb430f78d9a70137957c8fe42de8fa620597ef.zip
opensim-SC_OLD-d4bb430f78d9a70137957c8fe42de8fa620597ef.tar.gz
opensim-SC_OLD-d4bb430f78d9a70137957c8fe42de8fa620597ef.tar.bz2
opensim-SC_OLD-d4bb430f78d9a70137957c8fe42de8fa620597ef.tar.xz
get rid of all the ^M line endings
Diffstat (limited to 'OpenSim/Framework/Data.MySQL/MySQLAssetData.cs')
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLAssetData.cs318
1 files changed, 159 insertions, 159 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs
index 5bae4ec..a8f0fdb 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs
@@ -1,159 +1,159 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using MySql.Data.MySqlClient; 31using MySql.Data.MySqlClient;
32 32
33using libsecondlife; 33using libsecondlife;
34using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
35using OpenSim.Framework.Interfaces; 35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Types; 36using OpenSim.Framework.Types;
37 37
38namespace OpenSim.Framework.Data.MySQL 38namespace OpenSim.Framework.Data.MySQL
39{ 39{
40 class MySQLAssetData : IAssetProvider 40 class MySQLAssetData : IAssetProvider
41 { 41 {
42 MySQLManager _dbConnection; 42 MySQLManager _dbConnection;
43 #region IAssetProvider Members 43 #region IAssetProvider Members
44 44
45 private void UpgradeAssetsTable(string oldVersion) 45 private void UpgradeAssetsTable(string oldVersion)
46 { 46 {
47 // null as the version, indicates that the table didn't exist 47 // null as the version, indicates that the table didn't exist
48 if (oldVersion == null) 48 if (oldVersion == null)
49 { 49 {
50 MainLog.Instance.Notice("ASSETS", "Creating new database tables"); 50 MainLog.Instance.Notice("ASSETS", "Creating new database tables");
51 _dbConnection.ExecuteResourceSql("CreateAssetsTable.sql"); 51 _dbConnection.ExecuteResourceSql("CreateAssetsTable.sql");
52 return; 52 return;
53 } 53 }
54 } 54 }
55 55
56 /// <summary> 56 /// <summary>
57 /// Ensure that the assets related tables exists and are at the latest version 57 /// Ensure that the assets related tables exists and are at the latest version
58 /// </summary> 58 /// </summary>
59 private void TestTables() 59 private void TestTables()
60 { 60 {
61 61
62 Dictionary<string, string> tableList = new Dictionary<string, string>(); 62 Dictionary<string, string> tableList = new Dictionary<string, string>();
63 63
64 tableList["assets"] = null; 64 tableList["assets"] = null;
65 _dbConnection.GetTableVersion(tableList); 65 _dbConnection.GetTableVersion(tableList);
66 66
67 UpgradeAssetsTable(tableList["assets"]); 67 UpgradeAssetsTable(tableList["assets"]);
68 68
69 } 69 }
70 70
71 public AssetBase FetchAsset(LLUUID assetID) 71 public AssetBase FetchAsset(LLUUID assetID)
72 { 72 {
73 AssetBase asset = null; 73 AssetBase asset = null;
74 74
75 MySqlCommand cmd = new MySqlCommand("SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id", _dbConnection.Connection); 75 MySqlCommand cmd = new MySqlCommand("SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id", _dbConnection.Connection);
76 MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); 76 MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16);
77 p.Value = assetID.GetBytes(); 77 p.Value = assetID.GetBytes();
78 using (MySqlDataReader dbReader = cmd.ExecuteReader(System.Data.CommandBehavior.SingleRow)) 78 using (MySqlDataReader dbReader = cmd.ExecuteReader(System.Data.CommandBehavior.SingleRow))
79 { 79 {
80 if (dbReader.Read()) 80 if (dbReader.Read())
81 { 81 {
82 asset = new AssetBase(); 82 asset = new AssetBase();
83 asset.Data = (byte[])dbReader["data"]; 83 asset.Data = (byte[])dbReader["data"];
84 asset.Description = (string)dbReader["description"]; 84 asset.Description = (string)dbReader["description"];
85 asset.FullID = assetID; 85 asset.FullID = assetID;
86 asset.InvType = (sbyte)dbReader["invType"]; 86 asset.InvType = (sbyte)dbReader["invType"];
87 asset.Local = ((sbyte)dbReader["local"]) != 0 ? true : false; 87 asset.Local = ((sbyte)dbReader["local"]) != 0 ? true : false;
88 asset.Name = (string)dbReader["name"]; 88 asset.Name = (string)dbReader["name"];
89 asset.Type = (sbyte)dbReader["assetType"]; 89 asset.Type = (sbyte)dbReader["assetType"];
90 } 90 }
91 } 91 }
92 return asset; 92 return asset;
93 } 93 }
94 94
95 public void CreateAsset(AssetBase asset) 95 public void CreateAsset(AssetBase asset)
96 { 96 {
97 MySqlCommand cmd = new MySqlCommand("REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" + 97 MySqlCommand cmd = new MySqlCommand("REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" +
98 "VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)", _dbConnection.Connection); 98 "VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)", _dbConnection.Connection);
99 MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); 99 MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16);
100 p.Value = asset.FullID.GetBytes(); 100 p.Value = asset.FullID.GetBytes();
101 cmd.Parameters.AddWithValue("?name", asset.Name); 101 cmd.Parameters.AddWithValue("?name", asset.Name);
102 cmd.Parameters.AddWithValue("?description", asset.Description); 102 cmd.Parameters.AddWithValue("?description", asset.Description);
103 cmd.Parameters.AddWithValue("?assetType", asset.Type); 103 cmd.Parameters.AddWithValue("?assetType", asset.Type);
104 cmd.Parameters.AddWithValue("?invType", asset.InvType); 104 cmd.Parameters.AddWithValue("?invType", asset.InvType);
105 cmd.Parameters.AddWithValue("?local", asset.Local); 105 cmd.Parameters.AddWithValue("?local", asset.Local);
106 cmd.Parameters.AddWithValue("?temporary", asset.Temporary); 106 cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
107 cmd.Parameters.AddWithValue("?data", asset.Data); 107 cmd.Parameters.AddWithValue("?data", asset.Data);
108 cmd.ExecuteNonQuery(); 108 cmd.ExecuteNonQuery();
109 } 109 }
110 110
111 public void UpdateAsset(AssetBase asset) 111 public void UpdateAsset(AssetBase asset)
112 { 112 {
113 CreateAsset(asset); 113 CreateAsset(asset);
114 } 114 }
115 115
116 public bool ExistsAsset(LLUUID uuid) 116 public bool ExistsAsset(LLUUID uuid)
117 { 117 {
118 throw new Exception("The method or operation is not implemented."); 118 throw new Exception("The method or operation is not implemented.");
119 } 119 }
120 120
121 /// <summary> 121 /// <summary>
122 /// All writes are immediately commited to the database, so this is a no-op 122 /// All writes are immediately commited to the database, so this is a no-op
123 /// </summary> 123 /// </summary>
124 public void CommitAssets() 124 public void CommitAssets()
125 { 125 {
126 } 126 }
127 127
128 #endregion 128 #endregion
129 129
130 #region IPlugin Members 130 #region IPlugin Members
131 131
132 public void Initialise() 132 public void Initialise()
133 { 133 {
134 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); 134 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
135 string hostname = GridDataMySqlFile.ParseFileReadValue("hostname"); 135 string hostname = GridDataMySqlFile.ParseFileReadValue("hostname");
136 string database = GridDataMySqlFile.ParseFileReadValue("database"); 136 string database = GridDataMySqlFile.ParseFileReadValue("database");
137 string username = GridDataMySqlFile.ParseFileReadValue("username"); 137 string username = GridDataMySqlFile.ParseFileReadValue("username");
138 string password = GridDataMySqlFile.ParseFileReadValue("password"); 138 string password = GridDataMySqlFile.ParseFileReadValue("password");
139 string pooling = GridDataMySqlFile.ParseFileReadValue("pooling"); 139 string pooling = GridDataMySqlFile.ParseFileReadValue("pooling");
140 string port = GridDataMySqlFile.ParseFileReadValue("port"); 140 string port = GridDataMySqlFile.ParseFileReadValue("port");
141 141
142 _dbConnection = new MySQLManager(hostname, database, username, password, pooling, port); 142 _dbConnection = new MySQLManager(hostname, database, username, password, pooling, port);
143 143
144 TestTables(); 144 TestTables();
145 } 145 }
146 146
147 public string Version 147 public string Version
148 { 148 {
149 get { return _dbConnection.getVersion(); } 149 get { return _dbConnection.getVersion(); }
150 } 150 }
151 151
152 public string Name 152 public string Name
153 { 153 {
154 get { return "MySQL Asset storage engine"; } 154 get { return "MySQL Asset storage engine"; }
155 } 155 }
156 156
157 #endregion 157 #endregion
158 } 158 }
159} 159}