Mirroring 2.0 - Modifying pageproperies before transfer.

Vote:
 

I am about to change the Mirroring 2.0 behaviour for mirroring pages.
My "mission" is to remove values from certain pageproperties that contains confidential information before mirroring the content to the other site.

I was wondering if anyone have any tip on how to do this, and what not to do.
Preferably by an example (basic extension), but any help appreciated.

 

 

#49189
Mar 08, 2011 21:18
Vote:
 

If you look at this post

http://world.episerver.com/Blogs/Anders-Hattestad/Dates/2010/9/Shame-on-you-Mr-EPiServer/

you will se an reply that stats that DataFactory event will be triggered when a page is created by the mirroring service. So I guess you could remove those properties on a PageSaving event, based on the site id or something. Havent tried it myself thou

a

#49191
Mar 09, 2011 8:33
Vote:
 

I need to remove the properties before mirroring.So I would have to override on the source side.

Any further comments/examples on which events to attach to appreciated.

If anybody have a demo-plugin (example to dump into the mirroring-bin folder) I would be very happy.

 

#49218
Mar 09, 2011 12:05
Vote:
 

What you could do is to write a module that hooks up to the event ExportPropertyEvent on type EPiServer.Enterprise.Mirroring.MirroringDataExporter. 

In the eventhandler you could do something like:

    public static void ExportEventHandler(object sender, TransformPropertyEventArgs e)
        {
            //Here you should make sure it is correct property
            if (e.IsHandled || e.PropertySource == null || !String.Equals(e.PropertySource.Name, "YourPropName"))
            {
                return;
            }
            //Clear or modify data as you like
            e.PropertySource.Value = String.Empty;
            e.IsHandled = true;
        }

public static void ExportEventHandler(object sender, TransformPropertyEventArgs e)        

{          

 //Here you should make sure it is correct property            

if (e.IsHandled || e.PropertySource == null || !String.Equals(e.PropertySource.Name, "YourPropName"))            

{                return;            }

//Clear or modify data as you like          

 e.PropertySource.Value = String.Empty;
 e.IsHandled = true;        

}

The module should have InitializableModule attribute and hookup to the event in its Initialize method. The module should then be deployed to the bin folder for the mirroring service on the source side (typically in folder MirroringService\bin under site root).

#49274
Mar 11, 2011 7:45
Vote:
 

Found similar example in SDK, and it should probably do the job.
Since you don't mention any other eventhookups I expect that ExportEventHandler was what I was looking for.

#49277
Mar 11, 2011 10:24
Vote:
 

I made a module, and placed in the source bin folder.
Unfortunately, I cannot see that the module is activated (Not logging).

Log4Net output:

EPiServer.MirroringService.MirroringSourceService.MirroringSourceServer.EPiServer.MirroringService.MirroringSourceService.IMirroringSource.StartMirroring - siteId =RVPEPi and contextId = 6b048b09-d117-4ce0-b70c-2849f0b436e4
EPiServer.MirroringService.MirroringProviderBase.StartMirroring - siteId =RVPEPi and contextId = 6b048b09-d117-4ce0-b70c-2849f0b436e4
EPiServer.MirroringService.MirroringProviderBase.HandleMirroringCompleted - Context = 6b048b09-d117-4ce0-b70c-2849f0b436e4 State = MirroringJobCompleted 
EPiServer.MirroringService.MirroringProviderBase.UnInitialize - contextId = 6b048b09-d117-4ce0-b70c-2849f0b436e4 
EPiServer.MirroringService.MirroringSourceService.MirroringSourceServer.EPiServer.MirroringService.MirroringSourceService.IMirroringSource.StartMirroring - siteId =RVPEPi and contextId = 6b048b09-d117-4ce0-b70c-2849f0b436e4EPiServer.MirroringService.MirroringProviderBase.StartMirroring - siteId =RVPEPi and contextId = 6b048b09-d117-4ce0-b70c-2849f0b436e4EPiServer.MirroringService.MirroringProviderBase.HandleMirroringCompleted - Context = 6b048b09-d117-4ce0-b70c-2849f0b436e4 State = MirroringJobCompleted EPiServer.MirroringService.MirroringProviderBase.UnInitialize - contextId = 6b048b09-d117-4ce0-b70c-2849f0b436e4 

