/**
   * Assign persistent identifier to a Content-relation object.
   *
   * @param id The Id of the Content-relation witch is to assign with an ObjectPid.
   * @param taskParam XML snippet with parameter for the persistent identifier system.
   * @return The assigned persistent identifier for the Content-relation.
   * @throws ContentRelationNotFoundException Thrown if the object with id is does not exist or is
   *     no Item.
   * @throws LockingException Thrown if the Item is locked
   * @throws MissingMethodParameterException Thrown if a parameter is missing within {@code
   *     taskParam}.
   * @throws OptimisticLockingException Thrown if Item was altered in the mean time.
   * @throws PidAlreadyAssignedException Thrown if a Content-relation is already assigned a PID.
   * @throws SystemException Thrown in case of internal error.
   */
  @Override
  public String assignObjectPid(final String id, final String taskParam)
      throws ContentRelationNotFoundException, LockingException, MissingMethodParameterException,
          OptimisticLockingException, SystemException, PidAlreadyAssignedException,
          XmlCorruptedException {

    final ContentRelationCreate cr = setContentRelation(id);
    if (cr.getProperties().getPid() != null) {
      throw new PidAlreadyAssignedException(
          "A content relation with id " + id + " is already assigned a PID");
    }
    final TaskParamHandler taskParameter = XmlUtility.parseTaskParam(taskParam);
    checkLocked(cr);
    Utility.checkOptimisticLockingCriteria(
        cr.getProperties().getLastModificationDate(),
        taskParameter.getLastModificationDate(),
        "Content-relation " + cr.getObjid());

    String pid = taskParameter.getPid();
    if (pid == null) {
      // get PID from external PID System
      pid = getPid(id, taskParam);
    }
    cr.getProperties().setPid(pid);
    cr.persist();
    return prepareResponse(cr, pid);
  }