removes extremely silly try catch all when using the packager - why was this here !? So that nobody would ever know why creating their package failed?
This commit is contained in:
@@ -102,213 +102,205 @@ namespace umbraco.cms.businesslogic.packager
|
||||
var package = this;
|
||||
var pack = package.Data;
|
||||
|
||||
try
|
||||
var e = new PublishEventArgs();
|
||||
package.FireBeforePublish(e);
|
||||
|
||||
if (e.Cancel == false)
|
||||
{
|
||||
var outInt = 0;
|
||||
|
||||
var e = new PublishEventArgs();
|
||||
package.FireBeforePublish(e);
|
||||
//Path checking...
|
||||
var localPath = IOHelper.MapPath(SystemDirectories.Media + "/" + pack.Folder);
|
||||
|
||||
if (e.Cancel == false)
|
||||
if (Directory.Exists(localPath) == false)
|
||||
Directory.CreateDirectory(localPath);
|
||||
|
||||
//Init package file...
|
||||
CreatePackageManifest();
|
||||
//Info section..
|
||||
AppendElement(utill.PackageInfo(pack, _packageManifest));
|
||||
|
||||
//Documents...
|
||||
var contentNodeId = 0;
|
||||
if (string.IsNullOrEmpty(pack.ContentNodeId) == false && int.TryParse(pack.ContentNodeId, out contentNodeId))
|
||||
{
|
||||
var outInt = 0;
|
||||
XmlNode documents = _packageManifest.CreateElement("Documents");
|
||||
|
||||
//Path checking...
|
||||
var localPath = IOHelper.MapPath(SystemDirectories.Media + "/" + pack.Folder);
|
||||
XmlNode documentSet = _packageManifest.CreateElement("DocumentSet");
|
||||
XmlAttribute importMode = _packageManifest.CreateAttribute("importMode", "");
|
||||
importMode.Value = "root";
|
||||
documentSet.Attributes.Append(importMode);
|
||||
documents.AppendChild(documentSet);
|
||||
|
||||
if (Directory.Exists(localPath) == false)
|
||||
Directory.CreateDirectory(localPath);
|
||||
//load content from umbraco.
|
||||
var umbDocument = new Document(contentNodeId);
|
||||
documentSet.AppendChild(umbDocument.ToXml(_packageManifest, pack.ContentLoadChildNodes));
|
||||
|
||||
//Init package file...
|
||||
CreatePackageManifest();
|
||||
//Info section..
|
||||
AppendElement(utill.PackageInfo(pack, _packageManifest));
|
||||
|
||||
//Documents...
|
||||
var contentNodeId = 0;
|
||||
if (string.IsNullOrEmpty(pack.ContentNodeId) == false && int.TryParse(pack.ContentNodeId, out contentNodeId))
|
||||
{
|
||||
XmlNode documents = _packageManifest.CreateElement("Documents");
|
||||
|
||||
XmlNode documentSet = _packageManifest.CreateElement("DocumentSet");
|
||||
XmlAttribute importMode = _packageManifest.CreateAttribute("importMode", "");
|
||||
importMode.Value = "root";
|
||||
documentSet.Attributes.Append(importMode);
|
||||
documents.AppendChild(documentSet);
|
||||
|
||||
//load content from umbraco.
|
||||
var umbDocument = new Document(contentNodeId);
|
||||
documentSet.AppendChild(umbDocument.ToXml(_packageManifest, pack.ContentLoadChildNodes));
|
||||
|
||||
AppendElement(documents);
|
||||
}
|
||||
|
||||
//Document types..
|
||||
var dtl = new List<DocumentType>();
|
||||
var docTypes = _packageManifest.CreateElement("DocumentTypes");
|
||||
foreach (var dtId in pack.Documenttypes)
|
||||
{
|
||||
if (int.TryParse(dtId, out outInt))
|
||||
{
|
||||
DocumentType docT = new DocumentType(outInt);
|
||||
|
||||
AddDocumentType(docT, ref dtl);
|
||||
|
||||
}
|
||||
}
|
||||
foreach (DocumentType d in dtl)
|
||||
{
|
||||
docTypes.AppendChild(d.ToXml(_packageManifest));
|
||||
}
|
||||
|
||||
AppendElement(docTypes);
|
||||
|
||||
//Templates
|
||||
var templates = _packageManifest.CreateElement("Templates");
|
||||
foreach (var templateId in pack.Templates)
|
||||
{
|
||||
if (int.TryParse(templateId, out outInt))
|
||||
{
|
||||
var t = new Template(outInt);
|
||||
templates.AppendChild(t.ToXml(_packageManifest));
|
||||
}
|
||||
}
|
||||
AppendElement(templates);
|
||||
|
||||
//Stylesheets
|
||||
var stylesheets = _packageManifest.CreateElement("Stylesheets");
|
||||
foreach (var ssId in pack.Stylesheets)
|
||||
{
|
||||
if (int.TryParse(ssId, out outInt))
|
||||
{
|
||||
var s = new StyleSheet(outInt);
|
||||
stylesheets.AppendChild(s.ToXml(_packageManifest));
|
||||
}
|
||||
}
|
||||
AppendElement(stylesheets);
|
||||
|
||||
//Macros
|
||||
var macros = _packageManifest.CreateElement("Macros");
|
||||
foreach (var macroId in pack.Macros)
|
||||
{
|
||||
if (int.TryParse(macroId, out outInt))
|
||||
{
|
||||
macros.AppendChild(utill.Macro(int.Parse(macroId), true, localPath, _packageManifest));
|
||||
}
|
||||
}
|
||||
AppendElement(macros);
|
||||
|
||||
//Dictionary Items
|
||||
var dictionaryItems = _packageManifest.CreateElement("DictionaryItems");
|
||||
foreach (var dictionaryId in pack.DictionaryItems)
|
||||
{
|
||||
if (int.TryParse(dictionaryId, out outInt))
|
||||
{
|
||||
var di = new Dictionary.DictionaryItem(outInt);
|
||||
dictionaryItems.AppendChild(di.ToXml(_packageManifest));
|
||||
}
|
||||
}
|
||||
AppendElement(dictionaryItems);
|
||||
|
||||
//Languages
|
||||
var languages = _packageManifest.CreateElement("Languages");
|
||||
foreach (var langId in pack.Languages)
|
||||
{
|
||||
if (int.TryParse(langId, out outInt))
|
||||
{
|
||||
var lang = new language.Language(outInt);
|
||||
|
||||
languages.AppendChild(lang.ToXml(_packageManifest));
|
||||
}
|
||||
}
|
||||
AppendElement(languages);
|
||||
|
||||
//Datatypes
|
||||
var dataTypes = _packageManifest.CreateElement("DataTypes");
|
||||
foreach (var dtId in pack.DataTypes)
|
||||
{
|
||||
if (int.TryParse(dtId, out outInt))
|
||||
{
|
||||
datatype.DataTypeDefinition dtd = new datatype.DataTypeDefinition(outInt);
|
||||
dataTypes.AppendChild(dtd.ToXml(_packageManifest));
|
||||
}
|
||||
}
|
||||
AppendElement(dataTypes);
|
||||
|
||||
//Files
|
||||
foreach (var fileName in pack.Files)
|
||||
{
|
||||
utill.AppendFileToManifest(fileName, localPath, _packageManifest);
|
||||
}
|
||||
|
||||
//Load control on install...
|
||||
if (string.IsNullOrEmpty(pack.LoadControl) == false)
|
||||
{
|
||||
XmlNode control = _packageManifest.CreateElement("control");
|
||||
control.InnerText = pack.LoadControl;
|
||||
utill.AppendFileToManifest(pack.LoadControl, localPath, _packageManifest);
|
||||
AppendElement(control);
|
||||
}
|
||||
|
||||
//Actions
|
||||
if (string.IsNullOrEmpty(pack.Actions) == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var xdActions = new XmlDocument();
|
||||
xdActions.LoadXml("<Actions>" + pack.Actions + "</Actions>");
|
||||
var actions = xdActions.DocumentElement.SelectSingleNode(".");
|
||||
|
||||
|
||||
if (actions != null)
|
||||
{
|
||||
actions = _packageManifest.ImportNode(actions, true).Clone();
|
||||
AppendElement(actions);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
var manifestFileName = localPath + "/package.xml";
|
||||
|
||||
if (File.Exists(manifestFileName))
|
||||
File.Delete(manifestFileName);
|
||||
|
||||
_packageManifest.Save(manifestFileName);
|
||||
_packageManifest = null;
|
||||
|
||||
|
||||
//string packPath = Settings.PackagerRoot.Replace(System.IO.Path.DirectorySeparatorChar.ToString(), "/") + "/" + pack.Name.Replace(' ', '_') + "_" + pack.Version.Replace(' ', '_') + "." + Settings.PackageFileExtension;
|
||||
|
||||
// check if there's a packages directory below media
|
||||
var packagesDirectory = SystemDirectories.Media + "/created-packages";
|
||||
if (Directory.Exists(IOHelper.MapPath(packagesDirectory)) == false)
|
||||
{
|
||||
Directory.CreateDirectory(IOHelper.MapPath(packagesDirectory));
|
||||
}
|
||||
|
||||
|
||||
var packPath = packagesDirectory + "/" + (pack.Name + "_" + pack.Version).Replace(' ', '_') + "." + Settings.PackageFileExtension;
|
||||
utill.ZipPackage(localPath, IOHelper.MapPath(packPath));
|
||||
|
||||
pack.PackagePath = packPath;
|
||||
|
||||
if (pack.PackageGuid.Trim() == "")
|
||||
pack.PackageGuid = Guid.NewGuid().ToString();
|
||||
|
||||
package.Save();
|
||||
|
||||
//Clean up..
|
||||
File.Delete(localPath + "/package.xml");
|
||||
Directory.Delete(localPath, true);
|
||||
|
||||
package.FireAfterPublish(e);
|
||||
AppendElement(documents);
|
||||
}
|
||||
|
||||
//Document types..
|
||||
var dtl = new List<DocumentType>();
|
||||
var docTypes = _packageManifest.CreateElement("DocumentTypes");
|
||||
foreach (var dtId in pack.Documenttypes)
|
||||
{
|
||||
if (int.TryParse(dtId, out outInt))
|
||||
{
|
||||
DocumentType docT = new DocumentType(outInt);
|
||||
|
||||
AddDocumentType(docT, ref dtl);
|
||||
|
||||
}
|
||||
}
|
||||
foreach (DocumentType d in dtl)
|
||||
{
|
||||
docTypes.AppendChild(d.ToXml(_packageManifest));
|
||||
}
|
||||
|
||||
AppendElement(docTypes);
|
||||
|
||||
//Templates
|
||||
var templates = _packageManifest.CreateElement("Templates");
|
||||
foreach (var templateId in pack.Templates)
|
||||
{
|
||||
if (int.TryParse(templateId, out outInt))
|
||||
{
|
||||
var t = new Template(outInt);
|
||||
templates.AppendChild(t.ToXml(_packageManifest));
|
||||
}
|
||||
}
|
||||
AppendElement(templates);
|
||||
|
||||
//Stylesheets
|
||||
var stylesheets = _packageManifest.CreateElement("Stylesheets");
|
||||
foreach (var ssId in pack.Stylesheets)
|
||||
{
|
||||
if (int.TryParse(ssId, out outInt))
|
||||
{
|
||||
var s = new StyleSheet(outInt);
|
||||
stylesheets.AppendChild(s.ToXml(_packageManifest));
|
||||
}
|
||||
}
|
||||
AppendElement(stylesheets);
|
||||
|
||||
//Macros
|
||||
var macros = _packageManifest.CreateElement("Macros");
|
||||
foreach (var macroId in pack.Macros)
|
||||
{
|
||||
if (int.TryParse(macroId, out outInt))
|
||||
{
|
||||
macros.AppendChild(utill.Macro(int.Parse(macroId), true, localPath, _packageManifest));
|
||||
}
|
||||
}
|
||||
AppendElement(macros);
|
||||
|
||||
//Dictionary Items
|
||||
var dictionaryItems = _packageManifest.CreateElement("DictionaryItems");
|
||||
foreach (var dictionaryId in pack.DictionaryItems)
|
||||
{
|
||||
if (int.TryParse(dictionaryId, out outInt))
|
||||
{
|
||||
var di = new Dictionary.DictionaryItem(outInt);
|
||||
dictionaryItems.AppendChild(di.ToXml(_packageManifest));
|
||||
}
|
||||
}
|
||||
AppendElement(dictionaryItems);
|
||||
|
||||
//Languages
|
||||
var languages = _packageManifest.CreateElement("Languages");
|
||||
foreach (var langId in pack.Languages)
|
||||
{
|
||||
if (int.TryParse(langId, out outInt))
|
||||
{
|
||||
var lang = new language.Language(outInt);
|
||||
|
||||
languages.AppendChild(lang.ToXml(_packageManifest));
|
||||
}
|
||||
}
|
||||
AppendElement(languages);
|
||||
|
||||
//Datatypes
|
||||
var dataTypes = _packageManifest.CreateElement("DataTypes");
|
||||
foreach (var dtId in pack.DataTypes)
|
||||
{
|
||||
if (int.TryParse(dtId, out outInt))
|
||||
{
|
||||
datatype.DataTypeDefinition dtd = new datatype.DataTypeDefinition(outInt);
|
||||
dataTypes.AppendChild(dtd.ToXml(_packageManifest));
|
||||
}
|
||||
}
|
||||
AppendElement(dataTypes);
|
||||
|
||||
//Files
|
||||
foreach (var fileName in pack.Files)
|
||||
{
|
||||
utill.AppendFileToManifest(fileName, localPath, _packageManifest);
|
||||
}
|
||||
|
||||
//Load control on install...
|
||||
if (string.IsNullOrEmpty(pack.LoadControl) == false)
|
||||
{
|
||||
XmlNode control = _packageManifest.CreateElement("control");
|
||||
control.InnerText = pack.LoadControl;
|
||||
utill.AppendFileToManifest(pack.LoadControl, localPath, _packageManifest);
|
||||
AppendElement(control);
|
||||
}
|
||||
|
||||
//Actions
|
||||
if (string.IsNullOrEmpty(pack.Actions) == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var xdActions = new XmlDocument();
|
||||
xdActions.LoadXml("<Actions>" + pack.Actions + "</Actions>");
|
||||
var actions = xdActions.DocumentElement.SelectSingleNode(".");
|
||||
|
||||
|
||||
if (actions != null)
|
||||
{
|
||||
actions = _packageManifest.ImportNode(actions, true).Clone();
|
||||
AppendElement(actions);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
var manifestFileName = localPath + "/package.xml";
|
||||
|
||||
if (File.Exists(manifestFileName))
|
||||
File.Delete(manifestFileName);
|
||||
|
||||
_packageManifest.Save(manifestFileName);
|
||||
_packageManifest = null;
|
||||
|
||||
|
||||
//string packPath = Settings.PackagerRoot.Replace(System.IO.Path.DirectorySeparatorChar.ToString(), "/") + "/" + pack.Name.Replace(' ', '_') + "_" + pack.Version.Replace(' ', '_') + "." + Settings.PackageFileExtension;
|
||||
|
||||
// check if there's a packages directory below media
|
||||
var packagesDirectory = SystemDirectories.Media + "/created-packages";
|
||||
if (Directory.Exists(IOHelper.MapPath(packagesDirectory)) == false)
|
||||
{
|
||||
Directory.CreateDirectory(IOHelper.MapPath(packagesDirectory));
|
||||
}
|
||||
|
||||
|
||||
var packPath = packagesDirectory + "/" + (pack.Name + "_" + pack.Version).Replace(' ', '_') + "." + Settings.PackageFileExtension;
|
||||
utill.ZipPackage(localPath, IOHelper.MapPath(packPath));
|
||||
|
||||
pack.PackagePath = packPath;
|
||||
|
||||
if (pack.PackageGuid.Trim() == "")
|
||||
pack.PackageGuid = Guid.NewGuid().ToString();
|
||||
|
||||
package.Save();
|
||||
|
||||
//Clean up..
|
||||
File.Delete(localPath + "/package.xml");
|
||||
Directory.Delete(localPath, true);
|
||||
|
||||
package.FireAfterPublish(e);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<CreatedPackage>("An error occurred", ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void AddDocumentType(DocumentType dt, ref List<DocumentType> dtl)
|
||||
|
||||
Reference in New Issue
Block a user