public void persist() throws SystemException { if (this.isNew()) { WSRPConsumerPortletLocalServiceUtil.addWSRPConsumerPortlet(this); } else { WSRPConsumerPortletLocalServiceUtil.updateWSRPConsumerPortlet(this); } }
protected void importWSRPConsumerPortlet( PortletDataContext portletDataContext, WSRPConsumer wsrpConsumer, Element wsrpConsumerPortletElement, WSRPConsumerPortlet wsrpConsumerPortlet) throws Exception { try { WSRPConsumerPortlet importedWSRPConsumerPortlet = WSRPConsumerPortletLocalServiceUtil.getWSRPConsumerPortlet(wsrpConsumerPortlet.getUuid()); importedWSRPConsumerPortlet.setWsrpConsumerId(wsrpConsumer.getWsrpConsumerId()); importedWSRPConsumerPortlet.setName(wsrpConsumerPortlet.getName()); importedWSRPConsumerPortlet.setPortletHandle(wsrpConsumerPortlet.getPortletHandle()); WSRPConsumerPortletLocalServiceUtil.updateWSRPConsumerPortlet( importedWSRPConsumerPortlet, false); } catch (NoSuchConsumerPortletException nscpe) { ServiceContext serviceContext = portletDataContext.createServiceContext( wsrpConsumerPortletElement, wsrpConsumerPortlet, _NAMESPACE); serviceContext.setUuid(wsrpConsumerPortlet.getUuid()); WSRPConsumerPortletLocalServiceUtil.addWSRPConsumerPortlet( wsrpConsumer.getUuid(), wsrpConsumerPortlet.getName(), wsrpConsumerPortlet.getPortletHandle(), null, serviceContext); } }
@Override protected void doImportStagedModel( PortletDataContext portletDataContext, WSRPConsumerPortlet wsrpConsumerPortlet) throws Exception { StagedModelDataHandlerUtil.importReferenceStagedModel( portletDataContext, wsrpConsumerPortlet, WSRPConsumer.class, wsrpConsumerPortlet.getWsrpConsumerId()); Map<Long, Long> wsrpConsumerIds = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(WSRPConsumer.class); long wsrpConsumerId = MapUtil.getLong( wsrpConsumerIds, wsrpConsumerPortlet.getWsrpConsumerId(), wsrpConsumerPortlet.getWsrpConsumerId()); ServiceContext serviceContext = portletDataContext.createServiceContext(wsrpConsumerPortlet); WSRPConsumerPortlet importedWSRPConsumerPortlet = null; if (portletDataContext.isDataStrategyMirror()) { WSRPConsumerPortlet existingWSRPConsumerPortlet = WSRPConsumerPortletLocalServiceUtil.fetchWSRPConsumerPortletByUuidAndCompanyId( wsrpConsumerPortlet.getUuid(), portletDataContext.getCompanyId()); if (existingWSRPConsumerPortlet == null) { serviceContext.setUuid(wsrpConsumerPortlet.getUuid()); importedWSRPConsumerPortlet = WSRPConsumerPortletLocalServiceUtil.addWSRPConsumerPortlet( wsrpConsumerId, wsrpConsumerPortlet.getName(), wsrpConsumerPortlet.getPortletHandle(), serviceContext); } else { existingWSRPConsumerPortlet.setWsrpConsumerId(wsrpConsumerId); existingWSRPConsumerPortlet.setName(wsrpConsumerPortlet.getName()); existingWSRPConsumerPortlet.setPortletHandle(wsrpConsumerPortlet.getPortletHandle()); importedWSRPConsumerPortlet = WSRPConsumerPortletLocalServiceUtil.updateWSRPConsumerPortlet( existingWSRPConsumerPortlet); } } else { importedWSRPConsumerPortlet = WSRPConsumerPortletLocalServiceUtil.addWSRPConsumerPortlet( wsrpConsumerId, wsrpConsumerPortlet.getName(), wsrpConsumerPortlet.getPortletHandle(), serviceContext); } portletDataContext.importClassedModel(wsrpConsumerPortlet, importedWSRPConsumerPortlet); }
@Override public void deleteStagedModel(String uuid, long groupId, String className, String extraData) throws PortalException { Group group = GroupLocalServiceUtil.getGroup(groupId); WSRPConsumerPortlet wsrpConsumerPortlet = WSRPConsumerPortletLocalServiceUtil.fetchWSRPConsumerPortletByUuidAndCompanyId( uuid, group.getCompanyId()); if (wsrpConsumerPortlet != null) { WSRPConsumerPortletLocalServiceUtil.deleteWSRPConsumerPortlet(wsrpConsumerPortlet); } }
protected void exportWSRPConsumer( PortletDataContext portletDataContext, Element wsrpConsumersElement, WSRPConsumer wsrpConsumer) throws Exception { String path = getWSRPConsumerPath(portletDataContext, wsrpConsumer); if (!portletDataContext.isPathNotProcessed(path)) { return; } Element wsrpConsumerElement = wsrpConsumersElement.addElement("wsrp-consumer"); portletDataContext.addClassedModel(wsrpConsumerElement, path, wsrpConsumer, _NAMESPACE); if (portletDataContext.getBooleanParameter(_NAMESPACE, "wsrp-consumer-portlets")) { List<WSRPConsumerPortlet> wsrpConsumerPortlets = WSRPConsumerPortletLocalServiceUtil.getWSRPConsumerPortlets( wsrpConsumer.getWsrpConsumerId(), QueryUtil.ALL_POS, QueryUtil.ALL_POS); Element wsrpConsumerPortletsElement = wsrpConsumerElement.addElement("wsrp-consumer-portlets"); for (WSRPConsumerPortlet wsrpConsumerPortlet : wsrpConsumerPortlets) { exportWSRPConsumerPortlet( portletDataContext, wsrpConsumerPortletsElement, wsrpConsumerPortlet); } } }
protected void initActionableDynamicQuery(ActionableDynamicQuery actionableDynamicQuery) { actionableDynamicQuery.setBaseLocalService( com.liferay.wsrp.service.WSRPConsumerPortletLocalServiceUtil.getService()); actionableDynamicQuery.setClass(WSRPConsumerPortlet.class); actionableDynamicQuery.setClassLoader(getClassLoader()); actionableDynamicQuery.setPrimaryKeyPropertyName("wsrpConsumerPortletId"); }
@Override public ActionableDynamicQuery getActionableDynamicQuery() { ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery(); actionableDynamicQuery.setBaseLocalService( com.liferay.wsrp.service.WSRPConsumerPortletLocalServiceUtil.getService()); actionableDynamicQuery.setClass(WSRPConsumerPortlet.class); actionableDynamicQuery.setClassLoader(getClassLoader()); actionableDynamicQuery.setPrimaryKeyPropertyName("wsrpConsumerPortletId"); return actionableDynamicQuery; }
@Override protected boolean validateMissingReference(String uuid, long companyId, long groupId) { WSRPConsumerPortlet wsrpConsumerPortlet = WSRPConsumerPortletLocalServiceUtil.fetchWSRPConsumerPortletByUuidAndCompanyId( uuid, companyId); if (wsrpConsumerPortlet == null) { return false; } return true; }