protected WSRPConsumer importWSRPConsumer( PortletDataContext portletDataContext, Element wsrpConsumerElement, WSRPConsumer wsrpConsumer) throws Exception { WSRPConsumer importedWSRPConsumer = null; try { importedWSRPConsumer = WSRPConsumerLocalServiceUtil.getWSRPConsumer(wsrpConsumer.getUuid()); importedWSRPConsumer.setName(wsrpConsumer.getName()); importedWSRPConsumer.setUrl(wsrpConsumer.getUrl()); importedWSRPConsumer.setWsdl(wsrpConsumer.getWsdl()); importedWSRPConsumer.setForwardCookies(wsrpConsumer.getForwardCookies()); WSRPConsumerLocalServiceUtil.updateWSRPConsumer(importedWSRPConsumer, false); } catch (NoSuchConsumerException nsce) { ServiceContext serviceContext = portletDataContext.createServiceContext(wsrpConsumerElement, wsrpConsumer, _NAMESPACE); serviceContext.setUuid(wsrpConsumer.getUuid()); importedWSRPConsumer = WSRPConsumerLocalServiceUtil.addWSRPConsumer( portletDataContext.getCompanyId(), null, wsrpConsumer.getName(), wsrpConsumer.getUrl(), wsrpConsumer.getForwardCookies(), null, serviceContext); } return importedWSRPConsumer; }
@Override protected PortletPreferences doDeleteData( PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) throws Exception { long companyId = portletDataContext.getCompanyId(); if (portletDataContext.getBooleanParameter(_NAMESPACE, "wsrp-producers")) { List<WSRPProducer> wsrpProducers = WSRPProducerLocalServiceUtil.getWSRPProducers( companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS); for (WSRPProducer wsrpProducer : wsrpProducers) { WSRPProducerLocalServiceUtil.deleteWSRPProducer(wsrpProducer); } } if (portletDataContext.getBooleanParameter(_NAMESPACE, "wsrp-consumers")) { List<WSRPConsumer> wsrpConsumers = WSRPConsumerLocalServiceUtil.getWSRPConsumers( companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS); for (WSRPConsumer wsrpConsumer : wsrpConsumers) { WSRPConsumerLocalServiceUtil.deleteWSRPConsumer(wsrpConsumer); } } return null; }
@Override protected String doExportData( PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) throws Exception { Document document = SAXReaderUtil.createDocument(); Element rootElement = document.addElement("wsrp-data"); if (portletDataContext.getBooleanParameter(_NAMESPACE, "wsrp-producers")) { Element wsrpProducersElement = rootElement.addElement("wsrp-producers"); List<WSRPProducer> wsrpProducers = WSRPProducerLocalServiceUtil.getWSRPProducers( portletDataContext.getCompanyId(), QueryUtil.ALL_POS, QueryUtil.ALL_POS); for (WSRPProducer wsrpProducer : wsrpProducers) { exportWSRPProducer(portletDataContext, wsrpProducersElement, wsrpProducer); } } if (portletDataContext.getBooleanParameter(_NAMESPACE, "wsrp-consumers")) { Element wsrpConsumersElement = rootElement.addElement("wsrp-consumers"); List<WSRPConsumer> wsrpConsumers = WSRPConsumerLocalServiceUtil.getWSRPConsumers( portletDataContext.getCompanyId(), QueryUtil.ALL_POS, QueryUtil.ALL_POS); for (WSRPConsumer wsrpConsumer : wsrpConsumers) { exportWSRPConsumer(portletDataContext, wsrpConsumersElement, wsrpConsumer); } } return document.formattedString(); }
@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); }