コード例 #1
0
  /**
   * Can the users contained in this object's member SwordContext make a successful submission to
   * the selected collection.
   *
   * <p>See javadocs for individual canSubmitTo methods to see the conditions which are applied in
   * each situation
   *
   * @return true if yes, false if not
   * @throws DSpaceSwordException
   */
  public boolean canSubmit(SwordContext swordContext, DSpaceObject dso, VerboseDescription msg)
      throws DSpaceSwordException, SwordError {
    // determine if we can submit
    boolean submit = this.canSubmitTo(swordContext, dso);

    if (submit) {
      msg.append("User is authorised to submit to collection");
    } else {
      msg.append("User is not authorised to submit to collection");
    }

    return submit;
  }
コード例 #2
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");
  }
コード例 #3
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");
  }