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); } }
/** * Adds the w s r p consumer portlet to the database. Also notifies the appropriate model * listeners. * * @param wsrpConsumerPortlet the w s r p consumer portlet * @return the w s r p consumer portlet that was added */ @Indexable(type = IndexableType.REINDEX) @Override public WSRPConsumerPortlet addWSRPConsumerPortlet(WSRPConsumerPortlet wsrpConsumerPortlet) { wsrpConsumerPortlet.setNew(true); return wsrpConsumerPortletPersistence.update(wsrpConsumerPortlet); }
protected String getWSRPConsumerPortletsPath( PortletDataContext portletDataContext, WSRPConsumerPortlet wsrpConsumerPortlet) { StringBundler sb = new StringBundler(4); sb.append(portletDataContext.getPortletPath(_PORTLET_KEY)); sb.append("/wsrp-consumer-portlets/"); sb.append(wsrpConsumerPortlet.getWsrpConsumerPortletId()); sb.append(".xml"); return sb.toString(); }
@Override protected void doExportStagedModel( PortletDataContext portletDataContext, WSRPConsumerPortlet wsrpConsumerPortlet) throws Exception { WSRPConsumer wsrpConsumer = WSRPConsumerLocalServiceUtil.getWSRPConsumer(wsrpConsumerPortlet.getWsrpConsumerId()); StagedModelDataHandlerUtil.exportReferenceStagedModel( portletDataContext, wsrpConsumerPortlet, wsrpConsumer, PortletDataContext.REFERENCE_TYPE_STRONG); Element wsrpConsumerPortletElement = portletDataContext.getExportDataElement(wsrpConsumerPortlet); portletDataContext.addClassedModel( wsrpConsumerPortletElement, ExportImportPathUtil.getModelPath(wsrpConsumerPortlet), wsrpConsumerPortlet); }
@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 String getDisplayName(WSRPConsumerPortlet wsrpConsumerPortlet) { return wsrpConsumerPortlet.getName(); }