aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJeff Ames2008-06-04 22:31:47 +0000
committerJeff Ames2008-06-04 22:31:47 +0000
commited19c429b1ef6271d46c84cd38e6e22a0acbbc9c (patch)
tree79ea0b41607faf6c56b37dbb99566066c92e24fa /OpenSim
parent* Start writing out assets metadata file for archiver (diff)
downloadopensim-SC-ed19c429b1ef6271d46c84cd38e6e22a0acbbc9c.zip
opensim-SC-ed19c429b1ef6271d46c84cd38e6e22a0acbbc9c.tar.gz
opensim-SC-ed19c429b1ef6271d46c84cd38e6e22a0acbbc9c.tar.bz2
opensim-SC-ed19c429b1ef6271d46c84cd38e6e22a0acbbc9c.tar.xz
Update svn properties.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs258
1 files changed, 129 insertions, 129 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs
index 44757cc..12e1f81 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs
@@ -1,129 +1,129 @@
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
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.IO; 29using System.IO;
30using System.Reflection; 30using System.Reflection;
31using System.Xml; 31using System.Xml;
32using libsecondlife; 32using libsecondlife;
33using log4net; 33using log4net;
34using OpenSim.Framework; 34using OpenSim.Framework;
35 35
36namespace OpenSim.Region.Environment.Modules.World.Archiver 36namespace OpenSim.Region.Environment.Modules.World.Archiver
37{ 37{
38 /// <summary> 38 /// <summary>
39 /// Archives assets 39 /// Archives assets
40 /// </summary> 40 /// </summary>
41 public class AssetsArchiver 41 public class AssetsArchiver
42 { 42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 44
45 /// <summary> 45 /// <summary>
46 /// Archive assets 46 /// Archive assets
47 /// </summary> 47 /// </summary>
48 protected IDictionary<LLUUID, AssetBase> m_assets; 48 protected IDictionary<LLUUID, AssetBase> m_assets;
49 49
50 public AssetsArchiver(IDictionary<LLUUID, AssetBase> assets) 50 public AssetsArchiver(IDictionary<LLUUID, AssetBase> assets)
51 { 51 {
52 m_assets = assets; 52 m_assets = assets;
53 } 53 }
54 54
55 /// <summary> 55 /// <summary>
56 /// Archive the assets given to this archiver to the given archive. 56 /// Archive the assets given to this archiver to the given archive.
57 /// </summary> 57 /// </summary>
58 /// <param name="archive"></param> 58 /// <param name="archive"></param>
59 public void Archive(TarArchiveWriter archive) 59 public void Archive(TarArchiveWriter archive)
60 { 60 {
61 // It appears that gtar, at least, doesn't need the intermediate directory entries in the tar 61 // It appears that gtar, at least, doesn't need the intermediate directory entries in the tar
62 //archive.AddDir("assets"); 62 //archive.AddDir("assets");
63 63
64 WriteMetadata(archive); 64 WriteMetadata(archive);
65 WriteData(archive); 65 WriteData(archive);
66 } 66 }
67 67
68 /// <summary> 68 /// <summary>
69 /// Write an assets metadata file to the given archive 69 /// Write an assets metadata file to the given archive
70 /// </summary> 70 /// </summary>
71 /// <param name="archive"></param> 71 /// <param name="archive"></param>
72 protected void WriteMetadata(TarArchiveWriter archive) 72 protected void WriteMetadata(TarArchiveWriter archive)
73 { 73 {
74 StringWriter sw = new StringWriter(); 74 StringWriter sw = new StringWriter();
75 XmlTextWriter xtw = new XmlTextWriter(sw); 75 XmlTextWriter xtw = new XmlTextWriter(sw);
76 76
77 xtw.Formatting = Formatting.Indented; 77 xtw.Formatting = Formatting.Indented;
78 xtw.WriteStartDocument(); 78 xtw.WriteStartDocument();
79 79
80 xtw.WriteStartElement("assets"); 80 xtw.WriteStartElement("assets");
81 81
82 foreach (LLUUID uuid in m_assets.Keys) 82 foreach (LLUUID uuid in m_assets.Keys)
83 { 83 {
84 if (m_assets[uuid] != null) 84 if (m_assets[uuid] != null)
85 { 85 {
86 xtw.WriteStartElement("asset"); 86 xtw.WriteStartElement("asset");
87 87
88 AssetBase asset = m_assets[uuid]; 88 AssetBase asset = m_assets[uuid];
89 89
90 xtw.WriteElementString("filename", uuid.ToString() + ArchiveConstants.TEXTURE_EXTENSION); 90 xtw.WriteElementString("filename", uuid.ToString() + ArchiveConstants.TEXTURE_EXTENSION);
91 xtw.WriteElementString("name", asset.Name); 91 xtw.WriteElementString("name", asset.Name);
92 xtw.WriteElementString("description", asset.Description); 92 xtw.WriteElementString("description", asset.Description);
93 xtw.WriteElementString("asset-type", asset.Type.ToString()); 93 xtw.WriteElementString("asset-type", asset.Type.ToString());
94 xtw.WriteElementString("inventory-type", asset.InvType.ToString()); 94 xtw.WriteElementString("inventory-type", asset.InvType.ToString());
95 95
96 xtw.WriteEndElement(); 96 xtw.WriteEndElement();
97 } 97 }
98 98
99 } 99 }
100 100
101 xtw.WriteEndElement(); 101 xtw.WriteEndElement();
102 102
103 xtw.WriteEndDocument(); 103 xtw.WriteEndDocument();
104 104
105 archive.AddFile("assets.xml", sw.ToString()); 105 archive.AddFile("assets.xml", sw.ToString());
106 } 106 }
107 107
108 /// <summary> 108 /// <summary>
109 /// Write asset data files to the given archive 109 /// Write asset data files to the given archive
110 /// </summary> 110 /// </summary>
111 /// <param name="archive"></param> 111 /// <param name="archive"></param>
112 protected void WriteData(TarArchiveWriter archive) 112 protected void WriteData(TarArchiveWriter archive)
113 { 113 {
114 foreach (LLUUID uuid in m_assets.Keys) 114 foreach (LLUUID uuid in m_assets.Keys)
115 { 115 {
116 if (m_assets[uuid] != null) 116 if (m_assets[uuid] != null)
117 { 117 {
118 archive.AddFile( 118 archive.AddFile(
119 ArchiveConstants.TEXTURES_PATH + uuid.ToString() + ArchiveConstants.TEXTURE_EXTENSION, 119 ArchiveConstants.TEXTURES_PATH + uuid.ToString() + ArchiveConstants.TEXTURE_EXTENSION,
120 m_assets[uuid].Data); 120 m_assets[uuid].Data);
121 } 121 }
122 else 122 else
123 { 123 {
124 m_log.DebugFormat("[ARCHIVER]: Could not find asset {0} to archive", uuid); 124 m_log.DebugFormat("[ARCHIVER]: Could not find asset {0} to archive", uuid);
125 } 125 }
126 } 126 }
127 } 127 }
128 } 128 }
129} 129}