protected void importAssetLink(AssetLink assetLink, long entryId1)
      throws PortalException, SystemException {

    long entryId2 = assetLink.getEntryId2();

    AssetEntry assetEntry2 = assetEntryPersistence.findByPrimaryKey(entryId2);

    if (assetEntry2.getClassNameId() == classNameLocalService.getClassNameId(CalEvent.class)) {

      CalEvent calEvent = calEventPersistence.findByPrimaryKey(assetEntry2.getClassPK());

      importCalEvent(calEvent);

      assetEntry2 = assetEntryPersistence.findByG_CU(calEvent.getGroupId(), calEvent.getUuid());

      entryId2 = assetEntry2.getEntryId();
    }

    long linkId = counterLocalService.increment();

    addAssetLink(
        linkId,
        assetLink.getCompanyId(),
        assetLink.getUserId(),
        assetLink.getUserName(),
        assetLink.getCreateDate(),
        entryId1,
        entryId2,
        assetLink.getType(),
        assetLink.getWeight());
  }
  public int compareTo(AssetLink assetLink) {
    int value = 0;

    if (getWeight() < assetLink.getWeight()) {
      value = -1;
    } else if (getWeight() > assetLink.getWeight()) {
      value = 1;
    } else {
      value = 0;
    }

    if (value != 0) {
      return value;
    }

    return 0;
  }
  protected void readAssetLinks(PortletDataContext portletDataContext) throws Exception {

    String xml =
        portletDataContext.getZipEntryAsString(
            ExportImportPathUtil.getSourceRootPath(portletDataContext) + "/links.xml");

    if (xml == null) {
      return;
    }

    Document document = SAXReaderUtil.read(xml);

    Element rootElement = document.getRootElement();

    List<Element> assetLinkGroupElements = rootElement.elements("asset-link-group");

    for (Element assetLinkGroupElement : assetLinkGroupElements) {
      String sourceUuid = assetLinkGroupElement.attributeValue("source-uuid");

      AssetEntry sourceAssetEntry =
          AssetEntryLocalServiceUtil.fetchEntry(portletDataContext.getScopeGroupId(), sourceUuid);

      if (sourceAssetEntry == null) {
        sourceAssetEntry =
            AssetEntryLocalServiceUtil.fetchEntry(
                portletDataContext.getCompanyGroupId(), sourceUuid);
      }

      if (sourceAssetEntry == null) {
        if (_log.isWarnEnabled()) {
          _log.warn("Unable to find asset entry with uuid " + sourceUuid);
        }

        continue;
      }

      List<Element> assetLinksElements = assetLinkGroupElement.elements("asset-link");

      for (Element assetLinkElement : assetLinksElements) {
        String path = assetLinkElement.attributeValue("path");

        if (!portletDataContext.isPathNotProcessed(path)) {
          continue;
        }

        String targetUuid = assetLinkElement.attributeValue("target-uuid");

        AssetEntry targetAssetEntry =
            AssetEntryLocalServiceUtil.fetchEntry(portletDataContext.getScopeGroupId(), targetUuid);

        if (targetAssetEntry == null) {
          targetAssetEntry =
              AssetEntryLocalServiceUtil.fetchEntry(
                  portletDataContext.getCompanyGroupId(), targetUuid);
        }

        if (targetAssetEntry == null) {
          if (_log.isWarnEnabled()) {
            _log.warn("Unable to find asset entry with uuid " + targetUuid);
          }

          continue;
        }

        AssetLink assetLink = (AssetLink) portletDataContext.getZipEntryAsObject(path);

        long userId = portletDataContext.getUserId(assetLink.getUserUuid());

        AssetLinkLocalServiceUtil.updateLink(
            userId,
            sourceAssetEntry.getEntryId(),
            targetAssetEntry.getEntryId(),
            assetLink.getType(),
            assetLink.getWeight());
      }
    }
  }