Removes all MyGet dependencies for UmbracoExamine (since it is in the core now).

Converts UmbracoContextService and UmbracoMediaService for UmbracoExamine to use the new data api's
to extract latest data. Currently had to hack a bit with a new class called LegacyLibrary because at the moment
we'll have a circular dependency with Umbraco.Web which needs to be fixed. Moves all Examine event management to
Umbraco.Web (again mainly because of circular dependencies, but makes sense to have it there). Fixes the ExamineEvents
to implement IApplicationEventHandler instead of IApplicationStartupHandler to ensure that all resolvers have been
initialized before attempting to initialize examine indexes. Updates Examine ILogService to use the LogHelper.
Adds some new ContentExtensions for IMedia since currently Examine needs xml structures, but have kept it internal.
This commit is contained in:
Shannon Deminick
2013-01-05 22:46:50 +03:00
parent 6513097d38
commit 8b49d2d377
20 changed files with 570 additions and 367 deletions

View File

@@ -345,6 +345,18 @@ namespace Umbraco.Core.Models
return new Tuple<int, int, string>(widthTh, heightTh, newFileName);
}
/// <summary>
/// Gets the <see cref="IProfile"/> for the Creator of this media item.
/// </summary>
public static IProfile GetCreatorProfile(this IMedia media)
{
using (var repository = RepositoryResolver.Current.Factory.CreateUserRepository(
PetaPocoUnitOfWorkProvider.CreateUnitOfWork()))
{
return repository.GetProfileById(media.CreatorId);
}
}
/// <summary>
/// Gets the <see cref="IProfile"/> for the Creator of this content.
/// </summary>
@@ -389,43 +401,79 @@ namespace Umbraco.Core.Models
/// <returns>Xml representation of the passed in <see cref="IContent"/></returns>
public static XElement ToXml(this IContent content)
{
//nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias);
//var nodeName = content.ContentType.Alias.ToUmbracoAlias(StringAliasCaseType.CamelCase, true);
var nodeName = content.ContentType.Alias;
var niceUrl = content.Name.FormatUrl().ToLower();
var xml = new XElement(nodeName,
new XAttribute("id", content.Id),
new XAttribute("parentID", content.Level > 1 ? content.ParentId : -1),
new XAttribute("level", content.Level),
new XAttribute("writerID", content.WriterId),
new XAttribute("creatorID", content.CreatorId),
new XAttribute("nodeType", content.ContentType.Id),
new XAttribute("template", content.Template == null ? "0" : content.Template.Id.ToString()),
new XAttribute("sortOrder", content.SortOrder),
new XAttribute("createDate", content.CreateDate.ToString("s")),
new XAttribute("updateDate", content.UpdateDate.ToString("s")),
new XAttribute("nodeName", content.Name),
new XAttribute("urlName", niceUrl),//Format Url ?
new XAttribute("writerName", content.GetWriterProfile().Name),
new XAttribute("creatorName", content.GetCreatorProfile().Name),
new XAttribute("path", content.Path),
new XAttribute("isDoc", ""));
//nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias);
//var nodeName = content.ContentType.Alias.ToUmbracoAlias(StringAliasCaseType.CamelCase, true);
var nodeName = content.ContentType.Alias;
foreach (var property in content.Properties)
{
if (property == null) continue;
var x = content.ToXml(nodeName);
x.Add(new XAttribute("nodeType", content.ContentType.Id));
x.Add(new XAttribute("creatorName", content.GetCreatorProfile().Name));
x.Add(new XAttribute("writerName", content.GetWriterProfile().Name));
x.Add(new XAttribute("writerID", content.WriterId));
x.Add(new XAttribute("template", content.Template == null ? "0" : content.Template.Id.ToString()));
xml.Add(property.ToXml());
return x;
//Check for umbracoUrlName convention
if (property.Alias == "umbracoUrlName" && property.Value.ToString().Trim() != string.Empty)
xml.SetAttributeValue("urlName", property.Value);
}
return xml;
}
/// <summary>
/// Creates the xml representation for the <see cref="IMedia"/> object
/// </summary>
/// <param name="media"><see cref="IContent"/> to generate xml for</param>
/// <returns>Xml representation of the passed in <see cref="IContent"/></returns>
internal static XElement ToXml(this IMedia media)
{
//nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias);
//var nodeName = content.ContentType.Alias.ToUmbracoAlias(StringAliasCaseType.CamelCase, true);
var nodeName = media.ContentType.Alias;
var x = media.ToXml(nodeName);
x.Add(new XAttribute("nodeType", media.ContentType.Id));
x.Add(new XAttribute("creatorName", media.GetCreatorProfile().Name));
x.Add(new XAttribute("writerID", 0));
x.Add(new XAttribute("template", 0));
return x;
}
/// <summary>
/// Creates the xml representation for the <see cref="IContentBase"/> object
/// </summary>
/// <param name="contentBase"><see cref="IContent"/> to generate xml for</param>
/// <param name="nodeName"></param>
/// <returns>Xml representation of the passed in <see cref="IContent"/></returns>
private static XElement ToXml(this IContentBase contentBase, string nodeName)
{
var niceUrl = contentBase.Name.FormatUrl().ToLower();
var xml = new XElement(nodeName,
new XAttribute("id", contentBase.Id),
new XAttribute("parentID", contentBase.Level > 1 ? contentBase.ParentId : -1),
new XAttribute("level", contentBase.Level),
new XAttribute("creatorID", contentBase.CreatorId),
new XAttribute("sortOrder", contentBase.SortOrder),
new XAttribute("createDate", contentBase.CreateDate.ToString("s")),
new XAttribute("updateDate", contentBase.UpdateDate.ToString("s")),
new XAttribute("nodeName", contentBase.Name),
new XAttribute("urlName", niceUrl),//Format Url ?
new XAttribute("path", contentBase.Path),
new XAttribute("isDoc", ""));
foreach (var property in contentBase.Properties)
{
if (property == null) continue;
xml.Add(property.ToXml());
//Check for umbracoUrlName convention
if (property.Alias == "umbracoUrlName" && property.Value.ToString().Trim() != string.Empty)
xml.SetAttributeValue("urlName", property.Value);
}
return xml;
}
/// <summary>
/// Creates the xml representation for the <see cref="IContent"/> object
/// </summary>