2

I've added a custom module in the default processor in config/cd_deployer_conf.xml:

<Processor Action="Deploy" Class="com.tridion.deployer.Processor">
            ...
            <Module Type="MyCustomModuleDeploy" Class="com.tridion.new.extensions.MyCustomModule">
            </Module>
</Processor>

The code for the module looks something like this:

public class MyCustomModule extends com.tridion.deployer.modules.PageDeploy {

     static Logger logger = Logger.getLogger("customDeployerFirst");

    public MyCustomModule(Configuration config, Processor processor)
            throws ConfigurationException {
        super(config, processor);
        // TODO Auto-generated constructor stub
    }

    public void processPage(Page page, File pageFile) throws ProcessingException {
        // TODO Auto-generated method stub
            Date d = new Date();
        log.info("WORKING");
        log.info("Page ID: " + page.getId().toString());
        log.info("Publication date: "+ d.toString());
    }

}

In my log file I get the info I wanted, every time a page is published.

What I want to do next is to write the page ID and publication date to my Microsoft SQL database, in a table I previously created. How can I do that? How can I access the database table from MyCustomModule?

Thanks

Marko Letic
  • 2,460
  • 2
  • 28
  • 34
  • 2
    It looks like you already have the Tridion-specific part of the solution. Now you're just asking a question about Java and SQL Server. That's rather off-topic here. Have you tried Googling for 'Java SQL Server' or something? – Quirijn Jul 06 '12 at 11:58
  • 2
    Yeah, pretend that the code is _not_ a Tridion Deployer extension - that's the code you need. – Nuno Linhares Jul 06 '12 at 12:29
  • Thanks guys! I got caught up in Tridion I thought it's gonna be something more challenging. – Marko Letic Jul 06 '12 at 12:33
  • It's always easier than it seems... – Nuno Linhares Jul 07 '12 at 02:36
  • Hey Marko. Can you please accept one of the answers below, so that others can benefit from your findings. Don't hesitate to accept your own answer, if that's the one that solved your problem. – Frank van Puffelen Jul 17 '12 at 12:52

2 Answers2

3

Not sure of your requirement, but you already chose the deployer extension model vs storage extensions. With storage extensions, Tridion will provide a model on how you can extend storages (like JPAFramework and Base DAOEntities that you can extend). If you are going the deployer extension route, as Quirin and Nuno mentioned it is like writing a standard JDBC code like any other app.

But, I would suggest you also look at storage extension model and see if it fits your requirement. A very good starting point is to look at the below article: http://www.sdltridionworld.com/articles/sdltridion2011/tutorials/extending-content-delivery-storage-sdltridion-2011-1.aspx

Ram G
  • 4,829
  • 1
  • 16
  • 26
  • Is this type of solution available only in Tridion 2011, because my implementation is in 2009? – Marko Letic Jul 06 '12 at 19:09
  • Yes. This is only available in 2011 not on 2009. You have any plan to upgrade to 2011? It will be rewrite when you upgrade. – Ram G Jul 06 '12 at 19:20
  • In theory, it is possible to customise storage in older versions with custom "home" classes but information on this technique might be even harder to come by. It's great that in 2011 it's built on standard libraries. But until then, a custom deployer is a good choice. – Dominic Cronin Jul 07 '12 at 06:15
  • Also beware of the home classes, they are deprecated/removed in 2011. When you upgrade you have more work(rewriting) on migrating them. – Ram G Jul 07 '12 at 11:51
  • The code that Marko already has will work fine on 2011. The home classes are deprecated / gone, but the deployer modules aren't. – Quirijn Jul 07 '12 at 21:15
1

Ok, so what I did here to solve my problem is exactly what Quirijn suggested. Used the JDBC driver to connect to my database and then executed an sql update query:

int sqlStatement = st.executeUpdate("insert into Pages values ('" + page.getId().toString()+ "', '" + ... + "')");

This way each time a Page is published some data will be written to my database.

Marko Letic
  • 2,460
  • 2
  • 28
  • 34
  • I would also like to emphasize that I used this solution in Tridion 2009. If you use 2011, I suggest you to read Ram's answer about storage extensions. – Marko Letic Jul 17 '12 at 13:35