コード例 #1
0
  @Override
  public List<ContainerModel> getParentContainerModels(long classPK) throws PortalException {

    List<ContainerModel> containerModels = new ArrayList<ContainerModel>();

    ContainerModel containerModel = getParentContainerModel(classPK);

    if (containerModel == null) {
      return containerModels;
    }

    containerModels.add(containerModel);

    while (containerModel.getParentContainerModelId() > 0) {
      containerModel = getContainerModel(containerModel.getParentContainerModelId());

      if (containerModel == null) {
        break;
      }

      containerModels.add(containerModel);
    }

    return containerModels;
  }
コード例 #2
0
  @Override
  public TrashEntry getTrashEntry() throws PortalException {
    if (!isInTrash()) {
      return null;
    }

    TrashEntry trashEntry =
        TrashEntryLocalServiceUtil.fetchEntry(getModelClassName(), getTrashEntryClassPK());

    if (trashEntry != null) {
      return trashEntry;
    }

    TrashHandler trashHandler = getTrashHandler();

    if (!Validator.isNull(trashHandler.getContainerModelClassName(getPrimaryKey()))) {
      ContainerModel containerModel = null;

      try {
        containerModel = trashHandler.getParentContainerModel(this);
      } catch (NoSuchModelException nsme) {
        return null;
      }

      while (containerModel != null) {
        if (containerModel instanceof TrashedModel) {
          TrashedModel trashedModel = (TrashedModel) containerModel;

          return trashedModel.getTrashEntry();
        }

        trashHandler =
            TrashHandlerRegistryUtil.getTrashHandler(
                trashHandler.getContainerModelClassName(containerModel.getContainerModelId()));

        if (trashHandler == null) {
          return null;
        }

        containerModel = trashHandler.getContainerModel(containerModel.getParentContainerModelId());
      }
    }

    return null;
  }