Here is my module:

    [InitializableModule]
    public class DataExporterModule : IInitializableModule
    {

        private static readonly ILog Logger = LogManager.GetLogger(typeof(DataExporterModule));

        #region IInitializableModule Members

        public void Initialize(InitializationEngine context)
        {

            Logger.Debug("Initialize");
            MirroringDataExporter.ExportPropertyEvent += DataExporterPropertyEventHandler;

        }

        public void Preload(string[] parameters)
        {        }

        public void Uninitialize(InitializationEngine context)
        {

            DataExporter.ExportPropertyEvent -= DataExporterPropertyEventHandler;

            Logger.Debug("Uninitialize");

        }

        #endregion

        private static void DataExporterPropertyEventHandler(object sender, TransformPropertyEventArgs e)
        {
            Logger.Debug("Triggered DataExporterPropertyEventHandler");
        }

    }

 

Any idea what I am missing?

#49371
Mar 15, 2011 16:05
Vote:
 

One mistake I made was to remove my dll for the scanAssembly node. You can find this configuration option in EPiServerFramework.config. By default the node scanAssembly doesn't exist though.

You can read about it more in this blog: http://world.episerver.com/Blogs/Alexander-Haneng/Dates/2011/1/Starting-a-CMS-6-sites-faster-after-build/

#49372
Mar 15, 2011 16:36
Vote:
 

I may not have mentioned that the mirroring service is installed as a separate IIS application, and is working for standard mirroring.

No EPiServerFramework.config does exist in this folder.

That said, I haven't removed dll's from EPiServerFramework.config (yet)

#49373
Mar 15, 2011 16:40
Vote:
 

Each mirroring job will execute in an own AppDomain (to make it possible to run several jobs in parallell without interference). What you see in your log comes from the main appdomain. What probably happen in your case is that the main AppDomain will lock the logfile and thereby prevent the AppDomain that executes the job from writing tho the logfile. It should be possible to configure log4net so both AppDomains can log to same file. See for example following link for configuration

http://labs.episerver.com/en/Blogs/Svante-Seleborg/Dates/2009/1/Logging-woes-with-log4net-and-enterprise-sites/

#49376
Mar 15, 2011 19:46
Vote:
 

Added <lockingModel type=”log4net.Appender.FileAppender+MinimalLock” /> and tried once more.
A lot of other logentries appeared but sadly my module still wasn't one of the initializing modules listed in the log.

Maybe there is something wrong with my classlibrary ?

My module is the only class(file) in the classlibrary, targeting .net 3.5
Apart from that nothing special is done.

I am sure the problem relates to a minor mistake (probably done by me), but it is frustrating :-)

 

#49379
Mar 15, 2011 20:46
Vote:
 

Have you tried to attach a debugger (e.g. Visual Studio to the mirroring service process)? Then you could see if your module is loaded, (e.g. by clicking break all and then view Debug/Windows/Modules).

During the mirroring job a config file used for the appdomain is saved to disk in the root folder for the mirroring service (called something like <siteId>.config). That file is a merged config file (of web, episerver and framework.config) open that file and ensure that your module is not excluded (or not included) in the episerver.framework section in that config file.

#49383
Mar 16, 2011 7:01
Vote:
 

The merged config file contained <scanAssembly forceBinFolderScan="false" />

Checked EPiServerFramework.config in the episite, and there it was.

Setting value to true in the EPiServerFramework.config  fixed my problem.

 

#49392
Edited, Mar 16, 2011 8:29
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.