I cannot post formatted code in a comment, hence this new answer.
@sea_gull is right - you need indeed to call the new DAO. The reason for it being this is a new type, so the Content Delivery storage mechanism won't know what to do with it. You have to call it somehow (potentially from a deployer module, but not necessarily). I used a unit test for calling it (just to provie that it works).
This is my sample unit test code I use to call the storage extension with:
package com.tridion.extension.search.test;
import static org.junit.Assert.fail;
import java.util.Date;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.tridion.broker.StorageException;
import com.tridion.storage.StorageManagerFactory;
import com.tridion.storage.extension.search.PublishAction;
import com.tridion.storage.extension.search.PublishActionDAO;
/**
* @author Mihai Cadariu
*/
public class DAOTestCase {
private final Logger log = LoggerFactory.getLogger(DAOTestCase.class);
/**
* Test method for
* {@link com.tridion.storage.extension.search.PublishActionDAO#store(com.tridion.storage.search.PublishAction)}.
*/
@Test
public void testDAO() {
try {
log.debug("Get PublishActionDAO");
PublishActionDAO publishActionDAO = (PublishActionDAO) StorageManagerFactory.getDefaultDAO("PublishAction");
log.debug("Create new PublishAction bean");
PublishAction publishAction = new PublishAction();
publishAction.setAction("testStore action");
publishAction.setContent("testStore content");
publishAction.setTcmUri("testStore tcmUri");
publishAction.setUrl("testStore url");
publishAction.setCreationDate(new Date());
// Store
log.debug("Store bean");
publishAction = publishActionDAO.store(publishAction);
log.debug("Stored bean " + publishAction);
long id = publishAction.getId();
// FindByPrimaryKey
log.debug("Find PublishAction by PK=" + id);
publishAction = publishActionDAO.findByPrimaryKey(id);
log.debug("Found bean " + publishAction);
if (publishAction == null) {
log.error("Cannot find bean");
fail("TestFindByPrimaryKey failed: cannot retrieve object with pk " + id);
}
log.debug("Modifying bean content");
String content = publishAction.getContent();
content += "\r\nMODIFIED " + new Date();
publishAction.setContent(content);
// Update
log.debug("Update bean");
publishActionDAO.update(publishAction);
// Remove
log.debug("Remove bean");
publishActionDAO.remove(id);
} catch (StorageException se) {
log.debug("TestDAO failed: Exception occurred " + se);
fail("TestDAO failed: Exception occurred " + se);
se.printStackTrace();
}
}
}
If you call the code from a Deployer extension, this is the sample code I used:
public class PageDeployModule extends PageDeploy {
private final Logger log = LoggerFactory.getLogger(PageDeployModule.class);
public PageDeployModule(Configuration config, Processor processor) throws ConfigurationException {
super(config, processor);
}
/**
* Process the page to be published
*/
@Override
protected void processPage(Page page, File pageFile) throws ProcessingException {
log.debug("Called processPage");
super.processPage(page, pageFile);
processItem(page);
}
private void processItem(Page page) {
log.debug("Called processItem");
try {
SearchConfiguration config = SearchConfiguration.getInstance();
String externalUrl = config.getExternalAccessUrl() + page.getURLPath();
String internalUrl = config.getInternalAccessUrl() + page.getURLPath();
PublishAction publishAction = new PublishAction();
publishAction.setAction("Publish");
publishAction.setTcmUri(page.getId().toString());
publishAction.setUrl(externalUrl);
publishAction.setContent(Utils.getPageContent(internalUrl));
PublishActionDAO publishActionDAO = (PublishActionDAO) StorageManagerFactory.getDefaultDAO("PublishAction");
publishAction = publishActionDAO.store(publishAction);
log.debug("Stored bean " + publishAction);
} catch (StorageException se) {
log.error("Exception occurred " + se);
}
}
}
You can use the same approach for the PageUndeploy, where you mark the action as "Unpublish".