Giter Club home page Giter Club logo

dynamic-delivery-4-tridion's People

Contributors

chrismrgn avatar mvbrakel avatar quirijnslings avatar rsleggett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dynamic-delivery-4-tridion's Issues

ConfigurationHelper PublicationID should cache the result in a private variable

Currently, each call to the static property ConfigurationHelper.PublicationID results in a read from the Web.config. This can easily be cached in a private variable like this:

    public static int PublicationId
    {
        get
        {
            if (_publicationId > 0)
            {
                return _publicationId;
            }
            _publicationId = SafeGetConfigSettingAsInt(ConfigurationKeys.PublicationId);
            return _publicationId;
        }
    }

Providers should be static properties of factories

All factories have an instance property for the associated provider, like this:
private IPageProvider _pageProvider = null;

This should be a static property so that it is loaded only once:
private static IPageProvider _pageProvider = null;

Base Controler Redirect

I am having an issue where the tridion base controller does not redirect to the child or action code.

Reduce memory footprint in providers

The DD4T providers use the Tridion CD factories to get data (pages, components, binaries, etc). This is done in many different, inconsistent ways:

  • As static or instance variables
  • As properties which 'cache' the factory in a private variable
  • etc

The Tridion CD factories are all marked as IDisposable, but DD4T doesn't call Dispose on them (or wrap them in a using block).

Moreover, the items which are returned by these factories are also disposables, yet DD4T never makes use of this. All of this causes excessive memory consumption.

I propose the following changes:

  1. CD Factories are static properties, backed up by a private static variable like so:

    private static BinaryFactory _binaryFactory = null;
    private static readonly lockBinaryFactory = new Object();
    private static BinaryFactory BinaryFactory
    {
    get
    {
    if (_binaryFactory == null)
    {
    lock (lockBinaryFactory)
    {
    if (_binaryFactory == null)
    {
    _binaryFactory = new BinaryFactory();
    }
    }
    }
    return _binaryFactory;
    }
    }

  2. CD Factories which need a publication ID as constructor argument, must be cached in a static Dictionary with a GetXXFactory(string publicationID) method (leaving out the locking bit for brevity):

        private static Dictionary<int,ComponentMetaFactory > _tridionComponentMetaFactories = new Dictionary<int,ComponentMetaFactory>();
    

    private static readonly lockComponentMetaFactory = new Object();
    private static ComponentMetaFactory GetTridionComponentMetaFactory(int publicationId)
    {
    if (_tridionComponentMetaFactories.ContainsKey(publicationId))
    {
    return _tridionComponentMetaFactories[publicationId];
    }
    lock (lockComponentMetaFactory)
    {
    if (!_tridionComponentMetaFactories.ContainsKey(publicationId)) // we must test again, because in the mean time another thread might have added a record to the dictionary!
    {
    _tridionComponentMetaFactories.Add(publicationId, new ComponentMetaFactory(publicationId));
    }
    }
    return _tridionComponentMetaFactories[publicationId];
    }

  3. Add a using block when the factories are used to retrieve an item:

    using (var binaryData = BinaryFactory.GetBinary("tcm:2-123"))
    {
    // do something with binaryData
    }

  4. The DD4T providers themselves implement IDisposable, and clean up all factories in the Dispose method as follows:

    protected virtual void Dispose(bool isDisposed)
    {
    if (_binaryFactory != null)
    {
    _binaryFactory.Dispose();
    _binaryFactory = null;
    }

    if (_tridionComponentMetaFactories != null)
    {
        foreach (var factory in _tridionComponentMetaFactories.Values)
        {
            if (factory != null)
            {
                factory.Dispose();
            }
        }
        _tridionComponentMetaFactories.Clear();
        _tridionComponentMetaFactories = null;
    }
    

    }

With Arabic set as browser/system language, ExtendedQueryParameters.ToTridionQuery() fail

With Arabic set as browser/system language, ExtendedQueryParameters.ToTridionQuery() method fails with the following trace:

2015-09-23 15:12:05,179 [118] ERROR Core.Helpers.HtmlHelperExtensions - HtmlHelperExtensions
System.Web.HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'. ---> System.ArgumentOutOfRangeException: Specified time is not supported in this calendar. It should be between 04/30/1900 00:00:00 (Gregorian date) and 11/16/2077 23:59:59 (Gregorian date), inclusive.
Parameter name: time
at System.Globalization.UmAlQuraCalendar.CheckTicksRange(Int64 ticks)
at System.Globalization.UmAlQuraCalendar.GetDatePart(DateTime time, Int32 part)
at System.DateTimeFormat.FormatCustomized(DateTime dateTime, String format, DateTimeFormatInfo dtfi, TimeSpan offset)
at System.DateTimeFormat.Format(DateTime dateTime, String format, DateTimeFormatInfo dtfi, TimeSpan offset)
at DD4T.Providers.SDLTridion2011sp1.ExtendedQueryParameters.ToTridionQuery()
at DD4T.Providers.SDLTridion2011sp1.TridionComponentProvider.FindComponents(IQuery query)
...

Pull Request:
#27

ComponentBuilder does not set AltText

When requesting the multimedia.AltText it always returns null. When looking in the ComponentBuilder.cs it is not filled. My assumption was that we could create our own multimedia schema and add an "AltText" field that would be filled automaticly. Can someone tell me what the use of this field is, and if this assumption is correct ? If so the following change is suggested;

ComponentBuilder.cs
Line_43: multimedia.AltText = tcmComponent.Content["AltText"].Value;

Set correct content type for package item Output

Currently the content type is always XML, even if the format is JSON. We need this line in the BasePageTemplate as well as BaseComponentTemplate:

package.PushItem(Package.OutputName, package.CreateStringItem(SerializerService is XmlSerializerService ? ContentType.Xml : ContentType.Text, outputValue));

Remove direct database connections from BinaryProvider

Currently, if the property BinaryProvider.LoadBinariesAsStream is set to true (it defaults to false), the provider connects to the broker database directly. This goes against one of our principle to always use the Tridion API.
I suggest to mark this property as obsolete in 2.0 so we can remove it some time later. Is anyone using this feature (to load binaries as a stream rather than an array of bytes) at all?

Page link resolving

The linkfactory must be enabled to resolve page links, by implementing the following method:
public string ResolvePageLink(string tcmUri)

Note that the results must be cached just like component links.

White space is lost in RTF

Here on sdl.com implementation we use DD4T 1.31. Recently we've discovered a small bug related to rich text field formatting.
To reproduce it you should just do the following:

  • change formatting for some piece of text in RTF like bold italic underline Note, this text should only be separated with whitespace (check in Source tab of RTF in CME)
  • save and publish

As final result we see lost whitespaces between bold, italic, underline words. After a few debugging hours I've found that issue is in TridionXml helper and particularly in LoadXml method. There should be PreserveWhitespace=true assignement before base.LoadXml()

More info: Anatolii Lysenko ([email protected])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.