@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(); }