Ticket #96 (closed documentation issue: fixed)

Opened 6 months ago

Last modified 6 months ago

Make error_id used by filters configurable

Reported by: mikey Assigned to: mikey
Priority: major Milestone: 0.4.0
Component: Request Version: SVN-trunk
Keywords: Cc: rist

Description (Last modified by mikey)

Filters use error ids to retrieve the correct error messages from the stubRequestValueErrorFactory. It should be configurable which error id they use to enable overriding default error messages with specific error messages from the application.

Documentation needs to be updated.

Change History

11/12/07 14:38:25 changed by mikey

  • cc set to rist.
  • status changed from new to assigned.

11/12/07 14:50:05 changed by mikey

Implemented for net.stubbles.ipo.request.filters.stubHTTPURLFilter in changeset 1029.

11/12/07 14:57:22 changed by mikey

Implemented for net.stubbles.ipo.request.filters.stubMailFilter in changeset 1030.

11/12/07 15:38:42 changed by mikey

implemented for net.stubbles.ipo.request.filters.stubFloatFilter and net.stubbles.ipo.request.filters.stubIntegerFilter with changeset 1031

11/12/07 16:29:16 changed by mikey

Implemented for net.stubbles.ipo.request.filters.stubPasswordFilter with changeset 1032.

11/12/07 16:37:04 changed by mikey

Outstanding: implementation for string filters (will be done by rist), adjustment of broker filter annotations to the new feature.

11/13/07 00:30:53 changed by mikey

The implementation needs to be refactored, the current way has too much of the same code spread over several classes. Idea:

1. Introduce a new interface

interface stubConfigurableError extends stubFilter
{
    public function setErrorId($type, $errorId);
}

2. Introduce a new abstract filter class:

abstract class stubAbstractConfigurableErrorFilter extends stubAbstractFilter implements stubConfigurableError
{
    public function setErrorId($type, $errorId)
    {
        if (isset($this->errorIds[$type]) === false) {
            throw new stubIllegalArgumentException('Illegal type ' . $type . ' given. Allowed types are ' . join(', ', array_keys($this->errorIds)) . '.');
        }
        
        $this->errorIds[$type] = $errorId;
    }
}

Change all current implementations to inherit from the new abstract class.

The name stubConfigurableError needs to be reconsidered, I didn't come up with a better one until now.

11/13/07 08:44:29 changed by mikey

Much better idea: throw away all implementation in the filter classes. Instead create a decorator for the error value factory that contains a mapping of error ids. The filter will not notice if it gets the real factory or the decorated factory and therefore not know which real error it is creating. Additionally this means the feature is only available for filters that use the factory, which was the original intention.

11/13/07 16:10:18 changed by mikey

Added net::stubbles::ipo::request::stubRequestValueErrorFactoryMappingDecorator, reverted all previous implementations.

To change the error actually used by the filter do the following:

$rveFactory = new stubRequestValueErrorFactoryMappingDecorator(new stubRequestValueErrorXJConfFactory());
$rveFactory->addMapping('FIELD_EMPTY', 'MY_NEW_ERROR_ID');
$filter = new stubStringFilter(rveFactory, $regexValidator);

The filter will now try to create the error value with id FIELD_EMPTY, but the stubRequestValueErrorFactoryMappingDecorator takes care and maps this to MY_NEW_ERROR_ID.

Still to do: enhance documentation about request, filters and validators. Implement this for the broker filter annotations.

11/13/07 16:11:18 changed by mikey

Note: the change above was done with changeset 1037.

11/15/07 17:12:26 changed by mikey

  • type changed from enhancement to documentation issue.
  • description changed.

Changeset 1042 implements configurable error ids for request broker: every filter annotation now supports the errorMapping argument, in format errorMapping='OLD_ERROR_ID1=>NEW_ERROR_ID1:OLD_ERROR_ID2=>NEW_ERROR_ID2'.

11/16/07 16:19:12 changed by mikey

  • status changed from assigned to closed.
  • resolution set to fixed.

Documentation updated.