0

我只是想编写小型部署程序扩展,如果用户从 tridion 发布/取消发布页面/组件/二进制文件,它的记录将使用存储扩展进入特定表。

存储扩展部分已经完成!!

好吧,我可以轻松编写PageDeploy/ComponentDeploy 和 BinaryDeploy,因为我在 com.tridion.deployer.modules 中有这些类。

我也可以轻松编写自定义页面取消部署程序类,但是很难编写组件,二进制取消部署,因为我们没有任何类。

请建议是否可能,如果是的话,请指出我编写类或方法来获取它。

谢谢。

4

2 回答 2

4

是的,没有您自己发现的组件取消部署或二进制取消部署。

Frank 有一个很好的例子,说明如何在这里扩展二进制存储以跟踪取消部署事件,对于组件,您必须改用 ComponentPresentationUndeploy。

于 2013-01-10T07:09:14.883 回答
1

下面是在 DAO 中跟踪组件和二进制文件的示例代码。

组件:要添加的示例代码,更新和删除也是如此

@Component("JPAComponentDAOExtension")
@Scope("prototype")

public class JPAComponentDAOExtension extends JPAComponentPresentationDAO implements ComponentPresentationDAO 
{

    public JPAComponentDAOExtension(String storageId, EntityManagerFactory entityManagerFactory, String storageName) 
    {
        super(storageId, entityManagerFactory, storageName);
    }

    public JPAComponentDAOExtension(String storageId, EntityManagerFactory entityManagerFactory, EntityManager entityManager, String storageName) 
    {
        super(storageId, entityManagerFactory, entityManager, storageName);
    }

    public void create(ComponentPresentation itemToCreate, ComponentPresentationTypeEnum componentPresentationType) throws StorageException 
    {
        super.create(itemToCreate,componentPresentationType);   
        String tcmURI = Integer.toString(itemToCreate.getComponentId());
        ItemDAO item = (ItemDAO) StorageManagerFactory.getDAO(itemToCreate.getPublicationId(),StorageTypeMapping.COMPONENT_META);
        ComponentMeta meta = (ComponentMeta) item.findByPrimaryKey(itemToCreate.getPublicationId(),itemToCreate.getComponentId());
        String schemaID = Integer.toString(meta.getSchemaId()) ;

        PublishActionDAO publishActionDAO = (PublishActionDAO) StorageManagerFactory.getDefaultDAO("PublishAction");
        PublishAction publishAction = new PublishAction();
        publishAction.setAction("ADD"); 
        publishAction.setTcmUri(tcmURI);
        publishAction.setSchemaID(schemaID);
        publishActionDAO.store(publishAction);

    }
}

二进制:示例代码添加和更新和删除同样适用

@Component("JPABinaryDAOExtension")
@Scope("prototype")

public class JPABinaryDAOExtension extends JPABinaryContentDAO implements BinaryContentDAO 
{

    public JPABinaryDAOExtension(String storageId, EntityManagerFactory entityManagerFactory, String storageName) 
    {
        super(storageId, entityManagerFactory, storageName);
    }

    public JPABinaryDAOExtension(String storageId, EntityManagerFactory entityManagerFactory, EntityManager entityManager, String storageName) 
    {
        super(storageId, entityManagerFactory, entityManager, storageName);
    }

    public void create(final BinaryContent binaryContent, final String relativePath) throws StorageException 
    {
        super.create(binaryContent, relativePath);  
        String url = relativePath;
        String tcmURI = Integer.toString(binaryContent.getBinaryId());

        ItemDAO item = (ItemDAO) StorageManagerFactory.getDAO(binaryContent.getPublicationId(),StorageTypeMapping.BINARY_META);
        BinaryMeta binarymeta = (BinaryMeta) item.findBinaryByPrimaryKey(binaryContent.getPublicationId(),binaryContent.getBinaryId());
        binarymeta.getBinaryType();//to get the binary type

        //You can also check the Relative path as below for specific binary type entries as suggested by Mihai
        if (relativePath.toLowerCase().endsWith(".pdf")) //Looking for PDFs only
        { 
            PublishActionDAO publishActionDAO = (PublishActionDAO) StorageManagerFactory.getDefaultDAO("PublishAction");
            PublishAction publishAction = new PublishAction();
            publishAction.setAction("ADD");
            publishAction.setUrl(url);
            publishAction.setTcmUri(tcmURI);
            publishActionDAO.store(publishAction);
        }
    }
}
于 2013-01-12T07:49:32.933 回答