When a DCP is Published, the create
method is called.
When aDCP is unPublished, the remove
method is called.
But when a DCP is rePublished, the update
method is not called.
I don't know why the update
method isn't called, when a DCP is rePublished.
my source is shown below:
package com.tridion.storage.extension;
import java.util.Collection;
import java.io.*;
import javax.persistence.*;
import com.tridion.storage.annotations.*;
import com.tridion.broker.StorageException;
import org.springframework.context.annotation.*;
import org.springframework.stereotype.Component;
import com.tridion.storage.dao.ComponentPresentationDAO;
import com.tridion.storage.persistence.*;
import com.tridion.storage.util.ComponentPresentationTypeEnum;
import com.tridion.storage.*;
@Component("JPAComponentPresentationDAOImpl")
@Scope("prototype")
public class JPAComponentPresentationDAOImpl extends
JPAComponentPresentationDAO implements ComponentPresentationDAO {
public JPAComponentPresentationDAOImpl(String storageId,
EntityManagerFactory entityManagerFactory,
EntityManager entityManager, String storageName) {
super(storageId, entityManagerFactory, entityManager, storageName);
outputLog("JPAComponentPresentationDAOImplコンストラクタ1");
}
public JPAComponentPresentationDAOImpl(String storageId,
EntityManagerFactory entityManagerFactory, String storageName) {
super(storageId, entityManagerFactory, storageName);
outputLog("JPAComponentPresentationDAOImplコンストラクタ2");
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
}
public void create(ComponentPresentation componentPresentation,
ComponentPresentationTypeEnum type) throws StorageException {
super.create(componentPresentation, type);
outputLog("JPAComponentPresentationDAOImpl create");
connectDB(componentPresentation);
}
public Collection<ComponentPresentation> findAll(int publicationId,
int componentId,
ComponentPresentationTypeEnum componentPresentationType)
throws StorageException {
outputLog("findAll");
return super.findAll(publicationId, componentId,
componentPresentationType);
}
public ComponentPresentation getComponentPresentation(int publicationId,
int componentId, int templateId,
ComponentPresentationTypeEnum componentPresentationType)
throws StorageException {
outputLog("getComponentPresentation");
return super.getComponentPresentation(publicationId, componentId,
templateId, componentPresentationType);
// return null;
}
public void remove(ComponentPresentation componentPresentation,
ComponentPresentationTypeEnum type) throws StorageException {
outputLog("Remove1");
super.remove(componentPresentation, type);
}
public void remove(int publicationId, int componentId, int templateId,
ComponentPresentationTypeEnum componentPresentationType)
throws StorageException {
outputLog("Remove2");
super.remove(publicationId, componentId, templateId,
componentPresentationType);
}
// I think this method is called when DCP is republished. but not called.
public void update(ComponentPresentation componentPresentation,
ComponentPresentationTypeEnum componentPresentationType)
throws StorageException {
outputLog("update");
super.update(componentPresentation, componentPresentationType);
}
// custom code
// output logfile
private static void outputLog(String msg) {
try {
File f = new File("/tmp/output.log");
BufferedWriter bw = new BufferedWriter(new FileWriter(f, true));
bw.write(msg);
bw.newLine();
bw.close();
} catch (IOException e) {
}
}
}