0

我需要通过 json 请求获取 DDL 记录。Liferay 核心没有这样的服务。只有getRecordSet。

我编写 DDLRecordSetService Hook 来添加新方法getRecords(recordSetId)。我的代码:

public class ExtDDLRecordSetLocalServiceImpl extends DDLRecordSetServiceWrapper {


   public ExtDDLRecordSetLocalServiceImpl(DDLRecordSetService ddlRecordSetService) {
       super(ddlRecordSetService);
   }

   public com.liferay.portlet.dynamicdatalists.model.DDLRecordSet getRecordSet(long recordSetId) throws com.liferay.portal.kernel.exception.PortalException, com.liferay.portal.kernel.exception.SystemException{

       System.out.println("------override getRecordSet ");
      DDLRecordSet set = super.getRecordSet(recordSetId+10);
        return set;
   }

   @JSONWebService
   public List<DDLRecord> getRecords(long recordSetId) throws SystemException, PortalException {
        System.out.println("------override getRecords");
        return   getRecordSet(recordSetId).getRecords();
   }

}

我可以覆盖 getRecordSet(),但我无法通过 URL 访问 getRecordSet() 方法。

我得到:

{"exception":"No JSON web service action associated with path /ddlrecordset/get-records and method GET for /"}

如何添加新的 DDLRecordSetService,它可以通过 JSONWebService 返回记录集?

4

1 回答 1

1

DDL 的内置 JSON 服务比获取记录集更丰富。尝试将浏览器指向门户网站的 Web 服务 api 页面。登录后,

/api/jsonws

DDLRecord 有 7 个方法,DDLRecordSet 有 8 个方法。

在我看来,标准 API 将满足您的需求。

如果事实证明不是这样,那么……

JSON Web 服务方法是在运行服务构建器时创建的。这会将您的方法反向工程为 JSON、SOAP 等的正确对象。

由于您从不运行服务构建器,因此逆向工程永远不会发生。我怀疑在 Liferay 核心资源上运行 SB 是不是你的想法(无论如何,这都是不可取的,imo。)

我的建议是使用 Service Builder 创建您自己的服务,从而为您想要公开的服务对象创建您自己的 API。也看到这个问题

于 2013-04-18T13:58:41.137 回答