【问题标题】:How to use DPSSessionService through CQ API如何通过 CQ API 使用 DPSSessionService
【发布时间】:2015-09-11 03:06:09
【问题描述】:

我想使用 CQ API 调用来删除作品集制作器中的作品集。我看到http://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/adobe/cq/media/publishing/dps/fp/DPSSessionService.html可以创建会话。
创建会话后,我可以使用 http://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/adobe/cq/media/publishing/dps/fp/DPSFolioProducerService.html 删除具有 folioId 的作品集。
我不知道如何实现此接口以使其正常工作。我试图@Reference 私有 DPSSessionService dpssession;

但是,这不会将我的流程部署到我的工作流程中。我不知道我怎样才能让它工作。

【问题讨论】:

    标签: java aem adobe-dps


    【解决方案1】:

    也许您可以通过 OSGi 包的上下文获取服务。

    你可以尝试这样的事情(虽然没有测试):

    BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
    ServiceReference dpsFolioProducerServiceReference = bundleContext.getServiceReference(DPSFolioProducerService.class);
    DPSFolioProducerService yourDPSFolioProducerService = (DPSFolioProducerService) bundleContext.getService(dpsFolioProducerServiceReference );
    

    您可以在您的 servlet 中使用它。

    1. 获取包上下文
    2. 构造对您的服务的引用
    3. 使用您的参考获取服务

    【讨论】:

      【解决方案2】:

      终于搞定了:

      @Reference
      private DPSSessionService sessionService;
      private DPSSession dpsSession = null;
      private DPSFolioProducerService folioProducer; 
      
       try {
          dpsSession = sessionService.createSession("username", "password");
           folioProducer = dpsSession.adaptTo(DPSFolioProducerService.class);
           folioProducer.deleteFolio(folioId);
            sessionService.deleteSession(dpsSession);
         } catch (DPSSessionServiceException ex) {
             log.error("Failed setup", ex);
         } catch (DPSFolioProducerServiceException e) {
            log.error("Delete Folio failed", e);
          }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-08-27
        • 2014-11-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多