コード例 #1
0
  /**
   * Add the current date to the item metadata. This looks up the field in which to store this
   * metadata in the configuration sword.updated.field
   *
   * @param item
   * @throws DSpaceSwordException
   */
  protected void setUpdatedDate(Item item, VerboseDescription verboseDescription)
      throws DSpaceSwordException {
    String field = ConfigurationManager.getProperty("swordv2-server", "updated.field");
    if (field == null || "".equals(field)) {
      throw new DSpaceSwordException(
          "No configuration, or configuration is invalid for: sword.updated.field");
    }

    MDValue dc = this.configToDC(field, null);
    item.clearMetadata(dc.getSchema(), dc.getElement(), dc.getQualifier(), MDValue.ANY);
    item.addMetadata(
        dc.getSchema(), dc.getElement(), dc.getQualifier(), null, Utils.asISO8601(new Date()));

    verboseDescription.append("Updated date added to response from item metadata where available");
  }
コード例 #2
0
  /**
   * Store the given slug value (which is used for suggested identifiers, and which DSpace ignores)
   * in the item metadata. This looks up the field in which to store this metadata in the
   * configuration sword.slug.field
   *
   * @param item
   * @param slugVal
   * @throws DSpaceSwordException
   */
  protected void setSlug(Item item, String slugVal, VerboseDescription verboseDescription)
      throws DSpaceSwordException {
    // if there isn't a slug value, don't set it
    if (slugVal == null) {
      return;
    }

    String field = ConfigurationManager.getProperty("swordv2-server", "slug.field");
    if (field == null || "".equals(field)) {
      throw new DSpaceSwordException(
          "No configuration, or configuration is invalid for: sword.slug.field");
    }

    MDValue dc = this.configToDC(field, null);
    item.clearMetadata(dc.getSchema(), dc.getElement(), dc.getQualifier(), MDValue.ANY);
    item.addMetadata(dc.getSchema(), dc.getElement(), dc.getQualifier(), null, slugVal);

    verboseDescription.append("Slug value set in response where available");
  }