@Override
  public ArrayList<String> getIdentifiers(Context context, T dso) {
    ArrayList<String> identifiers = new ArrayList<>();

    IdentifierService identifierService = new DSpace().getSingletonService(IdentifierService.class);

    if (identifierService != null) {
      identifiers.addAll(identifierService.lookup(context, dso));
    } else {
      log.warn("No IdentifierService found, will return an list containing " + "the Handle only.");
      if (dso.getHandle() != null) {
        identifiers.add(handleService.getCanonicalForm(dso.getHandle()));
      }
    }

    if (log.isDebugEnabled()) {
      StringBuilder dbgMsg = new StringBuilder();
      for (String id : identifiers) {
        if (dbgMsg.capacity() == 0) {
          dbgMsg.append("This DSO's Identifiers are: ");
        } else {
          dbgMsg.append(", ");
        }
        dbgMsg.append(id);
      }
      dbgMsg.append(".");
      log.debug(dbgMsg.toString());
    }

    return identifiers;
  }
Exemple #2
0
  /**
   * Tries to lookup all Identifiers of this DSpaceObject.
   *
   * @return An array containing all found identifiers or an array with a length of 0.
   */
  public String[] getIdentifiers(Context context) {
    if (identifiers == null) {
      log.debug("This DSO's identifiers cache is empty, looking for identifiers...");
      identifiers = new String[0];

      IdentifierService identifierService =
          new DSpace().getSingletonService(IdentifierService.class);

      if (identifierService != null) {
        identifiers = identifierService.lookup(context, this);
      } else {
        log.warn(
            "No IdentifierService found, will return an array containing " + "the Handle only.");
        if (getHandle() != null) {
          identifiers = new String[] {HandleManager.getCanonicalForm(getHandle())};
        }
      }
    }

    // it the DSO has no identifiers at all including handle, we should return an empty array.
    // G.e. items during submission (workspace items) have no handle and no other identifier.
    if (identifiers == null) {
      identifiers = new String[] {};
    }

    if (log.isDebugEnabled()) {
      StringBuilder dbgMsg = new StringBuilder();
      for (String id : identifiers) {
        if (dbgMsg.capacity() == 0) {
          dbgMsg.append("This DSO's Identifiers are: ");
        } else {
          dbgMsg.append(", ");
        }
        dbgMsg.append(id);
      }
      dbgMsg.append(".");
      log.debug(dbgMsg.toString());
    }

    return identifiers;
  }