aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/NHibernate/NHibernateAssetData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/NHibernate/NHibernateAssetData.cs')
-rw-r--r--OpenSim/Data/NHibernate/NHibernateAssetData.cs48
1 files changed, 33 insertions, 15 deletions
diff --git a/OpenSim/Data/NHibernate/NHibernateAssetData.cs b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
index 875f4e5..4eb9eef 100644
--- a/OpenSim/Data/NHibernate/NHibernateAssetData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
@@ -60,7 +60,8 @@ namespace OpenSim.Data.NHibernate
60 // Split out the dialect, driver, and connect string 60 // Split out the dialect, driver, and connect string
61 char[] split = {';'}; 61 char[] split = {';'};
62 string[] parts = connect.Split(split, 3); 62 string[] parts = connect.Split(split, 3);
63 if (parts.Length != 3) { 63 if (parts.Length != 3)
64 {
64 // TODO: make this a real exception type 65 // TODO: make this a real exception type
65 throw new Exception("Malformed Inventory connection string '" + connect + "'"); 66 throw new Exception("Malformed Inventory connection string '" + connect + "'");
66 } 67 }
@@ -96,15 +97,22 @@ namespace OpenSim.Data.NHibernate
96 { 97 {
97 string regex = @"no such table: Assets"; 98 string regex = @"no such table: Assets";
98 Regex RE = new Regex(regex, RegexOptions.Multiline); 99 Regex RE = new Regex(regex, RegexOptions.Multiline);
99 try { 100 try
100 using (ISession session = factory.OpenSession()) { 101 {
102 using (ISession session = factory.OpenSession())
103 {
101 session.Load(typeof(AssetBase), LLUUID.Zero); 104 session.Load(typeof(AssetBase), LLUUID.Zero);
102 } 105 }
103 } catch (ObjectNotFoundException) { 106 }
107 catch (ObjectNotFoundException)
108 {
104 // yes, we know it's not there, but that's ok 109 // yes, we know it's not there, but that's ok
105 } catch (ADOException e) { 110 }
111 catch (ADOException e)
112 {
106 Match m = RE.Match(e.ToString()); 113 Match m = RE.Match(e.ToString());
107 if (m.Success) { 114 if (m.Success)
115 {
108 // We don't have this table, so create it. 116 // We don't have this table, so create it.
109 new SchemaExport(cfg).Create(true, true); 117 new SchemaExport(cfg).Create(true, true);
110 } 118 }
@@ -113,10 +121,14 @@ namespace OpenSim.Data.NHibernate
113 121
114 override public AssetBase FetchAsset(LLUUID uuid) 122 override public AssetBase FetchAsset(LLUUID uuid)
115 { 123 {
116 using (ISession session = factory.OpenSession()) { 124 using (ISession session = factory.OpenSession())
117 try { 125 {
126 try
127 {
118 return session.Load(typeof(AssetBase), uuid) as AssetBase; 128 return session.Load(typeof(AssetBase), uuid) as AssetBase;
119 } catch { 129 }
130 catch
131 {
120 return null; 132 return null;
121 } 133 }
122 } 134 }
@@ -124,9 +136,12 @@ namespace OpenSim.Data.NHibernate
124 136
125 override public void CreateAsset(AssetBase asset) 137 override public void CreateAsset(AssetBase asset)
126 { 138 {
127 if (!ExistsAsset(asset.FullID)) { 139 if (!ExistsAsset(asset.FullID))
128 using (ISession session = factory.OpenSession()) { 140 {
129 using (ITransaction transaction = session.BeginTransaction()) { 141 using (ISession session = factory.OpenSession())
142 {
143 using (ITransaction transaction = session.BeginTransaction())
144 {
130 session.Save(asset); 145 session.Save(asset);
131 transaction.Commit(); 146 transaction.Commit();
132 } 147 }
@@ -136,9 +151,12 @@ namespace OpenSim.Data.NHibernate
136 151
137 override public void UpdateAsset(AssetBase asset) 152 override public void UpdateAsset(AssetBase asset)
138 { 153 {
139 if (ExistsAsset(asset.FullID)) { 154 if (ExistsAsset(asset.FullID))
140 using (ISession session = factory.OpenSession()) { 155 {
141 using (ITransaction transaction = session.BeginTransaction()) { 156 using (ISession session = factory.OpenSession())
157 {
158 using (ITransaction transaction = session.BeginTransaction())
159 {
142 session.Update(asset); 160 session.Update(asset);
143 transaction.Commit(); 161 transaction.Commit();
144 } 162 }