@Override
  public WorkspaceItem abort(Context context, BasicWorkflowItem workflowItem, EPerson e)
      throws SQLException, AuthorizeException, IOException {
    // authorize a DSpaceActions.ABORT
    if (!authorizeService.isAdmin(context)) {
      throw new AuthorizeException("You must be an admin to abort a workflow");
    }

    // stop workflow regardless of its state
    taskListItemService.deleteByWorkflowItem(context, workflowItem);

    log.info(
        LogManager.getHeader(
            context,
            "abort_workflow",
            "workflow_item_id="
                + workflowItem.getID()
                + "item_id="
                + workflowItem.getItem().getID()
                + "collection_id="
                + workflowItem.getCollection().getID()
                + "eperson_id="
                + e.getID()));

    // convert into personal workspace
    return returnToWorkspace(context, workflowItem);
  }
  @Override
  public boolean isHidden(Context context, String schema, String element, String qualifier)
      throws SQLException {
    // the administrator's override
    if (context != null && authorizeService.isAdmin(context)) {
      return false;
    }

    // for schema.element, just check schema->elementSet
    if (!isInitialized()) {
      init();
    }

    if (qualifier == null) {
      Set<String> elts = hiddenElementSets.get(schema);
      return elts == null ? false : elts.contains(element);
    }

    // for schema.element.qualifier, just schema->eltMap->qualSet
    else {
      Map<String, Set<String>> elts = hiddenElementMaps.get(schema);
      if (elts == null) {
        return false;
      }
      Set<String> quals = elts.get(element);
      return quals == null ? false : quals.contains(qualifier);
    }
  }
Exemplo n.º 3
0
  @Override
  public WorkspaceItem abort(Context c, XmlWorkflowItem wi, EPerson e)
      throws AuthorizeException, SQLException, IOException {
    if (!authorizeService.isAdmin(c)) {
      throw new AuthorizeException("You must be an admin to abort a workflow");
    }

    c.turnOffAuthorisationSystem();
    // Restore permissions for the submitter
    // convert into personal workspace
    WorkspaceItem wsi = returnToWorkspace(c, wi);

    log.info(
        LogManager.getHeader(
            c,
            "abort_workflow",
            "workflow_item_id="
                + wi.getID()
                + "item_id="
                + wsi.getItem().getID()
                + "collection_id="
                + wi.getCollection().getID()
                + "eperson_id="
                + e.getID()));

    c.restoreAuthSystemState();
    return wsi;
  }
Exemplo n.º 4
0
  @Override
  public void delete(Context context, MetadataField metadataField)
      throws SQLException, AuthorizeException {
    // Check authorisation: Only admins may create DC types
    if (!authorizeService.isAdmin(context)) {
      throw new AuthorizeException("Only administrators may modify the metadata registry");
    }

    log.info(
        LogManager.getHeader(
            context, "delete_metadata_field", "metadata_field_id=" + metadataField.getFieldID()));

    metadataValueService.deleteByMetadataField(context, metadataField);
    metadataFieldDAO.delete(context, metadataField);
  }
Exemplo n.º 5
0
  @Override
  public MetadataField create(
      Context context,
      MetadataSchema metadataSchema,
      String element,
      String qualifier,
      String scopeNote)
      throws AuthorizeException, SQLException, NonUniqueMetadataException {
    // Check authorisation: Only admins may create DC types
    if (!authorizeService.isAdmin(context)) {
      throw new AuthorizeException("Only administrators may modify the metadata registry");
    }

    // Ensure the element and qualifier are unique within a given schema.
    if (hasElement(context, -1, metadataSchema, element, qualifier)) {
      throw new NonUniqueMetadataException(
          "Please make "
              + element
              + "."
              + qualifier
              + " unique within schema #"
              + metadataSchema.getSchemaID());
    }

    // Create a table row and update it with the values
    MetadataField metadataField = new MetadataField();
    metadataField.setElement(element);
    metadataField.setQualifier(qualifier);
    metadataField.setScopeNote(scopeNote);
    metadataField.setMetadataSchema(metadataSchema);
    metadataField = metadataFieldDAO.create(context, metadataField);
    metadataFieldDAO.save(context, metadataField);

    log.info(
        LogManager.getHeader(
            context, "create_metadata_field", "metadata_field_id=" + metadataField.getFieldID()));
    return metadataField;
  }
Exemplo n.º 6
0
  @Override
  public void update(Context context, MetadataField metadataField)
      throws SQLException, AuthorizeException, NonUniqueMetadataException, IOException {
    // Check authorisation: Only admins may update the metadata registry
    if (!authorizeService.isAdmin(context)) {
      throw new AuthorizeException("Only administrators may modiffy the Dublin Core registry");
    }

    // Ensure the element and qualifier are unique within a given schema.
    if (hasElement(
        context,
        metadataField.getFieldID(),
        metadataField.getMetadataSchema(),
        metadataField.getElement(),
        metadataField.getQualifier())) {
      throw new NonUniqueMetadataException(
          "Please make "
              + metadataField.getMetadataSchema().getName()
              + "."
              + metadataField.getElement()
              + "."
              + metadataField.getQualifier());
    }

    metadataFieldDAO.save(context, metadataField);

    log.info(
        LogManager.getHeader(
            context,
            "update_metadatafieldregistry",
            "metadata_field_id="
                + metadataField.getFieldID()
                + "element="
                + metadataField.getElement()
                + "qualifier="
                + metadataField.getQualifier()));
  }
Exemplo n.º 7
0
  @Override
  public Community create(Community parent, Context context, String handle)
      throws SQLException, AuthorizeException {
    if (!(authorizeService.isAdmin(context)
        || (parent != null
            && authorizeService.authorizeActionBoolean(context, parent, Constants.ADD)))) {
      throw new AuthorizeException("Only administrators can create communities");
    }

    Community newCommunity = communityDAO.create(context, new Community());

    try {
      if (handle == null) {
        handleService.createHandle(context, newCommunity);
      } else {
        handleService.createHandle(context, newCommunity, handle);
      }
    } catch (IllegalStateException ie) {
      // If an IllegalStateException is thrown, then an existing object is already using this handle
      throw ie;
    }

    if (parent != null) {
      parent.addSubCommunity(newCommunity);
      newCommunity.addParentCommunity(parent);
    }

    // create the default authorization policy for communities
    // of 'anonymous' READ
    Group anonymousGroup = groupService.findByName(context, Group.ANONYMOUS);

    authorizeService.createResourcePolicy(
        context, newCommunity, anonymousGroup, null, Constants.READ, null);

    communityDAO.save(context, newCommunity);

    context.addEvent(
        new Event(
            Event.CREATE,
            Constants.COMMUNITY,
            newCommunity.getID(),
            newCommunity.getHandle(),
            getIdentifiers(context, newCommunity)));

    // if creating a top-level Community, simulate an ADD event at the Site.
    if (parent == null) {
      context.addEvent(
          new Event(
              Event.ADD,
              Constants.SITE,
              siteService.findSite(context).getID(),
              Constants.COMMUNITY,
              newCommunity.getID(),
              newCommunity.getHandle(),
              getIdentifiers(context, newCommunity)));
    }

    log.info(
        LogManager.getHeader(context, "create_community", "community_id=" + newCommunity.getID())
            + ",handle="
            + newCommunity.getHandle());

    return newCommunity;
  }