コード例 #1
1
  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());
  }
コード例 #2
0
  public void addAssetLinks(Class<?> clazz, long classPK) throws PortalException, SystemException {

    AssetEntry assetEntry = null;

    try {
      assetEntry = AssetEntryLocalServiceUtil.getEntry(clazz.getName(), classPK);
    } catch (NoSuchEntryException nsee) {
      return;
    }

    List<AssetLink> directAssetLinks =
        AssetLinkLocalServiceUtil.getDirectLinks(assetEntry.getEntryId());

    if (directAssetLinks.isEmpty()) {
      return;
    }

    Map<Integer, List<AssetLink>> assetLinksMap = new HashMap<Integer, List<AssetLink>>();

    for (AssetLink assetLink : directAssetLinks) {
      List<AssetLink> assetLinks = assetLinksMap.get(assetLink.getType());

      if (assetLinks == null) {
        assetLinks = new ArrayList<AssetLink>();

        assetLinksMap.put(assetLink.getType(), assetLinks);
      }

      assetLinks.add(assetLink);
    }

    for (Map.Entry<Integer, List<AssetLink>> entry : assetLinksMap.entrySet()) {

      int assetLinkType = entry.getKey();
      List<AssetLink> assetLinks = entry.getValue();

      List<String> assetLinkUuids = new ArrayList<String>(directAssetLinks.size());

      for (AssetLink assetLink : assetLinks) {
        try {
          AssetEntry assetLinkEntry = AssetEntryLocalServiceUtil.getEntry(assetLink.getEntryId2());

          assetLinkUuids.add(assetLinkEntry.getClassUuid());
        } catch (NoSuchEntryException nsee) {
        }
      }

      _assetLinkUuidsMap.put(
          getPrimaryKeyString(assetEntry.getClassUuid(), String.valueOf(assetLinkType)),
          assetLinkUuids.toArray(new String[assetLinkUuids.size()]));
    }
  }
コード例 #3
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());
      }
    }
  }