Skip to content

Commit

Permalink
Merge changes from release branch before release 7.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tusmester committed Feb 2, 2018
2 parents ef0217a + 87549fb commit 88bfa99
Show file tree
Hide file tree
Showing 62 changed files with 3,341 additions and 399 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,4 @@ paket-files/
/src/nuget/snadmin/install-services/scripts/Install_03_Data_Phase1.sql
/src/nuget/snadmin/install-services/scripts/Install_04_Data_Phase2.sql
/src/nuget/snadmin/install-services/scripts/Install_Security.sql
/docs/nlb-environment.md
188 changes: 97 additions & 91 deletions docs/web-token-authentication.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/Configuration/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
[assembly: AssemblyProduct("sensenet ECM")]
[assembly: AssemblyTrademark("Sense/Net Inc.")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("7.0.0.0")]
[assembly: AssemblyFileVersion("7.0.0.0")]
[assembly: AssemblyInformationalVersion("7.0.0")]
[assembly: AssemblyVersion("7.0.1.0")]
[assembly: AssemblyFileVersion("7.0.1.0")]
[assembly: AssemblyInformationalVersion("7.0.1")]

[assembly: ComVisible(false)]
[assembly: Guid("dfbdb163-d9bb-481c-b3fd-e9eb0e37d27d")]
Expand Down
129 changes: 126 additions & 3 deletions src/ContentRepository/Aspect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,43 @@

