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;
  }
  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);
    }
  }
  protected String getWSRPConsumerPath(
      PortletDataContext portletDataContext, WSRPConsumer wsrpConsumer) {

    StringBundler sb = new StringBundler(4);

    sb.append(portletDataContext.getPortletPath(_PORTLET_KEY));
    sb.append("/wsrp-consumers/");
    sb.append(wsrpConsumer.getUuid());
    sb.append(".xml");

    return sb.toString();
  }