That is correct. Essentially, a Page Update is always done by the underlying JPA implementation as an JPASearchPageDAO.update
, followed by a JPASearchPageDAO.create
, so in essence both are doing the same things. This has got me stuck quite a while when I was building this as well.
If you want to change that behaviour because you have to do extra stuff while creating pages, you could do something like this:
@Component("JPASearchPageDAO")
@Scope("prototype")
public class JPASearchPageDAO extends JPAPageDAO implements PageDAO
{
private String storageId;
// Let's keep track of this DAO
private boolean isUpdating = false;
public void create(CharacterData page, String relativePath) throws StorageException
{
FactoryAction action = FactoryAction.CREATE
if (!this.isUpdating)
{
/**
* Do creation specific stuff here, or in the Factory, since we've now set
* the action to CREATE.
*/
}
else
{
action = FactoryAction.UPDATE
}
log.debug("Create.");
TridionPublishableItemProcessor tp;
try
{
tp = new TridionPublishableItemProcessor(
page.getString(),
action,
IndexType.PAGE,
Integer.toString(page.getPublicationId()),
"tcm:" + page.getPublicationId() +"-" + page.getId() + "-64"
, this.storageId);
CharacterData c = tp.processPageSource(page);
if (c != null)
{
super.create(c, relativePath);
}
else
{
log.error("Error processing page: " + relativePath + ", proceeding with deployment of original page");
super.create(page, relativePath);
}
}
catch (IOException e)
{
log.error(Utils.stacktraceToString(e.getStackTrace()));
throw new StorageException("IO Exception: " + e.getLocalizedMessage(),e);
}
}
// Note: An update triggers a create always.
@Override
public void update(CharacterData page, String originalRelativePath, String newRelativePath) throws StorageException
{
this.isUpdating = true;
// ...
}
}
Now that I think of it, I'll add this fix in the next release of SI4T as well. :)