namespace SenseNet.ContentRepository
{
/// <summary>
/// Provides an additional field set for an individual <see cref="Content"/> in XML
/// format similar to a ContentType definition.
/// </summary>
[ContentHandler]
public class Aspect : GenericContent
{
/// <summary>
/// Defines the XML namespace of the AspectDefinition schema.
/// The value is: "http://schemas.sensenet.com/SenseNet/ContentRepository/AspectDefinition"
/// </summary>
public static readonly string AspectDefinitionXmlNamespace = "http://schemas.sensenet.com/SenseNet/ContentRepository/AspectDefinition";
private static string AspectDefinitionSchemaManifestResourceName = "SenseNet.ContentRepository.Schema.AspectDefinition.xsd";
/// <summary>
/// Defines an empty AspectDefinition.
/// </summary>
public static readonly string DefaultAspectDefinition = String.Concat("<AspectDefinition xmlns='", AspectDefinitionXmlNamespace, "'><Fields /></AspectDefinition>");

private string _displayName;
private string _description;
private string _icon;

/// <summary>
/// Protected member that lets inheriting types access the raw value of the FieldSettings property.
/// </summary>
protected List<FieldSetting> _fieldSettings = new List<FieldSetting>();
private Dictionary<string, PerFieldIndexingInfo> _indexingInfo = new Dictionary<string, PerFieldIndexingInfo>();

// ================================================================================= Properties

/// <summary>
/// Defines a constant value for the name of the AspectDefinition property.
/// </summary>
public const string ASPECTDEFINITION = "AspectDefinition";
/// <summary>
/// Gets or sets the XML source of the AspectDefinition. Persisted as <see cref="RepositoryDataType.Text"/>.
/// </summary>
[RepositoryProperty(ASPECTDEFINITION, RepositoryDataType.Text)]
public string AspectDefinition
{
Expand All @@ -50,15 +71,31 @@ public string AspectDefinition
}
}

/// <summary>
/// Gets the list of <see cref="FieldSetting"/>s defined by the AspectDefinition xml.
/// </summary>
public List<FieldSetting> FieldSettings
{
get { return _fieldSettings; }
}

// ================================================================================= Construction

/// <summary>
/// Initializes a new instance of the <see cref="Aspect"/> class.
/// </summary>
/// <param name="parent">The parent.</param>
public Aspect(Node parent) : this(parent, null) { }
/// <summary>
/// Initializes a new instance of the <see cref="Aspect"/> class.
/// </summary>
/// <param name="parent">The parent.</param>
/// <param name="nodeTypeName">Name of the node type.</param>
public Aspect(Node parent, string nodeTypeName) : base(parent, nodeTypeName) { }
/// <summary>
/// Initializes a new instance of the <see cref="Aspect"/> class in the loading procedure.
/// Do not use this constructor directly from your code.
/// </summary>
protected Aspect(NodeToken nt) : base(nt) { }

private void Build()
Expand Down Expand Up @@ -135,7 +172,11 @@ private FieldSetting CreateNewFieldType(FieldDescriptor fieldInfo)
{
return FieldSetting.Create(fieldInfo, new List<string>(), this);
}
protected virtual void SetFieldSlots()
//UNDONE: Aspect.SetFieldSlots: make this internal or private.
/// <summary>
/// Set field slot indexes and readonly flags for aspect fields.
/// </summary>
protected virtual void SetFieldSlots()
{
// Field slot indices and readonly.
foreach (FieldSetting fieldSetting in this.FieldSettings)
Expand Down Expand Up @@ -192,9 +233,18 @@ protected virtual void SetFieldSlots()

// ================================================================================= Node

/// <summary>
/// Declares a constant for the aspect field separator. The value is: ".".
/// </summary>
public const string ASPECTFIELDSEPARATOR = ".";
private static readonly char[] AspectFieldSeparatorSplitter = ASPECTFIELDSEPARATOR.ToCharArray();

/// <summary>
/// Returns the <see cref="FieldSettings"/> specified by the given fieldName.
/// Return value is null if the <see cref="FieldSettings"/> does not exist.
/// The fieldName structure: {AspectName}.{FieldSettingName}
/// </summary>
/// <param name="fieldName">Full name of the field: {AspectName}.{FieldSettingName}.</param>
public static FieldSetting GetFieldSettingByFieldName(string fieldName)
{
string realFieldName;
Expand All @@ -204,6 +254,14 @@ public static FieldSetting GetFieldSettingByFieldName(string fieldName)
var fieldSetting = aspect.FieldSettings.Where(f => f.Name == realFieldName).FirstOrDefault();
return fieldSetting;
}
/// <summary>
/// Returns an existing <see cref="Aspect"/> by the given full name. If the <see cref="Aspect"/>
/// does not exist, returns null.
/// The Aspect name will be removed from the full name and the remainder will be
/// returned as the real field name output argument.
/// </summary>
/// <param name="fieldName">Full name of the field: {AspectName}.{FieldSettingName}</param>
/// <param name="realFieldName">Output value of the FieldSettingName part of the given fieldName.</param>
public static Aspect LoadAspectByFieldName(string fieldName, out string realFieldName)
{
realFieldName = null;
Expand All @@ -214,8 +272,10 @@ public static Aspect LoadAspectByFieldName(string fieldName, out string realFiel
return LoadAspectByName(sa[0]);
}
/// <summary>
/// Loads an aspect by its name.
/// Returns an existing <see cref="Aspect"/> by the given name.
/// If it is not found, returns null.
/// </summary>
/// <param name="name">Name of the <see cref="Aspect"/>.</param>
public static Aspect LoadAspectByName(string name)
{
// IMPORTANT:
Expand Down Expand Up @@ -245,17 +305,32 @@ public static Aspect LoadAspectByName(string name)

return aspect;
}
/// <summary>
/// Returns an existing <see cref="Aspect"/> by the given parameter.
/// If it is not found, returns null.
/// </summary>
/// <param name="pathOrName">Path or name of the <see cref="Aspect"/>.</param>
public static Aspect LoadAspectByPathOrName(string pathOrName)
{
return pathOrName.Contains('/') ? Node.LoadNode(pathOrName) as Aspect : Aspect.LoadAspectByName(pathOrName);
}
/// <summary>
/// Returns true if the <see cref="Aspect"/> exists.
/// </summary>
/// <param name="name">Name of the <see cref="Aspect"/>.</param>
public static bool AspectExists(string name)
{
if (RepositoryInstance.ContentQueryIsAllowed)
return ContentQuery.Query(SafeQueries.AspectExists, null, name).Count > 0;
return LoadAspectByName(name) != null;
}

/// <summary>
/// Persists the modifications of this Content.
/// Do not use this method directly from your code.
/// If the AspectDefinition is invalid, <see cref="InvalidContentException"/> will be thrown.
/// Also throws an <see cref="InvalidContentException"/> if the Path of the instance is not under the Aspects container.
/// </summary>
public override void Save(SavingMode mode)
{
Validate();
Expand All @@ -282,6 +357,11 @@ private void Validate()
}

private static object _saveSync = new object();
/// <summary>
/// Persist this Content's changes by the given settings.
/// Do not use this method directly from your code.
/// </summary>
/// <param name="settings"><see cref="NodeSaveSettings"/> that contains the persistence algorithm.</param>
public override void Save(NodeSaveSettings settings)
{
if (this.IsNew)
Expand All @@ -307,6 +387,11 @@ public override void Save(NodeSaveSettings settings)
throw new InvalidOperationException(String.Concat("Cannot create new Aspect because another Aspect exists with same name: ", existingAspect.Path));
}

/// <summary>
/// Deletes this <see cref="Aspect"/> permanently.
/// The logged-in user need to have ManageListsAndWorkspaces permission,
/// otherwise <see cref="SenseNetSecurityException"/> will be thrown.
/// </summary>
public override void ForceDelete()
{
Security.Assert(PermissionType.ManageListsAndWorkspaces);
Expand All @@ -315,6 +400,7 @@ public override void ForceDelete()

// ================================================================================= Generic Property handling

/// <inheritdoc/>
public override object GetProperty(string name)
{
switch (name)
Expand All @@ -325,6 +411,7 @@ public override object GetProperty(string name)
return base.GetProperty(name);
}
}
/// <inheritdoc/>
public override void SetProperty(string name, object value)
{
switch (name)
Expand Down Expand Up @@ -365,11 +452,21 @@ private static void CheckValidation(IXPathNavigable xml)

// ================================================================================= Tools

/// <summary>
/// Tool method that returns <see cref="FieldSettings"/> by the specified name from the given list.
/// </summary>
/// <param name="fieldName">Name of the desired <see cref="FieldSettings"/>.</param>
/// <param name="fieldSettings">The list that will be enumerated.</param>
protected static FieldSetting GetFieldTypeByName(string fieldName, List<FieldSetting> fieldSettings)
{
int i = GetFieldTypeIndexByName(fieldName, fieldSettings);
return i < 0 ? null : fieldSettings[i];
}
/// <summary>
/// Tool method that returns the index of the <see cref="FieldSettings"/> by the specified name in the given list.
/// </summary>
/// <param name="fieldName">Index of the desired <see cref="FieldSettings"/> in the given list.</param>
/// <param name="fieldSettings">The list that will be enumerated.</param>
protected static int GetFieldTypeIndexByName(string fieldName, List<FieldSetting> fieldSettings)
{
for (int i = 0; i < fieldSettings.Count; i++)
Expand All @@ -380,6 +477,7 @@ protected static int GetFieldTypeIndexByName(string fieldName, List<FieldSetting

// ================================================================================= Field operations

/// <inheritdoc />
public override List<FieldSetting> GetAvailableFields(bool rootFields)
{
var availableFields = base.GetAvailableFields(rootFields);
Expand All @@ -395,13 +493,21 @@ public override List<FieldSetting> GetAvailableFields(bool rootFields)
return availableFields;
}

/// <summary>
/// Adds one or more new fields to this instance or replaces existing ones and saves the modifications.
/// </summary>
/// <param name="fieldInfos">Array of <see cref="Schema.FieldInfo"/>s that will be added.</param>
public void AddFields(params SenseNet.ContentRepository.Schema.FieldInfo[] fieldInfos)
{
foreach(var fieldInfo in fieldInfos)
AddFieldInternal(FieldSetting.Create(fieldInfo, this));
Build();
Save();
}
/// <summary>
/// Removes the specified fields of his instance and saves the modifications.
/// </summary>
/// <param name="fieldNames">Array of the field names that will be removed.</param>
public void RemoveFields(params string[] fieldNames)
{
foreach(var fieldName in fieldNames)
Expand All @@ -410,6 +516,9 @@ public void RemoveFields(params string[] fieldNames)
Build();
Save();
}
/// <summary>
/// Empties the field collection of this instance and saves it.
/// </summary>
public void RemoveAllfields()
{
AspectDefinition = DefaultAspectDefinition;
Expand Down Expand Up @@ -476,6 +585,10 @@ private XmlNode FindFieldXmlNode(string fieldName, out XmlDocument doc)

private const string FIELDSETTINGSKEY = "FieldSettings";
private const string INDEXINGINFOKEY = "IndexingInfo";
/// <summary>
/// Overrides the base class behavior. Builds internal structures.
/// Do not use this method directly from your code.
/// </summary>
protected override void OnLoaded(object sender, NodeEventArgs e)
{
base.OnLoaded(sender, e);
Expand All @@ -491,6 +604,12 @@ protected override void OnLoaded(object sender, NodeEventArgs e)
Build();
}

/// <summary>
/// Returns <see cref="PerFieldIndexingInfo"/> of the requested <see cref="FieldSettings"/>.
/// Return value is null if the <see cref="Aspect"/> or <see cref="FieldSettings"/> does not exist.
/// The fieldName structure: {AspectName}.{FieldSettingName}
/// </summary>
/// <param name="fieldName">Full name of the field: {AspectName}.{FieldSettingName}.</param>
public static PerFieldIndexingInfo GetPerFieldIndexingInfo(string fieldName)
{
string realFieldName;
Expand All @@ -499,6 +618,11 @@ public static PerFieldIndexingInfo GetPerFieldIndexingInfo(string fieldName)
return null;
return aspect.GetLocalPerFieldIndexingInfo(realFieldName);
}
/// <summary>
/// Returns <see cref="PerFieldIndexingInfo"/> of the requested <see cref="FieldSettings"/>.
/// Return value is null if the <see cref="FieldSettings"/> does not exist.
/// </summary>
/// <param name="fieldName">Name of the field without aspect specifier.</param>
public PerFieldIndexingInfo GetLocalPerFieldIndexingInfo(string fieldName)
{
PerFieldIndexingInfo info = null;
Expand All @@ -510,5 +634,4 @@ internal void SetPerFieldIndexingInfo(string fieldName, PerFieldIndexingInfo ind
_indexingInfo[fieldName] = indexingInfo;
}
}

}
Loading

0 comments on commit 88bfa99

Please sign in to comment.