5

I want to do following operation by using Storage Extension

  1. When DCP is published, DCP is stored to Broker DB as usual.
  2. After that, extract some data from DCP and store it to another custom DB by Storage Extension.

But when I ran a test program of Storage Extension, the test program was executed but DCP was not stored to Broker DB. It seems Storage Extension program totally overrides existing behavior.

Is it possible to run Storage Extension program without changing exsting behavior? If it's possible, how can I do that?

package com.tridion.storage.extension;

@Component("JPAComponentPresentationDAOImpl")
@Scope("prototype")

public class JPAComponentPresentationDAOImpl extends JPABaseDAO 
                                             implements ComponentPresentationDAO {
public JPAComponentPresentationDAOImpl(String storageId,
        EntityManagerFactory entityManagerFactory,
        EntityManager entityManager, String storageName) {
    super(storageId, entityManagerFactory, entityManager, storageName);
    outputLog("JPAComponentPresentationDAOImpl Constructor 1");
}

public JPAComponentPresentationDAOImpl(String storageId,
        EntityManagerFactory entityManagerFactory,
        String storageName) {
    super(storageId, entityManagerFactory, storageName);
    outputLog("JPAComponentPresentationDAOImplConstructor2");
}
/**
 * @param args
 */
public static void main(String[] args) {}

public void create(ComponentPresentation componentPresentation,
                        ComponentPresentationTypeEnum type)
        throws StorageException {
    outputLog("JPAComponentPresentationDAOImpl create");

    try {
        outputLog("componentPresentation:" + new String(componentPresentation.getContent(),
                                                        "UTF-8"));
    } catch (UnsupportedEncodingException e) {
    }
}
private static void outputLog(String msg){
    try{
    File f = new File("C:\\tridion\\log-custom\\InsertAPITest.log");
    BufferedWriter bw = new BufferedWriter(new FileWriter(f,true));
    bw.write(msg);
    bw.newLine();
    bw.close();
    }catch(IOException e){}
}
}

This is storage DAO bundle configuration file, "JPAComponentPresentationDAOImpl.xml".

<?xml version="1.0" encoding="UTF-8"?>
<StorageDAOBundles>
  <StorageDAOBundle type="persistence">
    <StorageDAO typeMapping="ComponentPresentation" class="com.tridion.storage.extension.JPAComponentPresentationDAOImpl" />
  </StorageDAOBundle>
</StorageDAOBundles>

And those are setting in cd_storage_conf.xml

<StorageBindings>
    <Bundle src="undo_dao_bundle.xml"/>
    <Bundle src="JPAComponentPresentationDAOImpl.xml"/>
</StorageBindings>

<Item typeMapping="Binary" storageId="defaultFile" cached="false"/>
3
  • You may want to take a look at tridion.stackexchange.com/questions/136/… if you have not already. Commented Jul 25, 2013 at 5:13
  • Now I found a solution.My class should extends JPAComponentPresentationDAO, and call super.create() in my calss's create() method, then DCP is stored to Broker DB.Also, all other methods of ComponentPresentationDAO interface must call super.XXX(), otherwise DCP isn't removed from Broker DB even if it's unpublished.I refered This post. Thanks. Commented Jul 25, 2013 at 5:36
  • 2
    @HirokazuShikata: can you add that comment as an answer and mark it as accepted? That'll make it easier for future googlers to find things. Commented Jul 25, 2013 at 11:13

1 Answer 1

4

I found a solution.

To ensure the DCP is also stored in the Broker Database, my class needed to extend JPAComponentPresentationDAO and call super.create() in my class's create() method

Also, all other methods of the ComponentPresentationDAO interface must call super.XXX() otherwise the DCP isn't removed from the Broker DB even if it is unpublished.

The following posts were helpful in finding the solution for my problem:

1
  • Hirokazu, I edited your answer to include the details from your comment on the original question about the solution which worked for you. If you see any issues with this please feel free to make further edits or if needed, revert my edits. Commented Jul 31, 2013 at 3:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.